From 42947a3100bdaf9c2f9295732b3b1e184eeb0ed6 Mon Sep 17 00:00:00 2001 From: fryzahh Date: Fri, 24 Oct 2025 11:58:00 -0400 Subject: [PATCH 01/65] Pixelation system + Particle system updates * Added a global pixelated drawing system. * Added LightDustPixelated. * Added the GeneralDrawLayer enum, which is now used for layered drawing in both the pixelation and particle systems. * Updated the particle system: * Now supports drawing on multiple different layers now instead of just after everything else in the world has been drawn. * Collapsed the three draw lists in favor of two dictionaries, which store lists of non-pixelated and pixelated particles respectively based on their BlendState. * particlesToSpawnNextFrame is now a dictionary which stores Queues based on their draw layer. --- Dusts/LightDust.cs | 51 ++- Enums/GeneralDrawLayer.cs | 20 + ILEditing/ILChangesLoading.cs | 1 - ILEditing/MechanicILChanges.cs | 6 +- Particles/GeneralParticleHandler.cs | 420 +++++++++--------- Particles/Particle.cs | 15 +- .../PixelationSystem/PixelatedDrawer.cs | 15 + .../PixelationSystem/PixelationManager.cs | 311 +++++++++++++ 8 files changed, 611 insertions(+), 228 deletions(-) create mode 100644 Enums/GeneralDrawLayer.cs create mode 100644 Systems/Graphic/PixelationSystem/PixelatedDrawer.cs create mode 100644 Systems/Graphic/PixelationSystem/PixelationManager.cs diff --git a/Dusts/LightDust.cs b/Dusts/LightDust.cs index d0f83ba587..3da334e73c 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; + + public static Asset BloomCircle; + + 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,42 @@ 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.EntitySpriteDraw(BloomCircle.Value, dustCenter - 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.EntitySpriteDraw(BloomCircle.Value, dustCenter - 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.EntitySpriteDraw(SolidCircle.Value, dustCenter - 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) + { + Vector2 dustCenter = dust.position + new Vector2(0.25f, 0.25f); + + // Glow Orb + Main.spriteBatch.Draw(BloomCircle.Value, dustCenter - 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, dustCenter - 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, dustCenter - 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/Enums/GeneralDrawLayer.cs b/Enums/GeneralDrawLayer.cs new file mode 100644 index 0000000000..23aa7c20d0 --- /dev/null +++ b/Enums/GeneralDrawLayer.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CalamityMod.Enums +{ + public enum GeneralDrawLayer + { + BeforeTiles, + BeforeNPCs, + AfterNPCs, + BeforeProjectiles, + AfterProjectiles, + AfterPlayers, + AfterDusts, + AfterEverything, + } +} diff --git a/ILEditing/ILChangesLoading.cs b/ILEditing/ILChangesLoading.cs index f7428ad488..e0df1824a2 100644 --- a/ILEditing/ILChangesLoading.cs +++ b/ILEditing/ILChangesLoading.cs @@ -46,7 +46,6 @@ 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; diff --git a/ILEditing/MechanicILChanges.cs b/ILEditing/MechanicILChanges.cs index b181b5b09d..c0ac84b864 100644 --- a/ILEditing/MechanicILChanges.cs +++ b/ILEditing/MechanicILChanges.cs @@ -31,6 +31,7 @@ using CalamityMod.Projectiles; using CalamityMod.Projectiles.Ranged; using CalamityMod.Projectiles.Typeless; using CalamityMod.Systems; +using CalamityMod.Systems.Graphic.PixelationSystem; using CalamityMod.Tiles; using CalamityMod.Walls; using CalamityMod.Waterfalls; @@ -923,11 +924,6 @@ namespace CalamityMod.ILEditing orig(self); } - private static void DrawForegroundParticles(On_Main.orig_DrawInfernoRings orig, Main self) - { - GeneralParticleHandler.DrawAllParticles(Main.spriteBatch); - orig(self); - } #endregion #region Disable Moon Lord Style Flashes With Photosensitivity Config diff --git a/Particles/GeneralParticleHandler.cs b/Particles/GeneralParticleHandler.cs index 415b7653c4..8285f5ada9 100644 --- a/Particles/GeneralParticleHandler.cs +++ b/Particles/GeneralParticleHandler.cs @@ -2,7 +2,10 @@ using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; +using CalamityMod.Effects; +using CalamityMod.Enums; using CalamityMod.Graphics; +using CalamityMod.Systems.Graphic.PixelationSystem; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -17,39 +20,22 @@ namespace CalamityMod.Particles [Autoload(Side = ModSide.Client)] public sealed class GeneralParticleHandler : ModSystem { + #region Fields private static List particles; - private static Queue particlesToSpawnNextFrame; - //List containing the particles to delete + private static Dictionary> particlesToSpawnNextFrame; + // List containing the particles to delete private static List particlesToKill; - //Static list for details concerning every particle type + + // 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; - private static ManagedRenderTarget PixelationTarget_AlphaBlend; - private static ManagedRenderTarget PixelationTarget_NonPremultiplied; - private static ManagedRenderTarget PixelationTarget_AdditiveBlend; - - /// - /// Whether or not the system is currently rendering any pixelated prticles to the render target or not. - /// - private static bool CurrentlyRendering { get; set; } - - /// - /// The resolution ratio at which pixelated particles should draw.
- /// 0.5f will draw at half resolution, 0.25f will draw at quarter resolution, etc. - ///
- private const float PixelationResolution = 0.5f; - - /// - /// Creates a render target at half the screen's dimensions. - /// This is done due to the fact that when the target itself drawn, it needs to be drawn at double the original scale in order to pixelate its contents - /// - private static RenderTarget2D CreatePixelTarget(int width, int height) => new(Main.instance.GraphicsDevice, (int)(width * PixelationResolution), (int)(height * PixelationResolution)); + // Collections for storing and ordring particle instances for drawing. + private static Dictionary> ParticlesToDraw; + private static Dictionary> ParticlesToDraw_Pixelated; + #endregion + #region Loading and Unloading public override void PostSetupContent() { Type baseParticleType = typeof(Particle); @@ -71,8 +57,6 @@ namespace CalamityMod.Particles texturePath = instance.Texture; particleTextures[ID] = ModContent.Request(texturePath, AssetRequestMode.ImmediateLoad).Value; }); - - On_Main.CheckMonoliths += DrawToTarget; } public override void Load() @@ -83,16 +67,15 @@ namespace CalamityMod.Particles particleTypes = []; particleTextures = []; - batchedAlphaBlendParticles = []; - batchedNonPremultipliedParticles = []; - batchedAdditiveBlendParticles = []; + ParticlesToDraw = []; + ParticlesToDraw_Pixelated = []; - Main.QueueMainThreadAction(() => - { - PixelationTarget_AlphaBlend = new(true, CreatePixelTarget); - PixelationTarget_NonPremultiplied = new(true, CreatePixelTarget); - PixelationTarget_AdditiveBlend = new(true, CreatePixelTarget); - }); + On_Main.DrawBackgroundBlackFill += DrawParticles_BeforeTiles; + On_Main.DrawNPCs += DrawParticles_NPCs; + On_Main.DrawProjectiles += DrawParticles_Projectiles; + On_Main.DrawPlayers_AfterProjectiles += DrawParticles_AfterPlayers; + On_Main.DrawDust += DrawParticles_AfterDusts; + On_Main.DrawInfernoRings += DrawParticles_AfterEverything; } public override void Unload() @@ -103,17 +86,16 @@ namespace CalamityMod.Particles particleTypes = null; particleTextures = null; - batchedAlphaBlendParticles = null; - batchedNonPremultipliedParticles = null; - batchedAdditiveBlendParticles = null; - - On_Main.CheckMonoliths -= DrawToTarget; + ParticlesToDraw = null; + ParticlesToDraw_Pixelated = null; } + #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) + /// 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, GeneralDrawLayer? manualDrawLayerOverride = null) { // Don't queue particles if the game is paused. // This precedent is established with how Dust instances are created. @@ -124,11 +106,21 @@ namespace CalamityMod.Particles if (particles.Count >= CalamityClientConfig.Instance.ParticleLimit && !particle.Important) return; + if (manualDrawLayerOverride.HasValue) + particle.DrawLayer = manualDrawLayerOverride.Value; + particles.Add(particle); + ReturnAssociatedDrawCollection(particle).Add(particle); particle.Type = particleTypes[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.
+ ///
+ public static void QueueParticleForNextFrame(Particle particle, GeneralDrawLayer? manualDrawLayerOverride = null) { // Don't queue particles if the game is paused. // This precedent is established with how Dust instances are created. @@ -136,7 +128,24 @@ namespace CalamityMod.Particles if (Main.gamePaused || Main.dedServ || particles == null) return; - particlesToSpawnNextFrame.Enqueue(particle); + // Get the correct draw layer to spawn this particle on. + GeneralDrawLayer actualDrawLayer = manualDrawLayerOverride ?? particle.DrawLayer; + if (!particlesToSpawnNextFrame.ContainsKey(actualDrawLayer)) + particlesToSpawnNextFrame[actualDrawLayer] = []; + + particlesToSpawnNextFrame[actualDrawLayer].Enqueue(particle); + } + + /// + /// Removes an active particle instance from the world entirely. + /// + public static void RemoveParticle(Particle particle) + { + if (Main.dedServ) + return; + + particlesToKill.Add(particle); + ReturnAssociatedDrawCollection(particle).Remove(particle); } public static void Update() @@ -144,219 +153,206 @@ namespace CalamityMod.Particles if (Main.dedServ) return; - while (particlesToSpawnNextFrame.Count > 0) - SpawnParticle(particlesToSpawnNextFrame.Dequeue()); + // Spawn queued particles. + foreach (var keyValuePair in particlesToSpawnNextFrame) + { + while (keyValuePair.Value.Count > 0) + SpawnParticle(keyValuePair.Value.Dequeue(), keyValuePair.Key); + } + // Update all particle instances in the world. foreach (Particle particle in particles) { if (particle == null) continue; + particle.Position += particle.Velocity; particle.Time++; particle.Update(); } + //Clear out particles whose time is up - particles.RemoveAll(particle => (particle.Time >= particle.Lifetime && particle.SetLifetime) || particlesToKill.Contains(particle)); + particles.RemoveAll(particle => + { + if ((particle.Time >= particle.Lifetime && particle.SetLifetime) || particlesToKill.Contains(particle)) + { + ReturnAssociatedDrawCollection(particle).Remove(particle); + return true; + } + return false; + }); + particlesToKill.Clear(); } - public static void RemoveParticle(Particle particle) + private static void DrawParticles_BeforeTiles(On_Main.orig_DrawBackgroundBlackFill orig, Main self) { - if (Main.dedServ) - return; + Main.spriteBatch.End(); + DrawParticleCollectionsAtSpecificLayer(GeneralDrawLayer.BeforeTiles); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - particlesToKill.Add(particle); + orig(self); } - private static void DrawToTarget(On_Main.orig_CheckMonoliths orig) + private static void DrawParticles_NPCs(On_Main.orig_DrawNPCs orig, Main self, bool behindTiles) { - if (Main.gameMenu) + if (!behindTiles) { - orig(); - return; - } - - List pixelatedAlphaBlendParticles = []; - List pixelatedNonPremultipliedParticles = []; - List pixelatedAdditiveBlendParticles = []; - - // Add each particle to their respective lists. - foreach (Particle particle in particles) - { - if (particle != null && particle.Pixelate) - { - pixelatedAlphaBlendParticles.AddWithCondition(particle, !particle.UseAdditiveBlend && !particle.UseHalfTransparency); - pixelatedNonPremultipliedParticles.AddWithCondition(particle, !particle.UseAdditiveBlend && particle.UseHalfTransparency); - pixelatedAdditiveBlendParticles.AddWithCondition(particle, particle.UseAdditiveBlend && !particle.UseHalfTransparency); - } - } - - CurrentlyRendering = true; - - Matrix pixelationMatrix = 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); - - DrawParticlesToRenderTarget(PixelationTarget_AlphaBlend, pixelatedAlphaBlendParticles, BlendState.AlphaBlend, pixelationMatrix); - DrawParticlesToRenderTarget(PixelationTarget_NonPremultiplied, pixelatedNonPremultipliedParticles, BlendState.NonPremultiplied, pixelationMatrix); - DrawParticlesToRenderTarget(PixelationTarget_AdditiveBlend, pixelatedAdditiveBlendParticles, BlendState.Additive, pixelationMatrix); - - Main.instance.GraphicsDevice.SetRenderTarget(null); - CurrentlyRendering = false; - - orig(); - } - - private static void DrawParticlesToRenderTarget(RenderTarget2D target, List particles, BlendState blendStateToUse, Matrix pixelationMatrix) - { - target.SwapTo(); - - if (particles.Count > 0) - { - Main.spriteBatch.Begin(SpriteSortMode.Deferred, blendStateToUse, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, pixelationMatrix); - - foreach (Particle particle in particles) - { - 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 = particleTextures[particle.Type].Frame(1, particle.FrameVariants, 0, particle.Variant); - Main.spriteBatch.Draw(particleTextures[particle.Type], particle.Position - Main.screenPosition, frame, lightColor, particle.Rotation, frame.Size() * 0.5f, particle.Scale, SpriteEffects.None, 0f); - } - } - Main.spriteBatch.End(); + DrawParticleCollectionsAtSpecificLayer(GeneralDrawLayer.BeforeNPCs); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + } + + orig(self, behindTiles); + + if (!behindTiles) + { + Main.spriteBatch.End(); + DrawParticleCollectionsAtSpecificLayer(GeneralDrawLayer.AfterNPCs); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); } } - private static void DrawPixelatedParticles() + private static void DrawParticles_Projectiles(On_Main.orig_DrawProjectiles orig, Main self) { - DrawScaledTarget(PixelationTarget_AlphaBlend, Main.spriteBatch, BlendState.AlphaBlend); - DrawScaledTarget(PixelationTarget_NonPremultiplied, Main.spriteBatch, BlendState.NonPremultiplied); - DrawScaledTarget(PixelationTarget_AdditiveBlend, Main.spriteBatch, BlendState.Additive); + DrawParticleCollectionsAtSpecificLayer(GeneralDrawLayer.BeforeProjectiles); + + orig(self); + + DrawParticleCollectionsAtSpecificLayer(GeneralDrawLayer.AfterProjectiles); } - private static void DrawScaledTarget(ManagedRenderTarget targetToDraw, SpriteBatch spriteBatch, BlendState blendState) + private static void DrawParticles_AfterPlayers(On_Main.orig_DrawPlayers_AfterProjectiles orig, Main self) { - const float inversePixelationScale = 1f / PixelationResolution; - - spriteBatch.Begin(SpriteSortMode.Deferred, blendState, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - spriteBatch.Draw(targetToDraw, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, inversePixelationScale, SpriteEffects.None, 0f); - spriteBatch.End(); + orig(self); + DrawParticleCollectionsAtSpecificLayer(GeneralDrawLayer.AfterPlayers); } - public static void DrawAllParticles(SpriteBatch sb) + private static void DrawParticles_AfterDusts(On_Main.orig_DrawDust orig, Main self) + { + orig(self); + DrawParticleCollectionsAtSpecificLayer(GeneralDrawLayer.AfterDusts); + } + + private static void DrawParticles_AfterEverything(On_Main.orig_DrawInfernoRings orig, Main self) + { + orig(self); + + Main.spriteBatch.End(); + DrawParticleCollectionsAtSpecificLayer(GeneralDrawLayer.AfterEverything); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.Transform); + } + + private static void DrawParticleInstance(Particle particle) + { + 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 = particleTextures[particle.Type].Frame(1, particle.FrameVariants, 0, particle.Variant); + Main.spriteBatch.Draw(particleTextures[particle.Type], particle.Position - Main.screenPosition, frame, lightColor, particle.Rotation, frame.Size() * 0.5f, particle.Scale, SpriteEffects.None, 0f); + } + } + + 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 DrawParticleCollectionsAtSpecificLayer(GeneralDrawLayer drawLayer) { if (Main.dedServ) return; - if (particles.Count == 0) - return; + DrawParticleCollection(ParticlesToDraw, drawLayer); + DrawParticleCollection(ParticlesToDraw_Pixelated, drawLayer, true); + } - 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) + private static List ReturnAssociatedDrawCollection(Particle particle) + { + // Pixelated particles. + if (particle.Pixelate) { - if (particle == null) - continue; - - if (particle.Pixelate) - continue; - if (particle.UseAdditiveBlend) - batchedAdditiveBlendParticles.Add(particle); + { + if (!ParticlesToDraw_Pixelated.ContainsKey(BlendState.Additive)) + ParticlesToDraw_Pixelated[BlendState.Additive] = []; + return ParticlesToDraw_Pixelated[BlendState.Additive]; + } else if (particle.UseHalfTransparency) - batchedNonPremultipliedParticles.Add(particle); + { + if (!ParticlesToDraw_Pixelated.ContainsKey(BlendState.NonPremultiplied)) + ParticlesToDraw_Pixelated[BlendState.NonPremultiplied] = []; + return ParticlesToDraw_Pixelated[BlendState.NonPremultiplied]; + } 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); - } + if (!ParticlesToDraw_Pixelated.ContainsKey(BlendState.AlphaBlend)) + ParticlesToDraw_Pixelated[BlendState.AlphaBlend] = []; + return ParticlesToDraw_Pixelated[BlendState.AlphaBlend]; } - sb.End(); } - - - if (batchedNonPremultipliedParticles.Count > 0) + // Non-pixelated particles (regular). + else { - 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.UseAdditiveBlend) { - 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); - } + if (!ParticlesToDraw.ContainsKey(BlendState.Additive)) + ParticlesToDraw[BlendState.Additive] = []; + return ParticlesToDraw[BlendState.Additive]; } - 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) + else if (particle.UseHalfTransparency) { - 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); - } + 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]; } - sb.End(); } - - batchedAlphaBlendParticles.Clear(); - batchedNonPremultipliedParticles.Clear(); - batchedAdditiveBlendParticles.Clear(); - - // Draw all pixelated particles. - DrawPixelatedParticles(); - - sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.Transform); } /// diff --git a/Particles/Particle.cs b/Particles/Particle.cs index 0681436106..c53306ebaf 100644 --- a/Particles/Particle.cs +++ b/Particles/Particle.cs @@ -1,4 +1,6 @@ -using Microsoft.Xna.Framework; +using System.Collections.Generic; +using CalamityMod.Enums; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; namespace CalamityMod.Particles @@ -54,12 +56,20 @@ namespace CalamityMod.Particles /// public bool AffectedByLight = 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.AfterEverything; + public virtual int FrameVariants => 1; public int Variant = 0; + public virtual string Texture => ""; /// - /// Whether or not your particle should be drawn slightly pixelated to match Terraria's pixel size. + /// Whether or not your particle should be drawn with a pixelated effect to match Terraria's pixel size. + ///
Defaults to false.
///
public virtual bool Pixelate => false; @@ -95,6 +105,5 @@ namespace CalamityMod.Particles /// Removes the particle from the handler /// public void Kill() => GeneralParticleHandler.RemoveParticle(this); - } } 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..a30a5f65ca --- /dev/null +++ b/Systems/Graphic/PixelationSystem/PixelationManager.cs @@ -0,0 +1,311 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Enums; +using CalamityMod.Graphics; +using CalamityMod.Items.Ammo; +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_BeforeTiles; + 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_BeforeTiles; + 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); + } + } + + /// + /// Creates a render target at a ratio of the screen's current dimensions based on . + /// + internal static RenderTarget2D CreatePixelTarget(int width, int height) => new(Main.graphics.GraphicsDevice, (int)(width * PixelationResolution), (int)(height * PixelationResolution)); + + public override void OnModLoad() + { + if (Main.dedServ) + return; + + PixelTargets_BeforeTiles = []; + PixelTargets_BeforeNPCs = []; + PixelTargets_AfterNPCs = []; + PixelTargets_BeforeProjectiles = []; + PixelTargets_AfterProjectiles = []; + PixelTargets_AfterPlayers = []; + PixelTargets_AfterDusts = []; + PixelTargets_AfterEverything = []; + + ActivePixelatedDrawers_BeforeTiles = []; + ActivePixelatedDrawers_BeforeNPCs = []; + ActivePixelatedDrawers_AfterNPCs = []; + ActivePixelatedDrawers_BeforeProjectiles = []; + ActivePixelatedDrawers_AfterProjectiles = []; + ActivePixelatedDrawers_AfterPlayers = []; + ActivePixelatedDrawers_AfterDusts = []; + ActivePixelatedDrawers_AfterEverything = []; + + RenderTargetManager.RenderTargetUpdateLoopEvent += PrepareTargets; + On_Main.DrawBackgroundBlackFill += DrawPixelated_BeforeTiles; + On_Main.DrawNPCs += DrawPixelated_NPCs; + On_Main.DrawProjectiles += DrawPixelated_Projectiles; + On_Main.DrawPlayers_AfterProjectiles += DrawPixelated_AfterPlayers; + On_Main.DrawDust += DrawPixelated_AfterDusts; + On_Main.DrawInfernoRings += DrawPixelated_AfterEverything; + } + + public override void OnModUnload() + { + if (Main.dedServ) + return; + + PixelTargets_BeforeTiles = null; + PixelTargets_BeforeNPCs = null; + PixelTargets_AfterNPCs = null; + PixelTargets_BeforeProjectiles = null; + PixelTargets_AfterProjectiles = null; + PixelTargets_AfterPlayers = null; + PixelTargets_AfterDusts = null; + PixelTargets_AfterEverything = null; + + ActivePixelatedDrawers_BeforeTiles = 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; + + ActivePixelatedDrawers_BeforeTiles = null; + ActivePixelatedDrawers_BeforeNPCs = null; + ActivePixelatedDrawers_AfterNPCs = null; + ActivePixelatedDrawers_BeforeProjectiles = null; + ActivePixelatedDrawers_AfterProjectiles = null; + ActivePixelatedDrawers_AfterPlayers = null; + ActivePixelatedDrawers_AfterDusts = null; + ActivePixelatedDrawers_AfterEverything = null; + } + + + /// + /// 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_BeforeTiles, PixelationMatrix, ActivePixelatedDrawers_BeforeTiles); + 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); + + Main.graphics.GraphicsDevice.SetRenderTarget(null); + } + } + + private static void DrawPixelated_BeforeTiles(On_Main.orig_DrawBackgroundBlackFill orig, Main self) + { + DrawPixelatedTargets(PixelTargets_BeforeTiles); + orig(self); + } + + private static void DrawPixelated_NPCs(On_Main.orig_DrawNPCs orig, Main self, bool behindTiles) + { + if (!behindTiles) + DrawPixelatedTargets(PixelTargets_BeforeNPCs); + + orig(self, behindTiles); + + if (!behindTiles) + DrawPixelatedTargets(PixelTargets_AfterNPCs); + } + + private static void DrawPixelated_Projectiles(On_Main.orig_DrawProjectiles orig, Main self) + { + DrawPixelatedTargets(PixelTargets_BeforeProjectiles); + orig(self); + DrawPixelatedTargets(PixelTargets_AfterProjectiles); + } + + private static void DrawPixelated_AfterPlayers(On_Main.orig_DrawPlayers_AfterProjectiles orig, Main self) + { + orig(self); + DrawPixelatedTargets(PixelTargets_AfterPlayers); + } + + private static void DrawPixelated_AfterDusts(On_Main.orig_DrawDust orig, Main self) + { + orig(self); + DrawPixelatedTargets(PixelTargets_AfterDusts); + } + + private static void DrawPixelated_AfterEverything(On_Main.orig_DrawInfernoRings orig, Main self) + { + orig(self); + DrawPixelatedTargets(PixelTargets_AfterEverything); + } + + private static void DrawCollectionsToTarget(Dictionary targetCollection, Matrix pixelationMatrix, List drawerCollection) + { + foreach (var blendStateTargetPair in targetCollection) + { + blendStateTargetPair.Value.SwapTo(); + + Main.spriteBatch.Begin(default, blendStateTargetPair.Key, SamplerState.LinearClamp, default, default, 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(Dictionary targetCollection) + { + Main.spriteBatch.SafeAction(() => + { + foreach (var keyValuePair in targetCollection) + { + Main.spriteBatch.TryEnd(); + Main.spriteBatch.TryBegin(SpriteSortMode.Deferred, keyValuePair.Key, Main.DefaultSamplerState, default, default, null, Main.GameViewMatrix.TransformationMatrix); + + float targetScale = 1f / PixelationResolution; + Main.spriteBatch.Draw(keyValuePair.Value, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, targetScale, SpriteEffects.None, 0f); + } + }); + } + + private static List ReturnAssociatedDrawerCollection(GeneralDrawLayer drawLayer) + { + List drawerCollection = drawLayer switch + { + GeneralDrawLayer.BeforeTiles => ActivePixelatedDrawers_BeforeTiles, + 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 void VerifyTargetExistence(GeneralDrawLayer drawLayer, BlendState blendState) + { + switch (drawLayer) + { + case GeneralDrawLayer.BeforeTiles: + if (!PixelTargets_BeforeTiles.ContainsKey(blendState)) + Main.QueueMainThreadAction(() => PixelTargets_BeforeTiles[blendState] = new(true, CreatePixelTarget)); + break; + + case GeneralDrawLayer.BeforeNPCs: + if (!PixelTargets_BeforeNPCs.ContainsKey(blendState)) + Main.QueueMainThreadAction(() => PixelTargets_BeforeNPCs[blendState] = new(true, CreatePixelTarget)); + break; + + case GeneralDrawLayer.AfterNPCs: + if (!PixelTargets_AfterNPCs.ContainsKey(blendState)) + Main.QueueMainThreadAction(() => PixelTargets_AfterNPCs[blendState] = new(true, CreatePixelTarget)); + break; + + case GeneralDrawLayer.BeforeProjectiles: + if (!PixelTargets_BeforeProjectiles.ContainsKey(blendState)) + Main.QueueMainThreadAction(() => PixelTargets_BeforeProjectiles[blendState] = new(true, CreatePixelTarget)); + break; + + case GeneralDrawLayer.AfterProjectiles: + if (!PixelTargets_AfterProjectiles.ContainsKey(blendState)) + Main.QueueMainThreadAction(() => PixelTargets_AfterProjectiles[blendState] = new(true, CreatePixelTarget)); + break; + + case GeneralDrawLayer.AfterPlayers: + if (!PixelTargets_AfterPlayers.ContainsKey(blendState)) + Main.QueueMainThreadAction(() => PixelTargets_AfterPlayers[blendState] = new(true, CreatePixelTarget)); + break; + + case GeneralDrawLayer.AfterDusts: + if (!PixelTargets_AfterDusts.ContainsKey(blendState)) + Main.QueueMainThreadAction(() => PixelTargets_AfterDusts[blendState] = new(true, CreatePixelTarget)); + break; + + case GeneralDrawLayer.AfterEverything: + if (!PixelTargets_AfterEverything.ContainsKey(blendState)) + Main.QueueMainThreadAction(() => PixelTargets_AfterEverything[blendState] = new(true, CreatePixelTarget)); + break; + } + } + } +} From 98d075d8b1da017fa8d5ef611c68abd883afc263 Mon Sep 17 00:00:00 2001 From: Doze-Zoze Date: Sat, 1 Nov 2025 18:26:31 -0500 Subject: [PATCH 02/65] sun spriit and vengeful sun pt1 --- Buffs/Summon/SolarGodSpiritBuff.cs | 6 +- Buffs/Summon/SolarSpirit.cs | 6 +- CalPlayer/CalamityPlayer.cs | 8 +- Items/Weapons/Summon/SunSpiritStaff.cs | 32 +++- Items/Weapons/Summon/VengefulSunStaff.cs | 32 +++- .../Mods.CalamityMod.Projectiles.Summon.hjson | 4 + ModSupport/WeakReferenceSupport.cs | 4 +- Projectiles/Summon/SolarBeam.cs | 160 ++++++++++++++++-- Projectiles/Summon/SolarGod.cs | 133 --------------- Projectiles/Summon/SolarPixie.cs | 134 --------------- Projectiles/Summon/SunSpiritBeam.cs | 139 +++++++++++++++ Projectiles/Summon/SunSpiritMinion.cs | 139 +++++++++++++++ .../{SolarPixie.png => SunSpiritMinion.png} | Bin Projectiles/Summon/VengefulSunSpiritMinion.cs | 141 +++++++++++++++ ...larGod.png => VengefulSunSpiritMinion.png} | Bin 15 files changed, 624 insertions(+), 314 deletions(-) delete mode 100644 Projectiles/Summon/SolarGod.cs delete mode 100644 Projectiles/Summon/SolarPixie.cs create mode 100644 Projectiles/Summon/SunSpiritBeam.cs create mode 100644 Projectiles/Summon/SunSpiritMinion.cs rename Projectiles/Summon/{SolarPixie.png => SunSpiritMinion.png} (100%) create mode 100644 Projectiles/Summon/VengefulSunSpiritMinion.cs rename Projectiles/Summon/{SolarGod.png => VengefulSunSpiritMinion.png} (100%) 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/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 774fb4c83f..ddabc14203 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -1449,12 +1449,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 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; @@ -2626,7 +2626,7 @@ namespace CalamityMod.CalPlayer aSlime = false; brittleStar = false; aquaticStar = false; - SP = false; + sunSpirit = false; dCreeper = false; eAxe = false; endoCooper = false; @@ -2634,7 +2634,7 @@ namespace CalamityMod.CalPlayer gastricBelcher = false; hauntedDishes = false; stormjaw = false; - SPG = false; + vengefulSunMinion = false; sirius = false; aChicken = false; cLamp = false; diff --git a/Items/Weapons/Summon/SunSpiritStaff.cs b/Items/Weapons/Summon/SunSpiritStaff.cs index 61403820f0..9172986970 100644 --- a/Items/Weapons/Summon/SunSpiritStaff.cs +++ b/Items/Weapons/Summon/SunSpiritStaff.cs @@ -1,4 +1,5 @@ -using CalamityMod.Buffs.Summon; +using System.Linq; +using CalamityMod.Buffs.Summon; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; @@ -16,9 +17,9 @@ namespace CalamityMod.Items.Weapons.Summon { Item.width = 44; Item.height = 48; - Item.damage = 12; + Item.damage = 10; Item.mana = 10; - Item.useAnimation = Item.useTime = 35; + Item.useAnimation = Item.useTime = 10; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.knockBack = 1.15f; @@ -26,19 +27,32 @@ namespace CalamityMod.Items.Weapons.Summon Item.rare = ItemRarityID.Blue; Item.UseSound = SoundID.Item44; Item.buffType = ModContent.BuffType(); - Item.shoot = ModContent.ProjectileType(); + 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) { + 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); - CalamityUtils.KillShootProjectiles(true, type, player); - var minion = Projectile.NewProjectileDirect(source, position, Vector2.Zero, type, damage, knockback, player.whoAmI); - minion.originalDamage = Item.damage; - return false; + return true; } public override void AddRecipes() diff --git a/Items/Weapons/Summon/VengefulSunStaff.cs b/Items/Weapons/Summon/VengefulSunStaff.cs index 6a6e9735c3..e96e3d7911 100644 --- a/Items/Weapons/Summon/VengefulSunStaff.cs +++ b/Items/Weapons/Summon/VengefulSunStaff.cs @@ -1,4 +1,5 @@ -using CalamityMod.Buffs.Summon; +using System.Linq; +using CalamityMod.Buffs.Summon; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; @@ -17,9 +18,9 @@ namespace CalamityMod.Items.Weapons.Summon { Item.width = 72; Item.height = 72; - Item.damage = 60; + Item.damage = 30; Item.mana = 10; - Item.useAnimation = Item.useTime = 25; + Item.useAnimation = Item.useTime = 10; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.knockBack = 1.25f; @@ -27,19 +28,32 @@ namespace CalamityMod.Items.Weapons.Summon Item.rare = ItemRarityID.LightPurple; Item.UseSound = SoundID.Item44; Item.buffType = ModContent.BuffType(); - Item.shoot = ModContent.ProjectileType(); + 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) { + 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); - CalamityUtils.KillShootProjectiles(true, type, player); - var minion = Projectile.NewProjectileDirect(source, position, Vector2.Zero, type, damage, knockback, player.whoAmI); - minion.originalDamage = Item.damage; - return false; + return true; } public override void AddRecipes() diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson index 8571335f31..04f7cbba12 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson @@ -333,3 +333,7 @@ FlarebatMinion.DisplayName: Flarebat FrostbatMinion.DisplayName: Frostbat AmphibiansGuitarMinion.DisplayName: Amphibian's Guitars AmphibiansGuitarProjectile.DisplayName: Note +SunSpiritBeam.DisplayName: Sun Spirit Beam +SunSpiritMinion.DisplayName: Sun Spirit Minion +VengefulSunBeam.DisplayName: Vengeful Sun Beam +VengefulSunSpiritMinion.DisplayName: Vengeful Sun Spirit Minion diff --git a/ModSupport/WeakReferenceSupport.cs b/ModSupport/WeakReferenceSupport.cs index 741dcb63e1..75fd782345 100644 --- a/ModSupport/WeakReferenceSupport.cs +++ b/ModSupport/WeakReferenceSupport.cs @@ -1155,7 +1155,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()); @@ -1183,7 +1183,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()); diff --git a/Projectiles/Summon/SolarBeam.cs b/Projectiles/Summon/SolarBeam.cs index cee2d0e534..9847861d36 100644 --- a/Projectiles/Summon/SolarBeam.cs +++ b/Projectiles/Summon/SolarBeam.cs @@ -1,46 +1,172 @@ -using Microsoft.Xna.Framework; +using System; +using System.Linq; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Graphics.Primitives; +using CalamityMod.Particles; +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 SolarBeam : ModProjectile, ILocalizedModType + 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; - ProjectileID.Sets.CultistIsResistantTo[Type] = true; } public override void SetDefaults() { - Projectile.width = Projectile.height = 4; - Projectile.aiStyle = ProjAIStyleID.Ray; + Projectile.width = 24; + Projectile.height = 24; Projectile.friendly = true; - Projectile.extraUpdates = 220; - Projectile.timeLeft = 200; + 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() { - Projectile.localAI[0] += 1f; - if (Projectile.localAI[0] > 9f) + if (Projectile.ai[0] > 1) { - for (int i = 0; i < 4; i++) + Projectile.ai[0]--; + Projectile.timeLeft = 120; + } + if (Projectile.ai[0] > 0) + { + var target = Projectile.FindTargetWithinRange(640); + if (target != null) { - 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; + 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 = false; + } + 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); + p.penetrate = 1; + p.scale = 0.75f; + } + Projectile.damage = 0; + Projectile.timeLeft = 10; + Projectile.netUpdate = true; + } + + public override void OnKill(int timeLeft) + { + } + + public override bool? CanDamage() + { + return Projectile.ai[0] <= 90; + } + + public override bool PreDraw(ref Color lightColor) => false; + + public float FireWidthFunction(float completion) + { + 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) + { + 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); + } + + public float FireCoreWidthFunction(float completion) + { + 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) + { + Color mainColor = Color.OrangeRed; + 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, PixelationPrimitiveLayer 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, true, true, GameShaders.Misc["CalamityMod:ImpFlameTrail"]), Projectile.oldPos.Length + 32); + + // Render a smaller, pure white trail in the same position to represent the glowing core of the flame. + 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/SolarGod.cs b/Projectiles/Summon/SolarGod.cs deleted file mode 100644 index 47b224fc2b..0000000000 --- a/Projectiles/Summon/SolarGod.cs +++ /dev/null @@ -1,133 +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() - { - Main.projPet[Type] = true; - 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); - } -} diff --git a/Projectiles/Summon/SolarPixie.cs b/Projectiles/Summon/SolarPixie.cs deleted file mode 100644 index b3c3595cc5..0000000000 --- a/Projectiles/Summon/SolarPixie.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 SolarPixie : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Summon"; - public override void SetStaticDefaults() - { - Main.projPet[Type] = true; - 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); - } -} diff --git a/Projectiles/Summon/SunSpiritBeam.cs b/Projectiles/Summon/SunSpiritBeam.cs new file mode 100644 index 0000000000..e65c3d97f2 --- /dev/null +++ b/Projectiles/Summon/SunSpiritBeam.cs @@ -0,0 +1,139 @@ +using System; +using System.Linq; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Graphics.Primitives; +using CalamityMod.Particles; +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 = false; + } + } + + public override void OnKill(int timeLeft) + { + } + + public override bool PreDraw(ref Color lightColor) => false; + + public float FireWidthFunction(float completion) + { + 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) + { + 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) + { + float width; + float maxBodyWidth = Projectile.scale * 16; + float curveRatio = 0.25f; + var positions = Projectile.oldPos.ToList(); + positions.RemoveAll(x => x == Vector2.Zero); + //completion *= positions.Count() / (float)ProjectileID.Sets.TrailCacheLength[Type]; + + 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) + { + 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, PixelationPrimitiveLayer 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, true, true, GameShaders.Misc["CalamityMod:ImpFlameTrail"]), Projectile.oldPos.Length + 32); + + // Render a smaller, pure white trail in the same position to represent the glowing core of the flame. + 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..3ae18916ac --- /dev/null +++ b/Projectiles/Summon/SunSpiritMinion.cs @@ -0,0 +1,139 @@ +using System.Net.Http.Headers; +using CalamityMod.Buffs.Summon; +using CalamityMod.CalPlayer; +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--; + } + 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 * -16f); + #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 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/Particles/BloomRingThinLarge").Value; + + Main.spriteBatch.Draw(spTex, Projectile.Center - Main.screenPosition, null, Color.White, Main.GlobalTimeWrappedHourly, spTex.Size() * 0.5f, 0.75f, SpriteEffects.None, 0); + Main.spriteBatch.SafeBegin(SpriteSortMode.Deferred, BatchSetting.Additive, null, Main.GameViewMatrix.TransformationMatrix, () => + { + + for (var i = 0; i < Projectile.minionSlots && i < 5; i++) + { + var comp = (i / (Projectile.minionSlots)); + 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.02f + 0.0025f * offset + 0.005f * i, SpriteEffects.None); + } + }); + 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/VengefulSunSpiritMinion.cs b/Projectiles/Summon/VengefulSunSpiritMinion.cs new file mode 100644 index 0000000000..4b0e0be06a --- /dev/null +++ b/Projectiles/Summon/VengefulSunSpiritMinion.cs @@ -0,0 +1,141 @@ +using System; +using CalamityMod.Buffs.Summon; +using CalamityMod.CalPlayer; +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--; + } + 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 * -16f); + #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); + beam.DamageType = DamageClass.Summon; + Projectile.ai[1] += 60f / (0.75f + Projectile.minionSlots * 0.25f); + } + } + + 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); + Main.spriteBatch.SafeBegin(SpriteSortMode.Deferred, BatchSetting.Additive, null, Main.GameViewMatrix.TransformationMatrix, () => + { + Main.EntitySpriteDraw(ciTex, Projectile.Center - Main.screenPosition, null, Color.Gold, Main.GlobalTimeWrappedHourly, ciTex.Size() * 0.5f, 0.075f, SpriteEffects.None); + + float count = MathHelper.Min(Projectile.minionSlots * 2, 20); + 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), i % 2 == 0 ? Color.OrangeRed : Color.Gold, 2f); + } + }); + 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 From 2e2a51ee8d325b80a35514e4424f9b5f965a0dd9 Mon Sep 17 00:00:00 2001 From: doze-zoze Date: Sat, 1 Nov 2025 21:16:54 -0500 Subject: [PATCH 03/65] new visuals + saros pt1 --- Buffs/Summon/SarosPossessionBuff.cs | 2 +- Items/Weapons/Summon/SarosPossession.cs | 58 +++-- Projectiles/Summon/SarosAura.cs | 240 +++++++++++------- Projectiles/Summon/SarosSunfire.cs | 161 +++++++++--- Projectiles/Summon/SunSpiritBeam.cs | 2 +- Projectiles/Summon/SunSpiritMinion.cs | 27 +- .../{SolarBeam.cs => VengefulSunBeam.cs} | 16 +- Projectiles/Summon/VengefulSunSpiritMinion.cs | 47 +++- 8 files changed, 388 insertions(+), 165 deletions(-) rename Projectiles/Summon/{SolarBeam.cs => VengefulSunBeam.cs} (93%) 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/Items/Weapons/Summon/SarosPossession.cs b/Items/Weapons/Summon/SarosPossession.cs index 0e143371a0..d0f24770bd 100644 --- a/Items/Weapons/Summon/SarosPossession.cs +++ b/Items/Weapons/Summon/SarosPossession.cs @@ -1,8 +1,7 @@ -using CalamityMod.Buffs.Summon; +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.DataStructures; @@ -14,45 +13,54 @@ 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 override void SetDefaults() { - Item.width = Item.height = 56; - Item.damage = 500; - Item.knockBack = 4f; + Item.width = 44; + Item.height = 48; + Item.damage = 80; Item.mana = 10; - + Item.useAnimation = Item.useTime = 10; + Item.useStyle = ItemUseStyleID.Swing; + Item.noMelee = true; + Item.knockBack = 1.15f; + Item.value = CalamityGlobalItem.RarityBlueBuyPrice; + Item.rare = ItemRarityID.Blue; + Item.UseSound = SoundID.Item44; Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.useAnimation = Item.useTime = 10; Item.DamageType = DamageClass.Summon; - Item.useStyle = ItemUseStyleID.Swing; - Item.UseSound = SoundID.DD2_BetsyFlameBreath; - Item.rare = ModContent.RarityType(); - Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.noMelee = true; } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0 && player.maxMinions >= 8; + 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 || player.altFunctionUse == 2; + } 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; + } player.AddBuff(Item.buffType, 2); - CalamityUtils.KillShootProjectiles(true, type, player); - var minion = Projectile.NewProjectileDirect(source, position, Vector2.Zero, type, damage, knockback, player.whoAmI); - minion.originalDamage = Item.damage; - return false; + return true; } public override void AddRecipes() { CreateRecipe(). - AddIngredient(). - AddIngredient(8). - AddIngredient(8). - AddTile(). + AddIngredient(ItemID.SandstoneBrick, 20). + AddIngredient(2). + AddTile(TileID.Anvils). Register(); } } diff --git a/Projectiles/Summon/SarosAura.cs b/Projectiles/Summon/SarosAura.cs index 61ad52487e..68a219e8db 100644 --- a/Projectiles/Summon/SarosAura.cs +++ b/Projectiles/Summon/SarosAura.cs @@ -1,133 +1,191 @@ -using CalamityMod.Buffs.Summon; +using System; +using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; -using CalamityMod.Dusts; +using CalamityMod.Items.Potions.Alcohol; 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 = 6f; - 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) + 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--; + } + MinionSlotsToAdd = 0; + } + #endregion + + #region Checking alive + bool correctMinion = Projectile.type == ModContent.ProjectileType(); + if (correctMinion) + { + if (player.dead) + { + modPlayer.sunSpirit = false; + } + if (modPlayer.saros) + { Projectile.timeLeft = 2; - } - } - - public void SpawnEffect() - { - if (CheckForSpawning == false) - { - int dustAmount = 360; - 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(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; } } - CheckForSpawning = true; - } + #endregion - public void AttackTarget(NPC target) - { - if (GeneralTimer % 50f == 49f) + #region Positioning + Projectile.Center = player.Center + Vector2.UnitY * (player.gfxOffY + player.gravDir * -24f); + #endregion + + Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.25f / 255f, (255 - Projectile.alpha) * 0.25f / 255f, (255 - Projectile.alpha) * 0f / 255f); + + NPC target = GetTargetInRange(3200); + + if (target is null) + return; + + + if (Projectile.owner == Main.myPlayer) { - for (int i = -1; i < 2; i++) + + if (Projectile.ai[1] > 0f) { - 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.netUpdate = true; + Projectile.ai[1] -= 1f; + } + else + { + int damage = (int)(Projectile.damage * (0.75f + Projectile.minionSlots * 0.25f)); + float shootSpeed = 15f; + Vector2 source = Projectile.Center; + for (var i = 0; i < 3; i++) + { + 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.75f + Projectile.minionSlots * 0.25f); } - } - if (GeneralTimer % 100f == 99f) - { - float angle = (target.Center - Projectile.Center).ToRotation() + Main.rand.NextFloat(MathHelper.PiOver2, -MathHelper.PiOver2); - Vector2 velocity = angle.ToRotationVector2() * 25f; - SoundEngine.PlaySound(SarosDiskThrow, Projectile.Center); - - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), Projectile.damage * 2, Projectile.knockBack, Projectile.owner); - - Projectile.netUpdate = true; } } - #endregion + NPC GetTargetInRange(float range) + { + var player = Main.player[Projectile.owner]; + if (player.HasMinionAttackTargetNPC && Main.npc[player.MinionAttackTargetNPC].CanBeChasedBy(this) && 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; + for (int i = 0; i < Main.npc.Length; i++) + { + NPC npc = Main.npc[i]; + if (npc.CanBeChasedBy(this) && Projectile.IsInRangeOfMeOrMyOwner(npc, range, out var myDistance, out var _, out var _) && myDistance < currentDistance) + { + currentDistance = myDistance; + gotTarget = npc; + } + } + return gotTarget; + } + } + + public override bool? CanDamage() => false; + + public static Asset circle; + public override bool PreDraw(ref Color lightColor) + { + + //Vengeful Sun Drawing + 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); + Main.spriteBatch.SafeBegin(SpriteSortMode.Deferred, BatchSetting.Additive, null, Main.GameViewMatrix.TransformationMatrix, () => + { + //Main.EntitySpriteDraw(ciTex, Projectile.Center - Main.screenPosition, null, Color.Gold, Main.GlobalTimeWrappedHourly, ciTex.Size() * 0.5f, 0.075f, SpriteEffects.None); + + float count = (int)((Projectile.minionSlots - 1) / 3) * 2 + 1; + 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); + } + }); + + //Old sun spirit drawing + /* + var spTex = TextureAssets.Projectile[Type].Value; + var ciTex = CalamityUtils.GetTextureEfficient(ref circle, "CalamityMod/Particles/BloomRingThinLarge").Value; + */ + var ciTex = CalamityUtils.GetTextureEfficient(ref circle, "CalamityMod/Particles/BloomRingThinLarge").Value; + //Main.spriteBatch.Draw(spTex, Projectile.Center - Main.screenPosition, null, Color.White, Main.GlobalTimeWrappedHourly, spTex.Size() * 0.5f, 0.75f, SpriteEffects.None, 0); + Main.spriteBatch.SafeBegin(SpriteSortMode.Deferred, BatchSetting.Additive, null, Main.GameViewMatrix.TransformationMatrix, () => + { + int 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); + } + }); + return false; + } } } diff --git a/Projectiles/Summon/SarosSunfire.cs b/Projectiles/Summon/SarosSunfire.cs index d454f593ac..9dc7db33ac 100644 --- a/Projectiles/Summon/SarosSunfire.cs +++ b/Projectiles/Summon/SarosSunfire.cs @@ -1,70 +1,165 @@ -using CalamityMod.Dusts; +using System; +using System.Linq; +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 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] = 20; + 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.timeLeft = 180; + Projectile.DamageType = DamageClass.Summon; + Projectile.MaxUpdates = 3; Projectile.tileCollide = false; + Projectile.penetrate = 3; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 24; + Projectile.stopsDealingDamageAfterPenetrateHits = true; } + public override void OnSpawn(IEntitySource source) + { + ProjectileID.Sets.TrailCacheLength[Type] = 8; + SoundEngine.PlaySound(SoundID.Item20, Projectile.Center); + } + + 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; } - // 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 = null; + int targ = -1; + Projectile.Minion_FindTargetInRange(5000, ref targ, false, (ent, num) => + { + return (ent is NPC && Projectile.localNPCImmunity[(ent as NPC).whoAmI] <= 0); + }); + if (targ != -1) + target = Main.npc[targ]; + } + + 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 OnKill(int timeLeft) // Makes a dust explosion effect on death. + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); - for (int i = 0; i < 60; i++) + 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 void OnKill(int timeLeft) + { + } + + public override bool? CanDamage() + { + return Projectile.ai[0] <= 90; + } + + public override bool PreDraw(ref Color lightColor) => false; + + public float FireWidthFunction(float completion) + { + float width; + float maxBodyWidth = 48f * 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) + { + Color mainColor = new Color(238, 226, 153); + return Color.Lerp(mainColor, Color.Transparent, completion); + } + + public float FireCoreWidthFunction(float completion) + { + 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) + { + Color mainColor = new Color(255, 191, 73); + return mainColor;// Color.Lerp(mainColor, Color.Transparent, completion); + } + + public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, PixelationPrimitiveLayer 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, true, true, GameShaders.Misc["CalamityMod:ImpFlameTrail"]), Projectile.oldPos.Length + 32); + + // Render a smaller, pure white trail in the same position to represent the glowing core of the flame. + 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/SunSpiritBeam.cs b/Projectiles/Summon/SunSpiritBeam.cs index e65c3d97f2..91ad905e32 100644 --- a/Projectiles/Summon/SunSpiritBeam.cs +++ b/Projectiles/Summon/SunSpiritBeam.cs @@ -64,7 +64,7 @@ namespace CalamityMod.Projectiles.Summon 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; + dust.noLightEmittence = true; } } diff --git a/Projectiles/Summon/SunSpiritMinion.cs b/Projectiles/Summon/SunSpiritMinion.cs index 3ae18916ac..3d954d7d99 100644 --- a/Projectiles/Summon/SunSpiritMinion.cs +++ b/Projectiles/Summon/SunSpiritMinion.cs @@ -82,7 +82,7 @@ namespace CalamityMod.Projectiles.Summon #endregion #region Positioning - Projectile.Center = player.Center + Vector2.UnitY * (player.gfxOffY + player.gravDir * -16f); + 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); @@ -117,6 +117,29 @@ namespace CalamityMod.Projectiles.Summon public static Asset circle; public override bool PreDraw(ref Color lightColor) { + + //Vengeful Sun Drawing + 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); + Main.spriteBatch.SafeBegin(SpriteSortMode.Deferred, BatchSetting.Additive, null, Main.GameViewMatrix.TransformationMatrix, () => + { + //Main.EntitySpriteDraw(ciTex, Projectile.Center - Main.screenPosition, null, Color.Gold, Main.GlobalTimeWrappedHourly, ciTex.Size() * 0.5f, 0.075f, SpriteEffects.None); + + 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); + } + }); + + //Old sun spirit drawing + /* var spTex = TextureAssets.Projectile[Type].Value; var ciTex = CalamityUtils.GetTextureEfficient(ref circle, "CalamityMod/Particles/BloomRingThinLarge").Value; @@ -132,7 +155,7 @@ namespace CalamityMod.Projectiles.Summon 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.02f + 0.0025f * offset + 0.005f * i, SpriteEffects.None); } - }); + });*/ return false; } } diff --git a/Projectiles/Summon/SolarBeam.cs b/Projectiles/Summon/VengefulSunBeam.cs similarity index 93% rename from Projectiles/Summon/SolarBeam.cs rename to Projectiles/Summon/VengefulSunBeam.cs index 9847861d36..414272b0c7 100644 --- a/Projectiles/Summon/SolarBeam.cs +++ b/Projectiles/Summon/VengefulSunBeam.cs @@ -81,14 +81,14 @@ namespace CalamityMod.Projectiles.Summon 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; + 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); + 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; } @@ -129,7 +129,10 @@ namespace CalamityMod.Projectiles.Summon public Color FireColorFunction(float completion) { - Color mainColor = Color.Gold * 1.3f; + 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); } @@ -137,7 +140,7 @@ namespace CalamityMod.Projectiles.Summon public float FireCoreWidthFunction(float completion) { float width; - float maxBodyWidth = Projectile.scale * 16; + float maxBodyWidth = Projectile.scale * 24; float curveRatio = 0.25f; var positions = Projectile.oldPos.ToList(); positions.RemoveAll(x => x == Vector2.Zero); @@ -151,10 +154,11 @@ namespace CalamityMod.Projectiles.Summon public Color FireCoreColorFunction(float completion) { - Color mainColor = Color.OrangeRed; + 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 Color.Lerp(fullBodyColor, Color.White, 0.175f); + return fullBodyColor; } public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, PixelationPrimitiveLayer layer) diff --git a/Projectiles/Summon/VengefulSunSpiritMinion.cs b/Projectiles/Summon/VengefulSunSpiritMinion.cs index 4b0e0be06a..f31b44798e 100644 --- a/Projectiles/Summon/VengefulSunSpiritMinion.cs +++ b/Projectiles/Summon/VengefulSunSpiritMinion.cs @@ -82,7 +82,7 @@ namespace CalamityMod.Projectiles.Summon #endregion #region Positioning - Projectile.Center = player.Center + Vector2.UnitY * (player.gfxOffY + player.gravDir * -16f); + 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); @@ -106,7 +106,7 @@ namespace CalamityMod.Projectiles.Summon 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); + 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); } @@ -114,27 +114,62 @@ namespace CalamityMod.Projectiles.Summon 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; - Main.spriteBatch.Draw(spTex,Projectile.Center-Main.screenPosition,null,Color.White,Main.GlobalTimeWrappedHourly,spTex.Size()*0.5f, 0.75f,SpriteEffects.None,0); + 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); Main.spriteBatch.SafeBegin(SpriteSortMode.Deferred, BatchSetting.Additive, null, Main.GameViewMatrix.TransformationMatrix, () => { - Main.EntitySpriteDraw(ciTex, Projectile.Center - Main.screenPosition, null, Color.Gold, Main.GlobalTimeWrappedHourly, ciTex.Size() * 0.5f, 0.075f, SpriteEffects.None); + color = Color.Lerp(Color.Yellow, Color.OrangeRed, completion); + if (completion >= 1) + color = Color.LightBlue; + //Main.EntitySpriteDraw(ciTex, Projectile.Center - Main.screenPosition, null, color, Main.GlobalTimeWrappedHourly, ciTex.Size() * 0.5f, 0.075f, SpriteEffects.None); - float count = MathHelper.Min(Projectile.minionSlots * 2, 20); + float count = MathHelper.Min((Projectile.minionSlots-1) * 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), i % 2 == 0 ? Color.OrangeRed : Color.Gold, 2f); + 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); } }); + return false; } } From d95113418e9f21c45bba1a4ba4dc2927dee5cf67 Mon Sep 17 00:00:00 2001 From: fryzahh Date: Wed, 5 Nov 2025 11:48:22 -0400 Subject: [PATCH 04/65] ParticleAutoDrawingOverride + code cleanup, credits and bugfix * Added ParticleAutoDrawingOverride, which allows one to override the automatic drawing of a particular particle type and manually and efficiently control how each instance is drawn in the world. * Subsequently added the OverrideAutomaticDrawing property to Particle. * Multiple changes to GeneralParticleHander.cs: * Removed the noteToEveryone field, but moved the text to a comment at the top of the class. * Additionally, added credits to Luminance and their license notice since the new particle drawing logic was inspired by its system. * Reorganized fields based on their protection level. * Renamed "particles," "particleTypes" and "particleTextures" to "activeParticles," "particleIDsByTypes" and "particleTexturesByIDs" respectively. * Added documentation for all internal fields * Moved the GetTexture and FreeSpaceAvailable methods up with the rest of the public static methods for consistency. * The "ActivePixelatedDrawer_" fields in are now cleared upon unloading the world instead of being set to null to prevent a null reference exception when leaving and reentering worlds. --- Particles/GeneralParticleHandler.cs | 281 ++++++++++++------ Particles/Particle.cs | 9 +- Particles/ParticleAutoDrawingOverride.cs | 57 ++++ .../Melee/ArkoftheCosmos_Constellation.cs | 2 +- .../Melee/Galaxia_AriesWrathConstellation.cs | 2 +- .../PixelationSystem/PixelationManager.cs | 17 +- 6 files changed, 268 insertions(+), 100 deletions(-) create mode 100644 Particles/ParticleAutoDrawingOverride.cs diff --git a/Particles/GeneralParticleHandler.cs b/Particles/GeneralParticleHandler.cs index 8285f5ada9..62d85051c4 100644 --- a/Particles/GeneralParticleHandler.cs +++ b/Particles/GeneralParticleHandler.cs @@ -2,37 +2,69 @@ using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; -using CalamityMod.Effects; using CalamityMod.Enums; -using CalamityMod.Graphics; 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: + + // 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. + [Autoload(Side = ModSide.Client)] public sealed class GeneralParticleHandler : ModSystem { #region Fields - private static List particles; - private static Dictionary> particlesToSpawnNextFrame; - // List containing the particles to delete + /// + /// The integer ID of each particle type defined across all mods, identified by the internal type of the respective particle. + /// + internal static Dictionary particleIDsByTypes; + + /// + /// All types defined across all mods, identified by a string for each respective particle which follows the following format: + ///
{Particle's Home Mod's Internal Name}.{Particle's Internal Name}
+ ///
+ internal static Dictionary particleTypesByNames; + + /// + /// The individual, autoloaded textures of each particle type defined across all mods, identified by the ID of the respective particle. + /// + internal static Dictionary particleTexturesByIDs; + + /// + /// All types defined across all mods, identified by the type of the particle the drawers target. + /// + internal static Dictionary particleAutoDrawingOverrides; + + private static List activeParticles; private static List particlesToKill; - - // Static list for details concerning every particle type - internal static Dictionary particleTypes; - internal static Dictionary particleTextures; - - // Collections for storing and ordring particle instances for drawing. - private static Dictionary> ParticlesToDraw; - private static Dictionary> ParticlesToDraw_Pixelated; + private static Dictionary> particlesToSpawnNextFrame; + private static Dictionary> particlesToDraw; + private static Dictionary> particlesToDraw_Pixelated; #endregion #region Loading and Unloading @@ -41,8 +73,11 @@ namespace CalamityMod.Particles Type baseParticleType = typeof(Particle); 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; + + string registrationName = string.Concat(type.FullName.AsSpan(0, type.FullName.IndexOf('.')), ".", type.Name); + particleTypesByNames[registrationName] = type; // Flow: 2024/09/17 // 'UnintializedObject' is allowed to use here as it's only read for Texture string Property @@ -55,20 +90,39 @@ namespace CalamityMod.Particles 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, AssetRequestMode.ImmediateLoad).Value; }); + + foreach (Mod mod in ModLoader.Mods) + { + var drawers = mod.GetContent().Where(c => c is ParticleAutoDrawingOverride).Select(c => c as ParticleAutoDrawingOverride); + foreach (var drawer in drawers) + { + if (drawer.TargetParticleTypeName != "") + { + if (particleTypesByNames.TryGetValue(drawer.TargetParticleTypeName, out Type particleType)) + particleAutoDrawingOverrides.Add(particleType, drawer); + else + throw new Exception($"The Particle of name \"{drawer.TargetParticleTypeName}\" used in {drawer.GetType().Name} could not be found! " + + $"Please ensure the Paricle's internal name is spelt correctly and is prefixed by its home mod's internal name."); + } + } + } } public override void Load() { - particles = []; - particlesToSpawnNextFrame = []; - particlesToKill = []; - particleTypes = []; - particleTextures = []; + particleTypesByNames = []; + particleIDsByTypes = []; + particleTexturesByIDs = []; - ParticlesToDraw = []; - ParticlesToDraw_Pixelated = []; + particleAutoDrawingOverrides = []; + + activeParticles = []; + particlesToKill = []; + particlesToSpawnNextFrame = []; + particlesToDraw = []; + particlesToDraw_Pixelated = []; On_Main.DrawBackgroundBlackFill += DrawParticles_BeforeTiles; On_Main.DrawNPCs += DrawParticles_NPCs; @@ -80,14 +134,26 @@ namespace CalamityMod.Particles public override void Unload() { - particles = null; - particlesToSpawnNextFrame = null; - particlesToKill = null; - particleTypes = null; - particleTextures = null; + particleTypesByNames = null; + particleIDsByTypes = null; + particleTexturesByIDs = null; - ParticlesToDraw = null; - ParticlesToDraw_Pixelated = null; + particleAutoDrawingOverrides = null; + + activeParticles = null; + particlesToKill = null; + particlesToSpawnNextFrame = null; + particlesToDraw = null; + particlesToDraw_Pixelated = null; + } + + public override void OnWorldUnload() + { + activeParticles.Clear(); + particlesToKill.Clear(); + particlesToSpawnNextFrame.Clear(); + particlesToDraw.Clear(); + particlesToDraw_Pixelated.Clear(); } #endregion @@ -100,18 +166,18 @@ namespace CalamityMod.Particles // 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; if (manualDrawLayerOverride.HasValue) particle.DrawLayer = manualDrawLayerOverride.Value; - particles.Add(particle); - ReturnAssociatedDrawCollection(particle).Add(particle); - particle.Type = particleTypes[particle.GetType()]; + activeParticles.Add(particle); + AddToAssociatedDrawCollection(particle); + particle.Type = particleIDsByTypes[particle.GetType()]; } /// @@ -125,7 +191,7 @@ namespace CalamityMod.Particles // 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; // Get the correct draw layer to spawn this particle on. @@ -145,7 +211,31 @@ namespace CalamityMod.Particles return; particlesToKill.Add(particle); - ReturnAssociatedDrawCollection(particle).Remove(particle); + RemoveFromAssociatedDrawCollection(particle); + } + + /// + /// Gives you the amount of particle slots that are available. Useful when you need multiple particles at once to make an effect and dont want it to be only halfway drawn due to a lack of particle slots + /// + /// + public static int FreeSpacesAvailable() + { + //Safety check + if (Main.dedServ || activeParticles == null) + return 0; + + return CalamityClientConfig.Instance.ParticleLimit - activeParticles.Count(); + } + + /// + /// Gives you the texture of the particle type. Useful for custom drawing + /// + public static Texture2D GetTexture(int type) + { + if (Main.dedServ) + return null; + + return particleTexturesByIDs[type]; } public static void Update() @@ -161,7 +251,7 @@ namespace CalamityMod.Particles } // Update all particle instances in the world. - foreach (Particle particle in particles) + foreach (Particle particle in activeParticles) { if (particle == null) continue; @@ -172,11 +262,11 @@ namespace CalamityMod.Particles } //Clear out particles whose time is up - particles.RemoveAll(particle => + activeParticles.RemoveAll(particle => { if ((particle.Time >= particle.Lifetime && particle.SetLifetime) || particlesToKill.Contains(particle)) { - ReturnAssociatedDrawCollection(particle).Remove(particle); + RemoveFromAssociatedDrawCollection(particle); return true; } return false; @@ -255,8 +345,8 @@ namespace CalamityMod.Particles 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); - Main.spriteBatch.Draw(particleTextures[particle.Type], particle.Position - Main.screenPosition, frame, lightColor, particle.Rotation, frame.Size() * 0.5f, particle.Scale, SpriteEffects.None, 0f); + Rectangle frame = particleTexturesByIDs[particle.Type].Frame(1, particle.FrameVariants, 0, particle.Variant); + Main.spriteBatch.Draw(particleTexturesByIDs[particle.Type], particle.Position - Main.screenPosition, frame, lightColor, particle.Rotation, frame.Size() * 0.5f, particle.Scale, SpriteEffects.None, 0f); } } @@ -303,8 +393,31 @@ namespace CalamityMod.Particles if (Main.dedServ) return; - DrawParticleCollection(ParticlesToDraw, drawLayer); - DrawParticleCollection(ParticlesToDraw_Pixelated, drawLayer, true); + DrawParticleCollection(particlesToDraw, drawLayer); + DrawParticleCollection(particlesToDraw_Pixelated, drawLayer, true); + + foreach (ParticleAutoDrawingOverride drawer in particleAutoDrawingOverrides.Values) + { + if (!drawer.ShouldDrawParticles) + return; + + foreach (var keyValuePair in drawer.ActiveParticleInstances) + { + if (keyValuePair.Value.Count == 0) + return; + + if (drawer.DrawLayerOverride.HasValue) + { + if (drawer.DrawLayerOverride.Value == drawLayer) + drawer.DrawAllParticles(Main.spriteBatch, keyValuePair.Value); + } + else + { + if (keyValuePair.Key == drawLayer) + drawer.DrawAllParticles(Main.spriteBatch, keyValuePair.Value); + } + } + } } private static List ReturnAssociatedDrawCollection(Particle particle) @@ -314,21 +427,21 @@ namespace CalamityMod.Particles { if (particle.UseAdditiveBlend) { - if (!ParticlesToDraw_Pixelated.ContainsKey(BlendState.Additive)) - ParticlesToDraw_Pixelated[BlendState.Additive] = []; - return ParticlesToDraw_Pixelated[BlendState.Additive]; + 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]; + 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]; + if (!particlesToDraw_Pixelated.ContainsKey(BlendState.AlphaBlend)) + particlesToDraw_Pixelated[BlendState.AlphaBlend] = []; + return particlesToDraw_Pixelated[BlendState.AlphaBlend]; } } // Non-pixelated particles (regular). @@ -336,51 +449,45 @@ namespace CalamityMod.Particles { if (particle.UseAdditiveBlend) { - if (!ParticlesToDraw.ContainsKey(BlendState.Additive)) - ParticlesToDraw[BlendState.Additive] = []; - return ParticlesToDraw[BlendState.Additive]; + 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]; + 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]; + if (!particlesToDraw.ContainsKey(BlendState.AlphaBlend)) + particlesToDraw[BlendState.AlphaBlend] = []; + return particlesToDraw[BlendState.AlphaBlend]; } } } - /// - /// Gives you the amount of particle slots that are available. Useful when you need multiple particles at once to make an effect and dont want it to be only halfway drawn due to a lack of particle slots - /// - /// - public static int FreeSpacesAvailable() + private static void AddToAssociatedDrawCollection(Particle particle) { - //Safety check - if (Main.dedServ || particles == null) - return 0; - - return CalamityClientConfig.Instance.ParticleLimit - particles.Count(); + if (particle.OverrideAutomaticDrawing && particleAutoDrawingOverrides[particle.GetType()].ShouldDrawParticles) + { + if (!particleAutoDrawingOverrides[particle.GetType()].ActiveParticleInstances.ContainsKey(particle.DrawLayer)) + particleAutoDrawingOverrides[particle.GetType()].ActiveParticleInstances[particle.DrawLayer] = []; + particleAutoDrawingOverrides[particle.GetType()].ActiveParticleInstances[particle.DrawLayer].Add(particle); + } + else + { + ReturnAssociatedDrawCollection(particle).Add(particle); + } } - /// - /// Gives you the texture of the particle type. Useful for custom drawing - /// - public static Texture2D GetTexture(int type) + private static void RemoveFromAssociatedDrawCollection(Particle particle) { - if (Main.dedServ) - return null; - - return particleTextures[type]; + if (particle.OverrideAutomaticDrawing) + particleAutoDrawingOverrides[particle.GetType()].ActiveParticleInstances[particle.DrawLayer].Remove(particle); + else + ReturnAssociatedDrawCollection(particle).Remove(particle); } - -#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 } } diff --git a/Particles/Particle.cs b/Particles/Particle.cs index c53306ebaf..3174ba2aba 100644 --- a/Particles/Particle.cs +++ b/Particles/Particle.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using CalamityMod.Enums; +using CalamityMod.Enums; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -78,6 +77,12 @@ namespace CalamityMod.Particles /// public virtual bool UseCustomDraw => false; + /// + /// Override and set this to true to disable automatic drawing for all instances of this particle entirely. + ///
Drawing of this particle must be done from a class.
+ ///
+ public virtual bool OverrideAutomaticDrawing => false; + /// /// Use this method if you want to handle the particle drawing yourself. Only called if Particle.UseCustomDraw is set to true. /// diff --git a/Particles/ParticleAutoDrawingOverride.cs b/Particles/ParticleAutoDrawingOverride.cs new file mode 100644 index 0000000000..5a5ec3a257 --- /dev/null +++ b/Particles/ParticleAutoDrawingOverride.cs @@ -0,0 +1,57 @@ +using System.Collections.Generic; +using CalamityMod.Enums; +using Microsoft.Xna.Framework.Graphics; +using Terraria.ModLoader; + +namespace CalamityMod.Particles +{ + /// + /// Allows one to directly control how all active instances of a specified particle type in the world are drawn. + ///
Useful for cases such as applying shaders to particles without resetting the SpriteBatch for every individual particle instance.
+ ///
+ /// + /// Note that particles using an instance of this class MUST have set to true. + /// + public abstract class ParticleAutoDrawingOverride : ModType + { + /// + /// All active particle instances for this drawer, identified by a particle's draw layer. + /// + public Dictionary> ActiveParticleInstances { get; private set; } = []; + + /// + /// The internal name of the particle type that should be manually drawn. + ///
Particle names should be prefixed with the internal name of the mod they are from.
+ ///
e.g. "CalamityMod.PulseRing" is valid, while just "PulseRing" is not.
+ ///
+ /// + /// This is only checked once when the mod is loading. Changing this during runtime will not affect anything. + /// + public abstract string TargetParticleTypeName { get; } + + /// + /// Whether or not this drawer should draw its particles this frame. + ///
Return false to prevent currently stored particles from being drawn and new ones from being added to .
+ ///
+ /// + /// Returns true by default. + /// + public virtual bool ShouldDrawParticles => true; + + /// + /// An optional property which will override the draw layer of all particles for this drawer entirely, using the specified one here instead. + /// + public virtual GeneralDrawLayer? DrawLayerOverride => null; + + protected sealed override void Register() => ModTypeLookup.Register(this); + + public sealed override void SetupContent() => SetStaticDefaults(); + + /// + /// Write all relevenat draw code for your particles here. + /// + /// Stores particles based on their default draw layer. + ///
Iterate through this collection to run individual particle drawing logic.
+ public abstract void DrawAllParticles(SpriteBatch spriteBatch, List particlesToDraw); + } +} 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/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/Systems/Graphic/PixelationSystem/PixelationManager.cs b/Systems/Graphic/PixelationSystem/PixelationManager.cs index a30a5f65ca..c3d80ecc30 100644 --- a/Systems/Graphic/PixelationSystem/PixelationManager.cs +++ b/Systems/Graphic/PixelationSystem/PixelationManager.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.Enums; using CalamityMod.Graphics; -using CalamityMod.Items.Ammo; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -116,14 +115,14 @@ namespace CalamityMod.Systems.Graphic.PixelationSystem if (Main.dedServ) return; - ActivePixelatedDrawers_BeforeTiles = null; - ActivePixelatedDrawers_BeforeNPCs = null; - ActivePixelatedDrawers_AfterNPCs = null; - ActivePixelatedDrawers_BeforeProjectiles = null; - ActivePixelatedDrawers_AfterProjectiles = null; - ActivePixelatedDrawers_AfterPlayers = null; - ActivePixelatedDrawers_AfterDusts = null; - ActivePixelatedDrawers_AfterEverything = null; + ActivePixelatedDrawers_BeforeTiles.Clear(); + ActivePixelatedDrawers_BeforeNPCs.Clear(); + ActivePixelatedDrawers_AfterNPCs.Clear(); + ActivePixelatedDrawers_BeforeProjectiles.Clear(); + ActivePixelatedDrawers_AfterProjectiles.Clear(); + ActivePixelatedDrawers_AfterPlayers.Clear(); + ActivePixelatedDrawers_AfterDusts.Clear(); + ActivePixelatedDrawers_AfterEverything.Clear(); } From a16bd3ec6eac66fcca4f10898b497e44cb063332 Mon Sep 17 00:00:00 2001 From: fryzahh Date: Fri, 7 Nov 2025 13:16:02 -0400 Subject: [PATCH 05/65] Updated GeneralParticleHandler.SpawnParticle and reorganized Particle.cs * Updated GeneralParticleHandler.SpawnParticle with an optional pixelate parameter. Set to true to have spawned particles be pixelated. * Encapsulated GeneralParticleHandler's credits in a region. * Cleaned up and reorganized Particle.cs. * Added documentation comments for all fields and properties in Particle.cs. --- Particles/GeneralParticleHandler.cs | 68 ++++++++++--- Particles/Particle.cs | 151 +++++++++++++++++----------- 2 files changed, 148 insertions(+), 71 deletions(-) diff --git a/Particles/GeneralParticleHandler.cs b/Particles/GeneralParticleHandler.cs index 62d85051c4..873bf88ae8 100644 --- a/Particles/GeneralParticleHandler.cs +++ b/Particles/GeneralParticleHandler.cs @@ -12,7 +12,8 @@ using Terraria.ModLoader; namespace CalamityMod.Particles { - // IMPORTANT CREDITS: + // 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 @@ -34,6 +35,7 @@ namespace CalamityMod.Particles // // 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 @@ -63,6 +65,7 @@ namespace CalamityMod.Particles private static List activeParticles; private static List particlesToKill; private static Dictionary> particlesToSpawnNextFrame; + private static Dictionary> particlesToSpawnNextFrame_Pixelated; private static Dictionary> particlesToDraw; private static Dictionary> particlesToDraw_Pixelated; #endregion @@ -121,6 +124,7 @@ namespace CalamityMod.Particles activeParticles = []; particlesToKill = []; particlesToSpawnNextFrame = []; + particlesToSpawnNextFrame_Pixelated = []; particlesToDraw = []; particlesToDraw_Pixelated = []; @@ -143,6 +147,7 @@ namespace CalamityMod.Particles activeParticles = null; particlesToKill = null; particlesToSpawnNextFrame = null; + particlesToSpawnNextFrame_Pixelated = null; particlesToDraw = null; particlesToDraw_Pixelated = null; } @@ -152,6 +157,7 @@ namespace CalamityMod.Particles activeParticles.Clear(); particlesToKill.Clear(); particlesToSpawnNextFrame.Clear(); + particlesToSpawnNextFrame_Pixelated.Clear(); particlesToDraw.Clear(); particlesToDraw_Pixelated.Clear(); } @@ -161,7 +167,7 @@ namespace CalamityMod.Particles /// 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. /// /// 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, GeneralDrawLayer? manualDrawLayerOverride = null) + 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. @@ -172,6 +178,7 @@ namespace CalamityMod.Particles if (activeParticles.Count >= CalamityClientConfig.Instance.ParticleLimit && !particle.Important) return; + particle.Pixelate = pixelate; if (manualDrawLayerOverride.HasValue) particle.DrawLayer = manualDrawLayerOverride.Value; @@ -186,7 +193,7 @@ namespace CalamityMod.Particles /// another particle type.
///
The single frame buffer ensures the overall particle update loop isn't altered prematurely from within the loop itself.
/// - public static void QueueParticleForNextFrame(Particle particle, GeneralDrawLayer? manualDrawLayerOverride = null) + 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. @@ -194,12 +201,19 @@ namespace CalamityMod.Particles if (Main.gamePaused || Main.dedServ || activeParticles == null) return; - // Get the correct draw layer to spawn this particle on. GeneralDrawLayer actualDrawLayer = manualDrawLayerOverride ?? particle.DrawLayer; - if (!particlesToSpawnNextFrame.ContainsKey(actualDrawLayer)) - particlesToSpawnNextFrame[actualDrawLayer] = []; - - particlesToSpawnNextFrame[actualDrawLayer].Enqueue(particle); + if (pixelate) + { + if (!particlesToSpawnNextFrame_Pixelated.ContainsKey(actualDrawLayer)) + particlesToSpawnNextFrame_Pixelated[actualDrawLayer] = []; + particlesToSpawnNextFrame_Pixelated[actualDrawLayer].Enqueue(particle); + } + else + { + if (!particlesToSpawnNextFrame.ContainsKey(actualDrawLayer)) + particlesToSpawnNextFrame[actualDrawLayer] = []; + particlesToSpawnNextFrame[actualDrawLayer].Enqueue(particle); + } } /// @@ -207,11 +221,29 @@ namespace CalamityMod.Particles /// public static void RemoveParticle(Particle particle) { - if (Main.dedServ) - return; + if (!Main.dedServ) + particlesToKill.Add(particle); + } - particlesToKill.Add(particle); - RemoveFromAssociatedDrawCollection(particle); + /// + /// Removes all active particle instances in the world of a specified type. + /// + public static void RemoveParticlesOfType() where T : Particle + { + 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() + { + foreach (Particle particle in activeParticles) + particlesToKill.Add(particle); } /// @@ -244,10 +276,16 @@ namespace CalamityMod.Particles return; // Spawn queued particles. - foreach (var keyValuePair in particlesToSpawnNextFrame) + foreach (var collectionsByDrawLayer in particlesToSpawnNextFrame) { - while (keyValuePair.Value.Count > 0) - SpawnParticle(keyValuePair.Value.Dequeue(), keyValuePair.Key); + 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. diff --git a/Particles/Particle.cs b/Particles/Particle.cs index 3174ba2aba..ddc3f94bcf 100644 --- a/Particles/Particle.cs +++ b/Particles/Particle.cs @@ -7,18 +7,96 @@ namespace CalamityMod.Particles public 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; + + /// + /// The velocity of the particle. + /// + public Vector2 Velocity; + + /// + /// The point from which this particle's texture should be drawn from. + /// + public Vector2 Origin; + + /// + /// The color of the particle. + /// + public Color Color; + + /// + /// The current rotation of the particle in radians. + /// + public float Rotation; + + /// + /// The scale of the particle. + /// + 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.AfterEverything; + + /// + /// The path to this particle's autoloaded texture. + /// + /// + /// Can be accessed via . + /// + public virtual string Texture => ""; + + /// + /// The maximum amount of frames this particle's spritesheet has vertically. + /// + public virtual int FrameVariants => 1; + + /// + /// An 0-1 interpolant representing how close this particle is from its . + /// + public float LifetimeCompletion => Lifetime != 0 ? Time / (float)Lifetime : 0; + /// /// Set this to true if you NEED the particle to render even if the particle cap is reached. /// @@ -28,49 +106,16 @@ 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 + /// Set this to true to make your particle use additive blending instead of alphablend. /// - 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; + public virtual bool UseAdditiveBlend => false; /// - /// Whether your particle is affected by light levels. + /// Set this to true to make your particles work with semi transparent pixels. Is overriden if UseAdditiveBlend is set to true. /// - public bool AffectedByLight = 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.AfterEverything; - - public virtual int FrameVariants => 1; - public int Variant = 0; - - public virtual string Texture => ""; - - /// - /// Whether or not your particle should be drawn with a pixelated effect to match Terraria's pixel size. - ///
Defaults to false.
- ///
- public virtual bool Pixelate => false; + public virtual bool UseHalfTransparency => false; /// /// Set this to true to disable default particle drawing, thus calling Particle.CustomDraw() instead. @@ -84,28 +129,22 @@ namespace CalamityMod.Particles public virtual bool OverrideAutomaticDrawing => false; /// - /// Use this method if you want to handle the particle drawing yourself. Only called if Particle.UseCustomDraw is set to true. + /// 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) { } - public virtual void CustomDraw(SpriteBatch spriteBatch, Vector2 basePosition) { } /// - /// Called for every update of the particle handler. + /// 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) { } + + /// + /// Called every frame in . /// 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. - /// - public virtual bool UseAdditiveBlend => false; - - /// - /// Set this to true to make your particles work with semi transparent pixels. Is overriden if UseAdditiveBlend is set to true. - /// - public virtual bool UseHalfTransparency => false; - - /// /// Removes the particle from the handler /// From 4b962167cf46b47ef6d7b4a89d9ee2e1e0de96dd Mon Sep 17 00:00:00 2001 From: fryzahh Date: Sun, 9 Nov 2025 16:36:38 -0400 Subject: [PATCH 06/65] Pixelated dust variants * Added the following pixelated variants for their respective ModDust types: * DiamondDustPixelated * SquareDustPixelated * SquashDustPixelated * SquashDustHollowPixelated * SquashDustTileTouchPixelated * UnstableDustPixelated * VoidDustPixelated * VoidDustInvertedPixelated * Added missing documentation comment for the new "pixelate" parameter in GeneralParticleHandler.SpawnParticle. --- Dusts/DiamondDust.cs | 52 ++++++++++++++--- Dusts/LightDust.cs | 21 +++---- Dusts/SquareDust.cs | 47 ++++++++++++--- Dusts/SquashDust.cs | 55 +++++++++++++++--- Dusts/SquashDustHollow.cs | 51 ++++++++++++++--- Dusts/SquashDustTileTouch.cs | 32 +++++++---- Dusts/UnstableDust.cs | 47 ++++++++++++--- Dusts/VoidDust.cs | 49 ++++++++++++++-- Dusts/VoidDustInverted.cs | 57 +++++++++++++++---- Particles/GeneralParticleHandler.cs | 7 +-- .../PixelationSystem/PixelationManager.cs | 4 +- 11 files changed, 336 insertions(+), 86 deletions(-) diff --git a/Dusts/DiamondDust.cs b/Dusts/DiamondDust.cs index 501f5b7643..3b34857b02 100644 --- a/Dusts/DiamondDust.cs +++ b/Dusts/DiamondDust.cs @@ -1,5 +1,7 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Systems.Graphic.PixelationSystem; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ModLoader; @@ -7,7 +9,16 @@ 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); @@ -38,26 +49,51 @@ namespace CalamityMod.Dusts return false; } + public override bool PreDraw(Dust dust) { - Vector2 dustCenter = dust.position + new Vector2(0.25f, 0.25f); - - Texture2D bloom = ModContent.Request("CalamityMod/Particles/SquareRotated").Value; - // 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.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, squash * dust.scale * 0.1f, SpriteEffects.None, 0); + 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.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.2f) with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, squash * dust.scale * 0.09f, SpriteEffects.None, 0); + 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.EntitySpriteDraw(bloom, dustCenter - 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, bloom.Size() * 0.5f, squash * dust.scale * 0.08f * (i == 0 ? 0.7f : 1), SpriteEffects.None, 0); + 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 3da334e73c..6e5338861a 100644 --- a/Dusts/LightDust.cs +++ b/Dusts/LightDust.cs @@ -11,9 +11,9 @@ namespace CalamityMod.Dusts { public class LightDust : ModDust { - public static Asset SolidCircle; + public static Asset SolidCircle { get; private set; } - public static Asset BloomCircle; + public static Asset BloomCircle { get; private set; } public override void Load() { @@ -47,15 +47,12 @@ namespace CalamityMod.Dusts public override bool PreDraw(Dust dust) { - Vector2 dustCenter = dust.position + new Vector2(0.25f, 0.25f); - // Glow Orb - Main.EntitySpriteDraw(BloomCircle.Value, dustCenter - 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); + 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(BloomCircle.Value, dustCenter - 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(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(SolidCircle.Value, dustCenter - 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); - + 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; } } @@ -72,14 +69,12 @@ namespace CalamityMod.Dusts private static void DrawPixelated(Dust dust) { - Vector2 dustCenter = dust.position + new Vector2(0.25f, 0.25f); - // Glow Orb - Main.spriteBatch.Draw(BloomCircle.Value, dustCenter - 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); + 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, dustCenter - 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(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, dustCenter - 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); + 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 index 054b05ad37..7c25502b6a 100644 --- a/Dusts/SquareDust.cs +++ b/Dusts/SquareDust.cs @@ -1,6 +1,8 @@ using System; +using CalamityMod.Systems.Graphic.PixelationSystem; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ModLoader; @@ -8,7 +10,16 @@ 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); @@ -42,22 +53,44 @@ namespace CalamityMod.Dusts } public override bool PreDraw(Dust dust) { - Vector2 dustCenter = dust.position + new Vector2(0.25f, 0.25f); - - Texture2D bloom = ModContent.Request("CalamityMod/Particles/GlowSquareParticleThick").Value; - Vector2 squash = Vector2.One; // 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, squash * dust.scale * 0.1f, SpriteEffects.None, 0); + 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.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.3f) with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, squash * dust.scale * 0.095f, SpriteEffects.None, 0); + 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.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.3f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, squash * dust.scale * 0.09f, SpriteEffects.None, 0); + 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 index 5894cedb1b..8adfb2beaa 100644 --- a/Dusts/SquashDust.cs +++ b/Dusts/SquashDust.cs @@ -1,5 +1,7 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Systems.Graphic.PixelationSystem; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ModLoader; @@ -7,7 +9,21 @@ 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); @@ -37,24 +53,45 @@ namespace CalamityMod.Dusts return false; } + 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; - 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.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, squash * 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, squash * 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, squash * 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, squash * 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, squash * 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, 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 index 9378128784..ec82d5aa67 100644 --- a/Dusts/SquashDustHollow.cs +++ b/Dusts/SquashDustHollow.cs @@ -1,5 +1,7 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Systems.Graphic.PixelationSystem; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ModLoader; @@ -7,7 +9,16 @@ 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); @@ -36,25 +47,49 @@ namespace CalamityMod.Dusts return false; } + public override bool PreDraw(Dust dust) { - Vector2 dustCenter = dust.position + new Vector2(0.25f, 0.25f); - - Texture2D bloom = ModContent.Request("CalamityMod/Particles/BloomRing").Value; - // 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(bloom, dustCenter - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, squash * dust.scale * 0.1f, SpriteEffects.None, 0); + 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(bloom, dustCenter - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.2f) with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, squash * dust.scale * 0.09f, SpriteEffects.None, 0); + 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(bloom, dustCenter - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.4f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, squash * dust.scale * 0.075f, SpriteEffects.None, 0); + 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 index 0884d87cb4..8b994b462d 100644 --- a/Dusts/SquashDustTileTouch.cs +++ b/Dusts/SquashDustTileTouch.cs @@ -1,13 +1,15 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Systems.Graphic.PixelationSystem; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ModLoader; namespace CalamityMod.Dusts { - public class SquashDustTileTouch : ModDust + 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); @@ -16,12 +18,14 @@ namespace CalamityMod.Dusts public override bool Update(Dust dust) { bool touchedTiles = false; - int size = (int)(2); + 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; @@ -45,24 +49,30 @@ namespace CalamityMod.Dusts return false; } + } + + public class SquashDustTileTouchPixelated : SquashDustTileTouch + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + 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; + 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.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, squash * 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, squash * 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, squash * 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, squash * 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, squash * 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, squash * dust.scale * 0.075f, SpriteEffects.None, 0); } - return false; } } } diff --git a/Dusts/UnstableDust.cs b/Dusts/UnstableDust.cs index ee9cbf0fce..82f42fbfb5 100644 --- a/Dusts/UnstableDust.cs +++ b/Dusts/UnstableDust.cs @@ -1,6 +1,8 @@ using System; +using CalamityMod.Systems.Graphic.PixelationSystem; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ModLoader; @@ -8,7 +10,16 @@ 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); @@ -41,23 +52,45 @@ namespace CalamityMod.Dusts return false; } + public override bool PreDraw(Dust dust) { - Vector2 dustCenter = dust.position + new Vector2(0.25f, 0.25f); - - Texture2D bloom = ModContent.Request("CalamityMod/Particles/FullStar").Value; - Vector2 squash = new Vector2(0.4f, 1); float texScaling = 6; - Main.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, squash * dust.scale * 0.1f * texScaling, SpriteEffects.None, 0); + 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.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, squash * dust.scale * 0.04f * texScaling, SpriteEffects.None, 0); + 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.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.3f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, squash * dust.scale * 0.025f * texScaling, SpriteEffects.None, 0); + 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/Particles/GeneralParticleHandler.cs b/Particles/GeneralParticleHandler.cs index 873bf88ae8..bb495b64dc 100644 --- a/Particles/GeneralParticleHandler.cs +++ b/Particles/GeneralParticleHandler.cs @@ -57,15 +57,13 @@ namespace CalamityMod.Particles /// internal static Dictionary particleTexturesByIDs; - /// - /// All types defined across all mods, identified by the type of the particle the drawers target. - /// - internal static Dictionary particleAutoDrawingOverrides; + private static Dictionary particleAutoDrawingOverrides; private static List activeParticles; private static List particlesToKill; private static Dictionary> particlesToSpawnNextFrame; private static Dictionary> particlesToSpawnNextFrame_Pixelated; + private static Dictionary> particlesToDraw; private static Dictionary> particlesToDraw_Pixelated; #endregion @@ -166,6 +164,7 @@ namespace CalamityMod.Particles /// /// 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. /// + /// 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) { diff --git a/Systems/Graphic/PixelationSystem/PixelationManager.cs b/Systems/Graphic/PixelationSystem/PixelationManager.cs index c3d80ecc30..00628ffda8 100644 --- a/Systems/Graphic/PixelationSystem/PixelationManager.cs +++ b/Systems/Graphic/PixelationSystem/PixelationManager.cs @@ -213,7 +213,7 @@ namespace CalamityMod.Systems.Graphic.PixelationSystem { blendStateTargetPair.Value.SwapTo(); - Main.spriteBatch.Begin(default, blendStateTargetPair.Key, SamplerState.LinearClamp, default, default, null, pixelationMatrix); + 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(); @@ -236,7 +236,7 @@ namespace CalamityMod.Systems.Graphic.PixelationSystem foreach (var keyValuePair in targetCollection) { Main.spriteBatch.TryEnd(); - Main.spriteBatch.TryBegin(SpriteSortMode.Deferred, keyValuePair.Key, Main.DefaultSamplerState, default, default, null, Main.GameViewMatrix.TransformationMatrix); + Main.spriteBatch.TryBegin(default, keyValuePair.Key, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); float targetScale = 1f / PixelationResolution; Main.spriteBatch.Draw(keyValuePair.Value, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, targetScale, SpriteEffects.None, 0f); From 8b10aadab87227d598a7511884ca4650ca694def Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Wed, 12 Nov 2025 12:24:31 -0500 Subject: [PATCH 07/65] Odd Mushroom now copies particles --- Particles/GeneralParticleHandler.cs | 51 ++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/Particles/GeneralParticleHandler.cs b/Particles/GeneralParticleHandler.cs index bb495b64dc..c50b6d413e 100644 --- a/Particles/GeneralParticleHandler.cs +++ b/Particles/GeneralParticleHandler.cs @@ -105,7 +105,7 @@ namespace CalamityMod.Particles particleAutoDrawingOverrides.Add(particleType, drawer); else throw new Exception($"The Particle of name \"{drawer.TargetParticleTypeName}\" used in {drawer.GetType().Name} could not be found! " + - $"Please ensure the Paricle's internal name is spelt correctly and is prefixed by its home mod's internal name."); + $"Please ensure the Particle's internal name is spelt correctly and is prefixed by its home mod's internal name."); } } } @@ -372,18 +372,47 @@ namespace CalamityMod.Particles private static void DrawParticleInstance(Particle particle) { - if (particle.UseCustomDraw) + int drawIterations = Main.LocalPlayer.Calamity().trippy ? 4 : 1; + for (int i = 0; i < drawIterations; i++) { - particle.CustomDraw(Main.spriteBatch); - } - else - { - Color lightColor = particle.Color; - if (particle.AffectedByLight) - lightColor = particle.Color.MultiplyRGB(Lighting.GetColor((particle.Position / 16).ToPoint())); + // 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; + } - Rectangle frame = particleTexturesByIDs[particle.Type].Frame(1, particle.FrameVariants, 0, particle.Variant); - Main.spriteBatch.Draw(particleTexturesByIDs[particle.Type], particle.Position - Main.screenPosition, frame, lightColor, particle.Rotation, frame.Size() * 0.5f, particle.Scale, SpriteEffects.None, 0f); + 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], 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; } } From 391294f41c5e94eb923e1210cd0e75f64adad4a8 Mon Sep 17 00:00:00 2001 From: Nathanael Overton Date: Thu, 13 Nov 2025 21:23:28 -0500 Subject: [PATCH 08/65] Greatly decreased Shoreskipper spawn rate --- NPCs/SunkenSea/Shoreskipper.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NPCs/SunkenSea/Shoreskipper.cs b/NPCs/SunkenSea/Shoreskipper.cs index b63881c6aa..aa8b8041e4 100644 --- a/NPCs/SunkenSea/Shoreskipper.cs +++ b/NPCs/SunkenSea/Shoreskipper.cs @@ -392,9 +392,9 @@ namespace CalamityMod.NPCs.SunkenSea if (!spawnInfo.Player.Calamity().clamity) { if (spawnInfo.Player.Calamity().ZoneTimelessShores && !spawnInfo.Water) - return SpawnCondition.Cavern.Chance * 0.8f; + return SpawnCondition.Cavern.Chance * 0.6f; else if (spawnInfo.Player.Calamity().ZoneTimelessShores && spawnInfo.Water) - return SpawnCondition.Cavern.Chance * 0.45f; + return SpawnCondition.Cavern.Chance * 0.25f; } return 0f; } From 911fdcb1d5b2681f334d6100724fcac3587be9b3 Mon Sep 17 00:00:00 2001 From: Nathanael Overton Date: Thu, 13 Nov 2025 21:24:41 -0500 Subject: [PATCH 09/65] collision check for stormlion sentry spawning --- NPCs/SunkenSea/StormlionSentry.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/NPCs/SunkenSea/StormlionSentry.cs b/NPCs/SunkenSea/StormlionSentry.cs index ff64da0ff4..d143b98113 100644 --- a/NPCs/SunkenSea/StormlionSentry.cs +++ b/NPCs/SunkenSea/StormlionSentry.cs @@ -286,9 +286,12 @@ namespace CalamityMod.NPCs.SunkenSea } public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.Player.Calamity().ZoneTimelessShores && !spawnInfo.Water && !spawnInfo.Player.Calamity().clamity) + 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 * 0.7f; + return SpawnCondition.Cavern.Chance * 8f; } return 0f; } From 7dffc69f81f2d3b7218abf9e7d845f409dfd4464 Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Thu, 13 Nov 2025 23:49:47 -0500 Subject: [PATCH 10/65] Death Mode Blood Moon spawn rate boost only applies on the surface --- NPCs/CalamityGlobalNPC.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 8326c9b601..202cdc1820 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -5847,7 +5847,7 @@ 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 * 5f); From 56062876fda2c68626a7f759437ed515d6780e42 Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Fri, 14 Nov 2025 12:21:07 -0500 Subject: [PATCH 11/65] Decreased Tax Collector buff --- NPCs/CalamityGlobalTownNPC.cs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/NPCs/CalamityGlobalTownNPC.cs b/NPCs/CalamityGlobalTownNPC.cs index 3216f3dba2..ee25f5ae8d 100644 --- a/NPCs/CalamityGlobalTownNPC.cs +++ b/NPCs/CalamityGlobalTownNPC.cs @@ -42,19 +42,15 @@ namespace CalamityMod.NPCs { get { - // Max of 20 platinum. - if (DownedBossSystem.downedYharon) - return 40f; - - // Max of 10 platinum. + // 15 silver per NPC, max of 7 platinum 50 gold. if (DownedBossSystem.downedDoG) - return 20f; + return 15f; - // Max of 5 platinum. + // 10 silver per NPC, max of 5 platinum. if (NPC.downedMoonlord) return 10f; - // Max of 2 platinum. + // 4 silver per NPC, max of 2 platinum. if (NPC.downedPlantBoss) return 4f; @@ -62,7 +58,7 @@ namespace CalamityMod.NPCs } } - public static int TotalTaxesPerNPC => (int)(Item.buyPrice(0, 0, 1, 50) * TaxYieldFactor); + public static int TotalTaxesPerNPC => (int)(Item.buyPrice(0, 0, 1, 0) * TaxYieldFactor); public static int TaxesToCollectLimit => (int)(Item.buyPrice(0, 50, 0, 0) * TaxYieldFactor); From 3899891c3dd27395f2ad18d049fe882fdb8ad03d Mon Sep 17 00:00:00 2001 From: Altixal <73398287+Altixal@users.noreply.github.com> Date: Sat, 15 Nov 2025 01:54:08 +0700 Subject: [PATCH 12/65] Reduced the Tax Collector curve to match --- NPCs/CalamityGlobalTownNPC.cs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/NPCs/CalamityGlobalTownNPC.cs b/NPCs/CalamityGlobalTownNPC.cs index ee25f5ae8d..e76d91bf1a 100644 --- a/NPCs/CalamityGlobalTownNPC.cs +++ b/NPCs/CalamityGlobalTownNPC.cs @@ -42,25 +42,27 @@ namespace CalamityMod.NPCs { get { - // 15 silver per NPC, max of 7 platinum 50 gold. - if (DownedBossSystem.downedDoG) - return 15f; - // 10 silver per NPC, max of 5 platinum. - if (NPC.downedMoonlord) + if (DownedBossSystem.downedDoG) return 10f; - // 4 silver per NPC, 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, 0) * 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); #region Town NPC Patreon Name Sets private static readonly string[] AnglerNames = From 537ddbf44b78c1ae1af8f9b7d28a0fa1456646e7 Mon Sep 17 00:00:00 2001 From: Altixal <73398287+Altixal@users.noreply.github.com> Date: Sat, 15 Nov 2025 03:35:22 +0700 Subject: [PATCH 13/65] OOA pieces are so back --- Items/CalamityGlobalItem.cs | 115 ------------------ Items/CalamityGlobalItemTooltip.cs | 64 ++-------- .../MonkT2ArmorSetChange.cs | 19 ++- .../MonkT3ArmorSetChange.cs | 25 ++-- .../Mods.CalamityMod.Vanilla.Armor.hjson | 27 +--- .../en-US/Mods.CalamityMod.Vanilla.hjson | 90 +++++--------- 6 files changed, 63 insertions(+), 277 deletions(-) diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index e234e81a0c..a183cff0ee 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -1009,18 +1009,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) @@ -1050,44 +1038,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; @@ -1151,76 +1101,11 @@ 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; - break; - - case ItemID.HuntressJerkin: - player.GetDamage() -= 0.1f; - player.GetDamage() -= 0.15f; - player.GetCritChance() += 5; - break; - case ItemID.HuntressPants: - player.GetDamage() -= 0.05f; - break; - - case ItemID.ApprenticeHat: - player.GetDamage() -= 0.05f; - break; - case ItemID.ApprenticeRobe: - player.GetDamage() -= 0.1f; - break; - case ItemID.ApprenticeTrousers: - player.GetDamage() -= 0.05f; - player.GetCritChance() -= 15; - 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.HuntressAltShirt: - player.GetDamage() -= 0.15f; - player.GetDamage() -= 0.15f; - 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; - break; - case ItemID.ApprenticeAltPants: - player.GetDamage() -= 0.1f; - player.GetCritChance() -= 25; - break; - case ItemID.SolarFlareHelmet: player.GetCritChance() -= 6; break; diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index 8d418894b0..81e0ab211b 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -594,8 +594,17 @@ 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 @@ -1073,8 +1082,6 @@ namespace CalamityMod.Items // 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) @@ -1086,47 +1093,14 @@ namespace CalamityMod.Items // 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")); - if (item.type == ItemID.SquireGreaves) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("SquireGreaves")); - + // 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(0, (line) => line.Text = EditedTooltip("MonkPants1")); - EditTooltipByNum(1, (line) => line.Text = EditedTooltip("MonkPants2")); - } - - // Huntress armor - if (item.type == ItemID.HuntressJerkin) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("HuntressJerkin")); - if (item.type == ItemID.HuntressPants) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("HuntressPants")); - - // Apprentice armor - if (item.type == ItemID.ApprenticeHat) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("ApprenticeHat")); - if (item.type == ItemID.ApprenticeRobe) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("ApprenticeRobe")); - 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")); - if (item.type == ItemID.SquireAltShirt) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("SquireAltShirt")); - if (item.type == ItemID.SquireAltPants) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("SquireAltPants")); + EditTooltipByNum(1, (line) => line.Text = EditedTooltip("MonkPants")); // Shinobi Infiltrator armor if (item.type == ItemID.MonkAltHead) @@ -1138,20 +1112,6 @@ 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 diff --git a/Items/VanillaArmorChanges/MonkT2ArmorSetChange.cs b/Items/VanillaArmorChanges/MonkT2ArmorSetChange.cs index a0cf88de55..0858e7b99f 100644 --- a/Items/VanillaArmorChanges/MonkT2ArmorSetChange.cs +++ b/Items/VanillaArmorChanges/MonkT2ArmorSetChange.cs @@ -14,37 +14,34 @@ 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.2f; // 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.2f; // Replace melee damage with rogue 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..bfa4f0783a 100644 --- a/Items/VanillaArmorChanges/MonkT3ArmorSetChange.cs +++ b/Items/VanillaArmorChanges/MonkT3ArmorSetChange.cs @@ -14,39 +14,36 @@ namespace CalamityMod.Items.VanillaArmorChanges public override string ArmorSetName => "MonkTier3"; + public static float SetBonusRogueStealth = 0.95f; + 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() += 20; // Replace melee crit chance with rogue. } 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/Localization/en-US/Mods.CalamityMod.Vanilla.Armor.hjson b/Localization/en-US/Mods.CalamityMod.Vanilla.Armor.hjson index 833305aaac..edd4c8b9e2 100644 --- a/Localization/en-US/Mods.CalamityMod.Vanilla.Armor.hjson +++ b/Localization/en-US/Mods.CalamityMod.Vanilla.Armor.hjson @@ -70,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 @@ -128,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.hjson b/Localization/en-US/Mods.CalamityMod.Vanilla.hjson index 101aac404b..ae10dfeae2 100644 --- a/Localization/en-US/Mods.CalamityMod.Vanilla.hjson +++ b/Localization/en-US/Mods.CalamityMod.Vanilla.hjson @@ -121,17 +121,9 @@ EditedTooltip: { Summons the Eater of Worlds when used in the 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 - ''' - // Ancient Manipulator - LunarCraftingStation: Used to craft items from Lunar Fragments, Luminite, and Astral Bars - 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: @@ -144,8 +136,26 @@ 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 + SquireGreatHelm: Increases your max number of sentries by 1 and grants +2 HP/s life regen + // Valhalla Knight's Breastplate + SquireAltShirt: 30% increased summon damage and grants +4 HP/s life regen + SolarFlarePieces: Grants +1 HP/s life regeneration + /* + Others + */ + 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 + ''' + // Ancient Manipulator + LunarCraftingStation: Used to craft items from Lunar Fragments, Luminite, and Astral Bars + AnkhShield1: Grants immunity to knockback + AnkhShield2: Grants immunity to most debuffs, including Mighty Wind ArcheryPotion: 20% increased arrow speed and 5% increased arrow damage // Aerial Bane DD2BetsyBow: Shoots a tight spread of 6 splitting arrows @@ -202,54 +212,6 @@ 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 - */ - 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: - ''' - 5% increased summon damage and melee critical strike chance - 15% increased movement speed - ''' - 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 GravityGlobe: ''' Provides 32% increased jump speed and increased fall speed @@ -258,6 +220,14 @@ EditedTooltip: { Press {$Key.UP} to change gravity Press {$Key.DOWN} to fall faster ''' + MonkBrows: Increases your max number of sentries by 1 and increases rogue velocity by 20% + MonkShirt: 20% increased summon and rogue damage + MonkPants: 15% increased rogue critical strike chance and 20% increased movement speed + // 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: 20% increased summon damage and rogue critical strike chance } // Buff Descriptions From e51a87666f741532f038651c034912fc46bf1115 Mon Sep 17 00:00:00 2001 From: Altixal <73398287+Altixal@users.noreply.github.com> Date: Sat, 15 Nov 2025 04:01:07 +0700 Subject: [PATCH 14/65] Ion Blaster move manifested --- Items/Weapons/Magic/IonBlaster.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Items/Weapons/Magic/IonBlaster.cs b/Items/Weapons/Magic/IonBlaster.cs index 96b6aa113a..8126a4a72f 100644 --- a/Items/Weapons/Magic/IonBlaster.cs +++ b/Items/Weapons/Magic/IonBlaster.cs @@ -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(); } From f21cf28580b9f669a45902f9481942e8aa31abdc Mon Sep 17 00:00:00 2001 From: Altixal <73398287+Altixal@users.noreply.github.com> Date: Sat, 15 Nov 2025 05:42:55 +0700 Subject: [PATCH 15/65] Vanilla revisions and reorgs 1) Reverted Step Stool buff 2) Death Sickle no longer inflicts Whispering Death 3) Ankh Shield states immunity to fire blocks again 4) Slight tooltip revision to Archery Potion 5) Reorganised groups in tooltip files into basic types --- CalPlayer/CalamityPlayerMiscEffects.cs | 4 - CalPlayer/CalamityPlayerOnHit.cs | 8 - Items/CalamityGlobalItemTooltip.cs | 593 ++++++++---------- .../en-US/Mods.CalamityMod.Vanilla.hjson | 155 ++--- 4 files changed, 351 insertions(+), 409 deletions(-) diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 4cab67d89a..a0f65e9915 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -4370,10 +4370,6 @@ namespace CalamityMod.CalPlayer Player.GetCritChance() += 10; } - - if (Player.portableStoolInfo.IsInUse) - Player.GetCritChance(DamageClass.Generic) += 5; - // Amalgam boosts if (Main.myPlayer == Player.whoAmI) { diff --git a/CalPlayer/CalamityPlayerOnHit.cs b/CalPlayer/CalamityPlayerOnHit.cs index 9a5dbf505b..474eba0dcb 100644 --- a/CalPlayer/CalamityPlayerOnHit.cs +++ b/CalPlayer/CalamityPlayerOnHit.cs @@ -102,10 +102,6 @@ namespace CalamityMod.CalPlayer switch (item.type) { - case ItemID.DeathSickle: - target.AddBuff(BuffType(), 120); - break; - case ItemID.InfluxWaver: target.AddBuff(BuffID.Electrified, 300); break; @@ -276,10 +272,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); diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index 81e0ab211b..d0c6a5d89f 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -564,7 +564,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) @@ -607,93 +607,45 @@ namespace CalamityMod.Items 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.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")); - // Apparently 612 is a homestuck reference - if (item.type == ModContent.ItemType()) - EditTooltipByName("AxePower", (line) => line.Text = line.Text.Replace("610%", "612%")); + // +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")); - // 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")); + // +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")); - // 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")); + // 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")); - // 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")); + // Great breath boost + if (item.type == ItemID.GillsPotion) + EditTooltipByName("BuffTime", (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.AbyssBreathLevel3")); - // 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")); - - // Nerfed Archery Potion tooltip - if (item.type == ItemID.ArcheryPotion) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("ArcheryPotion")); - - // 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))); - - // Ancient Manipulator also crafts stuff with Astral Bars - if (item.type == ItemID.LunarCraftingStation) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("LunarCraftingStation")); - - // Reworked Gravity Globe - if (item.type == ItemID.GravityGlobe) - EditTooltipByNum(1, (line) => line.Text = EditedTooltip("GravityGlobe")); - - // "Buffed" Step Stool - if (item.type == ItemID.PortableStool) - EditTooltipByNum(0, (line) => line.Text += AddedTooltip("PortableStool")); - - // 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())); + 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")); @@ -732,17 +684,10 @@ namespace CalamityMod.Items if (item.type == ItemID.WormFood) EditTooltipByNum(0, (line) => line.Text = EditedTooltip("WormFood")); - #endregion - // 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)); + 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. @@ -770,109 +715,22 @@ namespace CalamityMod.Items } #endregion - // Other weapon changes - #region Other 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%")); + #region Accessories + // Brain of Confusion, Black Belt and Master Ninja Gear have guaranteed dodges with a fixed cooldown. + 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)); + // 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%")); - // 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")); - - // Melee speed removal. + // Melee speed removed from the Celestial Stone line. if (item.type == ItemID.MoonStone) EditTooltipByNum(1, (line) => line.Text = EditedTooltip("SunMoonStones")); if (item.type == ItemID.SunStone) @@ -882,120 +740,20 @@ namespace CalamityMod.Items if (item.type == ItemID.CelestialShell) EditTooltipByNum(2, (line) => line.Text = EditedTooltip("CelestialStoneShell")); - // Mana Flower tinker buffs. - if (item.type == ItemID.MagnetFlower) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("MagnetFlower")); - if (item.type == ItemID.ArcaneFlower || item.type == ItemID.ManaCloak) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("ArcaneFlowerManaCloak")); - if (item.type == ItemID.ArcaneFlower) - EditTooltipByNum(2, (line) => line.Text += AddedTooltip("ArcaneFlower")); - - // Magiluminescence nerf and clear explanation of what it actually does. - 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. - 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. - if (item.type == ItemID.EmpressFlightBooster) - { - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("EmpressFlightBooster1")); - EditTooltipByNum(1, (line) => line.Text = EditedTooltip("EmpressFlightBooster2")); - } - - if (item.type == ItemID.EyeoftheGolem) - { - EditTooltipByNum(0, (line) => line.Text += AddedTooltip("EyeoftheGolem")); - } - - // Rifle Scope visibility change - if (item.type == ItemID.RifleScope) - { - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("RifleScope1")); - EditTooltipByNum(1, (line) => line.Text = EditedTooltip("RifleScope2")); - } - - // Sniper Scope rebalance and visibility change - 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")); - } - - // Recon Scope visibility change - if (item.type == ItemID.ReconScope) - EditTooltipByNum(0, (line) => line.Text += AddedTooltip("RifleScope")); - - // Molten Quiver - if (item.type == ItemID.MoltenQuiver) - EditTooltipByNum(2, (line) => line.Text = EditedTooltip("MoltenQuiver")); - - // Magic Power Potion nerf - if (item.type == ItemID.MagicPowerPotion) - EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("20%", "10%")); - - // 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")); - - // Gem Robe nerfs - if (item.type == ItemID.AmethystRobe) - EditTooltipByNum(1, (line) => line.Text = line.Text.Replace("5%", "4%")); - if (item.type == ItemID.TopazRobe) - { - EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("40", "20")); - EditTooltipByNum(1, (line) => line.Text = line.Text.Replace("7%", "5%")); - } - if (item.type == ItemID.SapphireRobe) - EditTooltipByNum(1, (line) => line.Text = line.Text.Replace("9%", "6%")); - if (item.type == ItemID.EmeraldRobe) - { - EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("60", "40")); - EditTooltipByNum(1, (line) => line.Text = line.Text.Replace("11%", "7%")); - } - if (item.type == ItemID.RubyRobe || item.type == ItemID.AmberRobe) - EditTooltipByNum(1, (line) => line.Text = line.Text.Replace("13%", "8%")); - if (item.type == ItemID.DiamondRobe) - { - EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("80", "60")); - EditTooltipByNum(1, (line) => line.Text = line.Text.Replace("15%", "9%")); - } - // 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")); @@ -1006,12 +764,85 @@ namespace CalamityMod.Items 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")); + // 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 = line.Text.Replace("8%", "10%")); + if (item.type == ItemID.ArcaneFlower || item.type == ItemID.ManaCloak) + 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 clarify the movement effects given. + if (item.type == ItemID.Magiluminescence) + EditTooltipByNum(0, (line) => line.Text = EditedTooltip("Magiluminescence")); + + // 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 clarify the movement effects given. + if (item.type == ItemID.EmpressFlightBooster) + { + EditTooltipByNum(0, (line) => line.Text = EditedTooltip("EmpressFlightBooster1")); + EditTooltipByNum(1, (line) => line.Text = EditedTooltip("EmpressFlightBooster2")); + } + + // 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 - // Pre-Hardmode armor tooltip edits #region Pre-Hardmode Armor // Gladiator if (item.type == ItemID.GladiatorHelmet) @@ -1045,9 +876,39 @@ namespace CalamityMod.Items // Meteor if (item.type == ItemID.MeteorHelmet || item.type == ItemID.MeteorSuit || item.type == ItemID.MeteorLeggings) EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("9%", "8%")); + + // Magic Hat nerf + if (item.type == ItemID.MagicHat) + EditTooltipByNum(0, (line) => line.Text = EditedTooltip("MagicHat")); + + // Gem Robe nerfs + if (item.type == ItemID.AmethystRobe) + EditTooltipByNum(1, (line) => line.Text = line.Text.Replace("5%", "4%")); + if (item.type == ItemID.TopazRobe) + { + EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("40", "20")); + EditTooltipByNum(1, (line) => line.Text = line.Text.Replace("7%", "5%")); + } + if (item.type == ItemID.SapphireRobe) + EditTooltipByNum(1, (line) => line.Text = line.Text.Replace("9%", "6%")); + if (item.type == ItemID.EmeraldRobe) + { + EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("60", "40")); + EditTooltipByNum(1, (line) => line.Text = line.Text.Replace("11%", "7%")); + } + if (item.type == ItemID.RubyRobe || item.type == ItemID.AmberRobe) + EditTooltipByNum(1, (line) => line.Text = line.Text.Replace("13%", "8%")); + if (item.type == ItemID.DiamondRobe) + { + EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("80", "60")); + EditTooltipByNum(1, (line) => line.Text = line.Text.Replace("15%", "9%")); + } + + //Gi 10% melee speed into 10% jump speed replacement + if (item.type == ItemID.Gi) + EditTooltipByNum(1, (line) => line.Text = EditedTooltip("Gi")); #endregion - // Hardmode armor tooltip edits #region Hardmode Armor // Cobalt if (item.type == ItemID.CobaltHat) @@ -1091,7 +952,6 @@ namespace CalamityMod.Items } #endregion - // DD2 armor tooltip edits #region DD2 Armor // Tweaks into Rogue // Monk armor @@ -1114,31 +974,7 @@ namespace CalamityMod.Items EditTooltipByNum(0, (line) => line.Text = EditedTooltip("MonkAltPants")); #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.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 - - // 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)); // Forbidden (UNLESS you are wearing the Circlet, which is Summon/Rogue and does not get this line) @@ -1151,7 +987,50 @@ namespace CalamityMod.Items EditTooltipByName("SetBonus", (line) => line.Text = CalamityUtils.GetText($"Vanilla.Armor.SetBonus.Vortex").Format(CalamityUtils.GetArmorSetBonusKey())); #endregion - // Provide the full stats of every vanilla yoyo + #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 + #region Yoyo Stat Tooltips // This function is shorthand for appending a stat sheet to a yoyo. void AddYoyoStats(float d, float r, float s) @@ -1204,7 +1083,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. @@ -1350,7 +1228,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. @@ -1467,9 +1344,77 @@ 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")); + + 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 + + // 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 diff --git a/Localization/en-US/Mods.CalamityMod.Vanilla.hjson b/Localization/en-US/Mods.CalamityMod.Vanilla.hjson index ae10dfeae2..1db18e712d 100644 --- a/Localization/en-US/Mods.CalamityMod.Vanilla.hjson +++ b/Localization/en-US/Mods.CalamityMod.Vanilla.hjson @@ -8,14 +8,36 @@ DodgeInfo: ''' AddedTooltip: { + /* + Accessories + */ + TitanGloveLine: 10% increased true melee damage + YoyoGlove: Secondary yoyos will do 50% less damage EyeoftheGolem: 20% increased critical strike damage + RifleScope: The scope effect can be toggled with visibility + ArcaneFlower: 5% increased magic damage + 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, 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 25 RodofDiscord: Teleportation is disabled while Chaos State is active Pwnhammer: ''' @@ -28,32 +50,13 @@ 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 ''' - HandWarmer: Provides a regeneration boost while wearing the Snow armor GoldenFishingRod: Its fishing line will never break - // Step Stool - PortableStool: Standing on the stool grants 5% increased critical strike chance 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, 6 defense and 10% movement speed - Fairies are immune to damage and will no longer flee - ''' - 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 CrimsonBreastplate: +1 HP/s life regen CrimsonOtherPieces: +0.5 HP/s life regen Picksaw: Can mine Scoria Ore located in the Abyss @@ -143,52 +146,10 @@ EditedTooltip: { SquireAltShirt: 30% increased summon damage and grants +4 HP/s life regen SolarFlarePieces: Grants +1 HP/s life regeneration /* - Others + Accessories */ - 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 - ''' - // Ancient Manipulator - LunarCraftingStation: Used to craft items from Lunar Fragments, Luminite, and Astral Bars - AnkhShield1: Grants immunity to knockback - AnkhShield2: Grants immunity to most debuffs, including Mighty Wind - ArcheryPotion: 20% increased arrow speed and 5% increased arrow damage - // 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' - ''' 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 ( to zoom out) - RifleScope2: The scope effect can be toggled with visibility - SniperScope: 12% increased ranged critical strike chance - MoltenQuiver: Lights wooden arrows ablaze and all arrows inflict Hellfire - MagicHat: 6% increased magic critical strike chance PowerGlove: 10% increased melee speed, does not stack with downgrades BerserkerGlove: 10% increased true melee damage MechanicalGlove: @@ -202,16 +163,19 @@ EditedTooltip: { 14% increased melee damage 14% increased melee speed, does not stack with downgrades ''' - Gi: 10% increased movement and jump speed - GoldPickaxe: Can mine Demonite, Crimtane, Meteorite, Sea Prisms, and Sea Prism Crystals - 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 - FlaskofIchor: Melee, Whip, and Rogue attacks decrease enemies defense - FlaskofNanites: Melee, Whip, and Rogue attacks confuse enemies - 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 + 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 and jump speed by 10% and acceleration by 1.25x GravityGlobe: ''' Provides 32% increased jump speed and increased fall speed @@ -220,6 +184,17 @@ EditedTooltip: { Press {$Key.UP} to change gravity Press {$Key.DOWN} to fall faster ''' + FlameWakerBoots: + ''' + Multiplies all fire-based debuff damage by 1.25x + 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 MonkBrows: Increases your max number of sentries by 1 and increases rogue velocity by 20% MonkShirt: 20% increased summon and rogue damage MonkPants: 15% increased rogue critical strike chance and 20% increased movement speed @@ -228,6 +203,40 @@ EditedTooltip: { MonkAltShirt0: 20% increased summon damage and rogue velocity MonkAltShirt1: 5% increased rogue critical strike chance MonkAltPants: 20% increased summon damage and rogue critical strike chance + /* + Potions + */ + ArcheryPotion: 5% increased arrow damage and 20% increased arrow speed + AleSake: + ''' + Increases melee damage by 10% and reduces defense by 5% + 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 + FlaskofIchor: Melee, Whip, and Rogue attacks decrease enemies defense + FlaskofNanites: Melee, Whip, and Rogue attacks confuse enemies + 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 + /* + Others + */ + // 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: + ''' + Throws a mixture of slime and sparkling crystals + Slimed enemies take more damage from fire-based debuffs + ''' + // 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 From 613a491c1c7ce12a1b0f4c92c7535789f75388d5 Mon Sep 17 00:00:00 2001 From: Altixal <73398287+Altixal@users.noreply.github.com> Date: Sat, 15 Nov 2025 05:51:54 +0700 Subject: [PATCH 16/65] debumped crimson regen by a notch --- Items/CalamityGlobalItemTooltip.cs | 9 ++------- Items/VanillaArmorChanges/CrimsonArmorSetChange.cs | 7 +------ Localization/en-US/Mods.CalamityMod.Vanilla.hjson | 3 +-- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index d0c6a5d89f..f302480785 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -864,13 +864,8 @@ namespace CalamityMod.Items // 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; - }); + EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("3%", "6%")); + EditTooltipByNum(0, (line) => line.Text += AddedTooltip("CrimsonArmorPieces")); } // Meteor 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/Localization/en-US/Mods.CalamityMod.Vanilla.hjson b/Localization/en-US/Mods.CalamityMod.Vanilla.hjson index 1db18e712d..c71760a5ee 100644 --- a/Localization/en-US/Mods.CalamityMod.Vanilla.hjson +++ b/Localization/en-US/Mods.CalamityMod.Vanilla.hjson @@ -57,8 +57,7 @@ AddedTooltip: { Graveyards have various new item sales and recipes ''' FeatherfallPotion: Disables all airborne flight recovery - 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 } From 3fa9bf954cb937b83d289a07c9b941c1e0e658a1 Mon Sep 17 00:00:00 2001 From: Altixal <73398287+Altixal@users.noreply.github.com> Date: Sat, 15 Nov 2025 05:57:05 +0700 Subject: [PATCH 17/65] slightly nerfed victide again. sorry! --- Items/Armor/Victide/VictideBreastplate.cs | 2 +- Items/Armor/Victide/VictideGreaves.cs | 2 +- Items/Armor/Victide/VictideHeadBarrier.cs | 4 ++-- Items/Armor/Victide/VictideHeadBurrow.cs | 2 +- Items/Armor/Victide/VictideHeadSnail.cs | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Items/Armor/Victide/VictideBreastplate.cs b/Items/Armor/Victide/VictideBreastplate.cs index 5e39ddee61..9c7c4f70b3 100644 --- a/Items/Armor/Victide/VictideBreastplate.cs +++ b/Items/Armor/Victide/VictideBreastplate.cs @@ -41,7 +41,7 @@ namespace CalamityMod.Items.Armor.Victide Item.height = 18; Item.value = CalamityGlobalItem.RarityGreenBuyPrice; Item.rare = ItemRarityID.Green; - Item.defense = 5; + Item.defense = 4; } public override void UpdateEquip(Player player) diff --git a/Items/Armor/Victide/VictideGreaves.cs b/Items/Armor/Victide/VictideGreaves.cs index dd8c3b9b22..d31857818d 100644 --- a/Items/Armor/Victide/VictideGreaves.cs +++ b/Items/Armor/Victide/VictideGreaves.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Items.Armor.Victide Item.height = 18; Item.value = CalamityGlobalItem.RarityGreenBuyPrice; Item.rare = ItemRarityID.Green; - Item.defense = 4; + Item.defense = 3; } public override void UpdateEquip(Player player) diff --git a/Items/Armor/Victide/VictideHeadBarrier.cs b/Items/Armor/Victide/VictideHeadBarrier.cs index 5da260e68e..2c57ea4250 100644 --- a/Items/Armor/Victide/VictideHeadBarrier.cs +++ b/Items/Armor/Victide/VictideHeadBarrier.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Armor.Victide // Set Bonus public static int BarrierCooldown = CalamityUtils.SecondsToFrames(8); - public static int BarrierDefenseBoost = 5; + public static int BarrierDefenseBoost = 6; public static float BarrierDamageAbsorptionPercent = 0.1f; public static int BarrierFramesPerHeal = 15; public static int BarrierDamage = 50; @@ -35,7 +35,7 @@ namespace CalamityMod.Items.Armor.Victide Item.height = 18; Item.value = CalamityGlobalItem.RarityGreenBuyPrice; Item.rare = ItemRarityID.Green; - Item.defense = 6; // 15 + Item.defense = 5; // 12 } public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); diff --git a/Items/Armor/Victide/VictideHeadBurrow.cs b/Items/Armor/Victide/VictideHeadBurrow.cs index 8eaf0ed7be..2ccd1629aa 100644 --- a/Items/Armor/Victide/VictideHeadBurrow.cs +++ b/Items/Armor/Victide/VictideHeadBurrow.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Items.Armor.Victide Item.height = 18; Item.value = CalamityGlobalItem.RarityGreenBuyPrice; Item.rare = ItemRarityID.Green; - Item.defense = 5; // 14 + Item.defense = 3; // 10 } public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); diff --git a/Items/Armor/Victide/VictideHeadSnail.cs b/Items/Armor/Victide/VictideHeadSnail.cs index 7b4de4234d..8398d1903e 100644 --- a/Items/Armor/Victide/VictideHeadSnail.cs +++ b/Items/Armor/Victide/VictideHeadSnail.cs @@ -30,7 +30,7 @@ namespace CalamityMod.Items.Armor.Victide Item.height = 18; Item.value = CalamityGlobalItem.RarityGreenBuyPrice; Item.rare = ItemRarityID.Green; - Item.defense = 1; // 10 + Item.defense = 1; // 8 } public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); From 5174a5e77252210974b3e6947cdb714dbbf4452f Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Fri, 14 Nov 2025 19:02:51 -0500 Subject: [PATCH 18/65] Restored the nerfs to OOA armors made this update No stats on set bonus but I made those nerfs for a reason --- Items/CalamityGlobalItem.cs | 62 +++++++++++++++++++ Items/CalamityGlobalItemTooltip.cs | 35 +++++++++++ .../MonkT2ArmorSetChange.cs | 5 +- .../MonkT3ArmorSetChange.cs | 5 +- .../en-US/Mods.CalamityMod.Vanilla.hjson | 27 +++++--- 5 files changed, 120 insertions(+), 14 deletions(-) diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index a183cff0ee..f5b7460bbc 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -1101,11 +1101,73 @@ namespace CalamityMod.Items player.GetAttackSpeed() += 0.05f; break; + case ItemID.SquireGreaves: + player.GetDamage() -= 0.05f; + break; + + case ItemID.HuntressWig: + player.GetCritChance() += 5; + break; + + case ItemID.HuntressJerkin: + player.GetDamage() -= 0.05f; + player.GetDamage() -= 0.05f; + break; + + case ItemID.ApprenticeHat: + player.GetDamage() -= 0.1f; + break; + + case ItemID.ApprenticeRobe: + player.GetDamage() -= 0.05f; + 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.GetDamage() -= 0.1f; + break; + + case ItemID.SquireAltPants: + player.GetCritChance() -= 5; + player.GetDamage() -= 0.05f; + break; + + case ItemID.HuntressAltShirt: + player.GetDamage() -= 0.05f; + player.GetDamage() -= 0.05f; + break; + + case ItemID.HuntressAltPants: + player.GetDamage() -= 0.05f; + break; + + case ItemID.ApprenticeAltHead: + player.GetDamage() -= 0.05f; + player.GetDamage() -= 0.05f; + break; + + case ItemID.ApprenticeAltShirt: + player.GetDamage() -= 0.05f; + break; + + case ItemID.ApprenticeAltPants: + player.GetCritChance() -= 10; + break; + case ItemID.SolarFlareHelmet: player.GetCritChance() -= 6; break; diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index f302480785..5a95f46cb8 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -948,6 +948,41 @@ namespace CalamityMod.Items #endregion #region DD2 Armor + // Nerf sets that are too strong + if (item.type == ItemID.SquireGreaves) + EditTooltipByNum(0, (line) => line.Text = EditedTooltip("SquireGreaves")); + + 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 = line.Text.Replace("20%", "15%")); + + if (item.type == ItemID.ApprenticeHat) + EditTooltipByNum(0, (line) => line.Text = EditedTooltip("ApprenticeHat")); + if (item.type == ItemID.ApprenticeRobe) + EditTooltipByNum(0, (line) => line.Text = EditedTooltip("ApprenticeRobe")); + if (item.type == ItemID.ApprenticeTrousers) + EditTooltipByNum(0, (line) => line.Text = EditedTooltip("ApprenticeTrousers")); + + if (item.type == ItemID.SquireAltHead) + EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("10%", "15%")); + if (item.type == ItemID.SquireAltShirt) + EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("30%", "20%")); + if (item.type == ItemID.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) diff --git a/Items/VanillaArmorChanges/MonkT2ArmorSetChange.cs b/Items/VanillaArmorChanges/MonkT2ArmorSetChange.cs index 0858e7b99f..50f35ac57a 100644 --- a/Items/VanillaArmorChanges/MonkT2ArmorSetChange.cs +++ b/Items/VanillaArmorChanges/MonkT2ArmorSetChange.cs @@ -24,13 +24,14 @@ namespace CalamityMod.Items.VanillaArmorChanges public override void ApplyHeadPieceEffect(Player player) { player.GetAttackSpeed() -= 0.2f; - player.Calamity().rogueVelocity += 0.2f; // 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.2f; - player.GetDamage() += 0.2f; // 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) diff --git a/Items/VanillaArmorChanges/MonkT3ArmorSetChange.cs b/Items/VanillaArmorChanges/MonkT3ArmorSetChange.cs index bfa4f0783a..8ff9fa762b 100644 --- a/Items/VanillaArmorChanges/MonkT3ArmorSetChange.cs +++ b/Items/VanillaArmorChanges/MonkT3ArmorSetChange.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.VanillaArmorChanges public override string ArmorSetName => "MonkTier3"; - public static float SetBonusRogueStealth = 0.95f; + public static float SetBonusRogueStealth = 1f; public override void UpdateSetBonusText(ref string setBonusText) { @@ -38,7 +38,8 @@ namespace CalamityMod.Items.VanillaArmorChanges public override void ApplyLegPieceEffect(Player player) { player.GetCritChance() -= 20; - player.GetCritChance() += 20; // Replace melee crit chance with rogue. + player.GetCritChance() += 10; // Replace melee crit with rogue crit. + player.GetDamage() -= 0.1f; // Small nerf to summon damage. } public override void ApplyArmorSetBonus(Player player) diff --git a/Localization/en-US/Mods.CalamityMod.Vanilla.hjson b/Localization/en-US/Mods.CalamityMod.Vanilla.hjson index c71760a5ee..2a3d8e8414 100644 --- a/Localization/en-US/Mods.CalamityMod.Vanilla.hjson +++ b/Localization/en-US/Mods.CalamityMod.Vanilla.hjson @@ -140,10 +140,24 @@ EditedTooltip: { HamBat: Defeating enemies temporarily grants +3 HP/s life regen // Vital Crystal AegisCrystal: Permanently boosts natural life regeneration + /* + 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 - // Valhalla Knight's Breastplate + 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 - SolarFlarePieces: Grants +1 HP/s life regeneration + // 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 */ @@ -194,14 +208,7 @@ EditedTooltip: { */ MagicHat: 6% increased magic critical strike chance Gi: 10% increased movement and jump speed - MonkBrows: Increases your max number of sentries by 1 and increases rogue velocity by 20% - MonkShirt: 20% increased summon and rogue damage - MonkPants: 15% increased rogue critical strike chance and 20% increased movement speed - // 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: 20% increased summon damage and rogue critical strike chance + SolarFlarePieces: Grants +1 HP/s life regeneration /* Potions */ From f82e869bc3e6693d5b123828398304869f9c1509 Mon Sep 17 00:00:00 2001 From: doze-zoze Date: Fri, 14 Nov 2025 20:19:12 -0600 Subject: [PATCH 19/65] fixes and adjustments to saros --- Projectiles/Summon/SarosAura.cs | 25 +++++++++-------- Projectiles/Summon/SarosAura.png | Bin 6729 -> 7919 bytes Projectiles/Summon/SarosSunfire.cs | 42 +++++++++++++++++++++++------ 3 files changed, 46 insertions(+), 21 deletions(-) diff --git a/Projectiles/Summon/SarosAura.cs b/Projectiles/Summon/SarosAura.cs index 68a219e8db..4ae102b332 100644 --- a/Projectiles/Summon/SarosAura.cs +++ b/Projectiles/Summon/SarosAura.cs @@ -1,7 +1,5 @@ -using System; -using CalamityMod.Buffs.Summon; +using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; -using CalamityMod.Items.Potions.Alcohol; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -88,12 +86,12 @@ namespace CalamityMod.Projectiles.Summon Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.25f / 255f, (255 - Projectile.alpha) * 0.25f / 255f, (255 - Projectile.alpha) * 0f / 255f); - NPC target = GetTargetInRange(3200); + NPC target = GetTargetInRange(1600); if (target is null) return; - + if (Projectile.owner == Main.myPlayer) { @@ -103,7 +101,7 @@ namespace CalamityMod.Projectiles.Summon } else { - int damage = (int)(Projectile.damage * (0.75f + Projectile.minionSlots * 0.25f)); + 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++) @@ -112,7 +110,7 @@ namespace CalamityMod.Projectiles.Summon 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.75f + Projectile.minionSlots * 0.25f); + Projectile.ai[1] += 60f / (0.8f + Projectile.minionSlots * 0.2f); } } @@ -121,17 +119,18 @@ namespace CalamityMod.Projectiles.Summon NPC GetTargetInRange(float range) { var player = Main.player[Projectile.owner]; - if (player.HasMinionAttackTargetNPC && Main.npc[player.MinionAttackTargetNPC].CanBeChasedBy(this) && Projectile.IsInRangeOfMeOrMyOwner(Main.npc[player.MinionAttackTargetNPC], range, out var _, out var _, out var _)) + 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 + } + else { NPC gotTarget = null; float currentDistance = range; - for (int i = 0; i < Main.npc.Length; i++) + foreach (var npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; - if (npc.CanBeChasedBy(this) && Projectile.IsInRangeOfMeOrMyOwner(npc, range, out var myDistance, out var _, out var _) && myDistance < currentDistance) + var myDistance = npc.Distance(Projectile.Center); + if (npc.CanBeChasedBy() && myDistance < currentDistance) { currentDistance = myDistance; gotTarget = npc; @@ -155,7 +154,7 @@ namespace CalamityMod.Projectiles.Summon { //Main.EntitySpriteDraw(ciTex, Projectile.Center - Main.screenPosition, null, Color.Gold, Main.GlobalTimeWrappedHourly, ciTex.Size() * 0.5f, 0.075f, SpriteEffects.None); - float count = (int)((Projectile.minionSlots - 1) / 3) * 2 + 1; + float count = (int)((Projectile.minionSlots - 1) / 3) * 2 + 2; for (var i = 0; i < count; i++) { var comp = (i / count); diff --git a/Projectiles/Summon/SarosAura.png b/Projectiles/Summon/SarosAura.png index 1706469c4f7d00b8d6f70b8e8136dd5af9cded0a..8b4f1ddd5210584cd05d193dd18395c193352a13 100644 GIT binary patch literal 7919 zcmZ8`c|6qL_y3D5gBDvEJ7Zr`_MK+3j3q?2gfhvVy^K9e+4m*8?7L)(5XB(O7(!8~ zk+EbOYnFUpdVhZZ{9cd8z4zRid(Yj@J?Gr#i8eCOzCg=H3jn|c9i)aaSUx{X5GpW- zqDjeMLFR3&jR5Mf9Lr#Z!U28@4gd{_bjJ@U!8(lx($X6ME`B^qWc}_H56?RKXj=G~ zxIglF`oPN`FnZwh*hj)Z^A3-!grtO`>*HxPuuY4-h0Y@#9Z>)RRww~BGD?69q;$c= z{y+L`Ho|1*{{2o4(voE406kdV1(VYYihsX5gY?;VA53Tc|6lq44GNqCfFx>w0&HnO3M5Vy0sv>ejt2aW zpUqmHUYvbDdhT>rsXpLnc6~XY%Q(;irf(Fg*-cgw$poi!c=bC^yn{BaJGR@B(h`k& zNU%4Pe4`sy(}CB)xDtfzIU9R z{y(abaXE}|k0-^RI5FbKc;uETpRQq?jq>go6N;O6kKx(IGK=fe)A3J{-y=2y1{xBD zuPMX*?RKUsGZUaw3`Keo5;O{PT_N0-&@b`9`=RvhL0{nH8?7{>0(1>e8@9? zzQvZ?u+IX0z7af9HJH+1XXz^;@+yD!|pd<-#8;IwV_~uNAvfFf4oFA6cx=cfAoFuW(585qmWGcg{w8O zB|IsP>^fUb6o1|f;?H`1cbxq8ypAuD(KYrwd&w7_D1DMjyh#pjIVEy?E#x?C`#TpO zLj(k$z8xGub(G%v1x7aFN9cg_YsK0k=wbcY{JhBvLjv0WHZqcdpoI9n&8R`nc8$^` z=R^aN4naILa^g@e5W2?OD+fpB-M6nd-fS3)p@01As!9uzVR%s?6@nLtvQG5QIk^_Q zzZ8vkDSs^ImJip63o0>6QK2knHS8UbQ^%DG+Xcw;E~HXK&!r-J#?*s(TRJu6MPCI{ z{}Mu4<9^)RVIvzv@q5*%AYc)pL5#4%%hn(Q)-Hs1;$QhX6?c`RQ9xuN4KMyne#Sf9`A<0wt9}1IEC4Gy^`cN zE9Xi*HNxtqMlsD!xqTO2#{W!C4m-La5*MHUpi?d-Dp`eU zA=BQG7z=+wB3_xcQfl-N>D?qlEHn{~6=vK-ku_QB3 zmc3u&w4-OOxK(1wz+=t6mhokiOM|w3qikX6k%10QFCib=`D7(4x*?JId-EljMpiVf zJP&11SB$}%%M4zCu(#!dkFjYQY2xS?J13g$hEZukgBo%EUY84U9Jc;GFa^5r%hUk( zCG)0$*SS*{fTr36u2-_2WzHAw?T7!D90bV;jmJARUfO(F+)h`tmG{gy)n61iUPt_Qq-XzQ$I2Q$FtnQ8%MwjX29?f;ehhN^9E z*0h#g69%up3yd~BVXcp*5Y%Li<`9gpw`%RyY8vC0YI5RWDABtJ({wqObE@M#JMY%2 zazU*rtKUQB%%Uj|IIp?}#K0w1-P& zD-@0;2c8pdQvwq`uYpkf7M=_U+$cCLcR$yi_?P%Th#M#)W=aDU4%<|~Vye>xVC0R? z?8g?M&^Ncimnr&(H4N!|?e4qovVEjYI1=BKOmQ^O;P{<`eZi4QNBGc5pTyCcJNNG@ zUI{HKpkzCthtua4D@w4QQHZ0`6zFPJX|O zW!cdu6~-#@pZj+#seo|20wYQ#j(~X~037da{2f#VHcwA~CaRH#`g=9UO`&uDjO*ln zZJq>$D`!bHV~r8W7(zz1#JljtCrtH?iNA&?nF-b7HR|z8>GG9ig$5D4?nT!8{Zi;u zOmFa~mnr=g+G4E)*?+2*or$324(GD7Wj21~xyZz8hS&KdpR^CXLIT+Hi-he?dwAIU zTH@BiVF`K^mBt~GQ8q?c1h`!1;?zk}3Vd+Ak=9jz6^_`?SEf(|L6@AoSNx zRnPN&i+c=`E651V7_${Q|47XpE?*RiIT<3EBP*?8Cj(r!T7s_0h)g5%QL|rIS3_YBnKN0$r=F)$1ny9WlLK9UzRPz#%R7``J}gi^xvd_w zky>!>hN=}mLL8=;;dacfUQdWKpr~YdL<3}IZi@jG#9Q&mICT5tWEB3Tq8y2%dPyL; zh}VlBmc+t~NZNmUwf>(vx7LeW?Vw}`9cYM=n#>PV!CYY#c9#@4B{6Sp!&zxeGO7^# zePlpf{{#d`*hp9hx(7Q6%2D|+{}*tW=H(g7I%c3_`}@@UgbP83KYlU*3-+w$4%DVp zKyiRN6zJah5fUrydAocG<=XF4(!VqZpu)Z6@{;;rY6?ImNXp0ffRoj)%A9B@nY{1Y7|-IDJD zyw*~7{S6BteE%4*Oa*kG6bz$eQqAn={^X6 z%49y9OSDA#o-}Lfi#vXC8q} zLOAJ$4zITM$8)76DoTo6_F2X+%7ysSMHIXCr*6)l$e6qjcRn`Pl)V@!f9_hNJ|vwk zi$zLIx0Hn7>RNyPis+5_z5#;s3O>SkZND@gQcbkw(;2S#XKO|uf>W#dO# z3dh-M6_{6r8;J}4+`FcZcgjlYG6jdy#)hVa1xnqTOpTFlHOVPMlL{jWDBcKgViFWW z6iir3AqA#c>T3#281zRdfecbP*Z2266g7-?S3I}Rl^~6=4n@UzPMfe5;eIa2LeDvz zSE(@=bFDtp4AZNi;QlPb4-`h>DQn}6d=S-DX{~-Atm2AVp=O>FJ4+P`(o|$at`hK1ecz&3( zIUb!jVQC^ji-F?O2NWGtQdNXDdY~w@AT5>^H%8QSCT0nCIgRP)ZF!Wa zR?W}RzlsLbx5oQzA@{)!(!ik+Pow;lR@8alCnr7@$9XVe#VIYmM*yKg_l(x)X z$G-KQ^#HRT4=&Yn#5gOxS(pL_x=$t%v<^k(7BS3J9yHd8WYl%`FYU^J>O{dIO!BpU zudqfm)PD3&!aY(hSnU&I(4fhe4oz>Xpm2bhOA+I?-p~sW<5=3n6~WD@(xsKS`26d$ zw0m4})Hf?jI5;`ao0cu~ zq!IaI&GNhcso6}6$Lu?L#0_5=oaw95VRqhat=@oH>SnMa+Vok^{wBnuEC#e6mSS4G zLp1K;mwLomf}zrlyemmYO14-bw*8pvy14 zjOjHB6T?Ewg(Fp{82C(J)Tp=>Q|7D+1*?GA1x*XnfoJpj3+UhVDdiQSrnG~7Jrznx zpbWfaLkjdRIjW@T4sH$NpM8=>lO7F+8gMt$0ZGQX80b)pu_wkt&1Vp$L9SsOI3I&I z72MXUFxE45Ry>KjHq9zM6g@S<+z#!Z_)%^6p(6{i+ID>{F6)PrRh8GREB^Vzb9!mf zQglv=sNv;FY0OJ+?78lxCeZ3E{P3zH>91(9SEk9hxs)&>TpUVM-pICGPN7>3yBtR6 z*0GrDNwnj-$zIQj8a_;)^2n9!s;d6+pa*JYzGI1|t5Rn38+LIGhzIXQzSh*DB!Aw? z@7(LfL03$%BDM@qElN8me@Q!jt1w3Os`Nnst&b|}^>0n`fbJjo`{#kD8wsHL#103>7E60;Ewio;P!T7!AKp@y&~AR zH6!5r&{f*g@Y#x(5?X_sQ1Crr4mm!FScE zKx-P`9Ar0A*4P@vRXk;~?4OuyCNOAKqpC%^l0rNm=eufNQ@ybjSHuhm)0ui=4?L1C zMb6v#8C{HE4wT{ILY6MzxBN;-`UwUY>Z*Z>1MCl@Us)<>KJ2$A63usXA8J;Xe9|z> z&=nT=+1`J*MT7%L({2nLHyP$KSUp6@`ztnLo!ztByvug6GRyBLmB$b1$#W;V@(@!j z?G3k<8dTxFk z+5CumdOhgjJZR{~aE$~xmxYv(6+*3Ri{ih8Op=Gzm0tl|8((i-^l!V7EA|H3yAnDf zY_`Xmw*Yt?P_bi(9A(7QzZv~YF?&e~>$2y7x2HWMGT@$yQVz(}PU&1||0NubY<@!> zeGGu!#4V6MwhJZ$SjK-T0{V-GjGiHwj8>j{xQht;k+eU!n!TM5(VkvH?c493_6vaz zq4$Ty8>e)Dvf0%F^O@?BOKK|0)PS|EfZZ^kWCf2$m83-M0~qENMW}i3>cY!>hTXp7 z+|ymd-~;v7@B~nb8~~3e48;xL9q76PA_hBL#rq)nq21TcN4ns%p>hkxiRA$QHjYBk zU_l{TXn4KTi%0>ie^XW=4<(EfZUTNp?)QhjfZy@czl=bM@fK0kiw5}kZg=wW#-ivW zwb+j@vvPwmEI{F^PR)nbTur;CT`Vi#w&)|Xp>U0a2J%q6OK>PBPH2SN-1F&^aSV|i zMK-@~bqoR24%G`n&I80mY&|gl^T&h$pc3f8fXmD6V{&03CNpQI{t^K6$0SI*>sxDi zR@I!=AaoLx?7u!-p5iI%YrE*(Y#Tl+$b-Iu_*S}*`xK3#+sMsK(Q&C6;>X2Jnt2J{ zDz5!hB6WAhJY@TT0+2ZE%2#v=@(@%g<|Lnw+xo@ZGKp}tQn-HOTDt75#pmU2S&0ZU zPNJr7F3TG8-HKdki7X>Zma2uVZ0}dJburJFMTtW0+#F{8=;TC12H4j2qSg4r1W#;t z{%{}`H$28l*nK01b#!QIz}{6?8leI<2j^7$?l-lJH&$mkHRaiiENZzZ=M6hdTA1T< zN}pnJ#I<3?jqFJ|-iX4Hs=u1y@o|sjx7*;)O$C{Q78|GBmhalt%x!G-vL~D5#M0BJ zEm*2-1FQ&0R@`OZip5rD6*{tKllmnO$6m~r-XFW`pt$|b5ygK=x3xBz@k3K>vN3YJ zsjSOuoHI>;yc0%&NwH>~eNhLzbnSgBMqpYNdtiY~u#jFe7y$ZdS9=W=x> z&7cAiRl_V*zcA>2@#2eeQ~Q}uLmeqnVv$CX1KJOUZjNrpZ1K;O^!?qq#MSx0?Q(Sn5B6Awv@B?JN!(||zwp6N-etS@H#d52isD9baC9B=+c z;^=#6-xNRxRD9oMZXz~9PlB)P2R+_Uvo+9UCl7OC1G9a#`zY$ElS}F$_nR6ThpHoG zF(ZPpk4xK)~Tl8>{&)v+^$ujqMnsj0KlcTz^tM+@`vXc+TUSgb00U?VSW>Pn>- zr3?o|=zCp8Y~H*6BhbUx%PFrli!rMat0Pb%JNc;1coJ%Ed$4%?cW0&6y`W1@=_=K3 zM6*65BR%qGZe!pkwKA^w)3GY(o+w!RV-&0k#9n=$Q>X8KYW8k$`5p~1Ofo}7bC%!O zRW#+J`02D47Gy2W`=xrW#z3pQZ~p8FcmOhYeu8d$jd{EL%ja=?^R`o`$7I{rnk-A= znw^s~F?@WwnU~_dt2IFt;R53Yku5bw#5qXqUb2zg68&oulsVFIbtcsJlxemI^rju~ zN%9~H>^w}2` zF+{$`zJKMcXo882afWKc9H_BPe>0I)1Y_N-y3i1UL zbU7W7-aXCJ%k=b%%~@6~HIlOtH}c6}3AjIii8RIM_q;_upL~mXF<%=?@ruduM5hTv zi(IC3kz&`9qu`glCwG-iYHP)7(`zP;>~cgY$FpfnCs{8VkJR3&t=E1>cT!h>^cUokbr&0|$5xkKlDO8;;OsB!CIlFjXA|ypx_3pD&s3&d ztW7prOch-l%^ol|x!|R=*5yAp$jH9%)@irve@_XBr=f|3{f+TC0TMJt9Io+vB2`Jm_`iF(+UDJ}oX|R2J2gxB{&U?EwYLkL9O&4|1I*F<-Bl~@d6VbT zO>!l|ecFl19aQ!zwRD0M6r?L^-D}${XINUnp8xr=MzhJ~)xbSpwSW`a6-+PBZgX$( z;oYB|!B>5+N+ORsv`)KH{sswj2FLGw?&b0A)H*e2`kUw28GOM9Wta4LMfPyNZg0bS zZC9+qL6E9)Rrc`dyZwzP8@pmP<$_epO7(Cqlx-Sfq3{@^<~86W5lQ0E6{t_f*n1j^ z#N;AVAt`&d3r-!MGy}07^g4I?9Di*tcu)ZE_g~B%sR74-3jQv=0G-7rmy2I0X>xCC z=4RDOM@hf@o1u+p604^#rbxvG8EHwym#ait7tnpxi2oQKu7eM!q4_7`r!qA$QX` zj}_Rz^W#3^zBCwA1f&OL)T`>OKOxP29W+oI_kt1bzL8!Yo4v^}NKBx|?z7Q%LE& zqDwFx`Ru~;g6QO&l%Fl6%SWI8MOxTE`8eZ`+D&LSo#n#@#ypNuNv;OXw| zHeru~2G0md=PZp<3*p#k^BfFwIaQw%h8ilewYmRQ$o38 zi5Q8)+7Mo}6tSTCOS)y%ux7B~7UWY%QlYX(WF|w*}vEs9UpjSynb(USu^_3 z!1`90gEKj-=CsqFwcj38V}K(_jQrVyt4lmKm3L>=5H*9FUVhO*|785Jj7t{;T+Ol* z&6q%M`(8VSV~g+Y@|m1 zPo=ee4r_9dZ4P7D&YPtF_7;r81!lD;@L2msBUVy=SxyL$RkB+rb%{nSRs92y z^=VENZmkW{SX!|c(lGxwf;kwRTrSgSa|@b?^2h`IqW{G~{}&L=G&%(~8j`*LMs+ox PMQwF74K(Ty_rv}VgjM4? literal 6729 zcmYj$c|26_`~DGGGTE|?tl6cEL6*rDl5Ex3_ie1%vhR_74Vh*VlI&ZCDP-RnS+b0! zP)HcOnTG5?d_RBup4aP~=lpSA=iJYIU-xxi&;2Ak($lR5U5cE74_elmcqryS@5+Z5 z=TtR*_MG2T4H4YS)im5_F5gv{KP12Vzu}R#U`W5v!ax~s)xAQ;e_*`bAVK@Hocnq2 zdW)1!5eqHaCjzIEG$9BqGr5a}A3kdnx>s4IW$n!r8y}koydTEXhC~{CYmR<9wyBhZy2ed3;Y8_nW_13s zeOiZCD=0r%^}g3A{R_8%cLbaME1g}yMrf0EvT6~v;V0+Fo|Es!oy@s>cg4TM)V>=U zEex$3dov3Vi4M^MpTGj6haLU5884|YPbaHV^n%4CISSQ^?Ah~WF`d95+V&|KFStXm zM@Hb;oMW=y)?)n|kCJ5{b%Xq;jIno!cVDso0(W$FXlL>v&ukQxivIr7A>KD!F{!{J zbx-PE6OMgHegG7CGF2erTX)qQ_paHF(;XIl6aKfkkEy@|0ll0@su`fpfkuI=JK6p4 z#=wYwfuNKZ=P|?=c&>-I;)LVA9_MWw82jHxFHex_^iKwjsVo+ZI=bDKuE0+q zy=4x`<*36rus@Qa(FYp8bFX>$znGnNNOGA52ss=ze4;wM7i?WV*tT64CITAW#m?cs z;+-=5f^is*m;zUx@jK&3HEqnVL^sWm|ABtm{)_>4Oo*i-C^!Gyr7><3xVBWv`DKO* zeIs=bN9Tal`a)gFh5EBD0{@`(_L2%aZhNGE$aAKOObDI7p)Q09WgB1+QyZ`Bqo@*B z?Rj_HUZJf_nCK|;7ul=+FT5zw)c?vb12^mDAcOX9>@1W#;7*$8%_Wz*H}lGe*@M=a zzZbkqK#aZP3L@I-zqnEgsDYikU&(mQ5nx~(VM(rHD1%x2Vim^RJi`+WZq(Z#A7D5N zg{pETJ{{pmDqT!*H$e9Hf!Z%g)qh0Wd4&q>b^l-V-|*3y-f)Thu(xgExZqdd{vnnO z3YZ|aIZzHMEMNh{X%%HevjOd5I)rh1^HVnmw5` zY8Co-+<-oOISAlxCj9{cCky%!dwakF&&f_+1PEZWwzMEqF?=NhFw4$f0%pwE-+LTV z0y`E;)n#9pfU-yIFQ7UTe+7Z)P03y8FMV>xxx9B zA&zj>0fhH}NNPAsb~8yWnbzgcM0&?{g(nq_tOJ_XX|0VJ<#X-y_=+a8IX11)p=wjX6`EkNT<|DL<2922iUV9 z_dhJUW=XEbRE~RiQ-5D|x$D^GK*h&iDg!!b{+=0jk@n^|hA)r5eMGgZD|LU8h+=)P zcv;#kt`pQaHrdceXIh4N0c~^4qE`Em?s|160Q(JJ2~9UNYJhYp=#ts^_}>P3hu_%C z$*cTLlnWsen1Nr;@qTv;LzSKYC5aXU5JC{6Vfq?)x%O|(ER-$XOo=gJ4|63(^3r{; zTNDoU`y3V$J-&KDJY*X@XwE%Xc@`lrdpS?qbKufJyHu^a|0dTpB}uvS=kdU`-{nNk zM5lv`)J~np53>e9y)rVHDr?X71>!cYEFsy@sJ846=z;=GSB6-8> zUjyb8@Ovyhrntl9n>E%38hpsXN@t#+$1Be)DuH(;jaPt&S$rbqkZ-ikRe;SnN+;G~ zH0e!Bx=e1(=-|gG$JE<);>D25_$;d_wk*MO&XqHZHOb&YvHf&qsj6=OC(Suez5yB+ z+OZhQ1nbGJ(f}3uJ2F7ic27S)VB(p<0#v+WG!k|jH8Mg&MjbQB+75g($=d>yk0w2p zJi~cHJxRGoP6@34s`Ek*v;mQ-&n$q!tov199peGKYZ843n6UX>2D(47f69jr zhZF#2;$c%^w%--NY0HirFt%PY2TDH2xL!lh5}>%@h@I(b;9cn~D^T{H$-2)7^?oLi zm8mBmJ8edagj~sH?emCN0N8zd1A=+b?dmR4W#;(W4M8C(-WO{l-@dR^~B=C;L7qxO`Vqm~mmwNby;@>W{fw@&gz>G?#}dkC+-k!vK%LS1Ck4qjI7&nA6~>-~{%bF`M^pRP!dj90 z*CPbTmNHzqxySvx(f_fy^DTZyMaltCDq-QiW_DA8XxWTi;si6J;GpVsWU?ykg&D7? z)Jt#+@mTrvQ!>FGXdAQEd<{T+zfuEQ8BjYdOjm7IpIlIp&k4U%?60v0JFQ7%Hk=2K ze~V_v!VYn#s}cZj@)&@U8p~7d*&D6?y}0}@=`O4F1F)955%*r(((FR;OPX(1ljUQm zAtVMpz+|Csj9l33+$!HTi|tLaiQ_}o(e4Efe2Tp-u7ZA8V!vj7$mClBWI z!8a25gIWUyNJm6@?rRB!i$B)>$>%*;F`l%WUOGw%s1=lY5U$BiIT5PZ&#TK8ztvUQ z(7mM{#Mgu%6rL-fBxsl2MsbXoS5Zb%CvO$fc1M_<91YHkb_QQ3IeKu?eo)HXA1oSF zaa_<-45MoF>F1S*O)!n;kqelDf_ek?5#jD>)&%D4#yLP`?5|nKLsW5@26Ev5k{Dta zo1Sc2y{EU#2~z`=RdSZQUsQ&@CJ<5kYNhp>UKr)qqy;rj4rW`K_)FTp9qFK7;ElS@?OrH)_*RKj=Tn6|t~{0&NP2S_TRjQjft z*Veq0b>W-ok~3~3t-g$BO`OUraF!ieUGwysao7OK+3YL#ylHE@*?a;TaXcGd$9`OO zp#XT*P!%q{Cn}HhopgmiE0JUAewz(J%j|3tQ-^A&20oa%8*$)yt+dUkUF4G&)pHXp zt6^i43h`@e=}P5a7=cO8?{cHKoyH^3>e16}!iU_}x#l4}$x;m2_vtaN=%0?_Z1{_+b<*1`ugLc&==FwY?DJR2lHOE zzzee*JYhHG$et(Z_g)X07XhBv&ezw3a=nuLzL&lB80Bs9_J1SW=a%B&yN}t=Yw>Rd&;)kJ* zwo-?0z=ng_HonsKyx_F9K*~j|!F;rv@Vh&z=ynab#V24y#*iM!i(qn2E&R@1+yMPm zN@~o1y|;J>KU`S(Od3dZTL_dti8!t4(lRJqN}NoI*30^8a!F1Uqk4yxVqTMfR2 ztuUZWn3)WA^ie{Xy6Kge2oc@+G3uiapSsSJR7{v*X8GKIPU)$}Eu0JCX2X2*vQzf% ze514^ckK@|U{uUk3mggUV9*eB4Gvo3G5>Z-*TG{NH!dV1a3urc$Yt^!_O=(D%901WH@u zaNoNes}EBMuuLdC@7$hY@wOqcXsl^(sY8vZLYr* z4OIMS)p~d`9EWq@38mj6Yolrl+0B6tweBbJoGJnqR!HNvIxG6C=Yi%<<};zfjD=E8 z`r0kCPCD7J-toD0j=2OiXqUrd=6Uj4FE@u|L-?j7)cy-^$<>i;J|&`~pcDlS5y!PV zKES_&e&g4G7l||>1BC8(j};S13kP1!+#DAXyRKG0v54*+3CKw3x>92(NaDr0o07qG ziwD(>QY0Y=TPb`7*l<|sxSR|{V5nt((C+2I^-WflR$v39%?dM92~xK9bf6pi+>zSX zxc|)Zl8X6+-3r7%-isVqo`_irx3WZ@{rvB*V5NvEDtxcO_yh@NP2zu zN@%Bft036kfwIM#eG`A0{hmSFS#Xh%4C3V(-e+OMFCU?ZE5Tl2^;TVc_vQYEabAcg zRLXy+Qp3pgMvqdjGxl2KK?@3)?Vh`B}j9(v?nxMO_p5&U%4a}X+?Zb%Mo)Widfhnv0 z`D|SIz26dkkOppxJX23^H(m?ts=d0Cg@Y|bVj=PNg;o+#`$&9>@qIzWWjEr%Js%Z@ z{~o_2hi^E;`H&NTaQEvNFI;ikG0TWhS;4A5!{;n(bGK6fJ~b$7D!_$qhn#IX|DlM8 z03|2ROYoprnKIw-w-PJL<%M6BxHtr>hy-0>9@x%m+fV?EiYMy4xKM#R?&3`3C-%Fy z!Hx=Zt~@mU)%METO2jG8D8pq_SmQSf%}vgN*KWGPMjp1(#LUypTrzmoa)w0oaOi!7 zEVg19NcSzmZ-n#Y=gIhIh*+APpvOmQ38gyU7|xuqd9WRNPV@Gtm&A#EAH~6gKf&I| z-#wmNY}w{_+-j|!ow<3w_WD{byRyg+GU@k?px{btOwjK3>&l2}&nQ1W)Vi}c`ZD55 z>F%Vo-JHT>fu}$aGQ6&5N^R27oEQzVudTnZYF9lgQ_)vsk*L%P~khOhw_j9G= zvxz5~KYI)U%*oGiU-~R5r_<%xEtvw>&q`ezDzHuio?mex>uM0%oJD(?Mwg?E8tjix z=75NFapoDqyu);s*3lks|HgtE!m>h+Z!1ys@rYN3j7`! z`G99_qjK!6i@z=2ku$^nq5N|5`}nBF$YX(oO>65EFCODSrD?eZ=w#~{sqgtNto$DgIGWdSF zVe!uE)9s{T-=pPFCBrd1aUbIY!N0($EkdG7;idEB)%2<2nulsDX3}ZV=lF{Y1E+o( zE%%+({D_Lgn`bfVG(Xftz8h?N1IKQ%PwLzgg(*mzPUQOyUa9e@T*nDN8C!i+>E>u) z8CEli()=>%hi7$_!uyUuW>JEhJAF>N$- zCyV{oMg4J333B+5IqOsY=zhtktQjyN*ZdW@4}>>gZ7?+KpeE2*jW_>YeKc*`!+@=<3*=_c9n&M-Nt7B zAWX{xaKoU>~o~)a~Xut?5 zzpz>gzq7WwECX3Tt{ffJZf;%0O1ID`&Q1PcMTIh-yTkB@d9PG;k$R!5TIu@CAig$F zypt4qobY9U?gEdRQeAweH+)f1s5-iVD^CKp861Zn_Ae6(f4L9ml)#dXg+$Dwvzj81 zf1lvW2uwC*yFG98D!$+2p{)Igc5{IaNPBju$9?u-3F(n3VSR@!OA&v!2hTnO^fo@2 z2VdzL0~R_=sWkj=DlmIX%b)jx{QPomd|phQ?eF$o8KYAumo_7>4bMsNZFaJz<`(vF zS{V1GWW99{cKR*bHQ2wfNWa7ok%z4_m6ZJ|a7`TdBuEi9?<{!zObj$>SjuA5+(z{r zgRUJUzvl9|(aF*4Ha&|uYinU?xUZW&L`UvYaub86;|EnMqgp_+N-<~5=q*u?MgAOM zg0&8+G)~gzR|@kSpL7yKY-^M9R;}XkMu%-|>D9)>(R$&O$)-AKFn~v{JsTAjBaW zC4(_jnhL<5J!8p-M5&D1}?SJv-*^e#o&Ao_TM+L>CM0&oJD^+tR>)rI&N*x9T%3dYs>y=nin$I-gFJTGqeQsWEVg znTbWy-CUO2WsqHayO@(QpBMm1*Spr)#5~{S{_~>OygGoPk8Ao+cUv^{l$mlWnS6h5q;T8Ax=JT5^rgX-Cj&tgobwXV27U*ZKGc&pe;BH1yP~?%72BKY@GLP5=M^ diff --git a/Projectiles/Summon/SarosSunfire.cs b/Projectiles/Summon/SarosSunfire.cs index 9dc7db33ac..ead525251c 100644 --- a/Projectiles/Summon/SarosSunfire.cs +++ b/Projectiles/Summon/SarosSunfire.cs @@ -60,14 +60,7 @@ namespace CalamityMod.Projectiles.Summon } else { - target = null; - int targ = -1; - Projectile.Minion_FindTargetInRange(5000, ref targ, false, (ent, num) => - { - return (ent is NPC && Projectile.localNPCImmunity[(ent as NPC).whoAmI] <= 0); - }); - if (targ != -1) - target = Main.npc[targ]; + target = GetTargetInRange(2000); } if (Projectile.damage <= 0) @@ -77,9 +70,42 @@ namespace CalamityMod.Projectiles.Summon 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 bool? CanHitNPC(NPC target) + { + 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++) { Vector2 dustVelocity = Main.rand.NextVector2Circular(1f, 1f) * 6f; From aeb9479ef70db97adf58c6b92d0817183c9d2738 Mon Sep 17 00:00:00 2001 From: Flowaria Date: Sat, 15 Nov 2025 11:42:29 +0900 Subject: [PATCH 20/65] Fix: Mushy Buff now work in MP properly --- Items/Weapons/Rogue/Mycoroot.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Items/Weapons/Rogue/Mycoroot.cs b/Items/Weapons/Rogue/Mycoroot.cs index 0975e41c26..2bf4fb15ee 100644 --- a/Items/Weapons/Rogue/Mycoroot.cs +++ b/Items/Weapons/Rogue/Mycoroot.cs @@ -49,10 +49,11 @@ namespace CalamityMod.Items.Weapons.Rogue { 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); } } } From 15f2517ab04292ceb3532cfad54f1ea1814a3faf Mon Sep 17 00:00:00 2001 From: Nathanael Overton Date: Fri, 14 Nov 2025 21:52:23 -0500 Subject: [PATCH 21/65] Exoblade's hitbox + visuals match more Negligible effect on how powerful the weapon actually is --- Projectiles/Melee/ExobladeProj.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Projectiles/Melee/ExobladeProj.cs b/Projectiles/Melee/ExobladeProj.cs index 90957183db..6629398cec 100644 --- a/Projectiles/Melee/ExobladeProj.cs +++ b/Projectiles/Melee/ExobladeProj.cs @@ -223,8 +223,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) @@ -447,7 +447,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; From b30de0af5d4255a53a7fdd5b8ed2d0f188386047 Mon Sep 17 00:00:00 2001 From: Flowaria Date: Sat, 15 Nov 2025 12:12:44 +0900 Subject: [PATCH 22/65] Fix: Now uses correct EmptyTileCheck range --- Tiles/Abyss/AcidWoodTreeSapling.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tiles/Abyss/AcidWoodTreeSapling.cs b/Tiles/Abyss/AcidWoodTreeSapling.cs index 30a8bd2878..95ad79209e 100644 --- a/Tiles/Abyss/AcidWoodTreeSapling.cs +++ b/Tiles/Abyss/AcidWoodTreeSapling.cs @@ -71,7 +71,7 @@ namespace CalamityMod.Tiles.Abyss { 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; } From 60c1d04b4e8e9d5856a2bf58acedda43b0754b4b Mon Sep 17 00:00:00 2001 From: Nathanael Overton Date: Fri, 14 Nov 2025 23:31:16 -0500 Subject: [PATCH 23/65] Lightspeed tweaks - Increased Dash speed & duration - Made dash set the owner's LungingDown to true - Reduced proj size drain as the dash duration progresses - Made player's arm rotate along w/ the spin during the dash's startup - Made Elemental Mastery drain slower --- CalPlayer/CalamityPlayerMiscEffects.cs | 4 ++-- Projectiles/Melee/LightspeedHoldout.cs | 22 +++++++++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index a0f65e9915..8126757ded 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -452,8 +452,8 @@ namespace CalamityMod.CalPlayer else // Decrementing { elementalMasterySFXPlayed = false; - // Once every 20 ticks - if (elementalMasteryTimer >= 20) + // Once every 30 ticks + if (elementalMasteryTimer >= 30) { elementalMastery--; elementalMasteryTimer = 0; diff --git a/Projectiles/Melee/LightspeedHoldout.cs b/Projectiles/Melee/LightspeedHoldout.cs index 950233ac68..8fa26ea84d 100644 --- a/Projectiles/Melee/LightspeedHoldout.cs +++ b/Projectiles/Melee/LightspeedHoldout.cs @@ -44,8 +44,8 @@ namespace CalamityMod.Projectiles.Melee 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 = 42f; - private const float DashDuration = 36f; + private const float DashSpeed = 46f; + private const float DashDuration = 38f; private const float DashAcceleration = 0.9865f; private float AltSpinRotation = 0f; public bool createdSmear = false; @@ -298,6 +298,20 @@ namespace CalamityMod.Projectiles.Melee Projectile.Center = Owner.Center + 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.Center; + 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 @@ -348,10 +362,11 @@ namespace CalamityMod.Projectiles.Melee 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.3f, MathF.Pow(1f - DashTimer / DashDuration, 5)); + Projectile.scale = MathHelper.Lerp(1f, 0.4f, MathF.Pow(1f - DashTimer / DashDuration, 5)); Owner.heldProj = Projectile.whoAmI; Owner.itemTime = Owner.itemAnimation = 2; @@ -359,6 +374,7 @@ namespace CalamityMod.Projectiles.Melee if (DashTimer <= 0) { Owner.velocity *= 0.1f; + Owner.Calamity().LungingDown = false; Projectile.Kill(); } } From 88e9dffcaad8ac6e0194c0a51cad7234b49991af Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Sat, 15 Nov 2025 00:01:36 -0500 Subject: [PATCH 24/65] Fixed Fetid Emesis firing multiple projectiles in mp Removed our Player.ActiveItem() function because it is strictly worse and buggier than Player.HeldItem --- Balancing/BalancingChangesManager.cs | 2 +- Buffs/DamageOverTime/ShellfishClaps.cs | 2 +- CalPlayer/CalamityPlayer.cs | 20 ++++----- CalPlayer/CalamityPlayerDrawEffects.cs | 2 +- CalPlayer/CalamityPlayerHitHurt.cs | 6 +-- CalPlayer/CalamityPlayerMiscEffects.cs | 20 ++++----- CalPlayer/CalamityPlayerOnHit.cs | 6 +-- DataStructures/GemTechArmorState.cs | 22 +++++----- ILEditing/MechanicILChanges.cs | 2 +- Items/Accessories/StatMeter.cs | 2 +- Items/Accessories/TheCamper.cs | 12 +++--- Items/CalamityGlobalItem.cs | 8 ++-- .../MythrilArmorSetChange.cs | 2 +- Items/Weapons/Magic/Vehemence.cs | 2 +- Items/Weapons/Melee/StygianShield.cs | 4 +- Items/Weapons/Melee/WulfrumScrewdriver.cs | 4 +- Items/Weapons/Ranged/Hydra.cs | 4 +- Items/Weapons/Ranged/OntologicalDespoiler.cs | 2 +- NPCs/CalamityGlobalNPC.cs | 2 +- .../BaseGunHoldoutProjectile.cs | 2 +- .../BaseIdleHoldoutProjectile.cs | 4 +- Projectiles/CalamityGlobalProjectile.cs | 2 +- .../HolofibreImmolatorHoldout.cs | 4 +- .../HydraulicVoltCrasherProjectile.cs | 2 +- Projectiles/DraedonsArsenal/NidhoggHoldout.cs | 2 +- .../DraedonsArsenal/PhalanxSurgeHoldout.cs | 2 +- .../DraedonsArsenal/PhaseslayerProjectile.cs | 8 ++-- Projectiles/Magic/AetherfluxCannonHoldout.cs | 4 +- Projectiles/Magic/AnahitasArpeggioNote.cs | 2 +- Projectiles/Magic/ApoctosisArrayHoldout.cs | 2 +- Projectiles/Magic/ArtAttackHoldout.cs | 2 +- Projectiles/Magic/CauldronHoldout.cs | 6 +-- Projectiles/Magic/ChronomancersScytheSwing.cs | 6 +-- Projectiles/Magic/DarkSparkPrism.cs | 6 +-- Projectiles/Magic/EnormousConsumingVortex.cs | 2 +- Projectiles/Magic/GenesisHoldout.cs | 2 +- Projectiles/Magic/GhastlyVisageProj.cs | 8 ++-- Projectiles/Magic/HadalUrnHoldout.cs | 6 +-- Projectiles/Magic/HeliumFlashHoldout.cs | 2 +- Projectiles/Magic/HeresyProj.cs | 2 +- Projectiles/Magic/IncineratingFireball.cs | 4 +- Projectiles/Magic/IonBlasterHoldout.cs | 2 +- Projectiles/Magic/MelterAmp.cs | 2 +- Projectiles/Magic/NanoPurgeHoldout.cs | 4 +- Projectiles/Magic/NanoPurgeLaser.cs | 2 +- Projectiles/Magic/NebulousCataclysm_Held.cs | 8 ++-- Projectiles/Magic/OmicronHoldout.cs | 4 +- Projectiles/Magic/OmicronWingman.cs | 6 +-- Projectiles/Magic/PurgeGuzzlerHoldout.cs | 4 +- .../Magic/RainbowPartyCannonProjectile.cs | 2 +- Projectiles/Magic/RancorHoldout.cs | 2 +- Projectiles/Magic/SparklingEmpressHoldout.cs | 2 +- Projectiles/Magic/SylvestaffHoldout.cs | 2 +- Projectiles/Magic/Teslabeam.cs | 2 +- Projectiles/Magic/ValkyrieRayStaff.cs | 2 +- Projectiles/Magic/VehemenceHoldout.cs | 2 +- Projectiles/Magic/VitriolicViperHoldout.cs | 2 +- Projectiles/Magic/VolterionHoldout.cs | 8 ++-- Projectiles/Magic/WingmanHoldout.cs | 6 +-- Projectiles/Magic/YharimsCrystalPrism.cs | 6 +-- Projectiles/Melee/DevilsSunriseProj.cs | 4 +- Projectiles/Melee/ExobladeProj.cs | 6 +-- Projectiles/Melee/MurasamaSlash.cs | 4 +- Projectiles/Melee/PhotonRipperProjectile.cs | 4 +- Projectiles/Melee/RespiteblockHoldout.cs | 2 +- .../Melee/Shortswords/GalileoGladiusProj.cs | 2 +- Projectiles/Melee/StygianShieldAttack.cs | 2 +- Projectiles/Melee/TaintedBladeSlasher.cs | 10 ++--- Projectiles/Melee/TerratomereHoldoutProj.cs | 4 +- Projectiles/Melee/WulfrumScrewdriverProj.cs | 2 +- Projectiles/Pets/Sparks.cs | 2 +- Projectiles/Ranged/ArcNovaDiffuserHoldout.cs | 2 +- Projectiles/Ranged/BouncingShotgunPellet.cs | 2 +- Projectiles/Ranged/BuzzkillHoldout.cs | 6 +-- Projectiles/Ranged/ChickenCannonHeld.cs | 12 +++--- .../Ranged/ChromaticEruptionHoldout.cs | 2 +- Projectiles/Ranged/ClockworkBowHoldout.cs | 12 +++--- Projectiles/Ranged/CondemnationHoldout.cs | 2 +- Projectiles/Ranged/ContagionBow.cs | 2 +- Projectiles/Ranged/DaemonsFlameBow.cs | 12 +++--- Projectiles/Ranged/DragonsBreathHoldout.cs | 2 +- Projectiles/Ranged/DrataliornusBow.cs | 10 ++--- Projectiles/Ranged/FetidEmesisHoldout.cs | 43 +++++++++++-------- Projectiles/Ranged/FirestormCannonHoldout.cs | 8 ++-- Projectiles/Ranged/FlakKrakenHoldout.cs | 2 +- Projectiles/Ranged/FlakToxicannonHoldout.cs | 2 +- .../Ranged/FlurrystormCannonShooting.cs | 12 +++--- Projectiles/Ranged/FreedomStarHoldout.cs | 2 +- Projectiles/Ranged/HeavenlyGaleProj.cs | 14 +++--- Projectiles/Ranged/HydraHead.cs | 4 +- Projectiles/Ranged/KingsbaneHoldout.cs | 2 +- Projectiles/Ranged/M1GarandHoldout.cs | 4 +- Projectiles/Ranged/MaelstromHoldout.cs | 6 +-- Projectiles/Ranged/MagnaCannonHoldout.cs | 2 +- Projectiles/Ranged/MineralMortarHoldout.cs | 2 +- Projectiles/Ranged/NorfleetCannon.cs | 2 +- .../Ranged/OntologicalDespoilerHoldout.cs | 2 +- Projectiles/Ranged/OpalStrikerHoldout.cs | 2 +- Projectiles/Ranged/PhotovisceratorHoldout.cs | 10 ++--- Projectiles/Ranged/PumplerHoldout.cs | 6 +-- Projectiles/Ranged/RiftburstBow.cs | 12 +++--- Projectiles/Ranged/SevensStrikerHoldout.cs | 10 ++--- .../Ranged/SpectralstormCannonHoldout.cs | 10 ++--- Projectiles/Ranged/StarmageddonHeld.cs | 4 +- .../Ranged/SuperradiantSlaughtererHoldout.cs | 6 +-- Projectiles/Ranged/SurgeDriverHoldout.cs | 6 +-- Projectiles/Ranged/TauCannonHoldout.cs | 2 +- Projectiles/Ranged/UltimaBowProjectile.cs | 18 ++++---- Projectiles/Ranged/WildfireBloomHoldout.cs | 2 +- .../Summon/AtlasMunitionsAutocannon.cs | 2 +- .../Summon/AtlasMunitionsAutocannonHeld.cs | 4 +- Projectiles/Summon/CausticStaffProjectile.cs | 2 +- Projectiles/Typeless/EnergyShell.cs | 2 +- .../Typeless/RelicOfDeliveranceSpear.cs | 4 +- Projectiles/Typeless/VictideBobber.cs | 2 +- Projectiles/Typeless/VictideSeaSnail.cs | 6 +-- Tiles/Abyss/AcidWoodTree.cs | 2 +- Tiles/Astral/AstralShortPlants.cs | 2 +- Tiles/Astral/AstralTallPlants.cs | 2 +- Tiles/Astral/AstralTree.cs | 2 +- Tiles/AstralDesert/AstralPalmTree.cs | 2 +- Tiles/AstralSnow/AstralSnowTree.cs | 2 +- Tiles/CalamityGlobalTile.cs | 2 +- .../EnchantmentManager.cs | 16 +++---- UI/DraedonsArsenal/ChargeMeterUI.cs | 2 +- UI/DraedonsArsenal/ChargingStationUI.cs | 2 +- UI/EnchantmentMetersUI.cs | 2 +- Utilities/GeneralExtensionUtils.cs | 1 - Utilities/ItemUtils.cs | 2 +- Utilities/PlayerUtils.cs | 4 +- 130 files changed, 321 insertions(+), 317 deletions(-) diff --git a/Balancing/BalancingChangesManager.cs b/Balancing/BalancingChangesManager.cs index 4ab5c536b7..311a2dd753 100644 --- a/Balancing/BalancingChangesManager.cs +++ b/Balancing/BalancingChangesManager.cs @@ -50,7 +50,7 @@ namespace CalamityMod.Balancing 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(); + p.type == ProjectileType() && Main.player[p.owner].HeldItem.type == ItemType(); NPCSpecificBalancingChanges = new List(); diff --git a/Buffs/DamageOverTime/ShellfishClaps.cs b/Buffs/DamageOverTime/ShellfishClaps.cs index 00a8c48f9d..c70408473c 100644 --- a/Buffs/DamageOverTime/ShellfishClaps.cs +++ b/Buffs/DamageOverTime/ShellfishClaps.cs @@ -32,7 +32,7 @@ namespace CalamityMod.Buffs.DamageOverTime } } - Item heldItem = Main.player[owner].ActiveItem(); + Item heldItem = Main.player[owner].HeldItem; int totalDamage = (int)Main.player[owner].GetTotalDamage().ApplyTo(debuffData.EnemyLostRegen); if (CalamityUtils.ShouldTriggerSummonPenalty(Main.player[owner], heldItem)) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index b60958936c..47a1f4ac29 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -275,8 +275,8 @@ namespace CalamityMod.CalPlayer public int arsenalCooldown = 0; public int killModeCooldown = 0; public bool demonSwordKillMode = false; - public bool exaltedKillMode => (demonSwordKillMode && Player.ActiveItem().type == ItemType()); - public bool devilsDevastationKillMode => (demonSwordKillMode && Player.ActiveItem().type == 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.
@@ -2783,7 +2783,7 @@ namespace CalamityMod.CalPlayer disablePerfCystSpawns = false; disableVoodooSpawns = false; - EnchantHeldItemEffects(Player, Player.Calamity(), Player.ActiveItem()); + EnchantHeldItemEffects(Player, Player.Calamity(), Player.HeldItem); } #endregion @@ -3634,7 +3634,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; } @@ -3642,7 +3642,7 @@ 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(SilvaArmor.DispelSound, Player.Center); @@ -3661,7 +3661,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); @@ -5212,7 +5212,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); @@ -5384,7 +5384,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; @@ -5432,7 +5432,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. @@ -5579,7 +5579,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; diff --git a/CalPlayer/CalamityPlayerDrawEffects.cs b/CalPlayer/CalamityPlayerDrawEffects.cs index 0f2027ad8c..bb0316e90a 100644 --- a/CalPlayer/CalamityPlayerDrawEffects.cs +++ b/CalPlayer/CalamityPlayerDrawEffects.cs @@ -635,7 +635,7 @@ namespace CalamityMod.CalPlayer 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/CalamityPlayerHitHurt.cs b/CalPlayer/CalamityPlayerHitHurt.cs index 54f12dcede..afe9da6ed0 100644 --- a/CalPlayer/CalamityPlayerHitHurt.cs +++ b/CalPlayer/CalamityPlayerHitHurt.cs @@ -733,7 +733,7 @@ namespace CalamityMod.CalPlayer bool isSummon = proj.CountsAsClass(); if (isSummon) { - Item heldItem = Player.ActiveItem(); + Item heldItem = Player.HeldItem; if (CalamityUtils.ShouldTriggerSummonPenalty(Player, heldItem) && !CalamityProjectileSets.MinionWhichIgnoresSummonerNerf[proj.type]) modifiers.FinalDamage *= BalancingConstants.SummonerCrossClassNerf; @@ -841,7 +841,7 @@ namespace CalamityMod.CalPlayer if (bloodflareMelee && bloodflareFrenzy && !Player.HasCooldown(BloodflareFrenzy.ID)) modifiers.FinalDamage *= (1f - BloodflareHeadMelee.FrenzyContactDamageReduction); - if (Player.ownedProjectileCounts[ModContent.ProjectileType()] > 0 && Player.ActiveItem().type == ModContent.ItemType()) + if (Player.ownedProjectileCounts[ModContent.ProjectileType()] > 0 && Player.HeldItem.type == ModContent.ItemType()) modifiers.FinalDamage *= 0.5f; bool lifeAndShieldCondition = Player.statLife >= Player.statLifeMax2 && (!HasAnyEnergyShield || TotalEnergyShielding >= TotalMaxShieldDurability); @@ -1053,7 +1053,7 @@ namespace CalamityMod.CalPlayer modifiers.FinalDamage *= 0.75f; } - if (Player.ownedProjectileCounts[ModContent.ProjectileType()] > 0 && Player.ActiveItem().type == ModContent.ItemType()) + if (Player.ownedProjectileCounts[ModContent.ProjectileType()] > 0 && Player.HeldItem.type == ModContent.ItemType()) modifiers.FinalDamage *= 0.5f; bool lifeAndShieldCondition = Player.statLife >= Player.statLifeMax2 && (!HasAnyEnergyShield || TotalEnergyShielding >= TotalMaxShieldDurability); diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 8126757ded..05ec0a8a49 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -188,7 +188,7 @@ namespace CalamityMod.CalPlayer } } - 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) @@ -203,7 +203,7 @@ namespace CalamityMod.CalPlayer } // 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) { @@ -1160,7 +1160,7 @@ 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)) @@ -2807,7 +2807,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 @@ -2982,7 +2982,7 @@ namespace CalamityMod.CalPlayer } 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; @@ -3342,7 +3342,7 @@ namespace CalamityMod.CalPlayer else aquaticBoost = AquaticBoostMax; - if (Player.ActiveItem().type == ModContent.ItemType() && Player.StandingStill(0.1f)) + if (Player.HeldItem.type == ModContent.ItemType() && Player.StandingStill(0.1f)) { if (auralisStealthCounter < 300f) auralisStealthCounter++; @@ -3696,22 +3696,22 @@ namespace CalamityMod.CalPlayer } } - if (CalamityItemSets.FishingPoleThatNeverBreaks[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()) + if (Player.HeldItem.type != ModContent.ItemType()) { searedPanCounter = 0; searedPanTimer = 0; diff --git a/CalPlayer/CalamityPlayerOnHit.cs b/CalPlayer/CalamityPlayerOnHit.cs index 474eba0dcb..90d305f192 100644 --- a/CalPlayer/CalamityPlayerOnHit.cs +++ b/CalPlayer/CalamityPlayerOnHit.cs @@ -754,7 +754,7 @@ namespace CalamityMod.CalPlayer private void MeleeOnHit(Projectile proj, CalamityGlobalProjectile modProj, Vector2 position, bool crit, bool npcCheck, bool targetIsDummy) { var source = proj.GetSource_FromThis(); - Item heldItem = Player.ActiveItem(); + Item heldItem = Player.HeldItem; if (proj.IsTrueMelee()) { @@ -1330,7 +1330,7 @@ namespace CalamityMod.CalPlayer if (bloodflareThrowing && proj.CountsAsClass() && crit) Projectile.NewProjectile(proj.GetSource_OnHit(target), proj.Center, proj.velocity.SafeNormalize(Vector2.Zero) * Math.Min(((proj.velocity.Length() * proj.MaxUpdates) / 4f), 4f) * Main.rand.NextFloat(0.75f, 1.25f), ModContent.ProjectileType(), 4, 0f, proj.owner); - if (proj.CountsAsClass() && Player.ActiveItem().CountsAsClass()) + if (proj.CountsAsClass() && Player.HeldItem.CountsAsClass()) { if (manaOverloader) { @@ -1405,7 +1405,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/DataStructures/GemTechArmorState.cs b/DataStructures/GemTechArmorState.cs index d571a9cd05..e94f1a41ea 100644 --- a/DataStructures/GemTechArmorState.cs +++ b/DataStructures/GemTechArmorState.cs @@ -67,17 +67,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 +128,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 +153,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_ItemUse(Owner.HeldItem), target.Center, shootVelocity, ModContent.ProjectileType(), damage, 0f, OwnerIndex); } MeleeCrystalCountdown = GemTechHeadgear.MeleeShardDelay; @@ -173,7 +173,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_ItemUse(Owner.HeldItem), spawnPosition, shootVelocity, ModContent.ProjectileType(), damage, 0f, OwnerIndex); } public void OnItemUseEffects(Item item) @@ -277,7 +277,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); } } @@ -349,7 +349,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; } diff --git a/ILEditing/MechanicILChanges.cs b/ILEditing/MechanicILChanges.cs index 90aa61ab39..480634bd66 100644 --- a/ILEditing/MechanicILChanges.cs +++ b/ILEditing/MechanicILChanges.cs @@ -591,7 +591,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; } diff --git a/Items/Accessories/StatMeter.cs b/Items/Accessories/StatMeter.cs index b931db8898..4aaa5ad6b8 100644 --- a/Items/Accessories/StatMeter.cs +++ b/Items/Accessories/StatMeter.cs @@ -36,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"); diff --git a/Items/Accessories/TheCamper.cs b/Items/Accessories/TheCamper.cs index ff7b09897f..740b72b151 100644 --- a/Items/Accessories/TheCamper.cs +++ b/Items/Accessories/TheCamper.cs @@ -67,13 +67,13 @@ namespace CalamityMod.Items.Accessories } } } - 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/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index f5b7460bbc..84e7a6ee9f 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -613,7 +613,7 @@ namespace CalamityMod.Items // 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.ActiveItem().type == ItemType() || player.ActiveItem().type == ItemType()) + if (player.HeldItem.type == ItemType() || player.HeldItem.type == ItemType()) return false; } return base.CanPickup(item, player); @@ -724,7 +724,7 @@ namespace CalamityMod.Items { return false; } - if (player.ActiveItem().type == ItemType() && player.ownedProjectileCounts[ProjectileType()] == 0) + if (player.HeldItem.type == ItemType() && player.ownedProjectileCounts[ProjectileType()] == 0) { foreach (Projectile p in Main.ActiveProjectiles) { @@ -739,7 +739,7 @@ namespace CalamityMod.Items } return false; } - if (player.ActiveItem().type == ItemType()) + if (player.HeldItem.type == ItemType()) { bool canContinue = true; int count = 0; @@ -769,7 +769,7 @@ 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) diff --git a/Items/VanillaArmorChanges/MythrilArmorSetChange.cs b/Items/VanillaArmorChanges/MythrilArmorSetChange.cs index 0d162d6663..47d11890d2 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_ItemUse(owner.HeldItem), flareSpawnPosition, Vector2.Zero, ModContent.ProjectileType(), flareDamage, 0f, owner.whoAmI); } } } diff --git a/Items/Weapons/Magic/Vehemence.cs b/Items/Weapons/Magic/Vehemence.cs index a33d1a3aca..f09e59a4fb 100644 --- a/Items/Weapons/Magic/Vehemence.cs +++ b/Items/Weapons/Magic/Vehemence.cs @@ -46,7 +46,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) { - 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/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/WulfrumScrewdriver.cs b/Items/Weapons/Melee/WulfrumScrewdriver.cs index 2fc8fc039a..ff12b06675 100644 --- a/Items/Weapons/Melee/WulfrumScrewdriver.cs +++ b/Items/Weapons/Melee/WulfrumScrewdriver.cs @@ -93,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; } @@ -165,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/Ranged/Hydra.cs b/Items/Weapons/Ranged/Hydra.cs index 67c5b3927c..207ae0eb05 100644 --- a/Items/Weapons/Ranged/Hydra.cs +++ b/Items/Weapons/Ranged/Hydra.cs @@ -54,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) @@ -65,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) { diff --git a/Items/Weapons/Ranged/OntologicalDespoiler.cs b/Items/Weapons/Ranged/OntologicalDespoiler.cs index 6b55cd9968..40fc8c33f2 100644 --- a/Items/Weapons/Ranged/OntologicalDespoiler.cs +++ b/Items/Weapons/Ranged/OntologicalDespoiler.cs @@ -70,7 +70,7 @@ namespace CalamityMod.Items.Weapons.Ranged if (player.Calamity().mouseRight && player.whoAmI == Main.myPlayer && !Main.mapFullscreen && !Main.blockMouse && player.Calamity().despoilerNerf) { - Projectile holdout2 = Projectile.NewProjectileDirect(source, player.Center, Vector2.Zero, Item.shoot, player.ActiveItem().damage, 0f, player.whoAmI, 0, 0, 10 + (shotType ? 5 : 0)); + Projectile holdout2 = Projectile.NewProjectileDirect(source, player.Center, Vector2.Zero, Item.shoot, player.HeldItem.damage, 0f, player.whoAmI, 0, 0, 10 + (shotType ? 5 : 0)); 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); diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 202cdc1820..c67677b7b3 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -5283,7 +5283,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) { diff --git a/Projectiles/BaseProjectiles/BaseGunHoldoutProjectile.cs b/Projectiles/BaseProjectiles/BaseGunHoldoutProjectile.cs index da2ebc2cde..84fc068a5f 100644 --- a/Projectiles/BaseProjectiles/BaseGunHoldoutProjectile.cs +++ b/Projectiles/BaseProjectiles/BaseGunHoldoutProjectile.cs @@ -172,7 +172,7 @@ namespace CalamityMod.Projectiles.BaseProjectiles { // Multiplayer null-checking. Owner ??= Main.player[Projectile.owner]; - HeldItem ??= Owner.ActiveItem(); + HeldItem ??= Owner.HeldItem; KillHoldoutLogic(); ManageHoldout(); diff --git a/Projectiles/BaseProjectiles/BaseIdleHoldoutProjectile.cs b/Projectiles/BaseProjectiles/BaseIdleHoldoutProjectile.cs index a8658220ca..34929efa85 100644 --- a/Projectiles/BaseProjectiles/BaseIdleHoldoutProjectile.cs +++ b/Projectiles/BaseProjectiles/BaseIdleHoldoutProjectile.cs @@ -33,7 +33,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 +60,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/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 8cb004f06d..889546cb83 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -3667,7 +3667,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; } } diff --git a/Projectiles/DraedonsArsenal/HolofibreImmolatorHoldout.cs b/Projectiles/DraedonsArsenal/HolofibreImmolatorHoldout.cs index e1c2f33af3..f9f7846535 100644 --- a/Projectiles/DraedonsArsenal/HolofibreImmolatorHoldout.cs +++ b/Projectiles/DraedonsArsenal/HolofibreImmolatorHoldout.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public override void KillHoldoutLogic() { - if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.ActiveItem().type) + if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.HeldItem.type) Projectile.Kill(); } public override void OnSpawn(IEntitySource source) @@ -48,7 +48,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public override void HoldoutAI() { - CalamityGlobalItem modItem = Owner.ActiveItem().Calamity(); + CalamityGlobalItem modItem = Owner.HeldItem.Calamity(); Vector2 mountedCenter = Owner.MountedCenter; Vector2 ownerToMouse = Owner.Calamity().mouseWorld - mountedCenter; if (SoundEngine.TryGetActiveSound(ChargeSlot, out var ChargeSound) && ChargeSound.IsPlaying) diff --git a/Projectiles/DraedonsArsenal/HydraulicVoltCrasherProjectile.cs b/Projectiles/DraedonsArsenal/HydraulicVoltCrasherProjectile.cs index 6ef1364726..9fddad0e85 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(); diff --git a/Projectiles/DraedonsArsenal/NidhoggHoldout.cs b/Projectiles/DraedonsArsenal/NidhoggHoldout.cs index c20752da3c..1264d85669 100644 --- a/Projectiles/DraedonsArsenal/NidhoggHoldout.cs +++ b/Projectiles/DraedonsArsenal/NidhoggHoldout.cs @@ -78,7 +78,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal return; } - if (HeldItem.type != Owner.ActiveItem().type) + if (HeldItem.type != Owner.HeldItem.type) { StopSounds(); Projectile.Kill(); diff --git a/Projectiles/DraedonsArsenal/PhalanxSurgeHoldout.cs b/Projectiles/DraedonsArsenal/PhalanxSurgeHoldout.cs index 66852eb6ed..dbedcdee8d 100644 --- a/Projectiles/DraedonsArsenal/PhalanxSurgeHoldout.cs +++ b/Projectiles/DraedonsArsenal/PhalanxSurgeHoldout.cs @@ -99,7 +99,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal return; } - if (HeldItem.type != Owner.ActiveItem().type) + if (HeldItem.type != Owner.HeldItem.type) { StopSounds(); Projectile.Kill(); diff --git a/Projectiles/DraedonsArsenal/PhaseslayerProjectile.cs b/Projectiles/DraedonsArsenal/PhaseslayerProjectile.cs index 3e1d9adcde..06a6dbe62c 100644 --- a/Projectiles/DraedonsArsenal/PhaseslayerProjectile.cs +++ b/Projectiles/DraedonsArsenal/PhaseslayerProjectile.cs @@ -41,7 +41,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { get { - CalamityGlobalItem swordItem = Main.player[Projectile.owner].ActiveItem().Calamity(); + CalamityGlobalItem swordItem = Main.player[Projectile.owner].HeldItem.Calamity(); return swordItem.ChargeRatio < Phaseslayer.SizeChargeThreshold; } } @@ -92,7 +92,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; @@ -130,7 +130,7 @@ 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(); + Item playerItem = player.HeldItem; bool hasCharge = modItem.Charge > 0f; if (!player.CantUseHoldout() && playerItem.type == ModContent.ItemType() && hasCharge) { @@ -205,7 +205,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal 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); } diff --git a/Projectiles/Magic/AetherfluxCannonHoldout.cs b/Projectiles/Magic/AetherfluxCannonHoldout.cs index ae0e2654ae..f854372844 100644 --- a/Projectiles/Magic/AetherfluxCannonHoldout.cs +++ b/Projectiles/Magic/AetherfluxCannonHoldout.cs @@ -36,7 +36,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 +74,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) diff --git a/Projectiles/Magic/AnahitasArpeggioNote.cs b/Projectiles/Magic/AnahitasArpeggioNote.cs index 3d78d39107..b49c09dd1a 100644 --- a/Projectiles/Magic/AnahitasArpeggioNote.cs +++ b/Projectiles/Magic/AnahitasArpeggioNote.cs @@ -97,7 +97,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 diff --git a/Projectiles/Magic/ApoctosisArrayHoldout.cs b/Projectiles/Magic/ApoctosisArrayHoldout.cs index 05b4275fa3..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; 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/CauldronHoldout.cs b/Projectiles/Magic/CauldronHoldout.cs index b499fdf008..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); diff --git a/Projectiles/Magic/ChronomancersScytheSwing.cs b/Projectiles/Magic/ChronomancersScytheSwing.cs index 0aed3a8905..70d5574c79 100644 --- a/Projectiles/Magic/ChronomancersScytheSwing.cs +++ b/Projectiles/Magic/ChronomancersScytheSwing.cs @@ -62,7 +62,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 +78,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/DarkSparkPrism.cs b/Projectiles/Magic/DarkSparkPrism.cs index bf2299ddcd..310cec8de3 100644 --- a/Projectiles/Magic/DarkSparkPrism.cs +++ b/Projectiles/Magic/DarkSparkPrism.cs @@ -61,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; @@ -90,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) @@ -127,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/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/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/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/HadalUrnHoldout.cs b/Projectiles/Magic/HadalUrnHoldout.cs index af45bffc98..c5d7c6e301 100644 --- a/Projectiles/Magic/HadalUrnHoldout.cs +++ b/Projectiles/Magic/HadalUrnHoldout.cs @@ -33,7 +33,7 @@ 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]--; @@ -42,7 +42,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) - 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); diff --git a/Projectiles/Magic/HeliumFlashHoldout.cs b/Projectiles/Magic/HeliumFlashHoldout.cs index db956457ef..acc2c30f66 100644 --- a/Projectiles/Magic/HeliumFlashHoldout.cs +++ b/Projectiles/Magic/HeliumFlashHoldout.cs @@ -30,7 +30,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(); } 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/IncineratingFireball.cs b/Projectiles/Magic/IncineratingFireball.cs index 888af08d49..86ce41e8b0 100644 --- a/Projectiles/Magic/IncineratingFireball.cs +++ b/Projectiles/Magic/IncineratingFireball.cs @@ -56,7 +56,7 @@ 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 <= (int)BurningSea.FizzleOutTime) { @@ -101,7 +101,7 @@ namespace CalamityMod.Projectiles.Magic // Consume mana periodically. if (Timer % 15 == 0f) - Owner.CheckMana(Owner.ActiveItem(), -1, true); + Owner.CheckMana(Owner.HeldItem, -1, true); // Spawn little spark effects around the fireball when fully charged. if (Timer > BurningSea.ChargeTime && Timer < BurningSea.BurnOutTime) diff --git a/Projectiles/Magic/IonBlasterHoldout.cs b/Projectiles/Magic/IonBlasterHoldout.cs index 769edaea95..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; 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..f4ccd1089d 100644 --- a/Projectiles/Magic/NanoPurgeHoldout.cs +++ b/Projectiles/Magic/NanoPurgeHoldout.cs @@ -38,7 +38,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,7 +68,7 @@ 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; 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/NebulousCataclysm_Held.cs b/Projectiles/Magic/NebulousCataclysm_Held.cs index 7c83485dc5..016f2c14e1 100644 --- a/Projectiles/Magic/NebulousCataclysm_Held.cs +++ b/Projectiles/Magic/NebulousCataclysm_Held.cs @@ -88,12 +88,12 @@ namespace CalamityMod.Projectiles.Magic 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/OmicronHoldout.cs b/Projectiles/Magic/OmicronHoldout.cs index 2e17a22e6a..525eb01074 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) * 13, true)) + 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) && PostFireCooldown <= 0) + if (Owner.CheckMana(Owner.HeldItem, -1, true) && PostFireCooldown <= 0) { MaxFireRateShots++; diff --git a/Projectiles/Magic/OmicronWingman.cs b/Projectiles/Magic/OmicronWingman.cs index 6fd83a0954..a1c5c4d902 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; diff --git a/Projectiles/Magic/PurgeGuzzlerHoldout.cs b/Projectiles/Magic/PurgeGuzzlerHoldout.cs index 2f68a64135..fff3d95631 100644 --- a/Projectiles/Magic/PurgeGuzzlerHoldout.cs +++ b/Projectiles/Magic/PurgeGuzzlerHoldout.cs @@ -36,13 +36,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) { 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/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/SparklingEmpressHoldout.cs b/Projectiles/Magic/SparklingEmpressHoldout.cs index 8e544c347a..1c2ebb6dee 100644 --- a/Projectiles/Magic/SparklingEmpressHoldout.cs +++ b/Projectiles/Magic/SparklingEmpressHoldout.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Projectiles.Magic 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; diff --git a/Projectiles/Magic/SylvestaffHoldout.cs b/Projectiles/Magic/SylvestaffHoldout.cs index 3109ae5bff..4b9a08efb5 100644 --- a/Projectiles/Magic/SylvestaffHoldout.cs +++ b/Projectiles/Magic/SylvestaffHoldout.cs @@ -167,7 +167,7 @@ namespace CalamityMod.Projectiles.Magic ///
private void FireAwesomeMagicRays() { - Item heldItem = Owner.ActiveItem(); + Item heldItem = Owner.HeldItem; if (heldItem is null) return; diff --git a/Projectiles/Magic/Teslabeam.cs b/Projectiles/Magic/Teslabeam.cs index 71f6acda5e..4674fd9840 100644 --- a/Projectiles/Magic/Teslabeam.cs +++ b/Projectiles/Magic/Teslabeam.cs @@ -101,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; diff --git a/Projectiles/Magic/ValkyrieRayStaff.cs b/Projectiles/Magic/ValkyrieRayStaff.cs index a84949c126..64143f3e25 100644 --- a/Projectiles/Magic/ValkyrieRayStaff.cs +++ b/Projectiles/Magic/ValkyrieRayStaff.cs @@ -35,7 +35,7 @@ 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] = (ValkyrieRay.ChargeFrames + ValkyrieRay.CooldownFrames) / player.ActiveItem().useTime; + Projectile.localAI[0] = (ValkyrieRay.ChargeFrames + ValkyrieRay.CooldownFrames) / player.HeldItem.useTime; // Increment the timer for the staff. If the timer has passed the total time, destroy it. Projectile.ai[0] += Projectile.localAI[0]; diff --git a/Projectiles/Magic/VehemenceHoldout.cs b/Projectiles/Magic/VehemenceHoldout.cs index 6fc8bd8129..66c6aca0ca 100644 --- a/Projectiles/Magic/VehemenceHoldout.cs +++ b/Projectiles/Magic/VehemenceHoldout.cs @@ -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/VitriolicViperHoldout.cs b/Projectiles/Magic/VitriolicViperHoldout.cs index c5f84f4ffc..bf984dd2c2 100644 --- a/Projectiles/Magic/VitriolicViperHoldout.cs +++ b/Projectiles/Magic/VitriolicViperHoldout.cs @@ -39,7 +39,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(); } diff --git a/Projectiles/Magic/VolterionHoldout.cs b/Projectiles/Magic/VolterionHoldout.cs index b16cd4bd8d..5baba2a3b7 100644 --- a/Projectiles/Magic/VolterionHoldout.cs +++ b/Projectiles/Magic/VolterionHoldout.cs @@ -49,7 +49,7 @@ namespace CalamityMod.Projectiles.Magic public override void KillHoldoutLogic() { // Override typical CantUseHoldout such that the weapon typically runs through the use animation while not channeled - if (HeldItem.type != Owner.ActiveItem().type || Owner.dead || !Owner.active) + if (HeldItem.type != Owner.HeldItem.type || Owner.dead || !Owner.active) { Projectile.Kill(); Projectile.netUpdate = true; @@ -73,9 +73,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() || !Owner.CheckMana(Owner.ActiveItem())) + if (Owner.CantUseHoldout() || !Owner.CheckMana(Owner.HeldItem)) Projectile.Kill(); Projectile.frame = 0; @@ -98,7 +98,7 @@ namespace CalamityMod.Projectiles.Magic } Projectile.frameCounter++; - if (Owner.CheckMana(Owner.ActiveItem(), -1, true)) + if (Owner.CheckMana(Owner.HeldItem, -1, true)) { FlashTimer = 4f; FireSoundSlot = SoundEngine.PlaySound(FireSound, GunTipPosition); diff --git a/Projectiles/Magic/WingmanHoldout.cs b/Projectiles/Magic/WingmanHoldout.cs index 76512e79f1..b84863d7ba 100644 --- a/Projectiles/Magic/WingmanHoldout.cs +++ b/Projectiles/Magic/WingmanHoldout.cs @@ -59,7 +59,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 +81,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 +100,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; 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/DevilsSunriseProj.cs b/Projectiles/Melee/DevilsSunriseProj.cs index 3f72eacbf0..56e91d066e 100644 --- a/Projectiles/Melee/DevilsSunriseProj.cs +++ b/Projectiles/Melee/DevilsSunriseProj.cs @@ -90,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/ExobladeProj.cs b/Projectiles/Melee/ExobladeProj.cs index 6629398cec..7de46d9868 100644 --- a/Projectiles/Melee/ExobladeProj.cs +++ b/Projectiles/Melee/ExobladeProj.cs @@ -344,7 +344,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); } @@ -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) diff --git a/Projectiles/Melee/MurasamaSlash.cs b/Projectiles/Melee/MurasamaSlash.cs index 2b0d77c490..57d38701e3 100644 --- a/Projectiles/Melee/MurasamaSlash.cs +++ b/Projectiles/Melee/MurasamaSlash.cs @@ -156,9 +156,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; diff --git a/Projectiles/Melee/PhotonRipperProjectile.cs b/Projectiles/Melee/PhotonRipperProjectile.cs index 749fb11172..14fbdbdad7 100644 --- a/Projectiles/Melee/PhotonRipperProjectile.cs +++ b/Projectiles/Melee/PhotonRipperProjectile.cs @@ -61,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(); @@ -217,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/RespiteblockHoldout.cs b/Projectiles/Melee/RespiteblockHoldout.cs index 4ec0e55ed9..1a510e08a5 100644 --- a/Projectiles/Melee/RespiteblockHoldout.cs +++ b/Projectiles/Melee/RespiteblockHoldout.cs @@ -54,7 +54,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(); diff --git a/Projectiles/Melee/Shortswords/GalileoGladiusProj.cs b/Projectiles/Melee/Shortswords/GalileoGladiusProj.cs index 2843ec3b4a..59c39641ab 100644 --- a/Projectiles/Melee/Shortswords/GalileoGladiusProj.cs +++ b/Projectiles/Melee/Shortswords/GalileoGladiusProj.cs @@ -80,7 +80,7 @@ namespace CalamityMod.Projectiles.Melee.Shortswords var source = player.GetSource_FromThis(); if (player.Calamity().galileoCooldown <= 0) { - int damage = player.GetWeaponDamage(player.ActiveItem()) * 2; + int damage = player.GetWeaponDamage(player.HeldItem) * 2; CalamityUtils.ProjectileRain(source, player.Center, 400f, 100f, 500f, 800f, 25f, ModContent.ProjectileType(), damage, 15f, player.whoAmI); player.Calamity().galileoCooldown = 15; } diff --git a/Projectiles/Melee/StygianShieldAttack.cs b/Projectiles/Melee/StygianShieldAttack.cs index ed2b80decf..be62c60e25 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; diff --git a/Projectiles/Melee/TaintedBladeSlasher.cs b/Projectiles/Melee/TaintedBladeSlasher.cs index c17cd585cf..3b3a58cb78 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); @@ -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/TerratomereHoldoutProj.cs b/Projectiles/Melee/TerratomereHoldoutProj.cs index a4ce26890d..1baa26573b 100644 --- a/Projectiles/Melee/TerratomereHoldoutProj.cs +++ b/Projectiles/Melee/TerratomereHoldoutProj.cs @@ -161,7 +161,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 +177,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); diff --git a/Projectiles/Melee/WulfrumScrewdriverProj.cs b/Projectiles/Melee/WulfrumScrewdriverProj.cs index 17d96ac85f..42471ab1a5 100644 --- a/Projectiles/Melee/WulfrumScrewdriverProj.cs +++ b/Projectiles/Melee/WulfrumScrewdriverProj.cs @@ -69,7 +69,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); 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/Ranged/ArcNovaDiffuserHoldout.cs b/Projectiles/Ranged/ArcNovaDiffuserHoldout.cs index 782f935647..7845aed473 100644 --- a/Projectiles/Ranged/ArcNovaDiffuserHoldout.cs +++ b/Projectiles/Ranged/ArcNovaDiffuserHoldout.cs @@ -44,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(); } diff --git a/Projectiles/Ranged/BouncingShotgunPellet.cs b/Projectiles/Ranged/BouncingShotgunPellet.cs index c912fea852..b756c2149f 100644 --- a/Projectiles/Ranged/BouncingShotgunPellet.cs +++ b/Projectiles/Ranged/BouncingShotgunPellet.cs @@ -50,7 +50,7 @@ namespace CalamityMod.Projectiles.Ranged // 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); } return false; } diff --git a/Projectiles/Ranged/BuzzkillHoldout.cs b/Projectiles/Ranged/BuzzkillHoldout.cs index c10454ba39..467d4f0fba 100644 --- a/Projectiles/Ranged/BuzzkillHoldout.cs +++ b/Projectiles/Ranged/BuzzkillHoldout.cs @@ -55,7 +55,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,7 +78,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); @@ -88,7 +88,7 @@ namespace CalamityMod.Projectiles.Ranged 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); + 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); } 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 c46645ec5d..de7bed1a99 100644 --- a/Projectiles/Ranged/ChromaticEruptionHoldout.cs +++ b/Projectiles/Ranged/ChromaticEruptionHoldout.cs @@ -50,7 +50,7 @@ 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 _); + Owner.PickAmmo(Owner.HeldItem, out _, out float shootSpeed, out int damage, out float knockback, out _); 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); 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/CondemnationHoldout.cs b/Projectiles/Ranged/CondemnationHoldout.cs index 1adf47bc8f..de4c13edc7 100644 --- a/Projectiles/Ranged/CondemnationHoldout.cs +++ b/Projectiles/Ranged/CondemnationHoldout.cs @@ -68,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)) 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/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/DragonsBreathHoldout.cs b/Projectiles/Ranged/DragonsBreathHoldout.cs index 56c8347052..0a10fbfeb0 100644 --- a/Projectiles/Ranged/DragonsBreathHoldout.cs +++ b/Projectiles/Ranged/DragonsBreathHoldout.cs @@ -76,7 +76,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 _); + 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/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/FetidEmesisHoldout.cs b/Projectiles/Ranged/FetidEmesisHoldout.cs index 57ef4b03a1..99723a3edd 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 @@ -31,13 +32,13 @@ namespace CalamityMod.Projectiles.Ranged 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) { @@ -48,23 +49,24 @@ namespace CalamityMod.Projectiles.Ranged revSpeed = Utils.Remap(revFrames, 0, maxFrames - 120, 1, 20, true); if (shootingTimer >= initialFireTime && revFrames < maxFrames && secondShot) { - Owner.PickAmmo(Owner.ActiveItem(), out int bulletAMMO, out float SpeedNoUse, out int bulletDamage, out float kBackNoUse, out _); + 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 / 2, 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; @@ -72,10 +74,13 @@ namespace CalamityMod.Projectiles.Ranged } if (shootingTimer >= 60 && revFrames < maxFrames) { - Owner.PickAmmo(Owner.ActiveItem(), out int bulletAMMO, out float SpeedNoUse, out int bulletDamage, out float kBackNoUse, out _); + Owner.PickAmmo(Owner.HeldItem, out int bulletAMMO, out float SpeedNoUse, out int bulletDamage, out float kBackNoUse, out _); 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); + if (Main.myPlayer == Projectile.owner) + { + 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; } @@ -105,20 +110,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; } diff --git a/Projectiles/Ranged/FirestormCannonHoldout.cs b/Projectiles/Ranged/FirestormCannonHoldout.cs index 9b1b5d20bc..cb539519b4 100644 --- a/Projectiles/Ranged/FirestormCannonHoldout.cs +++ b/Projectiles/Ranged/FirestormCannonHoldout.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Projectiles.Ranged 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.ActiveItem().ModItem as FirestormCannon).BuiltUpHeat; + private int BuiltHeat => (Owner.HeldItem.ModItem as FirestormCannon).BuiltUpHeat; private bool displayOverheat = false; private const int WarningTime = FirestormCannon.OverheatLevel - 100; @@ -47,7 +47,7 @@ namespace CalamityMod.Projectiles.Ranged // 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.ActiveItem().type || + if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.HeldItem.type || (Owner.Calamity().mouseRight && !displayOverheat) || (BuiltHeat == 0 && !Main.mouseLeft)) { if (SoundEngine.TryGetActiveSound(WarningSlot, out var warn)) @@ -68,7 +68,7 @@ namespace CalamityMod.Projectiles.Ranged // Once holding the fire button down long enough, start actually firing if (Timer >= 30) { - // For some reason using ActiveItem() here breaks its functionality while being held on the cursor + // 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 @@ -106,7 +106,7 @@ namespace CalamityMod.Projectiles.Ranged 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.ActiveItem().shootSpeed; + 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; diff --git a/Projectiles/Ranged/FlakKrakenHoldout.cs b/Projectiles/Ranged/FlakKrakenHoldout.cs index f08a32c99e..de5b015a75 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) diff --git a/Projectiles/Ranged/FlakToxicannonHoldout.cs b/Projectiles/Ranged/FlakToxicannonHoldout.cs index 7c279bad0c..be7a32d993 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) 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/FreedomStarHoldout.cs b/Projectiles/Ranged/FreedomStarHoldout.cs index cc5ea44a41..2d54e518ad 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); diff --git a/Projectiles/Ranged/HeavenlyGaleProj.cs b/Projectiles/Ranged/HeavenlyGaleProj.cs index a3bd608917..990b715f3d 100644 --- a/Projectiles/Ranged/HeavenlyGaleProj.cs +++ b/Projectiles/Ranged/HeavenlyGaleProj.cs @@ -15,13 +15,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 +65,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 +78,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 +96,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(); diff --git a/Projectiles/Ranged/HydraHead.cs b/Projectiles/Ranged/HydraHead.cs index f40a49a417..87d44672c8 100644 --- a/Projectiles/Ranged/HydraHead.cs +++ b/Projectiles/Ranged/HydraHead.cs @@ -60,7 +60,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 +137,7 @@ namespace CalamityMod.Projectiles.Ranged public void PerformAttacks(Vector2 aimDestination) { - Item heldItem = Owner.ActiveItem(); + Item heldItem = Owner.HeldItem; Vector2 shootDirection = Projectile.SafeDirectionTo(aimDestination); diff --git a/Projectiles/Ranged/KingsbaneHoldout.cs b/Projectiles/Ranged/KingsbaneHoldout.cs index 6b94907398..36b521afc3 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) diff --git a/Projectiles/Ranged/M1GarandHoldout.cs b/Projectiles/Ranged/M1GarandHoldout.cs index 9a26341432..fceea02692 100644 --- a/Projectiles/Ranged/M1GarandHoldout.cs +++ b/Projectiles/Ranged/M1GarandHoldout.cs @@ -63,7 +63,7 @@ namespace CalamityMod.Projectiles.Ranged public override void KillHoldoutLogic() { // Only allow the projectile to kill if we're not reloading - if (CurrentState == 0 && HeldItem.type != Owner.ActiveItem().type) + if (CurrentState == 0 && HeldItem.type != Owner.HeldItem.type) { Projectile.Kill(); Projectile.netUpdate = true; @@ -90,7 +90,7 @@ namespace CalamityMod.Projectiles.Ranged if (Projectile.frame == 5) { Projectile.frameCounter++; - if (Projectile.frameCounter >= MathHelper.Clamp(Owner.ActiveItem().useAnimation - 18, 0f, Owner.ActiveItem().useAnimation)) + if (Projectile.frameCounter >= MathHelper.Clamp(Owner.HeldItem.useAnimation - 18, 0f, Owner.HeldItem.useAnimation)) { if (Owner.CantUseHoldout()) { 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 ca14d3554f..3a08835d95 100644 --- a/Projectiles/Ranged/MagnaCannonHoldout.cs +++ b/Projectiles/Ranged/MagnaCannonHoldout.cs @@ -31,7 +31,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(); } 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/NorfleetCannon.cs b/Projectiles/Ranged/NorfleetCannon.cs index 4e1a34b204..c5db0d0c11 100644 --- a/Projectiles/Ranged/NorfleetCannon.cs +++ b/Projectiles/Ranged/NorfleetCannon.cs @@ -51,7 +51,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(); diff --git a/Projectiles/Ranged/OntologicalDespoilerHoldout.cs b/Projectiles/Ranged/OntologicalDespoilerHoldout.cs index 8da1b46d64..e360eb1986 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(); } diff --git a/Projectiles/Ranged/OpalStrikerHoldout.cs b/Projectiles/Ranged/OpalStrikerHoldout.cs index c785d5e32d..54d701d687 100644 --- a/Projectiles/Ranged/OpalStrikerHoldout.cs +++ b/Projectiles/Ranged/OpalStrikerHoldout.cs @@ -31,7 +31,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(); } diff --git a/Projectiles/Ranged/PhotovisceratorHoldout.cs b/Projectiles/Ranged/PhotovisceratorHoldout.cs index 3ce94b93fa..25687275ff 100644 --- a/Projectiles/Ranged/PhotovisceratorHoldout.cs +++ b/Projectiles/Ranged/PhotovisceratorHoldout.cs @@ -117,7 +117,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 +150,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.Next(100) < AmmoSavedPercent); + 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; @@ -193,7 +193,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 +212,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; diff --git a/Projectiles/Ranged/PumplerHoldout.cs b/Projectiles/Ranged/PumplerHoldout.cs index 7333516569..e071319c86 100644 --- a/Projectiles/Ranged/PumplerHoldout.cs +++ b/Projectiles/Ranged/PumplerHoldout.cs @@ -88,7 +88,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 +149,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 +161,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/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/SevensStrikerHoldout.cs b/Projectiles/Ranged/SevensStrikerHoldout.cs index b94d1e005f..45ae61ddb7 100644 --- a/Projectiles/Ranged/SevensStrikerHoldout.cs +++ b/Projectiles/Ranged/SevensStrikerHoldout.cs @@ -48,8 +48,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 +57,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 +105,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 +319,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/SpectralstormCannonHoldout.cs b/Projectiles/Ranged/SpectralstormCannonHoldout.cs index 9c5d4cabd7..0c6b0ed23f 100644 --- a/Projectiles/Ranged/SpectralstormCannonHoldout.cs +++ b/Projectiles/Ranged/SpectralstormCannonHoldout.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Projectiles.Ranged public SlotId WarningSlot; public ref float Timer => ref Projectile.ai[0]; public ref float SoulTimer => ref Projectile.ai[1]; - private int BuiltHeat => (Owner.ActiveItem().ModItem as SpectralstormCannon).BuiltUpHeat; + private int BuiltHeat => (Owner.HeldItem.ModItem as SpectralstormCannon).BuiltUpHeat; private bool displayOverheat = false; private const int WarningTime = SpectralstormCannon.OverheatLevel - 100; @@ -49,7 +49,7 @@ namespace CalamityMod.Projectiles.Ranged // 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.ActiveItem().type || + if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.HeldItem.type || (Owner.Calamity().mouseRight && !displayOverheat) || (BuiltHeat == 0 && !Main.mouseLeft)) { if (SoundEngine.TryGetActiveSound(WarningSlot, out var warn)) @@ -84,7 +84,7 @@ namespace CalamityMod.Projectiles.Ranged // Once holding the fire button down long enough, start actually firing if (Timer >= 30) { - // For some reason using ActiveItem() here breaks its functionality while being held on the cursor + // 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 @@ -137,7 +137,7 @@ namespace CalamityMod.Projectiles.Ranged 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.ActiveItem().shootSpeed; + 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); } } @@ -150,7 +150,7 @@ namespace CalamityMod.Projectiles.Ranged 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.ActiveItem().shootSpeed * 0.8f; + 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); diff --git a/Projectiles/Ranged/StarmageddonHeld.cs b/Projectiles/Ranged/StarmageddonHeld.cs index 87f3bc97ff..dbca1a799b 100644 --- a/Projectiles/Ranged/StarmageddonHeld.cs +++ b/Projectiles/Ranged/StarmageddonHeld.cs @@ -82,8 +82,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/SuperradiantSlaughtererHoldout.cs b/Projectiles/Ranged/SuperradiantSlaughtererHoldout.cs index ae4ec09ad5..45cc3e937c 100644 --- a/Projectiles/Ranged/SuperradiantSlaughtererHoldout.cs +++ b/Projectiles/Ranged/SuperradiantSlaughtererHoldout.cs @@ -59,7 +59,7 @@ namespace CalamityMod.Projectiles.Ranged public override void KillHoldoutLogic() { - if (HeldItem.type != Owner.ActiveItem().type || Owner.dead || !Owner.active) + if (HeldItem.type != Owner.HeldItem.type || Owner.dead || !Owner.active) { Projectile.Kill(); Projectile.netUpdate = true; @@ -90,7 +90,7 @@ namespace CalamityMod.Projectiles.Ranged // End animation early NoSawOnHoldout = true; OffsetLengthFromArm -= 16f; - Projectile.timeLeft = Owner.ActiveItem().useAnimation; + Projectile.timeLeft = Owner.HeldItem.useAnimation; KeepRefreshingLifetime = false; Idle?.Stop(); @@ -119,7 +119,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); 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/TauCannonHoldout.cs b/Projectiles/Ranged/TauCannonHoldout.cs index 71a4e9c79a..a4b677a4e0 100644 --- a/Projectiles/Ranged/TauCannonHoldout.cs +++ b/Projectiles/Ranged/TauCannonHoldout.cs @@ -93,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) { 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/WildfireBloomHoldout.cs b/Projectiles/Ranged/WildfireBloomHoldout.cs index e545dd7d0a..981a28a453 100644 --- a/Projectiles/Ranged/WildfireBloomHoldout.cs +++ b/Projectiles/Ranged/WildfireBloomHoldout.cs @@ -40,7 +40,7 @@ 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 _); + Owner.PickAmmo(Owner.HeldItem, out _, out float shootSpeed, out int damage, out float knockback, out _); Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, (Projectile.velocity * 9).RotatedByRandom(0.08f), ModContent.ProjectileType(), damage, knockback, Projectile.owner); ShotsFired++; ShotCooldown = HeldItem.useTime; diff --git a/Projectiles/Summon/AtlasMunitionsAutocannon.cs b/Projectiles/Summon/AtlasMunitionsAutocannon.cs index fd34912391..b58b224b32 100644 --- a/Projectiles/Summon/AtlasMunitionsAutocannon.cs +++ b/Projectiles/Summon/AtlasMunitionsAutocannon.cs @@ -184,7 +184,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/CausticStaffProjectile.cs b/Projectiles/Summon/CausticStaffProjectile.cs index a5f79fccff..777d88f0e7 100644 --- a/Projectiles/Summon/CausticStaffProjectile.cs +++ b/Projectiles/Summon/CausticStaffProjectile.cs @@ -51,7 +51,7 @@ 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 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/RelicOfDeliveranceSpear.cs b/Projectiles/Typeless/RelicOfDeliveranceSpear.cs index 33aee8c768..cb3c00e61f 100644 --- a/Projectiles/Typeless/RelicOfDeliveranceSpear.cs +++ b/Projectiles/Typeless/RelicOfDeliveranceSpear.cs @@ -116,12 +116,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; diff --git a/Projectiles/Typeless/VictideBobber.cs b/Projectiles/Typeless/VictideBobber.cs index 8c9c4113de..2e74bf0eae 100644 --- a/Projectiles/Typeless/VictideBobber.cs +++ b/Projectiles/Typeless/VictideBobber.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Projectiles.Typeless public override bool PreAI() { // Snap if the snail is shelled, or just nowhere to be found - if (!Parent.active || Owner.ActiveItem().fishingPole <= 0 || Parent == null || Parent.frame < 6) + if (!Parent.active || Owner.HeldItem.fishingPole <= 0 || Parent == null || Parent.frame < 6) { Projectile.Kill(); return false; diff --git a/Projectiles/Typeless/VictideSeaSnail.cs b/Projectiles/Typeless/VictideSeaSnail.cs index 94282c071c..3b8f61194e 100644 --- a/Projectiles/Typeless/VictideSeaSnail.cs +++ b/Projectiles/Typeless/VictideSeaSnail.cs @@ -168,7 +168,7 @@ namespace CalamityMod.Projectiles.Typeless { // 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.ActiveItem().fishingPole > 0) + if (Owner.itemAnimation > 0 && Owner.HeldItem.fishingPole > 0) PlayerFishingTimer = 600f; else PlayerFishingTimer = Math.Max(PlayerFishingTimer -1f, 0f); @@ -176,11 +176,11 @@ namespace CalamityMod.Projectiles.Typeless // 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.ActiveItem().fishingPole > 0 && Projectile.owner == Main.myPlayer && PlayerFishingTimer > 0f) + 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.ActiveItem().shootSpeed; + 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); } } diff --git a/Tiles/Abyss/AcidWoodTree.cs b/Tiles/Abyss/AcidWoodTree.cs index ef235d14ed..c0979a9637 100644 --- a/Tiles/Abyss/AcidWoodTree.cs +++ b/Tiles/Abyss/AcidWoodTree.cs @@ -58,7 +58,7 @@ namespace CalamityMod.Tiles.Abyss // 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.ActiveItem().type == ModContent.ItemType() && WorldGen.genRand.NextBool(3)) + 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); 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/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/AstralTree.cs b/Tiles/Astral/AstralTree.cs index e0ef7fcfd1..c07c01ae02 100644 --- a/Tiles/Astral/AstralTree.cs +++ b/Tiles/Astral/AstralTree.cs @@ -77,7 +77,7 @@ namespace CalamityMod.Tiles.Astral // 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.ActiveItem().type == ModContent.ItemType() && WorldGen.genRand.NextBool(3)) + 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); diff --git a/Tiles/AstralDesert/AstralPalmTree.cs b/Tiles/AstralDesert/AstralPalmTree.cs index 085f713984..c73bc18a2c 100644 --- a/Tiles/AstralDesert/AstralPalmTree.cs +++ b/Tiles/AstralDesert/AstralPalmTree.cs @@ -75,7 +75,7 @@ namespace CalamityMod.Tiles.AstralDesert // 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.ActiveItem().type == ModContent.ItemType() && WorldGen.genRand.NextBool(3)) + 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()); diff --git a/Tiles/AstralSnow/AstralSnowTree.cs b/Tiles/AstralSnow/AstralSnowTree.cs index 1edb32555d..2857200913 100644 --- a/Tiles/AstralSnow/AstralSnowTree.cs +++ b/Tiles/AstralSnow/AstralSnowTree.cs @@ -78,7 +78,7 @@ namespace CalamityMod.Tiles.AstralSnow // 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.ActiveItem().type == ModContent.ItemType() && WorldGen.genRand.NextBool(3)) + 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); diff --git a/Tiles/CalamityGlobalTile.cs b/Tiles/CalamityGlobalTile.cs index 3874b46669..2399a89f22 100644 --- a/Tiles/CalamityGlobalTile.cs +++ b/Tiles/CalamityGlobalTile.cs @@ -58,7 +58,7 @@ namespace CalamityMod.Tiles // 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.ActiveItem().type == ItemType() && WorldGen.genRand.NextBool(3)) + if (nearestPlayer.active && nearestPlayer.HeldItem.type == ItemType() && WorldGen.genRand.NextBool(3)) { int treeDropItemType = 0; switch (treeType) diff --git a/UI/CalamitasEnchantments/EnchantmentManager.cs b/UI/CalamitasEnchantments/EnchantmentManager.cs index 21fa902136..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), diff --git a/UI/DraedonsArsenal/ChargeMeterUI.cs b/UI/DraedonsArsenal/ChargeMeterUI.cs index 57c70e0ead..df22dcd4cb 100644 --- a/UI/DraedonsArsenal/ChargeMeterUI.cs +++ b/UI/DraedonsArsenal/ChargeMeterUI.cs @@ -69,7 +69,7 @@ namespace CalamityMod.UI.DraedonsArsenal } // 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(); 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/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/Utilities/GeneralExtensionUtils.cs b/Utilities/GeneralExtensionUtils.cs index a7950a7edd..412bbb784a 100644 --- a/Utilities/GeneralExtensionUtils.cs +++ b/Utilities/GeneralExtensionUtils.cs @@ -15,7 +15,6 @@ namespace CalamityMod 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/ItemUtils.cs b/Utilities/ItemUtils.cs index b6f6d91391..bb08ebe275 100644 --- a/Utilities/ItemUtils.cs +++ b/Utilities/ItemUtils.cs @@ -505,7 +505,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; diff --git a/Utilities/PlayerUtils.cs b/Utilities/PlayerUtils.cs index 0287eca5ca..edfb980757 100644 --- a/Utilities/PlayerUtils.cs +++ b/Utilities/PlayerUtils.cs @@ -396,11 +396,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) { From a76e3581cca80a3c379c806f6570ecbdd7513b19 Mon Sep 17 00:00:00 2001 From: Nathanael Overton Date: Sat, 15 Nov 2025 00:05:26 -0500 Subject: [PATCH 25/65] Exoblade draws smaller as dash progresses + typo fix --- Projectiles/Melee/ExobladeProj.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Projectiles/Melee/ExobladeProj.cs b/Projectiles/Melee/ExobladeProj.cs index 7de46d9868..0431d5225b 100644 --- a/Projectiles/Melee/ExobladeProj.cs +++ b/Projectiles/Melee/ExobladeProj.cs @@ -373,13 +373,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); @@ -576,6 +576,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); From bca1a8e3601ab84b6999af4db985827d2ab7deee Mon Sep 17 00:00:00 2001 From: doze-zoze Date: Fri, 14 Nov 2025 23:05:42 -0600 Subject: [PATCH 26/65] finshed saros --- CalPlayer/CalamityPlayer.cs | 5 + Items/Weapons/Summon/SarosPossession.cs | 22 +-- Items/Weapons/Summon/VengefulSunStaff.cs | 2 +- ...ods.CalamityMod.Items.Weapons.Summon.hjson | 14 +- .../Mods.CalamityMod.Projectiles.Summon.hjson | 1 + Projectiles/Summon/SarosAura.cs | 24 ++-- Projectiles/Summon/SarosEclipseBeam.cs | 128 ++++++++++++++++++ Projectiles/Summon/SarosMicrosun.cs | 90 ------------ Projectiles/Summon/SarosSunfire.cs | 3 +- 9 files changed, 170 insertions(+), 119 deletions(-) create mode 100644 Projectiles/Summon/SarosEclipseBeam.cs delete mode 100644 Projectiles/Summon/SarosMicrosun.cs diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index be8080b276..a53920ea70 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -1502,6 +1502,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; @@ -2679,6 +2680,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; diff --git a/Items/Weapons/Summon/SarosPossession.cs b/Items/Weapons/Summon/SarosPossession.cs index b77a616e7b..a030e24c03 100644 --- a/Items/Weapons/Summon/SarosPossession.cs +++ b/Items/Weapons/Summon/SarosPossession.cs @@ -2,6 +2,7 @@ using CalamityMod.Buffs.Summon; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Summon; +using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -17,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Summon { Item.width = 44; Item.height = 48; - Item.damage = 80; + Item.damage = 60; Item.mana = 10; Item.useAnimation = Item.useTime = 24; Item.useStyle = ItemUseStyleID.Swing; @@ -29,17 +30,12 @@ namespace CalamityMod.Items.Weapons.Summon Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); Item.DamageType = DamageClass.Summon; + Item.channel = true; } 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 || player.altFunctionUse == 2; + 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) @@ -50,6 +46,9 @@ namespace CalamityMod.Items.Weapons.Summon p.ai[0]++; p.netUpdate = true; return false; + } else + { + player.channel = false; } player.AddBuff(Item.buffType, 2); return true; @@ -58,9 +57,10 @@ namespace CalamityMod.Items.Weapons.Summon public override void AddRecipes() { CreateRecipe(). - AddIngredient(ItemID.SandstoneBrick, 20). - AddIngredient(2). - AddTile(TileID.Anvils). + AddIngredient(). + AddIngredient(5). + AddIngredient(15). + AddTile(). Register(); } } diff --git a/Items/Weapons/Summon/VengefulSunStaff.cs b/Items/Weapons/Summon/VengefulSunStaff.cs index 6864ee175d..6baedebc3b 100644 --- a/Items/Weapons/Summon/VengefulSunStaff.cs +++ b/Items/Weapons/Summon/VengefulSunStaff.cs @@ -60,7 +60,7 @@ namespace CalamityMod.Items.Weapons.Summon { CreateRecipe(). AddIngredient(). - AddIngredient(5). + AddIngredient(ItemID.MoonStone). AddIngredient(ItemID.SoulofFright, 3). AddIngredient(ItemID.SoulofMight, 3). AddIngredient(ItemID.SoulofSight, 3). diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson index 580a0190a4..75d477aace 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson @@ -661,10 +661,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 6 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 ''' } @@ -779,7 +779,7 @@ SunSpiritStaff: { Tooltip: ''' Summons a solar spirit to protect you - There can only be one spirit at a time + Repeated summons increase its power ''' } @@ -838,8 +838,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 ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson index f3ef8628e8..df88751a5d 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson @@ -335,3 +335,4 @@ SunSpiritBeam.DisplayName: Sun Spirit Beam SunSpiritMinion.DisplayName: Sun Spirit Minion VengefulSunBeam.DisplayName: Vengeful Sun Beam VengefulSunSpiritMinion.DisplayName: Vengeful Sun Spirit Minion +SarosEclipseBeam.DisplayName: Saros Eclipse Beam diff --git a/Projectiles/Summon/SarosAura.cs b/Projectiles/Summon/SarosAura.cs index 4ae102b332..8529826e79 100644 --- a/Projectiles/Summon/SarosAura.cs +++ b/Projectiles/Summon/SarosAura.cs @@ -60,6 +60,11 @@ namespace CalamityMod.Projectiles.Summon Projectile.minionSlots++; minionSlotsAvaliable--; MinionSlotsToAdd--; + player.channel = false; + } + 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; } @@ -101,16 +106,19 @@ namespace CalamityMod.Projectiles.Summon } else { - 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++) + if (player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0) { - 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; + 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++) + { + 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); } - Projectile.ai[1] += 60f / (0.8f + Projectile.minionSlots * 0.2f); } } diff --git a/Projectiles/Summon/SarosEclipseBeam.cs b/Projectiles/Summon/SarosEclipseBeam.cs new file mode 100644 index 0000000000..3518feb284 --- /dev/null +++ b/Projectiles/Summon/SarosEclipseBeam.cs @@ -0,0 +1,128 @@ +using System; +using System.Collections.Generic; +using System.Linq; +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 SarosEclipseBeam : ModProjectile, ILocalizedModType, IPixelatedPrimitiveRenderer + { + public new string LocalizationCategory => "Projectiles.Summon"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 20; + 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 = 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(SoundID.Item20, Projectile.Center); + Projectile.rotation = SarosPos.DirectionTo(Owner.Calamity().mouseWorld).ToRotation(); + } + + Player Owner => Main.player[Projectile.owner]; + + + public override void AI() + { + 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) + { + 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)); + } + + public Color FireColorFunction(float completion) + { + 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) + { + 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)); + } + + public Color FireCoreColorFunction(float completion) + { + return Color.Black * MathF.Pow(1 - completion, 0.5f); + } + + public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, PixelationPrimitiveLayer layer) + { + Vector2[] pos = [SarosPos, Projectile.Center]; + List posList = []; + for (var i = 0; i <= 10; i++) + { + posList.Add(Vector2.Lerp(SarosPos, Projectile.Center, i / 10f)); + } + pos = posList.ToArray(); + // Render the main trail for the body for the flame. + 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); + + // Render a smaller, pure white trail in the same position to represent the glowing core of the flame. + Vector2[] fireCoreLength = pos; + GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); + PrimitiveRenderer.RenderTrail(fireCoreLength, 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 ead525251c..63c00635d5 100644 --- a/Projectiles/Summon/SarosSunfire.cs +++ b/Projectiles/Summon/SarosSunfire.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { - ProjectileID.Sets.TrailCacheLength[Type] = 20; + ProjectileID.Sets.TrailCacheLength[Type] = 8; ProjectileID.Sets.TrailingMode[Type] = 2; ProjectileID.Sets.MinionShot[Type] = true; } @@ -40,7 +40,6 @@ namespace CalamityMod.Projectiles.Summon public override void OnSpawn(IEntitySource source) { - ProjectileID.Sets.TrailCacheLength[Type] = 8; SoundEngine.PlaySound(SoundID.Item20, Projectile.Center); } From 4913d5995fcf50829a969cfcc396e56cbec66984 Mon Sep 17 00:00:00 2001 From: Nathanael Overton Date: Sat, 15 Nov 2025 00:33:18 -0500 Subject: [PATCH 27/65] Moon Walkers flavor tooltip change Requested by Doze --- .../en-US/Mods.CalamityMod.Items.Accessories.Wings.hjson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Localization/en-US/Mods.CalamityMod.Items.Accessories.Wings.hjson b/Localization/en-US/Mods.CalamityMod.Items.Accessories.Wings.hjson index 1df3645b44..8328241b9d 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Accessories.Wings.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Accessories.Wings.hjson @@ -109,7 +109,7 @@ MoonWalkers: { 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!' + 'Hee hee!' ''' } From 2df42567aa59a77c19fe3c60b03aa69e22ac64a5 Mon Sep 17 00:00:00 2001 From: Flowaria Date: Sat, 15 Nov 2025 14:34:59 +0900 Subject: [PATCH 28/65] Fix: Seeds are consumed only when they are placed + Now do netsync --- Items/Placeables/Astral/AstralGrassSeeds.cs | 18 ++++++++++++------ Items/Placeables/Crags/CinderBlossomSeeds.cs | 18 ++++++++++++------ 2 files changed, 24 insertions(+), 12 deletions(-) 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/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; } From 7e85c118e3427c9883b5b6a489dfbfe22fd34633 Mon Sep 17 00:00:00 2001 From: Flowaria Date: Sat, 15 Nov 2025 14:44:57 +0900 Subject: [PATCH 29/65] Remove Unreasonable Health check on IsAnEnemy, Replace to NPCSets --- Systems/Collections/CalamityNPCSets.cs | 5 +++++ Utilities/NPCUtils.cs | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Systems/Collections/CalamityNPCSets.cs b/Systems/Collections/CalamityNPCSets.cs index 44be2f0a60..5b8dca1dd6 100644 --- a/Systems/Collections/CalamityNPCSets.cs +++ b/Systems/Collections/CalamityNPCSets.cs @@ -208,6 +208,11 @@ namespace CalamityMod.Systems.Collections /// public static bool[] DoCheckDeadRegardlessRealLife = Factory.CreateBoolSet(NPCType(), NPCType()); + /// + /// If for an NPC type, Does not count specified NPC as Enemy + /// + 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. diff --git a/Utilities/NPCUtils.cs b/Utilities/NPCUtils.cs index eefc10586b..3ebfcf40c2 100644 --- a/Utilities/NPCUtils.cs +++ b/Utilities/NPCUtils.cs @@ -14,6 +14,7 @@ using CalamityMod.NPCs.SlimeGod; using CalamityMod.NPCs.SunkenSea; using CalamityMod.NPCs.Yharon; using CalamityMod.Packets; +using CalamityMod.Systems.Collections; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -266,8 +267,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. From 28933ce50b7c45697af9340d5311da9ac1ac34a4 Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Sat, 15 Nov 2025 00:51:58 -0500 Subject: [PATCH 30/65] Main.myPlayer == Projectile.owner --- .../CountermeasureMittHoldout.cs | 3 +- .../HolofibreImmolatorHoldout.cs | 18 ++++--- Projectiles/DraedonsArsenal/NidhoggHoldout.cs | 14 ++++-- .../DraedonsArsenal/PhalanxSurgeHoldout.cs | 47 ++++++++++-------- Projectiles/DraedonsArsenal/VulcanHoldout.cs | 12 +++-- Projectiles/Magic/HeliumFlashHoldout.cs | 5 +- Projectiles/Magic/NanoPurgeHoldout.cs | 29 ++++++----- Projectiles/Magic/OmicronHoldout.cs | 22 +++++---- Projectiles/Magic/PurgeGuzzlerHoldout.cs | 24 ++++++---- Projectiles/Magic/SparklingEmpressHoldout.cs | 9 ++-- .../Magic/UnstableCastersGauntletHoldout.cs | 14 ++++-- Projectiles/Magic/VitriolicViperHoldout.cs | 12 +++-- .../Ranged/ChromaticEruptionHoldout.cs | 8 ++-- Projectiles/Ranged/DragonsBreathHoldout.cs | 5 +- Projectiles/Ranged/FlakKrakenHoldout.cs | 29 ++++++----- Projectiles/Ranged/FlakToxicannonHoldout.cs | 29 ++++++----- Projectiles/Ranged/HellbornHoldout.cs | 15 +++--- Projectiles/Ranged/M1GarandHoldout.cs | 24 ++++++---- Projectiles/Ranged/MagnaCannonHoldout.cs | 3 +- .../Ranged/OntologicalDespoilerHoldout.cs | 46 ++++++++++-------- Projectiles/Ranged/ScorchedEarthHoldout.cs | 3 +- Projectiles/Ranged/ScorpioHoldout.cs | 23 +++++---- Projectiles/Ranged/StarfleetHoldout.cs | 31 +++++++----- Projectiles/Ranged/StarmadaHoldout.cs | 34 +++++++------ .../Ranged/SuperradiantSlaughtererHoldout.cs | 12 +++-- Projectiles/Ranged/TheHiveHoldout.cs | 48 +++++++++---------- Projectiles/Ranged/WildfireBloomHoldout.cs | 5 +- 27 files changed, 307 insertions(+), 217 deletions(-) diff --git a/Projectiles/DraedonsArsenal/CountermeasureMittHoldout.cs b/Projectiles/DraedonsArsenal/CountermeasureMittHoldout.cs index 67d89b1f73..78de098435 100644 --- a/Projectiles/DraedonsArsenal/CountermeasureMittHoldout.cs +++ b/Projectiles/DraedonsArsenal/CountermeasureMittHoldout.cs @@ -390,7 +390,8 @@ namespace CalamityMod.Projectiles.DraedonsArsenal 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); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), pos, vel, ModContent.ProjectileType(), (int)(Projectile.damage * damageMult), 0, Projectile.owner, 0, npc.whoAmI); + 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++) diff --git a/Projectiles/DraedonsArsenal/HolofibreImmolatorHoldout.cs b/Projectiles/DraedonsArsenal/HolofibreImmolatorHoldout.cs index f9f7846535..aae2452af4 100644 --- a/Projectiles/DraedonsArsenal/HolofibreImmolatorHoldout.cs +++ b/Projectiles/DraedonsArsenal/HolofibreImmolatorHoldout.cs @@ -72,9 +72,12 @@ namespace CalamityMod.Projectiles.DraedonsArsenal 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); + if (Main.myPlayer == Projectile.owner) + { + 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++) { @@ -92,10 +95,13 @@ namespace CalamityMod.Projectiles.DraedonsArsenal 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++) + if (Main.myPlayer == Projectile.owner) { - 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 < 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++) { diff --git a/Projectiles/DraedonsArsenal/NidhoggHoldout.cs b/Projectiles/DraedonsArsenal/NidhoggHoldout.cs index 1264d85669..0d7f3975c8 100644 --- a/Projectiles/DraedonsArsenal/NidhoggHoldout.cs +++ b/Projectiles/DraedonsArsenal/NidhoggHoldout.cs @@ -147,12 +147,15 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Owner.AddCooldown(ArsenalPower.ID, 540); Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY); - int chargeDamage = (int)(Projectile.damage * 33); - Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity * 6, ModContent.ProjectileType(), chargeDamage, 0, Projectile.owner); - + 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); + 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++) @@ -178,7 +181,8 @@ namespace CalamityMod.Projectiles.DraedonsArsenal 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; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, shootVelocity, ModContent.ProjectileType(), Projectile.damage, 0, Projectile.owner); + 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++) { diff --git a/Projectiles/DraedonsArsenal/PhalanxSurgeHoldout.cs b/Projectiles/DraedonsArsenal/PhalanxSurgeHoldout.cs index dbedcdee8d..1449a379e7 100644 --- a/Projectiles/DraedonsArsenal/PhalanxSurgeHoldout.cs +++ b/Projectiles/DraedonsArsenal/PhalanxSurgeHoldout.cs @@ -250,10 +250,13 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Owner.AddCooldown(ArsenalPower.ID, 300); Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY); - 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); + 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); @@ -266,9 +269,8 @@ namespace CalamityMod.Projectiles.DraedonsArsenal dust.color = Effects.ArsenalEffects.ArsenalLaserColor; dust.alpha = 100; } - - shootingTimer = (didDash ? -25 : -10); + shootingTimer = didDash ? -25 : -10; } else { @@ -277,22 +279,25 @@ namespace CalamityMod.Projectiles.DraedonsArsenal 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; - float angle1 = MathHelper.ToRadians(2f); - int projType = ModContent.ProjectileType(); - for (int i = 0; i < 2; i++) + if (Main.myPlayer == Projectile.owner) { - 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; + 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++) diff --git a/Projectiles/DraedonsArsenal/VulcanHoldout.cs b/Projectiles/DraedonsArsenal/VulcanHoldout.cs index ef2b9b0a0a..8e64ffa231 100644 --- a/Projectiles/DraedonsArsenal/VulcanHoldout.cs +++ b/Projectiles/DraedonsArsenal/VulcanHoldout.cs @@ -173,13 +173,16 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { if (isSpear) { - Vector2 spearPos = GunTipPosition + Projectile.velocity.RotatedBy(MathHelper.PiOver2 * Projectile.direction) * 12 - Projectile.velocity * 8; - Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedByRandom(0f) * 6f; 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); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), spearPos, shootVelocity, ModContent.ProjectileType(), Projectile.damage * 5, 0, Projectile.owner); + 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 { @@ -190,7 +193,8 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedByRandom(0f) * 6f; Vector2 position = GunTipPosition + Projectile.velocity.RotatedBy(MathHelper.PiOver2 * (shotsFired % 2 == 0 ? -1 : 1)) * 4; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), position, shootVelocity, ModContent.ProjectileType(), Projectile.damage, 0, Projectile.owner); + 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++) { diff --git a/Projectiles/Magic/HeliumFlashHoldout.cs b/Projectiles/Magic/HeliumFlashHoldout.cs index acc2c30f66..2278dc795f 100644 --- a/Projectiles/Magic/HeliumFlashHoldout.cs +++ b/Projectiles/Magic/HeliumFlashHoldout.cs @@ -56,7 +56,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 +67,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); diff --git a/Projectiles/Magic/NanoPurgeHoldout.cs b/Projectiles/Magic/NanoPurgeHoldout.cs index f4ccd1089d..23c0ad88b7 100644 --- a/Projectiles/Magic/NanoPurgeHoldout.cs +++ b/Projectiles/Magic/NanoPurgeHoldout.cs @@ -74,20 +74,23 @@ namespace CalamityMod.Projectiles.Magic 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/OmicronHoldout.cs b/Projectiles/Magic/OmicronHoldout.cs index 525eb01074..cac7134819 100644 --- a/Projectiles/Magic/OmicronHoldout.cs +++ b/Projectiles/Magic/OmicronHoldout.cs @@ -107,7 +107,8 @@ namespace CalamityMod.Projectiles.Magic } Owner.SetScreenshake(6.5f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, firingVelocity3, ModContent.ProjectileType(), Projectile.damage * 32, Projectile.knockBack, Projectile.owner, 0, 0); + 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); diff --git a/Projectiles/Magic/PurgeGuzzlerHoldout.cs b/Projectiles/Magic/PurgeGuzzlerHoldout.cs index fff3d95631..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 @@ -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++) { @@ -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/SparklingEmpressHoldout.cs b/Projectiles/Magic/SparklingEmpressHoldout.cs index 1c2ebb6dee..3d68532d78 100644 --- a/Projectiles/Magic/SparklingEmpressHoldout.cs +++ b/Projectiles/Magic/SparklingEmpressHoldout.cs @@ -172,9 +172,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/UnstableCastersGauntletHoldout.cs b/Projectiles/Magic/UnstableCastersGauntletHoldout.cs index 712b1c6641..dc8010ae7d 100644 --- a/Projectiles/Magic/UnstableCastersGauntletHoldout.cs +++ b/Projectiles/Magic/UnstableCastersGauntletHoldout.cs @@ -150,7 +150,8 @@ namespace CalamityMod.Projectiles.Magic GeneralParticleHandler.SpawnParticle(shootPulse); // Spawn needle - 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); + 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 @@ -172,8 +173,8 @@ namespace CalamityMod.Projectiles.Magic calPlayer.unstableCastersGauntletVis -= 12f; SoundEngine.PlaySound(new("CalamityMod/Sounds/Item/MagicRockSound") { Volume = 0.4f, PitchVariance = 0.05f }, Projectile.Center); - - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Owner.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Owner.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); shootingTimer = 0f; } } @@ -268,9 +269,12 @@ namespace CalamityMod.Projectiles.Magic SoundEngine.PlaySound(SoundID.DD2_EtherianPortalOpen with { Volume = 0.6f }, Projectile.Center); // Spawn Warp Sigils for each empty slot - foreach (int sigilIndex in availableIndices) + if (Main.myPlayer == Projectile.owner) { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), thisParent.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, thisParent.identity, sigilIndex); + 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; diff --git a/Projectiles/Magic/VitriolicViperHoldout.cs b/Projectiles/Magic/VitriolicViperHoldout.cs index bf984dd2c2..f0497c75f1 100644 --- a/Projectiles/Magic/VitriolicViperHoldout.cs +++ b/Projectiles/Magic/VitriolicViperHoldout.cs @@ -78,9 +78,10 @@ namespace CalamityMod.Projectiles.Magic // Vipers can apparently have 33 teeth or something like that Owner.SetScreenshake(4f); - for (int i = 0; i < 33; i++) + 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); @@ -117,8 +118,11 @@ 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); diff --git a/Projectiles/Ranged/ChromaticEruptionHoldout.cs b/Projectiles/Ranged/ChromaticEruptionHoldout.cs index de7bed1a99..a406ae5b0e 100644 --- a/Projectiles/Ranged/ChromaticEruptionHoldout.cs +++ b/Projectiles/Ranged/ChromaticEruptionHoldout.cs @@ -51,13 +51,15 @@ namespace CalamityMod.Projectiles.Ranged { SoundEngine.PlaySound(SoundID.Item34, Projectile.Center); Owner.PickAmmo(Owner.HeldItem, out _, out float shootSpeed, out int damage, out float knockback, out _); - for (int i = 0; i < 2; i++) + 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; diff --git a/Projectiles/Ranged/DragonsBreathHoldout.cs b/Projectiles/Ranged/DragonsBreathHoldout.cs index 0a10fbfeb0..52471464d3 100644 --- a/Projectiles/Ranged/DragonsBreathHoldout.cs +++ b/Projectiles/Ranged/DragonsBreathHoldout.cs @@ -50,7 +50,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 +67,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; } } diff --git a/Projectiles/Ranged/FlakKrakenHoldout.cs b/Projectiles/Ranged/FlakKrakenHoldout.cs index de5b015a75..952a65edc8 100644 --- a/Projectiles/Ranged/FlakKrakenHoldout.cs +++ b/Projectiles/Ranged/FlakKrakenHoldout.cs @@ -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; diff --git a/Projectiles/Ranged/FlakToxicannonHoldout.cs b/Projectiles/Ranged/FlakToxicannonHoldout.cs index be7a32d993..c2c80b9bc6 100644 --- a/Projectiles/Ranged/FlakToxicannonHoldout.cs +++ b/Projectiles/Ranged/FlakToxicannonHoldout.cs @@ -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; diff --git a/Projectiles/Ranged/HellbornHoldout.cs b/Projectiles/Ranged/HellbornHoldout.cs index 84f16af0ea..781335298d 100644 --- a/Projectiles/Ranged/HellbornHoldout.cs +++ b/Projectiles/Ranged/HellbornHoldout.cs @@ -111,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)); @@ -123,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)); @@ -146,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)); diff --git a/Projectiles/Ranged/M1GarandHoldout.cs b/Projectiles/Ranged/M1GarandHoldout.cs index fceea02692..7a606842e0 100644 --- a/Projectiles/Ranged/M1GarandHoldout.cs +++ b/Projectiles/Ranged/M1GarandHoldout.cs @@ -154,15 +154,18 @@ namespace CalamityMod.Projectiles.Ranged Vector2 velocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * HeldItem.shootSpeed; - // 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) + if (Main.myPlayer == Projectile.owner) { - 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); + // 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); - 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); + 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 @@ -177,8 +180,11 @@ namespace CalamityMod.Projectiles.Ranged GeneralParticleHandler.SpawnParticle(shootPulse); // Shot starts from slightly behind the tip - Vector2 offsetPos = GunTipPosition - Projectile.velocity.SafeNormalize(Vector2.UnitY) * 18f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), offsetPos, velocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + 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 diff --git a/Projectiles/Ranged/MagnaCannonHoldout.cs b/Projectiles/Ranged/MagnaCannonHoldout.cs index 3a08835d95..8440f44443 100644 --- a/Projectiles/Ranged/MagnaCannonHoldout.cs +++ b/Projectiles/Ranged/MagnaCannonHoldout.cs @@ -58,7 +58,8 @@ 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, ModContent.DustType(), shootVelocity.RotatedByRandom(MathHelper.ToRadians(25f)) * Main.rand.NextFloat(0.2f, 0.9f), 0, default, Main.rand.NextFloat(1.3f, 1.6f)); diff --git a/Projectiles/Ranged/OntologicalDespoilerHoldout.cs b/Projectiles/Ranged/OntologicalDespoilerHoldout.cs index e360eb1986..438610e813 100644 --- a/Projectiles/Ranged/OntologicalDespoilerHoldout.cs +++ b/Projectiles/Ranged/OntologicalDespoilerHoldout.cs @@ -210,17 +210,20 @@ namespace CalamityMod.Projectiles.Ranged 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.SetScreenshake(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 +264,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.2f), 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 / 1.2f), 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 / 2.5f), Projectile.knockBack, Projectile.owner, 0, 0, 5); + } } } diff --git a/Projectiles/Ranged/ScorchedEarthHoldout.cs b/Projectiles/Ranged/ScorchedEarthHoldout.cs index f28b909feb..67fe2cbcfe 100644 --- a/Projectiles/Ranged/ScorchedEarthHoldout.cs +++ b/Projectiles/Ranged/ScorchedEarthHoldout.cs @@ -71,7 +71,8 @@ namespace CalamityMod.Projectiles.Ranged // Spawns the projectile. Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 12; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity.RotatedByRandom(MathHelper.ToRadians(10f)), ModContent.ProjectileType(), damage, knockback, Projectile.owner, rocketType); + 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. diff --git a/Projectiles/Ranged/ScorpioHoldout.cs b/Projectiles/Ranged/ScorpioHoldout.cs index ea27ca7445..fb49925b4d 100644 --- a/Projectiles/Ranged/ScorpioHoldout.cs +++ b/Projectiles/Ranged/ScorpioHoldout.cs @@ -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/StarfleetHoldout.cs b/Projectiles/Ranged/StarfleetHoldout.cs index a2304bf696..e8b51cbd0c 100644 --- a/Projectiles/Ranged/StarfleetHoldout.cs +++ b/Projectiles/Ranged/StarfleetHoldout.cs @@ -162,15 +162,19 @@ namespace CalamityMod.Projectiles.Ranged Owner.SetScreenshake(naildriver ? 9 : scattershot ? 7 : 4); OffsetLengthFromArm = naildriver ? 0 : scattershot ? 7 : 15; - int baseShotCount = 6; - for (int i = 0; i < baseShotCount; i++) + if (Main.myPlayer == Projectile.owner) { - 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; + 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); @@ -202,11 +206,14 @@ namespace CalamityMod.Projectiles.Ranged if (starburstCooldown < extendedCooldown) starburstCooldown = extendedCooldown; - float blastSize = 140; - float minMultiplier = 0.1f; - int hitsToMinMult = 6; - Projectile blast = Projectile.NewProjectileDirect(Owner.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 3), -45, Owner.whoAmI, blastSize, minMultiplier, hitsToMinMult); - blast.timeLeft = 15; + 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++) { diff --git a/Projectiles/Ranged/StarmadaHoldout.cs b/Projectiles/Ranged/StarmadaHoldout.cs index 87175f9859..7383465a48 100644 --- a/Projectiles/Ranged/StarmadaHoldout.cs +++ b/Projectiles/Ranged/StarmadaHoldout.cs @@ -246,14 +246,17 @@ namespace CalamityMod.Projectiles.Ranged float gunPowerMult = MathHelper.Lerp(gunPower, 1, 0.7f); - int baseShotCount = 7; - for (int i = 0; i < baseShotCount + gunPower; i++) + if (Main.myPlayer == Projectile.owner) { - 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, 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; + 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++) { @@ -293,13 +296,16 @@ namespace CalamityMod.Projectiles.Ranged starburstCooldown = extendedCooldown; setVel = true; - 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, ModContent.ProjectileType(), damage, -45, Owner.whoAmI, blastSize, minMultiplier, hitsToMinMult); - blast.timeLeft = 15; + 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++) diff --git a/Projectiles/Ranged/SuperradiantSlaughtererHoldout.cs b/Projectiles/Ranged/SuperradiantSlaughtererHoldout.cs index 45cc3e937c..763139711d 100644 --- a/Projectiles/Ranged/SuperradiantSlaughtererHoldout.cs +++ b/Projectiles/Ranged/SuperradiantSlaughtererHoldout.cs @@ -83,9 +83,12 @@ namespace CalamityMod.Projectiles.Ranged 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); + 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; @@ -128,7 +131,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/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/WildfireBloomHoldout.cs b/Projectiles/Ranged/WildfireBloomHoldout.cs index 981a28a453..02dfc11b39 100644 --- a/Projectiles/Ranged/WildfireBloomHoldout.cs +++ b/Projectiles/Ranged/WildfireBloomHoldout.cs @@ -41,10 +41,11 @@ namespace CalamityMod.Projectiles.Ranged { SoundEngine.PlaySound(SoundID.Item34, Projectile.Center); Owner.PickAmmo(Owner.HeldItem, out _, out float shootSpeed, out int damage, out float knockback, out _); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, (Projectile.velocity * 9).RotatedByRandom(0.08f), ModContent.ProjectileType(), damage, knockback, Projectile.owner); + 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; From a5bd57a7a0dacd7db571078e115459c01a2b044b Mon Sep 17 00:00:00 2001 From: Flowaria Date: Sat, 15 Nov 2025 15:31:14 +0900 Subject: [PATCH 31/65] Shroomble DrawOffsetY --- NPCs/NormalNPCs/Shroomble.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NPCs/NormalNPCs/Shroomble.cs b/NPCs/NormalNPCs/Shroomble.cs index 4e9f5de5f8..def5849bf4 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(); @@ -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) { From 10ea83faa60cf4b779ae102d04cd0f1b84385d8f Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Sat, 15 Nov 2025 13:06:10 -0500 Subject: [PATCH 32/65] 1 - Cal Clone hovers closer to the player 2 - Some very small nerfs to a couple weapons to offset this, and a large nerf to the Chlorophyte Crystal 3 - Massive nerfs to Abaddon and Void of Extinction --- Items/Accessories/Abaddon.cs | 2 +- Items/Accessories/VoidofExtinction.cs | 2 +- Items/CalamityGlobalItemTweaks.cs | 6 +++--- NPCs/CalClone/CalamitasClone.cs | 4 ++-- Projectiles/CalamityGlobalProjectile.cs | 4 ++++ 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Items/Accessories/Abaddon.cs b/Items/Accessories/Abaddon.cs index a0d0fe0025..cf3c780050 100644 --- a/Items/Accessories/Abaddon.cs +++ b/Items/Accessories/Abaddon.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Items.Accessories { public new string LocalizationCategory => "Items.Accessories"; - public static int AbaddonExploDamage = 90; + public static int AbaddonExploDamage = 25; public override void SetDefaults() { Item.width = 26; diff --git a/Items/Accessories/VoidofExtinction.cs b/Items/Accessories/VoidofExtinction.cs index a0bf58d13f..30403dc4de 100644 --- a/Items/Accessories/VoidofExtinction.cs +++ b/Items/Accessories/VoidofExtinction.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Items.Accessories public const int FireProjectiles = 2; public const float FireAngleSpread = 120; public int FireCountdown = 0; - public static int VoidExploDamage = 150; + public static int VoidExploDamage = 50; public override void SetDefaults() { diff --git a/Items/CalamityGlobalItemTweaks.cs b/Items/CalamityGlobalItemTweaks.cs index 8320f3c3fc..2526913ed4 100644 --- a/Items/CalamityGlobalItemTweaks.cs +++ b/Items/CalamityGlobalItemTweaks.cs @@ -74,7 +74,7 @@ namespace CalamityMod.Items { 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(UseMeleeSpeed, DamageExact(98)) }, + { ItemID.ChlorophytePartisan, Do(UseMeleeSpeed, DamageExact(95)) }, { ItemID.ChlorophyteSaber, Do(UseMeleeSpeed, DamageExact(92), UseExact(10)) }, { ItemID.ChristmasTreeSword, Do(UseTurn, UseMeleeSpeed, DamageExact(80), UseExact(30)) }, { ItemID.ClingerStaff, Do(DamageExact(63)) }, @@ -101,7 +101,7 @@ namespace CalamityMod.Items { 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.DeadlySphereStaff, Do(DamageExact(50)) }, - { ItemID.DeathSickle, Do(UseMeleeSpeed, DamageExact(70), ShootSpeedExact(15f)) }, + { 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 @@ -129,7 +129,7 @@ namespace CalamityMod.Items { ItemID.GreenPhaseblade, phaseblade }, { ItemID.GreenPhasesaber, phasesaber }, { ItemID.GrenadeLauncher, Do(DamageExact(105)) }, - { ItemID.Gungnir, Do(TrueMelee, DamageExact(132), ShootSpeedExact(7f)) }, + { ItemID.Gungnir, Do(TrueMelee, DamageExact(130), ShootSpeedExact(7f)) }, { ItemID.HallowedRepeater, Do(UseExact(12)) }, { ItemID.Handgun, Do(UseExact(20)) }, { ItemID.HighVelocityBullet, Do(DamageExact(13)) }, diff --git a/NPCs/CalClone/CalamitasClone.cs b/NPCs/CalClone/CalamitasClone.cs index e588ba9e12..c7d6141f08 100644 --- a/NPCs/CalClone/CalamitasClone.cs +++ b/NPCs/CalClone/CalamitasClone.cs @@ -307,7 +307,7 @@ namespace CalamityMod.NPCs.CalClone bool inBulletHell = calamityGlobalNPC.newAI[2] > 0f; - //arena on death mode + //arena in rev+ if (revenge) { if (ArenaBox is null) @@ -486,7 +486,7 @@ namespace CalamityMod.NPCs.CalClone xPos = -1; // How far Cal Clone should be from the target - float averageDistance = 500f; + float averageDistance = 400f; float chargeDistance = phase4 ? 300f : 400f; // This is where Cal Clone should be diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 889546cb83..e9e6b69a59 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -334,6 +334,10 @@ namespace CalamityMod.Projectiles // 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) From fc5c951430057c24c1827282261bbeee9352550b Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Sat, 15 Nov 2025 14:53:12 -0500 Subject: [PATCH 33/65] Further nerfed Void of Extinction --- Items/Accessories/VoidofExtinction.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Items/Accessories/VoidofExtinction.cs b/Items/Accessories/VoidofExtinction.cs index 30403dc4de..33898f8cf4 100644 --- a/Items/Accessories/VoidofExtinction.cs +++ b/Items/Accessories/VoidofExtinction.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Items.Accessories public const int FireProjectiles = 2; public const float FireAngleSpread = 120; public int FireCountdown = 0; - public static int VoidExploDamage = 50; + public static int VoidExploDamage = 40; public override void SetDefaults() { From b33a70fd086f0df4bcbc9dee6f68d6bfe6e13cf9 Mon Sep 17 00:00:00 2001 From: fryzahh Date: Sat, 15 Nov 2025 16:41:52 -0400 Subject: [PATCH 34/65] GeneralDrawLayer generalization + TempParticle start * Split up GeneralDrawLayer.BeforeTiles into BeforeAllTiles and BeforeSolidTiles. * Moved screen renderers, metaballs and pixelated primitive drawing to use GeneralDrawLayer and subsequentially removed their own draw layer enums. * Moved screen renderers, metaballs, particles, pixelated primitive drawing and pixelated drawers draw calls to MechanicalILChanges. * Added TempParticle and TempParticleManager, used for defining temporary particle handlers in any file for short-term, fully-modifiable particle effects * Removed ParticleAutoDrawingOverride and added a "CustomShader" property and "PrepareCustomShader" method to Particle.cs. These should be used in conjunction when wanting to apply shader effects to particles. If anything more precise is needed, use the new TempParticleManager class. --- Enums/GeneralDrawLayer.cs | 25 +-- Graphics/Metaballs/BigRipMetaball.cs | 3 +- Graphics/Metaballs/BloodBoilerMetaball.cs | 3 +- Graphics/Metaballs/BloodBoilerMetaball2.cs | 3 +- Graphics/Metaballs/BloodMetaball.cs | 3 +- Graphics/Metaballs/CalamitasMetaball.cs | 4 +- Graphics/Metaballs/CataclysmMetaball.cs | 4 +- Graphics/Metaballs/CatastropheMetaball.cs | 4 +- Graphics/Metaballs/DoGDistortionMetaball.cs | 3 +- Graphics/Metaballs/DragonsBreathMetaball.cs | 3 +- Graphics/Metaballs/DragonsBreathMetaball2.cs | 3 +- Graphics/Metaballs/GalaxyMetaball.cs | 3 +- Graphics/Metaballs/GruesomeMetaball.cs | 3 +- Graphics/Metaballs/Metaball.cs | 3 +- Graphics/Metaballs/MetaballDrawLayer.cs | 9 -- Graphics/Metaballs/MetaballManager.cs | 44 +---- Graphics/Metaballs/PaintMetaballs.cs | 3 +- Graphics/Metaballs/PhotoMetaball.cs | 4 +- Graphics/Metaballs/PhotoMetaball2.cs | 4 +- Graphics/Metaballs/PhotoMetaball3.cs | 4 +- Graphics/Metaballs/PhotoMetaball4.cs | 4 +- Graphics/Metaballs/RancorLavaMetaball.cs | 3 +- Graphics/Metaballs/ScalArenaMetaball.cs | 9 +- Graphics/Metaballs/SeekersMetaball.cs | 4 +- Graphics/Metaballs/SignusMetaball.cs | 4 +- Graphics/Metaballs/StarsmokeMetaball.cs | 5 +- Graphics/Metaballs/StreamGougeMetaball.cs | 4 +- Graphics/Metaballs/VoidGeneratorMetaball.cs | 3 +- .../Primitives/IPixelatedPrimitiveRenderer.cs | 7 +- .../Primitives/PixelationPrimitiveLayer.cs | 17 -- .../Primitives/PrimitivePixelationSystem.cs | 143 ++++++++++------ Graphics/Primitives/PrimitiveRenderer.cs | 2 +- Graphics/Renderers/BaseRenderer.cs | 3 +- .../DeerclopsShadowRenderer.cs | 5 +- .../DoGDeathAnimationRenderer.cs | 5 +- .../DyeableShadersRenderer.cs | 3 +- .../CalamityRenderers/HolyInfernoRenderer.cs | 5 +- .../MiracleBlightRenderer.cs | 3 +- Graphics/Renderers/RendererManager.cs | 115 ++----------- ILEditing/ILChangesLoading.cs | 9 ++ ILEditing/MechanicILChanges.cs | 80 +++++++++ Particles/GeneralParticleHandler.cs | 152 +++++------------- Particles/Particle.cs | 25 +-- Particles/ParticleAutoDrawingOverride.cs | 57 ------- Projectiles/Boss/DoGFire.cs | 4 +- Projectiles/Magic/SHPB.cs | 5 +- Projectiles/Magic/SHPL.cs | 5 +- Projectiles/Magic/SHPS.cs | 3 +- Projectiles/Magic/SylvestaffHoldout.cs | 7 +- .../Melee/Galaxia_PhoenixsPrideFirewall.cs | 3 +- Projectiles/Summon/LiliesOfEternityBullet.cs | 5 +- Projectiles/Summon/LiliesOfFinalityBullet.cs | 5 +- .../PixelationSystem/PixelationManager.cs | 113 ++++++------- .../TempParticleSystem/TempParticle.cs | 67 ++++++++ .../TempParticleSystem/TempParticleManager.cs | 152 ++++++++++++++++++ 55 files changed, 636 insertions(+), 535 deletions(-) delete mode 100644 Graphics/Metaballs/MetaballDrawLayer.cs delete mode 100644 Graphics/Primitives/PixelationPrimitiveLayer.cs delete mode 100644 Particles/ParticleAutoDrawingOverride.cs create mode 100644 Systems/Graphic/TempParticleSystem/TempParticle.cs create mode 100644 Systems/Graphic/TempParticleSystem/TempParticleManager.cs diff --git a/Enums/GeneralDrawLayer.cs b/Enums/GeneralDrawLayer.cs index 23aa7c20d0..319e734f49 100644 --- a/Enums/GeneralDrawLayer.cs +++ b/Enums/GeneralDrawLayer.cs @@ -1,20 +1,21 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; 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 { - BeforeTiles, - BeforeNPCs, - AfterNPCs, - BeforeProjectiles, - AfterProjectiles, - AfterPlayers, - AfterDusts, - AfterEverything, + BeforeAllTiles = 0, + BeforeSolidTiles = 1, + BeforeNPCs = 2, + AfterNPCs = 4, + BeforeProjectiles = 8, + AfterProjectiles = 16, + AfterPlayers = 32, + AfterDusts = 64, + AfterEverything = 128, } } diff --git a/Graphics/Metaballs/BigRipMetaball.cs b/Graphics/Metaballs/BigRipMetaball.cs index c78acfa9c5..faee855da9 100644 --- a/Graphics/Metaballs/BigRipMetaball.cs +++ b/Graphics/Metaballs/BigRipMetaball.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 ReLogic.Content; @@ -77,7 +78,7 @@ namespace CalamityMod.Graphics.Metaballs // Load the layer asset wrapper. LayerAsset = ModContent.Request($"CalamityMod/Graphics/Metaballs/BigRipLayer", AssetRequestMode.ImmediateLoad); } - public override MetaballDrawLayer DrawContext => MetaballDrawLayer.BeforeProjectiles; + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.BeforeProjectiles; public override Color EdgeColor => new Color(239, 111, 85) * 0.5f; diff --git a/Graphics/Metaballs/BloodBoilerMetaball.cs b/Graphics/Metaballs/BloodBoilerMetaball.cs index 86bf43c440..e3ea116062 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 }; diff --git a/Graphics/Metaballs/BloodBoilerMetaball2.cs b/Graphics/Metaballs/BloodBoilerMetaball2.cs index a6034d5219..6f3829158d 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 }; diff --git a/Graphics/Metaballs/BloodMetaball.cs b/Graphics/Metaballs/BloodMetaball.cs index 28457126f8..952950e6ce 100644 --- a/Graphics/Metaballs/BloodMetaball.cs +++ b/Graphics/Metaballs/BloodMetaball.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 ReLogic.Content; @@ -79,7 +80,7 @@ namespace CalamityMod.Graphics.Metaballs // Load the layer asset wrapper. LayerAsset = ModContent.Request($"CalamityMod/Graphics/Metaballs/BloodLayer", AssetRequestMode.ImmediateLoad); } - public override MetaballDrawLayer DrawContext => MetaballDrawLayer.BeforeProjectiles; + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.BeforeProjectiles; public override Color EdgeColor => new Color(67, 17, 17); diff --git a/Graphics/Metaballs/CalamitasMetaball.cs b/Graphics/Metaballs/CalamitasMetaball.cs index 86bcd3fa23..52e9eeb066 100644 --- a/Graphics/Metaballs/CalamitasMetaball.cs +++ b/Graphics/Metaballs/CalamitasMetaball.cs @@ -1,11 +1,11 @@ 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; -using static CalamityMod.Graphics.Metaballs.StreamGougeMetaball; namespace CalamityMod.Graphics.Metaballs { @@ -71,7 +71,7 @@ namespace CalamityMod.Graphics.Metaballs // Load the layer asset wrapper. LayerAsset = ModContent.Request($"CalamityMod/Graphics/Metaballs/CalamitasLayer", AssetRequestMode.ImmediateLoad); } - public override MetaballDrawLayer DrawContext => MetaballDrawLayer.BeforeProjectiles; + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.BeforeProjectiles; public override Color EdgeColor => Color.Lerp(Color.Crimson, Color.Black, 0f); diff --git a/Graphics/Metaballs/CataclysmMetaball.cs b/Graphics/Metaballs/CataclysmMetaball.cs index 62131a6df4..59221f3d51 100644 --- a/Graphics/Metaballs/CataclysmMetaball.cs +++ b/Graphics/Metaballs/CataclysmMetaball.cs @@ -1,11 +1,11 @@ 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; -using static CalamityMod.Graphics.Metaballs.StreamGougeMetaball; namespace CalamityMod.Graphics.Metaballs { @@ -71,7 +71,7 @@ namespace CalamityMod.Graphics.Metaballs // Load the layer asset wrapper. LayerAsset = ModContent.Request($"CalamityMod/Graphics/Metaballs/CataclysmLayer", AssetRequestMode.ImmediateLoad); } - public override MetaballDrawLayer DrawContext => MetaballDrawLayer.BeforeProjectiles; + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.BeforeProjectiles; public override Color EdgeColor => new Color(255,0,229); diff --git a/Graphics/Metaballs/CatastropheMetaball.cs b/Graphics/Metaballs/CatastropheMetaball.cs index 24f54493a0..399af76ad4 100644 --- a/Graphics/Metaballs/CatastropheMetaball.cs +++ b/Graphics/Metaballs/CatastropheMetaball.cs @@ -1,11 +1,11 @@ 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; -using static CalamityMod.Graphics.Metaballs.StreamGougeMetaball; namespace CalamityMod.Graphics.Metaballs { @@ -73,7 +73,7 @@ namespace CalamityMod.Graphics.Metaballs // Load the layer asset wrapper. LayerAsset = ModContent.Request($"CalamityMod/Graphics/Metaballs/CatastropheLayer", AssetRequestMode.ImmediateLoad); } - public override MetaballDrawLayer DrawContext => MetaballDrawLayer.BeforeProjectiles; + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.BeforeProjectiles; public override Color EdgeColor => new Color(0,255,255); diff --git a/Graphics/Metaballs/DoGDistortionMetaball.cs b/Graphics/Metaballs/DoGDistortionMetaball.cs index 173b2430ea..c2c8992591 100644 --- a/Graphics/Metaballs/DoGDistortionMetaball.cs +++ b/Graphics/Metaballs/DoGDistortionMetaball.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using CalamityMod.Effects; +using CalamityMod.Enums; using CalamityMod.Projectiles.Boss; using CalamityMod.Systems.Graphic; using Microsoft.Xna.Framework; @@ -33,7 +34,7 @@ namespace CalamityMod.Graphics.Metaballs public static List Particles { get; private set; } = []; - public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.AfterProjectiles; public override bool AnythingToDraw => Particles.Count > 0 || CalamityUtils.AnyProjectiles(ModContent.ProjectileType()); diff --git a/Graphics/Metaballs/DragonsBreathMetaball.cs b/Graphics/Metaballs/DragonsBreathMetaball.cs index e041506bb2..0f39f10fe5 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() { diff --git a/Graphics/Metaballs/DragonsBreathMetaball2.cs b/Graphics/Metaballs/DragonsBreathMetaball2.cs index c07f13e894..1af9bd38ca 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() { diff --git a/Graphics/Metaballs/GalaxyMetaball.cs b/Graphics/Metaballs/GalaxyMetaball.cs index 4d93ed1020..feec8791a1 100644 --- a/Graphics/Metaballs/GalaxyMetaball.cs +++ b/Graphics/Metaballs/GalaxyMetaball.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 ReLogic.Content; @@ -56,7 +57,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..348099bcd6 100644 --- a/Graphics/Metaballs/GruesomeMetaball.cs +++ b/Graphics/Metaballs/GruesomeMetaball.cs @@ -1,6 +1,7 @@ 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; @@ -56,7 +57,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 adff926565..f4d6f366bf 100644 --- a/Graphics/Metaballs/Metaball.cs +++ b/Graphics/Metaballs/Metaball.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; @@ -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; } 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 2e7721341b..123e007766 100644 --- a/Graphics/Metaballs/MetaballManager.cs +++ b/Graphics/Metaballs/MetaballManager.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; @@ -15,8 +16,6 @@ namespace CalamityMod.Graphics.Metaballs { // Prepare event subscribers. RenderTargetManager.RenderTargetUpdateLoopEvent += PrepareMetaballTargets; - On_Main.DrawProjectiles += DrawMetaballsAfterProjectiles; - On_Main.DrawNPCs += DrawMetaballsBeforeNPCs; } public override void OnModUnload() @@ -86,51 +85,20 @@ namespace CalamityMod.Graphics.Metaballs 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) + internal static void DrawMetaballs(GeneralDrawLayer layerType) { - foreach (Metaball metaball in metaballs.Where(m => m.DrawContext == layerType && m.AnythingToDraw)) + foreach (Metaball metaball in metaballs.Where(m => m.DrawLayer == layerType && m.AnythingToDraw)) { for (int i = 0; i < metaball.LayerTargets.Count; i++) { diff --git a/Graphics/Metaballs/PaintMetaballs.cs b/Graphics/Metaballs/PaintMetaballs.cs index 0501af90ff..8242812c96 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 { diff --git a/Graphics/Metaballs/PhotoMetaball.cs b/Graphics/Metaballs/PhotoMetaball.cs index 6d3447dd90..e8d6a3bdca 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; diff --git a/Graphics/Metaballs/PhotoMetaball2.cs b/Graphics/Metaballs/PhotoMetaball2.cs index f1cdc7737f..0178d70457 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; diff --git a/Graphics/Metaballs/PhotoMetaball3.cs b/Graphics/Metaballs/PhotoMetaball3.cs index cfb21ea60d..71c5d56f7a 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; diff --git a/Graphics/Metaballs/PhotoMetaball4.cs b/Graphics/Metaballs/PhotoMetaball4.cs index 2df1a25d8b..ad720df0c6 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; diff --git a/Graphics/Metaballs/RancorLavaMetaball.cs b/Graphics/Metaballs/RancorLavaMetaball.cs index ef0d3c6124..33047c5d9e 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 { diff --git a/Graphics/Metaballs/ScalArenaMetaball.cs b/Graphics/Metaballs/ScalArenaMetaball.cs index a57d474009..c7a1039e74 100644 --- a/Graphics/Metaballs/ScalArenaMetaball.cs +++ b/Graphics/Metaballs/ScalArenaMetaball.cs @@ -1,18 +1,13 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; -using CalamityMod.NPCs; +using CalamityMod.Enums; using CalamityMod.NPCs.SupremeCalamitas; -using CalamityMod.Systems.Mechanic; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.ModLoader; -using static CalamityMod.Graphics.Metaballs.StreamGougeMetaball; -using static CalamityMod.Systems.LavaRenderingSystem; namespace CalamityMod.Graphics.Metaballs { @@ -82,7 +77,7 @@ namespace CalamityMod.Graphics.Metaballs WavyLineLayer = ModContent.Request($"CalamityMod/Graphics/Metaballs/ScalArenaLayerWave", AssetRequestMode.ImmediateLoad).Value; } - public override MetaballDrawLayer DrawContext => MetaballDrawLayer.BeforeNPCs; + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.BeforeNPCs; public override Color EdgeColor => SupremeCalamitas.CurrentColor; diff --git a/Graphics/Metaballs/SeekersMetaball.cs b/Graphics/Metaballs/SeekersMetaball.cs index d389e569e5..a0658bb66d 100644 --- a/Graphics/Metaballs/SeekersMetaball.cs +++ b/Graphics/Metaballs/SeekersMetaball.cs @@ -1,11 +1,11 @@ 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; -using static CalamityMod.Graphics.Metaballs.StreamGougeMetaball; namespace CalamityMod.Graphics.Metaballs { @@ -73,7 +73,7 @@ namespace CalamityMod.Graphics.Metaballs // Load the layer asset wrapper. LayerAsset = ModContent.Request($"CalamityMod/Graphics/Metaballs/SeekersLayer", AssetRequestMode.ImmediateLoad); } - public override MetaballDrawLayer DrawContext => MetaballDrawLayer.BeforeProjectiles; + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.BeforeProjectiles; public override Color EdgeColor => new Color(255,106,0); diff --git a/Graphics/Metaballs/SignusMetaball.cs b/Graphics/Metaballs/SignusMetaball.cs index 7c90c5fda0..c0179a8ebc 100644 --- a/Graphics/Metaballs/SignusMetaball.cs +++ b/Graphics/Metaballs/SignusMetaball.cs @@ -1,11 +1,11 @@ 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.ID; using Terraria.ModLoader; namespace CalamityMod.Graphics.Metaballs @@ -77,7 +77,7 @@ namespace CalamityMod.Graphics.Metaballs } } - public override MetaballDrawLayer DrawContext => MetaballDrawLayer.BeforeNPCs; + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.BeforeNPCs; public override void Load() { if (Main.dedServ) diff --git a/Graphics/Metaballs/StarsmokeMetaball.cs b/Graphics/Metaballs/StarsmokeMetaball.cs index e5f2565257..3bdfa5e22d 100644 --- a/Graphics/Metaballs/StarsmokeMetaball.cs +++ b/Graphics/Metaballs/StarsmokeMetaball.cs @@ -1,12 +1,11 @@ using System; using System.Collections.Generic; using System.Linq; -using CalamityMod.Particles; +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 @@ -80,7 +79,7 @@ namespace CalamityMod.Graphics.Metaballs } } - public override MetaballDrawLayer DrawContext => MetaballDrawLayer.BeforeNPCs; + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.BeforeNPCs; public override void Load() { if (Main.dedServ) 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 14edbcb506..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, PixelationPrimitiveLayer layer); + void RenderPixelatedPrimitives(SpriteBatch spriteBatch, GeneralDrawLayer layer); } } diff --git a/Graphics/Primitives/PixelationPrimitiveLayer.cs b/Graphics/Primitives/PixelationPrimitiveLayer.cs deleted file mode 100644 index 4f05c51ef2..0000000000 --- a/Graphics/Primitives/PixelationPrimitiveLayer.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; - -namespace CalamityMod.Graphics.Primitives -{ - /// - /// Controls what layer the renders to. - /// - [Flags] - public enum PixelationPrimitiveLayer - { - BeforeNPCs = 1, - AfterNPCs = 2, - BeforeProjectiles = 4, - AfterProjectiles = 8, - AfterPlayers = 16 - } -} diff --git a/Graphics/Primitives/PrimitivePixelationSystem.cs b/Graphics/Primitives/PrimitivePixelationSystem.cs index 4d2bc635de..36a0e186b8 100644 --- a/Graphics/Primitives/PrimitivePixelationSystem.cs +++ b/Graphics/Primitives/PrimitivePixelationSystem.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; @@ -10,6 +11,10 @@ namespace CalamityMod.Graphics.Primitives public class PrimitivePixelationSystem : ModSystem { #region Fields/Properties + private static ManagedRenderTarget PixelationTarget_BeforeAllTiles; + + private static ManagedRenderTarget PixelationTarget_BeforeSolidTiles; + private static ManagedRenderTarget PixelationTarget_BeforeNPCs; private static ManagedRenderTarget PixelationTarget_AfterNPCs; @@ -20,6 +25,10 @@ namespace CalamityMod.Graphics.Primitives private static ManagedRenderTarget PixelationTarget_AfterPlayers; + private static ManagedRenderTarget PixelationTarget_AfterDusts; + + private static ManagedRenderTarget PixelationTarget_AfterEverything; + private static RenderTarget2D CreatePixelTarget(int width, int height) => new(Main.instance.GraphicsDevice, width / 2, height / 2); /// @@ -35,22 +44,38 @@ 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; - On_Main.DrawPlayers_AfterProjectiles += DrawTarget_Players; + if (Main.dedServ) + return; - PixelationTarget_BeforeNPCs = new(true, CreatePixelTarget); - PixelationTarget_AfterNPCs = new(true, CreatePixelTarget); - PixelationTarget_BeforeProjectiles = new(true, CreatePixelTarget); - PixelationTarget_AfterProjectiles = new(true, CreatePixelTarget); - PixelationTarget_AfterPlayers = new(true, CreatePixelTarget); + Main.QueueMainThreadAction(() => + { + PixelationTarget_BeforeAllTiles = new(true, CreatePixelTarget); + PixelationTarget_BeforeSolidTiles = new(true, CreatePixelTarget); + PixelationTarget_BeforeNPCs = new(true, CreatePixelTarget); + PixelationTarget_AfterNPCs = new(true, CreatePixelTarget); + PixelationTarget_BeforeProjectiles = new(true, CreatePixelTarget); + PixelationTarget_AfterProjectiles = new(true, CreatePixelTarget); + PixelationTarget_AfterPlayers = new(true, CreatePixelTarget); + PixelationTarget_AfterDusts = new(true, CreatePixelTarget); + PixelationTarget_AfterEverything = new(true, CreatePixelTarget); + }); + + On_Main.CheckMonoliths += 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() { + if (Main.dedServ) + return; + On_Main.CheckMonoliths -= DrawToTargets; - On_Main.DoDraw_DrawNPCsOverTiles -= DrawTarget_NPCs; } #endregion @@ -63,11 +88,15 @@ namespace CalamityMod.Graphics.Primitives 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) @@ -75,14 +104,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) { - if (pixelPrimitiveProjectile.LayerToRenderTo.HasFlag(PixelationPrimitiveLayer.BeforeNPCs)) + 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(PixelationPrimitiveLayer.AfterNPCs)) + if (pixelPrimitiveProjectile.LayerToRenderTo.HasFlag(GeneralDrawLayer.AfterNPCs)) afterNPCs.Add(pixelPrimitiveProjectile); - if (pixelPrimitiveProjectile.LayerToRenderTo.HasFlag(PixelationPrimitiveLayer.BeforeProjectiles)) + if (pixelPrimitiveProjectile.LayerToRenderTo.HasFlag(GeneralDrawLayer.BeforeProjectiles)) beforeProjectiles.Add(pixelPrimitiveProjectile); - if (pixelPrimitiveProjectile.LayerToRenderTo.HasFlag(PixelationPrimitiveLayer.AfterPlayers)) + 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); } } @@ -92,24 +131,38 @@ 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) { - if (pixelPrimitiveNPC.LayerToRenderTo.HasFlag(PixelationPrimitiveLayer.BeforeNPCs)) + 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(PixelationPrimitiveLayer.AfterNPCs)) + if (pixelPrimitiveNPC.LayerToRenderTo.HasFlag(GeneralDrawLayer.AfterNPCs)) afterNPCs.Add(pixelPrimitiveNPC); - if (pixelPrimitiveNPC.LayerToRenderTo.HasFlag(PixelationPrimitiveLayer.BeforeProjectiles)) + if (pixelPrimitiveNPC.LayerToRenderTo.HasFlag(GeneralDrawLayer.BeforeProjectiles)) beforeProjectiles.Add(pixelPrimitiveNPC); - if (pixelPrimitiveNPC.LayerToRenderTo.HasFlag(PixelationPrimitiveLayer.AfterPlayers)) + 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, PixelationPrimitiveLayer.BeforeNPCs, beforeNPCs); - DrawPrimsToRenderTarget(PixelationTarget_AfterNPCs, PixelationPrimitiveLayer.AfterNPCs, afterNPCs); - DrawPrimsToRenderTarget(PixelationTarget_BeforeProjectiles, PixelationPrimitiveLayer.BeforeProjectiles, beforeProjectiles); - DrawPrimsToRenderTarget(PixelationTarget_AfterProjectiles, PixelationPrimitiveLayer.AfterProjectiles, afterProjectiles); - DrawPrimsToRenderTarget(PixelationTarget_AfterPlayers, PixelationPrimitiveLayer.AfterPlayers, afterPlayers); + DrawPrimsToRenderTarget(PixelationTarget_BeforeAllTiles, GeneralDrawLayer.BeforeAllTiles, beforeAllTiles); + DrawPrimsToRenderTarget(PixelationTarget_BeforeSolidTiles, GeneralDrawLayer.BeforeSolidTiles, beforeSolidTiles); + DrawPrimsToRenderTarget(PixelationTarget_BeforeNPCs, GeneralDrawLayer.BeforeNPCs, beforeNPCs); + DrawPrimsToRenderTarget(PixelationTarget_AfterNPCs, GeneralDrawLayer.AfterNPCs, afterNPCs); + DrawPrimsToRenderTarget(PixelationTarget_BeforeProjectiles, GeneralDrawLayer.BeforeProjectiles, beforeProjectiles); + DrawPrimsToRenderTarget(PixelationTarget_AfterProjectiles, GeneralDrawLayer.AfterProjectiles, afterProjectiles); + DrawPrimsToRenderTarget(PixelationTarget_AfterPlayers, GeneralDrawLayer.AfterPlayers, afterPlayers); + DrawPrimsToRenderTarget(PixelationTarget_AfterDusts, GeneralDrawLayer.AfterDusts, afterDusts); + DrawPrimsToRenderTarget(PixelationTarget_AfterEverything, GeneralDrawLayer.AfterEverything, afterEverything); Main.instance.GraphicsDevice.SetRenderTarget(null); @@ -117,7 +170,7 @@ namespace CalamityMod.Graphics.Primitives orig(); } - private static void DrawPrimsToRenderTarget(RenderTarget2D renderTarget, PixelationPrimitiveLayer layer, 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(); @@ -135,31 +188,31 @@ namespace CalamityMod.Graphics.Primitives #endregion #region Target Drawing - private void DrawTarget_NPCs(On_Main.orig_DoDraw_DrawNPCsOverTiles orig, Main self) + internal static void DrawTargetScaled(GeneralDrawLayer drawLayer, bool startSpritebatch = true) { - DrawTargetScaled(PixelationTarget_BeforeNPCs); - orig(self); - DrawTargetScaled(PixelationTarget_AfterNPCs); + if (startSpritebatch) + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + + Main.spriteBatch.Draw(ReturnAssociatedRenderTarget(drawLayer), Vector2.Zero, null, Color.White, 0f, Vector2.Zero, 2f, SpriteEffects.None, 0f); + + if (startSpritebatch) + Main.spriteBatch.End(); } - private void DrawTarget_Projectiles(On_Main.orig_DrawProjectiles orig, Main self) + private static RenderTarget2D ReturnAssociatedRenderTarget(GeneralDrawLayer drawLayer) { - DrawTargetScaled(PixelationTarget_BeforeProjectiles); - orig(self); - DrawTargetScaled(PixelationTarget_AfterProjectiles); - } - - private void DrawTarget_Players(On_Main.orig_DrawPlayers_AfterProjectiles orig, Main self) - { - orig(self); - DrawTargetScaled(PixelationTarget_AfterPlayers); - } - - private static void DrawTargetScaled(ManagedRenderTarget target) - { - 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.End(); + return drawLayer switch + { + GeneralDrawLayer.BeforeAllTiles => PixelationTarget_BeforeAllTiles, + GeneralDrawLayer.BeforeSolidTiles => PixelationTarget_BeforeSolidTiles, + GeneralDrawLayer.BeforeNPCs => PixelationTarget_BeforeNPCs, + GeneralDrawLayer.AfterNPCs => PixelationTarget_AfterNPCs, + GeneralDrawLayer.BeforeProjectiles => PixelationTarget_BeforeProjectiles, + GeneralDrawLayer.AfterProjectiles => PixelationTarget_AfterProjectiles, + GeneralDrawLayer.AfterPlayers => PixelationTarget_AfterPlayers, + GeneralDrawLayer.AfterDusts => PixelationTarget_AfterDusts, + _ => PixelationTarget_AfterEverything + }; } #endregion } diff --git a/Graphics/Primitives/PrimitiveRenderer.cs b/Graphics/Primitives/PrimitiveRenderer.cs index 2fcc1b9acf..84e3d9ca65 100644 --- a/Graphics/Primitives/PrimitiveRenderer.cs +++ b/Graphics/Primitives/PrimitiveRenderer.cs @@ -18,7 +18,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 diff --git a/Graphics/Renderers/BaseRenderer.cs b/Graphics/Renderers/BaseRenderer.cs index 8cdfa0ae6d..cb1e3dc5a8 100644 --- a/Graphics/Renderers/BaseRenderer.cs +++ b/Graphics/Renderers/BaseRenderer.cs @@ -1,4 +1,5 @@ using System; +using CalamityMod.Enums; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria.ModLoader; @@ -14,7 +15,7 @@ namespace CalamityMod.Graphics.Renderers /// /// The layer that the target should be drawn at. /// - public abstract DrawLayer Layer { get; } + public abstract GeneralDrawLayer Layer { get; } /// /// Whether the target should draw and be drawn to this frame. diff --git a/Graphics/Renderers/CalamityRenderers/DeerclopsShadowRenderer.cs b/Graphics/Renderers/CalamityRenderers/DeerclopsShadowRenderer.cs index ac4203ca1b..8c2f927e08 100644 --- a/Graphics/Renderers/CalamityRenderers/DeerclopsShadowRenderer.cs +++ b/Graphics/Renderers/CalamityRenderers/DeerclopsShadowRenderer.cs @@ -1,4 +1,5 @@ -using CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses; +using CalamityMod.Enums; +using CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -11,7 +12,7 @@ namespace CalamityMod.Graphics.Renderers.CalamityRenderers { #region Fields/Properties - public override DrawLayer Layer => DrawLayer.AfterEverything; + public override GeneralDrawLayer Layer => GeneralDrawLayer.AfterEverything; public static NPC Deerclops => Main.npc[NPC.deerclopsBoss]; diff --git a/Graphics/Renderers/CalamityRenderers/DoGDeathAnimationRenderer.cs b/Graphics/Renderers/CalamityRenderers/DoGDeathAnimationRenderer.cs index a00c083af6..fab7fc3d6f 100644 --- a/Graphics/Renderers/CalamityRenderers/DoGDeathAnimationRenderer.cs +++ b/Graphics/Renderers/CalamityRenderers/DoGDeathAnimationRenderer.cs @@ -1,4 +1,5 @@ -using CalamityMod.NPCs; +using CalamityMod.Enums; +using CalamityMod.NPCs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -18,7 +19,7 @@ namespace CalamityMod.Graphics.Renderers.CalamityRenderers private set; } - public override DrawLayer Layer => DrawLayer.NPC; + public override GeneralDrawLayer Layer => GeneralDrawLayer.AfterNPCs; public override bool ShouldDraw => !Main.gameMenu && CalamityDrawParameterNPC.DoGDeathAnimationTimer > 0; diff --git a/Graphics/Renderers/CalamityRenderers/DyeableShadersRenderer.cs b/Graphics/Renderers/CalamityRenderers/DyeableShadersRenderer.cs index 3b4b977c61..1e4c5f474e 100644 --- a/Graphics/Renderers/CalamityRenderers/DyeableShadersRenderer.cs +++ b/Graphics/Renderers/CalamityRenderers/DyeableShadersRenderer.cs @@ -3,6 +3,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using CalamityMod.DataStructures; +using CalamityMod.Enums; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -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; diff --git a/Graphics/Renderers/CalamityRenderers/HolyInfernoRenderer.cs b/Graphics/Renderers/CalamityRenderers/HolyInfernoRenderer.cs index 409ff05a3e..6599c20f89 100644 --- a/Graphics/Renderers/CalamityRenderers/HolyInfernoRenderer.cs +++ b/Graphics/Renderers/CalamityRenderers/HolyInfernoRenderer.cs @@ -1,4 +1,5 @@ -using CalamityMod.NPCs; +using CalamityMod.Enums; +using CalamityMod.NPCs; using CalamityMod.NPCs.Providence; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -13,7 +14,7 @@ namespace CalamityMod.Graphics.Renderers.CalamityRenderers { #region Fields/Properties - public override DrawLayer Layer => DrawLayer.BeforeTiles; + public override GeneralDrawLayer Layer => GeneralDrawLayer.BeforeAllTiles; public static Providence Provi { diff --git a/Graphics/Renderers/CalamityRenderers/MiracleBlightRenderer.cs b/Graphics/Renderers/CalamityRenderers/MiracleBlightRenderer.cs index 98871deb15..95ef112087 100644 --- a/Graphics/Renderers/CalamityRenderers/MiracleBlightRenderer.cs +++ b/Graphics/Renderers/CalamityRenderers/MiracleBlightRenderer.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using CalamityMod.Enums; using CalamityMod.NPCs; using CalamityMod.NPCs.ExoMechs.Ares; using Microsoft.Xna.Framework; @@ -42,7 +43,7 @@ namespace CalamityMod.Graphics.Renderers.CalamityRenderers private set; } - public override DrawLayer Layer => DrawLayer.NPC; + public override GeneralDrawLayer Layer => GeneralDrawLayer.AfterNPCs; // Unsure whether its more performant to always draw, or to check if any NPC actually has the debuff. public override bool ShouldDraw => true; diff --git a/Graphics/Renderers/RendererManager.cs b/Graphics/Renderers/RendererManager.cs index a4b0132ce1..338feab7b0 100644 --- a/Graphics/Renderers/RendererManager.cs +++ b/Graphics/Renderers/RendererManager.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; @@ -24,16 +25,8 @@ 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. + Main.QueueMainThreadAction(() => On_Main.CheckMonoliths += DrawToTargets); } public override void Unload() @@ -43,24 +36,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 +51,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,6 +60,17 @@ namespace CalamityMod.Graphics.Renderers #endregion #region Drawing + internal static void DrawRendererAtLayer(GeneralDrawLayer drawLayer) + { + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise); + + var renderers = Renderers.Where(renderer => renderer.ShouldDraw && renderer.Layer == drawLayer); + foreach (var renderer in renderers) + renderer.DrawTarget(Main.spriteBatch); + + Main.spriteBatch.End(); + } + private void DrawToTargets(On_Main.orig_CheckMonoliths orig) { orig(); @@ -106,82 +99,6 @@ namespace CalamityMod.Graphics.Renderers 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/ILChangesLoading.cs b/ILEditing/ILChangesLoading.cs index 33d7ff2632..3ae73efc26 100644 --- a/ILEditing/ILChangesLoading.cs +++ b/ILEditing/ILChangesLoading.cs @@ -57,6 +57,15 @@ namespace CalamityMod.ILEditing IL_TileDrawing.DrawTrees += DrawTreeGlowMask; On_TileDrawing.DrawBasicTile += DrawTreeTrunkAndCactusGlowMask; + // Graphics (GeneralDrawLayer detours) + 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; + // NPC behavior IL_Main.UpdateTime += PermitNighttimeTownNPCSpawning; On_Main.UpdateTime_SpawnTownNPCs += AlterTownNPCSpawnRate; diff --git a/ILEditing/MechanicILChanges.cs b/ILEditing/MechanicILChanges.cs index ecc6161446..4c3b68fb83 100644 --- a/ILEditing/MechanicILChanges.cs +++ b/ILEditing/MechanicILChanges.cs @@ -9,6 +9,9 @@ using CalamityMod.DataStructures; using CalamityMod.Enums; using CalamityMod.Events; using CalamityMod.FluidSimulation; +using CalamityMod.Graphics.Metaballs; +using CalamityMod.Graphics.Primitives; +using CalamityMod.Graphics.Renderers; using CalamityMod.Items.Accessories; using CalamityMod.Items.Accessories.Vanity; using CalamityMod.Items.Armor.Wulfrum; @@ -31,6 +34,7 @@ using CalamityMod.Projectiles; using CalamityMod.Projectiles.Ranged; using CalamityMod.Projectiles.Typeless; using CalamityMod.Systems; +using CalamityMod.Systems.Graphic.PixelationSystem; using CalamityMod.Systems.Mechanic; using CalamityMod.Tiles; using CalamityMod.Walls; @@ -914,6 +918,82 @@ namespace CalamityMod.ILEditing } #endregion + #region GeneralDrawLayer Systems Drawing + private static void GeneralDrawLayer_DrawForSupportedSystems(GeneralDrawLayer drawLayer) + { + Main.spriteBatch.SafeAction(() => + { + Main.spriteBatch.TryEnd(); + GeneralParticleHandler.DrawParticleCollectionsAtSpecificLayer(drawLayer); + }); + + Main.spriteBatch.SafeAction(() => + { + Main.spriteBatch.TryEnd(); + Main.spriteBatch.TryBegin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + MetaballManager.DrawMetaballs(drawLayer); + }); + + Main.spriteBatch.SafeAction(() => + { + Main.spriteBatch.TryEnd(); + PrimitivePixelationSystem.DrawTargetScaled(drawLayer); + }); + + PixelationManager.DrawPixelatedTargets(drawLayer); + + Main.spriteBatch.SafeAction(() => + { + Main.spriteBatch.TryEnd(); + RendererManager.DrawRendererAtLayer(drawLayer); + }); + } + + private static void GeneralDrawLayer_DrawToLayer_BeforeAllTiles(On_Main.orig_DrawBackgroundBlackFill orig, Main self) + { + GeneralDrawLayer_DrawForSupportedSystems(GeneralDrawLayer.BeforeAllTiles); + orig(self); + } + + private static void GeneralDrawLayer_DrawToLayer_BeforeSolidTiles(On_Main.orig_DoDraw_Tiles_Solid orig, Main self) + { + GeneralDrawLayer_DrawForSupportedSystems(GeneralDrawLayer.BeforeSolidTiles); + orig(self); + } + + private static void GeneralDrawLayer_DrawToLayer_NPCs(On_Main.orig_DoDraw_DrawNPCsOverTiles orig, Main self) + { + GeneralDrawLayer_DrawForSupportedSystems(GeneralDrawLayer.BeforeNPCs); + orig(self); + GeneralDrawLayer_DrawForSupportedSystems(GeneralDrawLayer.AfterNPCs); + } + + private static void GeneralDrawLayer_DrawToLayer_Projectiles(On_Main.orig_DrawProjectiles orig, Main self) + { + GeneralDrawLayer_DrawForSupportedSystems(GeneralDrawLayer.BeforeProjectiles); + orig(self); + GeneralDrawLayer_DrawForSupportedSystems(GeneralDrawLayer.AfterProjectiles); + } + + private static void GeneralDrawLayer_DrawToLayer_AfterPlayers(On_Main.orig_DrawPlayers_AfterProjectiles orig, Main self) + { + orig(self); + GeneralDrawLayer_DrawForSupportedSystems(GeneralDrawLayer.AfterPlayers); + } + + private static void GeneralDrawLayer_DrawToLayer_AfterDusts(On_Main.orig_DrawDust orig, Main self) + { + orig(self); + GeneralDrawLayer_DrawForSupportedSystems(GeneralDrawLayer.AfterDusts); + } + + private static void GeneralDrawLayer_DrawToLayer_AfterEverything(On_Main.orig_DrawInfernoRings orig, Main self) + { + orig(self); + GeneralDrawLayer_DrawForSupportedSystems(GeneralDrawLayer.AfterEverything); + } + #endregion + #region General Particle Rendering private static void DrawFusableParticles(On_Main.orig_SortDrawCacheWorms orig, Main self) { diff --git a/Particles/GeneralParticleHandler.cs b/Particles/GeneralParticleHandler.cs index c50b6d413e..0e87641d04 100644 --- a/Particles/GeneralParticleHandler.cs +++ b/Particles/GeneralParticleHandler.cs @@ -57,15 +57,16 @@ namespace CalamityMod.Particles /// internal static Dictionary particleTexturesByIDs; - private static Dictionary particleAutoDrawingOverrides; - + // 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 @@ -93,22 +94,6 @@ namespace CalamityMod.Particles texturePath = instance.Texture; particleTexturesByIDs[ID] = ModContent.Request(texturePath, AssetRequestMode.ImmediateLoad).Value; }); - - foreach (Mod mod in ModLoader.Mods) - { - var drawers = mod.GetContent().Where(c => c is ParticleAutoDrawingOverride).Select(c => c as ParticleAutoDrawingOverride); - foreach (var drawer in drawers) - { - if (drawer.TargetParticleTypeName != "") - { - if (particleTypesByNames.TryGetValue(drawer.TargetParticleTypeName, out Type particleType)) - particleAutoDrawingOverrides.Add(particleType, drawer); - else - throw new Exception($"The Particle of name \"{drawer.TargetParticleTypeName}\" used in {drawer.GetType().Name} could not be found! " + - $"Please ensure the Particle's internal name is spelt correctly and is prefixed by its home mod's internal name."); - } - } - } } public override void Load() @@ -117,21 +102,14 @@ namespace CalamityMod.Particles particleIDsByTypes = []; particleTexturesByIDs = []; - particleAutoDrawingOverrides = []; - activeParticles = []; particlesToKill = []; particlesToSpawnNextFrame = []; particlesToSpawnNextFrame_Pixelated = []; + particlesToDraw = []; particlesToDraw_Pixelated = []; - - On_Main.DrawBackgroundBlackFill += DrawParticles_BeforeTiles; - On_Main.DrawNPCs += DrawParticles_NPCs; - On_Main.DrawProjectiles += DrawParticles_Projectiles; - On_Main.DrawPlayers_AfterProjectiles += DrawParticles_AfterPlayers; - On_Main.DrawDust += DrawParticles_AfterDusts; - On_Main.DrawInfernoRings += DrawParticles_AfterEverything; + particlesToDraw_CustomShader = []; } public override void Unload() @@ -140,14 +118,14 @@ namespace CalamityMod.Particles particleIDsByTypes = null; particleTexturesByIDs = null; - particleAutoDrawingOverrides = null; - activeParticles = null; particlesToKill = null; particlesToSpawnNextFrame = null; particlesToSpawnNextFrame_Pixelated = null; + particlesToDraw = null; particlesToDraw_Pixelated = null; + particlesToDraw_CustomShader = null; } public override void OnWorldUnload() @@ -156,8 +134,10 @@ namespace CalamityMod.Particles particlesToKill.Clear(); particlesToSpawnNextFrame.Clear(); particlesToSpawnNextFrame_Pixelated.Clear(); + particlesToDraw.Clear(); particlesToDraw_Pixelated.Clear(); + particlesToDraw_CustomShader.Clear(); } #endregion @@ -312,62 +292,14 @@ namespace CalamityMod.Particles particlesToKill.Clear(); } - private static void DrawParticles_BeforeTiles(On_Main.orig_DrawBackgroundBlackFill orig, Main self) + internal static void DrawParticleCollectionsAtSpecificLayer(GeneralDrawLayer drawLayer) { - Main.spriteBatch.End(); - DrawParticleCollectionsAtSpecificLayer(GeneralDrawLayer.BeforeTiles); - Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + if (Main.dedServ) + return; - orig(self); - } - - private static void DrawParticles_NPCs(On_Main.orig_DrawNPCs orig, Main self, bool behindTiles) - { - if (!behindTiles) - { - Main.spriteBatch.End(); - DrawParticleCollectionsAtSpecificLayer(GeneralDrawLayer.BeforeNPCs); - Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - } - - orig(self, behindTiles); - - if (!behindTiles) - { - Main.spriteBatch.End(); - DrawParticleCollectionsAtSpecificLayer(GeneralDrawLayer.AfterNPCs); - Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - } - } - - private static void DrawParticles_Projectiles(On_Main.orig_DrawProjectiles orig, Main self) - { - DrawParticleCollectionsAtSpecificLayer(GeneralDrawLayer.BeforeProjectiles); - - orig(self); - - DrawParticleCollectionsAtSpecificLayer(GeneralDrawLayer.AfterProjectiles); - } - - private static void DrawParticles_AfterPlayers(On_Main.orig_DrawPlayers_AfterProjectiles orig, Main self) - { - orig(self); - DrawParticleCollectionsAtSpecificLayer(GeneralDrawLayer.AfterPlayers); - } - - private static void DrawParticles_AfterDusts(On_Main.orig_DrawDust orig, Main self) - { - orig(self); - DrawParticleCollectionsAtSpecificLayer(GeneralDrawLayer.AfterDusts); - } - - private static void DrawParticles_AfterEverything(On_Main.orig_DrawInfernoRings orig, Main self) - { - orig(self); - - Main.spriteBatch.End(); - DrawParticleCollectionsAtSpecificLayer(GeneralDrawLayer.AfterEverything); - Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.Transform); + DrawParticleCollection(particlesToDraw, drawLayer); + DrawParticleCollection(particlesToDraw_Pixelated, drawLayer, true); + DrawParticlesWithShaders(drawLayer); } private static void DrawParticleInstance(Particle particle) @@ -454,35 +386,27 @@ namespace CalamityMod.Particles } } - private static void DrawParticleCollectionsAtSpecificLayer(GeneralDrawLayer drawLayer) + private static void DrawParticlesWithShaders(GeneralDrawLayer drawLayer) { - if (Main.dedServ) - return; - - DrawParticleCollection(particlesToDraw, drawLayer); - DrawParticleCollection(particlesToDraw_Pixelated, drawLayer, true); - - foreach (ParticleAutoDrawingOverride drawer in particleAutoDrawingOverrides.Values) + foreach (var keyValuePair in particlesToDraw_CustomShader) { - if (!drawer.ShouldDrawParticles) - return; - - foreach (var keyValuePair in drawer.ActiveParticleInstances) + // If there's nothing to be drawn, remove the effect from the dictionary and return. + if (keyValuePair.Value.Count == 0) { - if (keyValuePair.Value.Count == 0) - return; - - if (drawer.DrawLayerOverride.HasValue) - { - if (drawer.DrawLayerOverride.Value == drawLayer) - drawer.DrawAllParticles(Main.spriteBatch, keyValuePair.Value); - } - else - { - if (keyValuePair.Key == drawLayer) - drawer.DrawAllParticles(Main.spriteBatch, keyValuePair.Value); - } + particlesToDraw_CustomShader.Remove(keyValuePair.Key); + return; } + + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullNone, keyValuePair.Key, Main.GameViewMatrix.TransformationMatrix); + + var particlesAtDrawLayer = keyValuePair.Value.Where(p => p.DrawLayer == drawLayer); + foreach (Particle particle in particlesAtDrawLayer) + { + particle.PrepareCustomShader(keyValuePair.Key); + DrawParticleInstance(particle); + } + + Main.spriteBatch.End(); } } @@ -536,11 +460,11 @@ namespace CalamityMod.Particles private static void AddToAssociatedDrawCollection(Particle particle) { - if (particle.OverrideAutomaticDrawing && particleAutoDrawingOverrides[particle.GetType()].ShouldDrawParticles) + if (particle.CustomShader != null) { - if (!particleAutoDrawingOverrides[particle.GetType()].ActiveParticleInstances.ContainsKey(particle.DrawLayer)) - particleAutoDrawingOverrides[particle.GetType()].ActiveParticleInstances[particle.DrawLayer] = []; - particleAutoDrawingOverrides[particle.GetType()].ActiveParticleInstances[particle.DrawLayer].Add(particle); + if (!particlesToDraw_CustomShader.ContainsKey(particle.CustomShader)) + particlesToDraw_CustomShader[particle.CustomShader] = []; + particlesToDraw_CustomShader[particle.CustomShader].Add(particle); } else { @@ -550,8 +474,8 @@ namespace CalamityMod.Particles private static void RemoveFromAssociatedDrawCollection(Particle particle) { - if (particle.OverrideAutomaticDrawing) - particleAutoDrawingOverrides[particle.GetType()].ActiveParticleInstances[particle.DrawLayer].Remove(particle); + if (particle.CustomShader != null) + particlesToDraw_CustomShader[particle.CustomShader].Remove(particle); else ReturnAssociatedDrawCollection(particle).Remove(particle); } diff --git a/Particles/Particle.cs b/Particles/Particle.cs index ddc3f94bcf..2de8391621 100644 --- a/Particles/Particle.cs +++ b/Particles/Particle.cs @@ -75,9 +75,14 @@ namespace CalamityMod.Particles /// /// The "layer" or point at which you'd like your particle to draw in Terraria's internal draw order. - ///
Defaults to .
+ ///
Defaults to .
///
- public GeneralDrawLayer DrawLayer = GeneralDrawLayer.AfterEverything; + 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. @@ -92,11 +97,6 @@ namespace CalamityMod.Particles /// public virtual int FrameVariants => 1; - /// - /// An 0-1 interpolant representing how close this particle is from its . - /// - public float LifetimeCompletion => Lifetime != 0 ? Time / (float)Lifetime : 0; - /// /// Set this to true if you NEED the particle to render even if the particle cap is reached. /// @@ -123,10 +123,10 @@ namespace CalamityMod.Particles public virtual bool UseCustomDraw => false; /// - /// Override and set this to true to disable automatic drawing for all instances of this particle entirely. - ///
Drawing of this particle must be done from a class.
+ /// An optional shader parameter for this paricle to be drawn with. + /// Use to set shader parameters accordingly. ///
- public virtual bool OverrideAutomaticDrawing => false; + public virtual Effect CustomShader => null; /// /// Use this method if you want to handle the particle drawing yourself. Only called if is set to true. @@ -139,6 +139,11 @@ namespace CalamityMod.Particles /// 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. diff --git a/Particles/ParticleAutoDrawingOverride.cs b/Particles/ParticleAutoDrawingOverride.cs deleted file mode 100644 index 5a5ec3a257..0000000000 --- a/Particles/ParticleAutoDrawingOverride.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.Enums; -using Microsoft.Xna.Framework.Graphics; -using Terraria.ModLoader; - -namespace CalamityMod.Particles -{ - /// - /// Allows one to directly control how all active instances of a specified particle type in the world are drawn. - ///
Useful for cases such as applying shaders to particles without resetting the SpriteBatch for every individual particle instance.
- ///
- /// - /// Note that particles using an instance of this class MUST have set to true. - /// - public abstract class ParticleAutoDrawingOverride : ModType - { - /// - /// All active particle instances for this drawer, identified by a particle's draw layer. - /// - public Dictionary> ActiveParticleInstances { get; private set; } = []; - - /// - /// The internal name of the particle type that should be manually drawn. - ///
Particle names should be prefixed with the internal name of the mod they are from.
- ///
e.g. "CalamityMod.PulseRing" is valid, while just "PulseRing" is not.
- ///
- /// - /// This is only checked once when the mod is loading. Changing this during runtime will not affect anything. - /// - public abstract string TargetParticleTypeName { get; } - - /// - /// Whether or not this drawer should draw its particles this frame. - ///
Return false to prevent currently stored particles from being drawn and new ones from being added to .
- ///
- /// - /// Returns true by default. - /// - public virtual bool ShouldDrawParticles => true; - - /// - /// An optional property which will override the draw layer of all particles for this drawer entirely, using the specified one here instead. - /// - public virtual GeneralDrawLayer? DrawLayerOverride => null; - - protected sealed override void Register() => ModTypeLookup.Register(this); - - public sealed override void SetupContent() => SetStaticDefaults(); - - /// - /// Write all relevenat draw code for your particles here. - /// - /// Stores particles based on their default draw layer. - ///
Iterate through this collection to run individual particle drawing logic.
- public abstract void DrawAllParticles(SpriteBatch spriteBatch, List particlesToDraw); - } -} diff --git a/Projectiles/Boss/DoGFire.cs b/Projectiles/Boss/DoGFire.cs index e036754e9f..dcb6e68f66 100644 --- a/Projectiles/Boss/DoGFire.cs +++ b/Projectiles/Boss/DoGFire.cs @@ -4,6 +4,7 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.DataStructures; using CalamityMod.Graphics.Primitives; using CalamityMod.Particles; +using CalamityMod.Enums; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria.DataStructures; @@ -12,6 +13,7 @@ using Terraria.Audio; using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Boss { public class DoGFire : ModProjectile, ILocalizedModType, IPixelatedPrimitiveRenderer @@ -159,7 +161,7 @@ namespace CalamityMod.Projectiles.Boss return Color.Lerp(fullBodyColor, Color.White, 0.175f); } - public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, PixelationPrimitiveLayer layer) + 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")); diff --git a/Projectiles/Magic/SHPB.cs b/Projectiles/Magic/SHPB.cs index 8e37b4b884..9b2448527d 100644 --- a/Projectiles/Magic/SHPB.cs +++ b/Projectiles/Magic/SHPB.cs @@ -2,6 +2,7 @@ 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; @@ -13,7 +14,7 @@ namespace CalamityMod.Projectiles.Magic { public class SHPB : ModProjectile, ILocalizedModType, IPixelatedPrimitiveRenderer { - public PixelationPrimitiveLayer LayerToRenderTo => PixelationPrimitiveLayer.BeforeProjectiles; + public GeneralDrawLayer LayerToRenderTo => GeneralDrawLayer.BeforeProjectiles; public ref float ExplodeTimer => ref Projectile.ai[2]; @@ -377,7 +378,7 @@ namespace CalamityMod.Projectiles.Magic return Color.Lerp(endColor, Color.White, deathInterpolant); } - public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, PixelationPrimitiveLayer layer) + 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/SHPL.cs b/Projectiles/Magic/SHPL.cs index 055311f127..2d704a38a0 100644 --- a/Projectiles/Magic/SHPL.cs +++ b/Projectiles/Magic/SHPL.cs @@ -2,6 +2,7 @@ using System.Linq; using CalamityMod.Graphics.Primitives; using CalamityMod.Particles; +using CalamityMod.Enums; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -22,7 +23,7 @@ namespace CalamityMod.Projectiles.Magic public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - public PixelationPrimitiveLayer LayerToRenderTo => PixelationPrimitiveLayer.BeforeProjectiles; + public GeneralDrawLayer LayerToRenderTo => GeneralDrawLayer.BeforeProjectiles; public override void SetStaticDefaults() { @@ -137,7 +138,7 @@ namespace CalamityMod.Projectiles.Magic return Color.Lerp(startColor, bodyColor, completion); } - public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, PixelationPrimitiveLayer layer) + 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")); diff --git a/Projectiles/Magic/SHPS.cs b/Projectiles/Magic/SHPS.cs index bd02542b8b..d4d256b49c 100644 --- a/Projectiles/Magic/SHPS.cs +++ b/Projectiles/Magic/SHPS.cs @@ -3,6 +3,7 @@ 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; @@ -234,7 +235,7 @@ namespace CalamityMod.Projectiles.Magic return Color.Lerp(Color.White, tipColor, completion); } - public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, PixelationPrimitiveLayer layer) + 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")); diff --git a/Projectiles/Magic/SylvestaffHoldout.cs b/Projectiles/Magic/SylvestaffHoldout.cs index 3109ae5bff..095581baa7 100644 --- a/Projectiles/Magic/SylvestaffHoldout.cs +++ b/Projectiles/Magic/SylvestaffHoldout.cs @@ -2,6 +2,7 @@ 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; @@ -14,7 +15,7 @@ namespace CalamityMod.Projectiles.Magic { public class SylvestaffHoldout : ModProjectile, IPixelatedPrimitiveRenderer { - public PixelationPrimitiveLayer LayerToRenderTo => PixelationPrimitiveLayer.BeforeProjectiles | PixelationPrimitiveLayer.AfterPlayers; + public GeneralDrawLayer LayerToRenderTo => GeneralDrawLayer.BeforeProjectiles | GeneralDrawLayer.AfterPlayers; public override LocalizedText DisplayName => CalamityUtils.GetItemName(); @@ -186,9 +187,9 @@ namespace CalamityMod.Projectiles.Magic } } - public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, PixelationPrimitiveLayer layer) + public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, GeneralDrawLayer layer) { - bool backLayer = layer == PixelationPrimitiveLayer.BeforeProjectiles; + bool backLayer = layer == GeneralDrawLayer.BeforeProjectiles; RenderRibbon(LeftRibbon, -1, backLayer); RenderRibbon(RightRibbon, 1, backLayer); } diff --git a/Projectiles/Melee/Galaxia_PhoenixsPrideFirewall.cs b/Projectiles/Melee/Galaxia_PhoenixsPrideFirewall.cs index 90f305fa35..9bc3a59757 100644 --- a/Projectiles/Melee/Galaxia_PhoenixsPrideFirewall.cs +++ b/Projectiles/Melee/Galaxia_PhoenixsPrideFirewall.cs @@ -2,6 +2,7 @@ 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; @@ -81,7 +82,7 @@ namespace CalamityMod.Projectiles.Melee public float WidthFunction(float completionRatio) => MathF.Max(50f * Scale * (MathF.Pow(1f - completionRatio, 2) * 2.75f), 0.35f); public Color ColorFunction(float completionRatio) => Color.Orange * (completionRatio > 0.1f ? 1f : completionRatio * 10f); - public void RenderPixelatedPrimitives(SpriteBatch spritebatch, PixelationPrimitiveLayer layer) + public void RenderPixelatedPrimitives(SpriteBatch spritebatch, GeneralDrawLayer layer) { GameShaders.Misc["CalamityMod:Bordernado"].UseSaturation(-0.2f); GameShaders.Misc["CalamityMod:Bordernado"].UseOpacity(fadeOut); diff --git a/Projectiles/Summon/LiliesOfEternityBullet.cs b/Projectiles/Summon/LiliesOfEternityBullet.cs index d87e226da0..d60b3bb10a 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; @@ -60,7 +61,7 @@ namespace CalamityMod.Projectiles.Summon private Color PrimitiveColorFunction(float completionRatio) => Color.Lerp(Color.DarkGoldenrod, Color.LightGoldenrodYellow, completionRatio); - public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, PixelationPrimitiveLayer layer) + public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, GeneralDrawLayer layer) { 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/LiliesOfFinalityBullet.cs b/Projectiles/Summon/LiliesOfFinalityBullet.cs index 19a527e5d2..b969ecd814 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; @@ -64,7 +65,7 @@ namespace CalamityMod.Projectiles.Summon private Color PrimitiveColorFunction(float completionRatio) => Color.Lerp(Color.DarkGoldenrod, Color.LightGoldenrodYellow, completionRatio); - public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, PixelationPrimitiveLayer layer) + public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, GeneralDrawLayer layer) { 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/Systems/Graphic/PixelationSystem/PixelationManager.cs b/Systems/Graphic/PixelationSystem/PixelationManager.cs index 00628ffda8..8758c40444 100644 --- a/Systems/Graphic/PixelationSystem/PixelationManager.cs +++ b/Systems/Graphic/PixelationSystem/PixelationManager.cs @@ -12,7 +12,8 @@ namespace CalamityMod.Systems.Graphic.PixelationSystem { public class PixelationManager : ModSystem { - private static Dictionary PixelTargets_BeforeTiles; + 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; @@ -21,7 +22,8 @@ namespace CalamityMod.Systems.Graphic.PixelationSystem private static Dictionary PixelTargets_AfterDusts; private static Dictionary PixelTargets_AfterEverything; - private static List ActivePixelatedDrawers_BeforeTiles; + 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; @@ -54,12 +56,13 @@ namespace CalamityMod.Systems.Graphic.PixelationSystem ///
internal static RenderTarget2D CreatePixelTarget(int width, int height) => new(Main.graphics.GraphicsDevice, (int)(width * PixelationResolution), (int)(height * PixelationResolution)); - public override void OnModLoad() + public override void Load() { if (Main.dedServ) return; - PixelTargets_BeforeTiles = []; + PixelTargets_BeforeAllTiles = []; + PixelTargets_BeforeSolidTiles = []; PixelTargets_BeforeNPCs = []; PixelTargets_AfterNPCs = []; PixelTargets_BeforeProjectiles = []; @@ -68,7 +71,8 @@ namespace CalamityMod.Systems.Graphic.PixelationSystem PixelTargets_AfterDusts = []; PixelTargets_AfterEverything = []; - ActivePixelatedDrawers_BeforeTiles = []; + ActivePixelatedDrawers_BeforeAllTiles = []; + ActivePixelatedDrawers_BeforeSolidTiles = []; ActivePixelatedDrawers_BeforeNPCs = []; ActivePixelatedDrawers_AfterNPCs = []; ActivePixelatedDrawers_BeforeProjectiles = []; @@ -78,20 +82,15 @@ namespace CalamityMod.Systems.Graphic.PixelationSystem ActivePixelatedDrawers_AfterEverything = []; RenderTargetManager.RenderTargetUpdateLoopEvent += PrepareTargets; - On_Main.DrawBackgroundBlackFill += DrawPixelated_BeforeTiles; - On_Main.DrawNPCs += DrawPixelated_NPCs; - On_Main.DrawProjectiles += DrawPixelated_Projectiles; - On_Main.DrawPlayers_AfterProjectiles += DrawPixelated_AfterPlayers; - On_Main.DrawDust += DrawPixelated_AfterDusts; - On_Main.DrawInfernoRings += DrawPixelated_AfterEverything; } - public override void OnModUnload() + public override void Unload() { if (Main.dedServ) return; - PixelTargets_BeforeTiles = null; + PixelTargets_BeforeAllTiles = null; + PixelTargets_BeforeSolidTiles = null; PixelTargets_BeforeNPCs = null; PixelTargets_AfterNPCs = null; PixelTargets_BeforeProjectiles = null; @@ -100,7 +99,8 @@ namespace CalamityMod.Systems.Graphic.PixelationSystem PixelTargets_AfterDusts = null; PixelTargets_AfterEverything = null; - ActivePixelatedDrawers_BeforeTiles = null; + ActivePixelatedDrawers_BeforeAllTiles = null; + ActivePixelatedDrawers_BeforeSolidTiles = null; ActivePixelatedDrawers_BeforeNPCs = null; ActivePixelatedDrawers_AfterNPCs = null; ActivePixelatedDrawers_BeforeProjectiles = null; @@ -115,7 +115,8 @@ namespace CalamityMod.Systems.Graphic.PixelationSystem if (Main.dedServ) return; - ActivePixelatedDrawers_BeforeTiles.Clear(); + ActivePixelatedDrawers_BeforeAllTiles.Clear(); + ActivePixelatedDrawers_BeforeSolidTiles.Clear(); ActivePixelatedDrawers_BeforeNPCs.Clear(); ActivePixelatedDrawers_AfterNPCs.Clear(); ActivePixelatedDrawers_BeforeProjectiles.Clear(); @@ -152,7 +153,8 @@ namespace CalamityMod.Systems.Graphic.PixelationSystem if (!Main.gameMenu && !Main.dedServ) { // Draw all collections to their respctive render targets. - DrawCollectionsToTarget(PixelTargets_BeforeTiles, PixelationMatrix, ActivePixelatedDrawers_BeforeTiles); + 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); @@ -164,49 +166,7 @@ namespace CalamityMod.Systems.Graphic.PixelationSystem Main.graphics.GraphicsDevice.SetRenderTarget(null); } } - - private static void DrawPixelated_BeforeTiles(On_Main.orig_DrawBackgroundBlackFill orig, Main self) - { - DrawPixelatedTargets(PixelTargets_BeforeTiles); - orig(self); - } - - private static void DrawPixelated_NPCs(On_Main.orig_DrawNPCs orig, Main self, bool behindTiles) - { - if (!behindTiles) - DrawPixelatedTargets(PixelTargets_BeforeNPCs); - - orig(self, behindTiles); - - if (!behindTiles) - DrawPixelatedTargets(PixelTargets_AfterNPCs); - } - - private static void DrawPixelated_Projectiles(On_Main.orig_DrawProjectiles orig, Main self) - { - DrawPixelatedTargets(PixelTargets_BeforeProjectiles); - orig(self); - DrawPixelatedTargets(PixelTargets_AfterProjectiles); - } - - private static void DrawPixelated_AfterPlayers(On_Main.orig_DrawPlayers_AfterProjectiles orig, Main self) - { - orig(self); - DrawPixelatedTargets(PixelTargets_AfterPlayers); - } - - private static void DrawPixelated_AfterDusts(On_Main.orig_DrawDust orig, Main self) - { - orig(self); - DrawPixelatedTargets(PixelTargets_AfterDusts); - } - - private static void DrawPixelated_AfterEverything(On_Main.orig_DrawInfernoRings orig, Main self) - { - orig(self); - DrawPixelatedTargets(PixelTargets_AfterEverything); - } - + private static void DrawCollectionsToTarget(Dictionary targetCollection, Matrix pixelationMatrix, List drawerCollection) { foreach (var blendStateTargetPair in targetCollection) @@ -229,8 +189,9 @@ namespace CalamityMod.Systems.Graphic.PixelationSystem drawerCollection.Clear(); } - private static void DrawPixelatedTargets(Dictionary targetCollection) + internal static void DrawPixelatedTargets(GeneralDrawLayer drawLayer) { + var targetCollection = ReturnAssociatedTargetCollection(drawLayer); Main.spriteBatch.SafeAction(() => { foreach (var keyValuePair in targetCollection) @@ -248,7 +209,8 @@ namespace CalamityMod.Systems.Graphic.PixelationSystem { List drawerCollection = drawLayer switch { - GeneralDrawLayer.BeforeTiles => ActivePixelatedDrawers_BeforeTiles, + GeneralDrawLayer.BeforeAllTiles => ActivePixelatedDrawers_BeforeAllTiles, + GeneralDrawLayer.BeforeSolidTiles => ActivePixelatedDrawers_BeforeSolidTiles, GeneralDrawLayer.BeforeNPCs => ActivePixelatedDrawers_BeforeNPCs, GeneralDrawLayer.AfterNPCs => ActivePixelatedDrawers_AfterNPCs, GeneralDrawLayer.BeforeProjectiles => ActivePixelatedDrawers_BeforeProjectiles, @@ -261,13 +223,36 @@ namespace CalamityMod.Systems.Graphic.PixelationSystem 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.BeforeTiles: - if (!PixelTargets_BeforeTiles.ContainsKey(blendState)) - Main.QueueMainThreadAction(() => PixelTargets_BeforeTiles[blendState] = new(true, CreatePixelTarget)); + case GeneralDrawLayer.BeforeAllTiles: + if (!PixelTargets_BeforeAllTiles.ContainsKey(blendState)) + Main.QueueMainThreadAction(() => PixelTargets_BeforeAllTiles[blendState] = new(true, CreatePixelTarget)); + break; + + case GeneralDrawLayer.BeforeSolidTiles: + if (!PixelTargets_BeforeSolidTiles.ContainsKey(blendState)) + Main.QueueMainThreadAction(() => PixelTargets_BeforeSolidTiles[blendState] = new(true, CreatePixelTarget)); break; case GeneralDrawLayer.BeforeNPCs: diff --git a/Systems/Graphic/TempParticleSystem/TempParticle.cs b/Systems/Graphic/TempParticleSystem/TempParticle.cs new file mode 100644 index 0000000000..19b747cbe7 --- /dev/null +++ b/Systems/Graphic/TempParticleSystem/TempParticle.cs @@ -0,0 +1,67 @@ +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 Depth; + + 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 depth, int lifetime, int frameX, int frameY, int maxHorizontalFrames, int maxVerticalFrames) + { + StoredTexture = storedTexture; + Position = position; + StoredPosition = storedPosition; + Velocity = velocity; + Scale = scale; + DrawColor = drawColor; + Rotation = rotation; + Opacity = opacity; + Depth = depth; + Lifetime = lifetime; + FrameX = frameX; + FrameY = frameY; + MaxHorizontalFrames = maxHorizontalFrames; + MaxVerticalFrames = maxVerticalFrames; + + Time = 0; + ExtraData = new float[8]; + } + } +} diff --git a/Systems/Graphic/TempParticleSystem/TempParticleManager.cs b/Systems/Graphic/TempParticleSystem/TempParticleManager.cs new file mode 100644 index 0000000000..3a63fabf46 --- /dev/null +++ b/Systems/Graphic/TempParticleSystem/TempParticleManager.cs @@ -0,0 +1,152 @@ +using System; +using System.Collections.Generic; +using System.Linq; +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 List ActiveParticles; + + public Queue ParticlePool; + + public int MaxParticles; + + public Asset BaseParticleTexture; + + public ParticleUpdateFunctionDelegate ParticleUpdateFunction; + + public ParticleDrawFunctionDelegate ParticleDrawingOverride; + + /// + /// 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) + { + 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 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 depth = 0f, int frameX = 0, int frameY = 0, int maxHorizontalFrames = 0, int maxVerticalFrames = 0, Vector2? storedPosition = null) + { + if (ActiveParticles.Count >= MaxParticles || ActiveParticles.Count >= CalamityClientConfig.Instance.ParticleLimit) + return; + + if (ParticlePool.Count > 0) + { + TempParticle pooledParticle = ParticlePool.Dequeue(); + pooledParticle.SetBasicParticleData(BaseParticleTexture, position, storedPosition ?? Vector2.Zero, velocity, scale, drawColor, rotation, opacity, depth, lifetime, frameX, frameY, maxHorizontalFrames, maxVerticalFrames); + ActiveParticles.Add(pooledParticle); + } + } + + public void SpawnParticle(Vector2 position, Vector2 velocity, float scale, Color drawColor, int lifetime, float rotation = 0f, float opacity = 1f, float depth = 0f, int frameX = 0, int frameY = 0, int maxHorizontalFrames = 0, int maxVerticalFrames = 0, Vector2? storedPosition = null) + { + if (ActiveParticles.Count >= MaxParticles || ActiveParticles.Count >= CalamityClientConfig.Instance.ParticleLimit) + return; + + if (ParticlePool.Count > 0) + { + TempParticle pooledParticle = ParticlePool.Dequeue(); + pooledParticle.SetBasicParticleData(BaseParticleTexture, position, storedPosition ?? Vector2.Zero, velocity, new(scale), drawColor, rotation, opacity, depth, lifetime, frameX, frameY, maxHorizontalFrames, maxVerticalFrames); + ActiveParticles.Add(pooledParticle); + } + } + + /// + /// Updates all active particles attached to this + /// + public void Update() + { + FastParallel.For(0, MaxParticles, (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) + { + 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); + } + } + } + } +} From 9c11d520d686b9cc73b2f529c4268691d870e8ea Mon Sep 17 00:00:00 2001 From: fryzahh Date: Sat, 15 Nov 2025 21:30:02 -0400 Subject: [PATCH 35/65] General cleanup and fixes * Fixed an out of bounds error caused by TempParticleManager's update loop iterating through the maximum amount of particles that can exist at once rather than the maximum amount of particles that are currently active. * Removed particleTypesByNames from GeneralParticleHandler. * Renamed "Depth" to "ParallaxStrength" in TempParticle and other associated areas. * Added Main.dedServ checks where necessary in TempParticleManager. Other general cleanup besides that. * Added the "ReturnAll" method to TempParticleManager to allow users to forcibly return all active particles in the manager to the particle pool. --- Particles/GeneralParticleHandler.cs | 19 ++-- .../TempParticleSystem/TempParticle.cs | 16 ++-- .../TempParticleSystem/TempParticleManager.cs | 89 ++++++++++++------- 3 files changed, 77 insertions(+), 47 deletions(-) diff --git a/Particles/GeneralParticleHandler.cs b/Particles/GeneralParticleHandler.cs index 0e87641d04..fe209f6950 100644 --- a/Particles/GeneralParticleHandler.cs +++ b/Particles/GeneralParticleHandler.cs @@ -46,12 +46,6 @@ namespace CalamityMod.Particles ///
internal static Dictionary particleIDsByTypes; - /// - /// All types defined across all mods, identified by a string for each respective particle which follows the following format: - ///
{Particle's Home Mod's Internal Name}.{Particle's Internal Name}
- ///
- internal static Dictionary particleTypesByNames; - /// /// The individual, autoloaded textures of each particle type defined across all mods, identified by the ID of the respective particle. /// @@ -78,9 +72,6 @@ namespace CalamityMod.Particles int ID = particleIDsByTypes.Count; //Get the ID of the particle particleIDsByTypes[type] = ID; - string registrationName = string.Concat(type.FullName.AsSpan(0, type.FullName.IndexOf('.')), ".", type.Name); - particleTypesByNames[registrationName] = type; - // 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. @@ -98,7 +89,6 @@ namespace CalamityMod.Particles public override void Load() { - particleTypesByNames = []; particleIDsByTypes = []; particleTexturesByIDs = []; @@ -114,7 +104,6 @@ namespace CalamityMod.Particles public override void Unload() { - particleTypesByNames = null; particleIDsByTypes = null; particleTexturesByIDs = null; @@ -172,6 +161,8 @@ namespace CalamityMod.Particles /// 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. @@ -209,6 +200,9 @@ namespace CalamityMod.Particles /// public static void RemoveParticlesOfType() where T : Particle { + if (Main.dedServ || activeParticles is null || activeParticles.Count == 0) + return; + foreach (Particle particle in activeParticles) { if (particle.GetType() == typeof(T)) @@ -221,6 +215,9 @@ namespace CalamityMod.Particles /// public static void RemoveAllParticles() { + if (Main.dedServ || activeParticles is null || activeParticles.Count == 0) + return; + foreach (Particle particle in activeParticles) particlesToKill.Add(particle); } diff --git a/Systems/Graphic/TempParticleSystem/TempParticle.cs b/Systems/Graphic/TempParticleSystem/TempParticle.cs index 19b747cbe7..c73b3f8027 100644 --- a/Systems/Graphic/TempParticleSystem/TempParticle.cs +++ b/Systems/Graphic/TempParticleSystem/TempParticle.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Systems.Graphic.TempParticleSystem public float Opacity; - public float Depth; + public float ParallaxStrength; public int Lifetime; @@ -43,8 +43,11 @@ namespace CalamityMod.Systems.Graphic.TempParticleSystem /// 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 depth, int lifetime, int frameX, int frameY, int maxHorizontalFrames, int maxVerticalFrames) + 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; @@ -53,15 +56,16 @@ namespace CalamityMod.Systems.Graphic.TempParticleSystem DrawColor = drawColor; Rotation = rotation; Opacity = opacity; - Depth = depth; + ParallaxStrength = parallaxStrength; Lifetime = lifetime; FrameX = frameX; FrameY = frameY; MaxHorizontalFrames = maxHorizontalFrames; MaxVerticalFrames = maxVerticalFrames; - - Time = 0; - ExtraData = new float[8]; + 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 index 3a63fabf46..495226760d 100644 --- a/Systems/Graphic/TempParticleSystem/TempParticleManager.cs +++ b/Systems/Graphic/TempParticleSystem/TempParticleManager.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; +using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -16,17 +14,17 @@ namespace CalamityMod.Systems.Graphic.TempParticleSystem public delegate void ParticleDrawFunctionDelegate(TempParticle tempParticle, SpriteBatch spriteBatch, Vector2 drawOffset); - public List ActiveParticles; + public readonly List ActiveParticles; - public Queue ParticlePool; + public readonly int MaxParticles; - public int MaxParticles; + public readonly Asset BaseParticleTexture; - public Asset BaseParticleTexture; + public readonly ParticleUpdateFunctionDelegate ParticleUpdateFunction; - public ParticleUpdateFunctionDelegate ParticleUpdateFunction; + public readonly ParticleDrawFunctionDelegate ParticleDrawingOverride; - public 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 . @@ -38,6 +36,9 @@ namespace CalamityMod.Systems.Graphic.TempParticleSystem /// 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; @@ -54,6 +55,7 @@ namespace CalamityMod.Systems.Graphic.TempParticleSystem /// /// 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. @@ -62,44 +64,54 @@ namespace CalamityMod.Systems.Graphic.TempParticleSystem /// 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 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 depth = 0f, int frameX = 0, int frameY = 0, int maxHorizontalFrames = 0, int maxVerticalFrames = 0, Vector2? storedPosition = null) + 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) + 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, depth, lifetime, frameX, frameY, maxHorizontalFrames, maxVerticalFrames); - ActiveParticles.Add(pooledParticle); - } - } - - public void SpawnParticle(Vector2 position, Vector2 velocity, float scale, Color drawColor, int lifetime, float rotation = 0f, float opacity = 1f, float depth = 0f, int frameX = 0, int frameY = 0, int maxHorizontalFrames = 0, int maxVerticalFrames = 0, Vector2? storedPosition = null) - { - if (ActiveParticles.Count >= MaxParticles || ActiveParticles.Count >= CalamityClientConfig.Instance.ParticleLimit) - return; - - if (ParticlePool.Count > 0) - { - TempParticle pooledParticle = ParticlePool.Dequeue(); - pooledParticle.SetBasicParticleData(BaseParticleTexture, position, storedPosition ?? Vector2.Zero, velocity, new(scale), drawColor, rotation, opacity, depth, lifetime, frameX, frameY, maxHorizontalFrames, maxVerticalFrames); + 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); } } /// - /// Updates all active particles attached to this + /// 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() { - FastParallel.For(0, MaxParticles, (start, end, context) => + if (ActiveParticles.Count == 0) + return; + + FastParallel.For(0, ActiveParticles.Count, (start, end, context) => { for (int i = start; i < end; i++) { @@ -122,15 +134,17 @@ namespace CalamityMod.Systems.Graphic.TempParticleSystem } /// - /// Draws all active particles attached to this + /// 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) { - Vector2 drawOffset = baseOffset ?? -Main.screenPosition; + if (ActiveParticles.Count == 0) + return; + Vector2 drawOffset = baseOffset ?? -Main.screenPosition; if (ParticleDrawingOverride != null) { foreach (TempParticle tempParticle in ActiveParticles) @@ -148,5 +162,20 @@ namespace CalamityMod.Systems.Graphic.TempParticleSystem } } } + + /// + /// 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; + }); + } } } From 855ee59028a1675a428530c8777fb7d0bd9ea3c8 Mon Sep 17 00:00:00 2001 From: fryzahh Date: Sat, 15 Nov 2025 21:36:02 -0400 Subject: [PATCH 36/65] Removed unnecessary documentation from Particle.cs --- Particles/Particle.cs | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/Particles/Particle.cs b/Particles/Particle.cs index 2de8391621..7e82f578cf 100644 --- a/Particles/Particle.cs +++ b/Particles/Particle.cs @@ -32,29 +32,14 @@ namespace CalamityMod.Particles ///
public Vector2 Position; - /// - /// The velocity of the particle. - /// public Vector2 Velocity; - /// - /// The point from which this particle's texture should be drawn from. - /// public Vector2 Origin; - /// - /// The color of the particle. - /// public Color Color; - /// - /// The current rotation of the particle in radians. - /// public float Rotation; - /// - /// The scale of the particle. - /// public float Scale; /// From 1316031c8dc718adfebeaab8ab8bbc9c047b5c98 Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Sat, 15 Nov 2025 22:58:33 -0500 Subject: [PATCH 37/65] Fixed Death DoG final phase laser walls spawning multiple times in multiplayer --- NPCs/DevourerofGods/DevourerofGodsHead.cs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/NPCs/DevourerofGods/DevourerofGodsHead.cs b/NPCs/DevourerofGods/DevourerofGodsHead.cs index e52fb3572b..c7ec46e223 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHead.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHead.cs @@ -849,7 +849,7 @@ namespace CalamityMod.NPCs.DevourerofGods } // Laser walls - if (laserWallPhase == (int)LaserWallPhase.FireLaserWalls) + if (laserWallPhase == (int)LaserWallPhase.FireLaserWalls && Main.netMode != NetmodeID.MultiplayerClient) { if (death && phase6) { @@ -860,8 +860,8 @@ namespace CalamityMod.NPCs.DevourerofGods 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 + 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); @@ -881,16 +881,13 @@ namespace CalamityMod.NPCs.DevourerofGods spacing += 64; if (phase6) spacing += death ? 64 : 32; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - 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); + 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); - } + 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; } From 8b7acb5e2c56d29db75b1f54c51798257c039da0 Mon Sep 17 00:00:00 2001 From: Nathanael Overton Date: Sat, 15 Nov 2025 23:42:12 -0500 Subject: [PATCH 38/65] Custom DoG fireball sfx --- Projectiles/Boss/DoGFire.cs | 3 ++- Sounds/Custom/DoGFireball.ogg | Bin 0 -> 23275 bytes 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 Sounds/Custom/DoGFireball.ogg diff --git a/Projectiles/Boss/DoGFire.cs b/Projectiles/Boss/DoGFire.cs index e036754e9f..5ee4f66faa 100644 --- a/Projectiles/Boss/DoGFire.cs +++ b/Projectiles/Boss/DoGFire.cs @@ -24,6 +24,7 @@ namespace CalamityMod.Projectiles.Boss 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() { @@ -48,7 +49,7 @@ namespace CalamityMod.Projectiles.Boss public override void OnSpawn(IEntitySource source) { if (IsAPassiveFireball) - SoundEngine.PlaySound(SoundID.Item20, Projectile.Center); + SoundEngine.PlaySound(SpawnSound, Projectile.Center); } public override void AI() diff --git a/Sounds/Custom/DoGFireball.ogg b/Sounds/Custom/DoGFireball.ogg new file mode 100644 index 0000000000000000000000000000000000000000..54b891b04016f246a16fbd2c864fe8895e2c96b8 GIT binary patch literal 23275 zcmeFZby!tT*D$;fT>>KA-5}k_0R?F!rMpAA>wvU?v@{6PT~bma-5@R9jWitx6UassJ4DPr}jpTM?+vYKD+Q-0Yohuy^|>jP6Cd;P*)LGlTlI><=_wkGZz;-FF(iML=Fy{y)m&jHFFY`H*z!K z<7DS%=j7mcc!<@2a~JbYd5oL zH`i%5U#;X|od#d6hG3nUV7<#=Bf^k>@|Ew>-wy4))5vt`L=yMb!ffohCDAfWUhJUk7MZIzn;|H2VeT^GlZ(eF^eIXYyG8 zV!{L40RYNL+T}>v2U0_YZNiE7wX^87v%)k;iU*4PpHsjec>y;)~y1^H$)L)e`WNa-7mWQIn+x0&f&E+}o2S2v~2l9!+&%ar$5qd=xon#PDD z5&cn;kYuNRrUFna{*!UXv?Gtn#{MIZ{3KPzp#$?67n>@#sJfc^Yd1Ts53cj|!Fn^U zOVhqf(@_QlA^%md{;fFxs5C);bTYv>lCvlMt)c|#Uk3k6a~yGdVoCdAY2~VE6~P?tO^6O8+PRoj}(S?yg^nW?lm+vjc-s*OTq z@Yq8EJ`w?#JrGg_cv88CtK%WbOaKbFkfA3JmlT-V$9SMmM4?Y4|2F?;C5VVe83D}y zECV7MQ-h50{DTX`(#|ajHn_qe<|?aQUDZj z2qyT$m-tA<0tXX-0HJHpI7*pg9+-*Nv4{t;{F7x(d=acvgyv}C zJCF{*MVn|r<5cLWg*f?mNO5-1V;kxqmjIXG?l4}3Nuq4nglalqKde5-X|3U(DXLt`gBkQ)z#q8oVNQBiR*8rYfu z2^IWc?-m#Def|7E|7lmF`3K_fHMN6ucQqqwc(}e<(E&io0RWgQja-A`bE?|Giw^GL zz6|0-VFGO~B&tu?64Fe;G5=K>!8tJOe>@bvNTYvhj%feswfryt<^RvxjJ8c#od!TS z91IWD3X0+`rOm*LMj{}t#sN@JL9UC3acQjF)M{S*~hQ+oZIPJ~uM%p|7-ViaJ4ss~cAptfdBVbYBvhlyYuq z$K!mxB3EStfo(uppfQaq>edDY2h}VxifuB%c^DCZiV6TwIzn*k|R|56# zKtdb{m-o*AhzMN&p8*gNxXj-fVCBICPkexVsQf959%^9oZ~1p14@3lZ{_T1|1UCO! z?+>B`73RN9@c4y)IQ?jt*}f@qmy5u?#O0EQ{?S>`L&HX{s-4m&n1$0NlJlkDhMGhVA$W=h0s#DD zt|utC(0~98KmaNo0|%g?V~}-9LZR$bx$W5w@&XJQd;lOGHi#V_)u^4_QBeK{RG{>K<^vA_m4|CloiRp?N`zlVT1NDloRox;thAnvvFW|pz1n@y zebl|jeIQu3T<0kw*mH8ja8b(DP>lEEJTeT8JhYmWjrOCM$w2|;A-Rjs6di@^PnISl ztUrn4M&)bsQB~(z0zNFw~LXXVPSi41rLt)^MTIOsI@;1W^Svh4( z#YBlo7*2SBT>(_s%Y`IrpvWQf;HN-{1ZH}u`6=O%y=|B!A9oeSy06gyPS<&IWn}04D%9_V~Ze*l&nn6P1YYgt&E$>o~YaTYDJo@ zR9RhX_c5CCc}X~TWR5@_M}%D{J?%HnFh=|&3PpM2=g256$K@2G(NKiyYDAqKK5!xUuOh^b3R%D}*P=uvpgy{MS^O@jl z(d32k21@Y|KYkIZ;mTb6JeLy9t>Qh&^$p`E&!GEgW6bBchyg&PF*-E>Fn0X{%Z7>9 z?_!8hja29`s_)(~ysNS)&6%ObdyFS3+OH(YftK6Uzu@|Mr<%5#%fqqYb~FBFQugio`b{U8=9|;CfL$F< zxJuWG#3gY$W4>_Z2C=fm$#IyVDKd?^MlJi7xgrP3w>T_Xe3V+0b{3>B$tb1z zo`yS`GP}6(-TKZ5f!~o%IP)9B>3*u0o-kC%*- z|0-@>Yh_ud=J$G*qf?0Z?j72X)Jxf(?ffSN+Na?-8H zTJC=zB!!I*u}z|r#MH>-&oN<~g908a%l1HtOYovPoOx>nw`uk{eOI~O#r2Ww#iVz_ z&HF1}3N^71r<0=-syg%glYN6}KVMx%GRa7itxh7r~Vd~7jaj*!Q(-NwQ@oLygkXK9Mb!txin2>$T&Xh4V5=Ts_*`B+%iTF(pn9zTq+rH?l|~?V=qP=-SJmG^2WZk^FZ%Qf5V%k6NyT9V zczoaimtwd4h6C5ygHg*8BRc#gHN|9Vz%(k765+>YR_?+F@+Wa`>ngf*?TZd|G%=6T z@k~wNBYhQi!?yhYjM#L)GZNd9{C673yP+PGhA38EQ?&^^T? znY11DyTToWt zL>6jIbQHp*FH_w7fDuWcGza{I6Cwg&&-sYC{n4Ua`J800v1+&RM|x@dM!6>i5Yg|n zeu%(K0fos6O+IQ}b7Rh*WvZya3pEHZp%kLcn)11Q+|sR-xJZ@ayY(s4Y?j5Mhd`&_ z!M(6aOIk}BgBV4U7QtL2dqG*GAdmHp&!92kFJjg?8cfcj0y#}h4GJZ=#M68u^Rv89pDgfGR0?Y`qNq|FcVzn_BishF zd0%7jkeSbM+tjj?F(>F3MJ$VQ3x?xo?=@c7#vZo^Pu!Kyz;UJiv_2rh4k`xd@!4HS zMDp=T!q{F&Jo%+Y{Vmy4nG)#8LBeh%AfcBqr+r$S7YhwW?0j$6g9ON8w~shu`fCM; zA}Og_nE63aG2eB_`Y7};DBKb-!gC?@@Da`%3SKZj#q21JGwdLoB9+0>)YJq}4B6CL zK;P{Zut=JjgFc5*OTa_wuXECYPDtU<$}s-;ROC#m%Escu^NzynS*uvk8))(yAcKe1 zt(Eo~rcWLz^}ey%Ph6NBU7R+(6+h>zyf{6X;)W-YxY<;%q#PY-RbnGAYZHM zay7`gYS8$uV5P>N@dL+(hix!PlZ;MZ&bXggwr_pG?uc!cgvLZFr3*Pma3BE{zaDR< z^SMS$3{g-kHykNSz4m+*0@S!PMBWMQB@P)pXq>lJ5CoIn0(G1+) zTlVVCO8ZPJ}+14>@ zao$pLN+W8%(Oxl;_Er7NqXw2I>gV^kg15~_6W%rDoCmF<_unfj&4sx%M`YL6ve=4+ ztG@95%s9B+(iXKo-0;~`9zx4mQf23qR1)o>v_4Iyh>L1j@44 z$>y*7X0sf>mizNu@tK9Z-n#GqR>jaP%Dz?6aqenEoj`9@FD zNSoNjm!|_ua-_5$4AXAar^4G0S6`)jL@UCt{UF{OF;e?TU*!})ikMLtGMl9m*DuL2 z+gQy~M z!i8s(TDxKf+d}}D3?P6*Mv6xRTyqv~5CjtO!4AHBNXe=raildO%M2lQpy>Ve+1%&WsLIrW z>Bc;cc&J{DsJGF5&5wK5pRrkGdH%*az3^5v(_8v%Ol`-g{%p{0NcMIe!WJ4naMhTd4tMnHc1&)h zzLRlyyu}~a2!RqfJ~`JV_dh!Rx^jFyt`5-o_<_C~HA-#!1}}i99EN}bp`keOy zg0=(WwbA~@k)P8B6om^zhg3Ju&puA9w~ZA0;%<6M=h!bIu#TOjDLkp(&i&Dx{e1m{ z$Bz!*txOb>_wPxa+v9m1!&CaC68CKpF<2AWo(oUc3cXNv*=WeYeKG0FmfIl9h0PM6 zYfVSZxL#ZrRuZ9|%fS?6Ba{{{mn2d=!?cDSksN6)#OKD>uybR_JD3n#370D2+f7op z1`&|icw5+5L;7I{1LsP=A}qV0B7b4l7a36? z^7&h`kZ!;b*yq?>GQ^F>v{68{yomUiMce+%7RbaWs-y^t+V(WQ6TrGhD>5Cw`rrO;Mlltx_<61 z;UtM^dAA^nY7+LwatJk45U#L7B>A;`x#lx#N{AnZu{CiLEkMF$$_$Fe4m3u5Ymt8PPVT!JBG8SfBFXsT5IW4Ol@ZujkC)E zUM`cF3reE1yhrA?KWyHk_DrYy>-h^WMW&Hv%$%{`mH#sMV!k9|_x8t5dqF(KftgwB ztm04UB-hCI-k9(M>3q-f-`AKazHr{&8@YYiiEtzav!j{zEaqr3kwFa}sT1>{ew`qx z;=)6---2|N+$t-Ss1>T96qtJLZV2jI<)X$uqz*--1o|(rwCjnH}wN;{0@Q z;McI^Gn4Xowe`@XLf@k3J#t={u;mj0Yqf1Al~N|Tj&!I*=dzvV{Saz;j+mb+kk#Z+TzEAmc2l)rBD=lLwtvWl{=Qh&zi#2Ag6}7H_W?T0fDv$et_0yQ)9Vx}}k? z-z+F*7G}wE!N7oTo@US9NF6dMpM`Hv#)J@37Rfs`K$dTRMmKEn$LxJoXjEWQsz0&F zO3D9d6O!*=U|2h2;Cs2kVL*yA^PLx%DZDUi7am7t`Za};3c$WNqXXk{F`2F~lzl?% z$S-7AH0|S%KBN@YoK?n-H9p4ekK+ak#mMw=oM2Q^61YQ;c9cbf2mCs_pME4_3@3V{ z_ltC-q~z$NP43+DnJP?qNoxtE=Cezb8*tzm6d4a45C+~#Q@#}P;ea<{Q?hUkg)cdg| z)3aGm;pW8)(*okJE~M(MeFZgz(MJ`qnDD?n#xFInCI)Uv{2YcoQw|%6wiWEXPIi0= zl~m$wl^OPu=xwczY%AujG7*k^XAf=95YBkU!~Qv}#t}2o0HSb3#Z1NLewIy2hc)q{ zOJfS>9X<)6M)q9oK7&mop&3V%-NwYfes=47*9*Q0DChSh%oiJcVkF=k-dNjcQQdSx zxBr49_40cclQc|bcuW56x6F=k;^bbXm!#JHdYsxU)=*=-IQ^;_l(+G0GdzY7QXpW3siz^b%=XlG*@wmBF1z-2hg_T(pDHWv|Ub!O43K-4M>PrZ-3g1?e)V z7;1pqI3rLAzBq*@y}It;BgE!A?!zqctw#-#qQM4Gu3aBvpmcBH!!Sf}A<#FYFHUFy zTtAG=UxfX@GO6yNE5-r@<~>3$#o+3<>jq<(vh>9_3DS6baZqXs2Yo`)O2RfV)>oL$ zbFcJubK%l*qj*W{Lrf`t=)v6X`ZXF$naf*yGcHxKYTw3lnVXcB0X+WhLPhOQSYq4` zxzh+oNTby^a=GOxB>5BZk%6sO2Y0@@x*Uz)Z*?8b9xJf(<9TyA+-148s(b!EBIPpp zAu6$9q%_6qEQgIb#v4EOHa>|?xL}`bkA>%n;=AG)Y>bW}QYt^Z*18m z`qz*+KaA9ejReXNIvC*I3`sdC?c3iB?!R`W+g}u1ki++7emSv+sFgLZ-8OhKwQ|_V z4oj_1`#fB^a+cpUF&da+bacm2y7s8k;T*N*=Nmh2;CWkOpZpJGwWU+5;xGD0_oVQ! z$4C`O2=JQiD7{ZAG2TD{OvqyyV~m;1Ny-4fb~yCjkZA!|e-}JBF)1H-l(0wY;!OLG z`8*JTxAl;!Af9qi0ifb|xWL^2**h#V7-DqeLaNF((mJ_fy)%P`lC8iGaU+VM5POoS z$FiIYpj{7}ak<|z@OM5~(mP$hvFqY~q?cjKBeFHBJrBK~UTIrgX&Di;>0#Y z@x86wUAVcvY8m$97?fno=~tzwc(?EQ`wK_wR%2w(&YF(Agp%7=_sxj3JIAew#K-EY z4VRv#3v?^qQ$nqd0h=cmZj6f&%_7pVJ%w!_#sqY_qmK38;y&V5WyDcz z2gw{ZmUx&y&nkYSx^RBYa&v;@ROonfJHltL*mgZ3*VyW^S!BFG;hLIWgA6V!Mif zy9l;n1YC!XYW(>ec1PaqvPvK4{-3dvmu1@;PkD4t8`t={30pPJ?cS%^`fQ3>N$jD9^>-dN#ohBPVt@atX3YC^clPt! z%TZf|I_IYRzKB#Bv6EwQ`TZ&##^0&Ip+=cv3v;_i&o4=v3D~u6q$gr_3%wPe*ITb& z?(fJk@swsvs&Z(XZ$4u|)Sy#vCdz|xP*3=$PB2xMPh~{LuPB}Z6GvKkRf%_Bc7G4@ zH~RK0jWguFe~g38z^QIwo$Dz^H|Rzf61_wcq4|r#Vpt z$U6O|_dUT82_rC!ezSke|4Enp)9Lfi55b0j+GaZV5Qx6Dt0Dq!UIP|SZexU&lXn40muzgP0P-B8RDD0FW9iglG( z{$ru;qW0xc32Al3O(<`D>ZHwKNyQ{%iQsR~lhd9!y+`?YFDZmx>sKH7mM%;Z%;Bl> z_?#T1HYb0YrS^M&oFs_M5s8%(7*+bBkbg$2$RECCN+~tzW>rrAq$m^g2^$I`Bl{+t zA2){w9+9VJitd!D`n|-!aS(6S5Yma|zQ(TUxpLjWuAclYX3qq#`(9k1dz&!g1v2=RkHoz5qF;zk-~djQu?RA z7A%%jkqAf>4QOHJ#D)CT{H`BvAMz6rA=l2&gys4GY(TmH=92B%xpHd?MKuX_OprPPp2;;87ZM1TdOWMWn86;dDCkJ}+?_ur~ytjm$Xf_r5q zF13#m&uhwQ15#2-ocM05w)z)~Z~9aVQ%USEr{nl8hwFJpgxvC#uyVeg_&B$`#?BLC zN!w;W$3x%mN{}q^_tbLxf+cokee(PO>+|!V7fJ16Ff77$#kgw`KQ%W@?%|uFz98Li z-}C7vzbh(VW|(?m@z>}ChM0hkB8#4^FK5l!VKn*+&;-q|&cE63d!wqPtwDYme|r$J zD6mI=`cfj(?INHAQ%sBCxNmsOoNr8h$k(aOZ#rO(b)1r-kp9TKH~Oa= zVP?EQ>o{Ga#a(=Me^K)-1p^@YW;?{f;FQ!>h`0H4QQx9pLka`1{^ zJRGc)`O$Hxe4%OjD%}3Bz>ryVdc<31qz$YvW3%>=lFKQ0SnMMd;5zS;dNdRd2$05i ze0)6#z6&>m?B5<=c4mE6!FT#S^6cK7iNx>z?iLXML)ZW*PA_Pdwo^h3tujs+g2@(z zqVy5W5K7}xtV`rNI#6QR375Q+jdR@^qMfFpE$e7dRgdr|oO(klTb7@A+4s^_RkrBEI;?v{hY4!CMjmRBOuM*CnJ%ac zJ*Qr%y{Y81-iX^%+rp?E@pR@wrAYnEhb=6tzNEO8{?Jxmb$o(S1{M|HB>h~kL2s`8IlSeCWF78 zb?;B9y%xI=g?8kL<9u7fuOoy1B5g$i78%I`j-kLXnPUt>j;U=*t}hOBx|{ z!hJX1l7&aoH1r&5`8B{dCnz8pjjs{b9eog)Bct zts}epE!+C6SX=M)VI`A8ub8xq+ba<}-#u3Ls&7>TXB%^~Hy3`s*)F6xH%I)dnU`t@ zedB`^3L7a+`@6-Ngj402Y|$qM1g0XS`mdQT--l=}l{fE9N++$)N7AHqK|<#pcVh3&gd&%nsCo=(s84jk;~+lFt_ufRj!5P0Q} zK87?n68;#NLGeFBJcV~K1z>87@O16w;;ph0h~nZ6H(IQ5kGl78j3R-AgH5^Ow6bhX zHBLCL?o?ho96*t!OF4;b29@!j;Ksu%1TZ~(oAL0?#s@sOW&C@e`CCmjyU!g zQ@<_t>5(+*rSs+>!|?vu?`X?5^8P;ZVx+$DQ_}9fuoI6Dw=xa&BHp5tO{F z%X{C$*NF8&YZ%E|)gZ$0jsHr`eNU0z-kg_+iSX?g?puDhxAUf4@)q;;_dcIz&$#JR zKNQVP7F=@sJ{oCnHFV$7eKCE2>-Ph>w5;I{x6*elpoe3j(xMeLSl8hG%`C4Oru}M= zk(;B?vsoai8-9g6So6;V8p))Opt(ysf2HiD<$-Z1+Hf-|{H&EvQdUt=Z zzC`@Qm~ZB800FCc1>G17qCwbJ#}IdZ-j!PM zp;`GidW*?QHP(@^i4BfMiSoI#G#Ye9aqj7i+iqn3JH)FX{AJUCUy-atAYM;Fu|cb!gKetu>o5E-^v zfa7y7<;p%x+hyC+xh{V)ht9V7CUeZL(oG`&>D{7MGlf4=D#f%eWHbh_Xd5LwQHTgs zB7g&upK>0Vpw-5(!%_CILA#K=GSd|ci6I+BzcUjmWALF!Fv;xKg$xO@WZ(s{(2WEX zN7eP3_>CONj~`>8QO-22N2R1@_JDW{yCCra3(+9p4?R;TrP#33D$VCvH{pr}|I;Z-m zed@g#m6=JelzEdqo|G03UOOD;KVQ zD3^zmojY0RM(JWp?+h&7yJggQ$@|JsfB3|e&CDeKLI`|J6YvoYH50jWd< zcRtO9*(92Zey-IH;=%m^kHD|uTqnPhFZ`CG=6}i@gIG44Wk-NycPEf9OJh!p@Qkgy zBr3@E&_}mI(#7VcTUsik!`6f-oVJl7{^Lf#QVpI&lp_Ru-)uuxGRT9nZHQ9N9xn}n zhz{0oWyyHlE538R`lYq>(Jnu+tjvs_s=MF&M_-L==eII{%?+zvTajygf7j0W6(zHq zN}F_{`!vV9a8XN9|KG;^yLh>Q&2NUah1U!-2@f`ECCM#TD-YH@vdn%~I-Sc-9C`** zRlu2xeOG=Wh}_nNS4^$Zp=&cR>!hDU-@3pcR)#@#&Zg`xwI#>O`+l30Koy5GtFbLt z1(xM~IYf1V#YDPv%9r5n?$&jA`rU_+k*)PzE8{2OyRK<^s>uyH`Y%R3_CZ1s<2C#k zH>>P8={cCmx2k~YZ(=!w#iKi|r{`XAzm(QzO@4P8WIL_BQCL{a$4TYRLNbM6K!{=a z$X^UM4?aENNT3u(N(pmRIyt>UyT0wA=k~DT|IyulqkPb^#|Ha^RSy6d*@!hTB22vA zfGk8x(%Y&>(n#&BGw6hnE4)g+QmkN%S~=Wm#t+!-z15K$xx*m|$-pYWwa1K2tqY(7 zM22{V5PXNV-(Tb3oj`G%HAikmQzzgtwM;d>LqGt&%sOwpbu%9+=y=@u%y(Wx z=ji2aq)!7A4|m*xa(8n@#!t?SbLD-j)jr*KcBkyFM^Z!-B(8E?h&3Wug7t!}%pn!0 z!Q}e2q`6(MX18jdQ=6V&`}`)iY-&q5oH0pLi^i$%^n?!N4WKT2t5hoKp2Zoqp>{|e zcv42rO;|M1J4&G|-_fglO6XdTdCTYf=*rh&Ce)gMD zT~Oe#eCd2t*Y|u__g?NOCw?KfYg%`!qI>G1>ZVHA{%S9=ocg1gwf?eKsuiQh(FHm# zt|;OKB#Ah}ow!hO-5{ODvT5xb)ZRMjNu+SrVYjC_ih0^hh#+E$_}ORSx6kiI9Qp-P zCSp=zl&9I3iaO0L-6mgarDeidE?c87k3TxbIF5$EAzVG`Q2wn0#E9Tg+osv^0mggN zWGkwgOoRf!SAAM1pYt~<*lM^LOJTBNZR8M+SGKErZ~*pKLn=m(^W-;##+gni6U(vYHRRP-f8}kDl z{{@CB0^^xS2gKSb+@_dEwC63mWj{^41@=>ZJUzQS%avVBxesCKgJX=?S4GbYT#;mjiwi>ubS|5qssQK-MAnnG-Kh3HV5i@EX|iHq z9g$jdZeZX2Pl7-!E&rs2G6(zXN z5rvJ(EP1a>F%mE9@THFOd;gKa1U-g)n-Gzkc6rgfcOh00id=$NqRy(mSx;ZN@_WlT zjf7km)y{_S>)$SH0nUEb*1eyoQ1{Arc8cI?v7q`vDE_N6Je$ZKv(9vRw-TAD)lDbg6T zovx2o(cn-VK+~2GFf@{^8^ppm%R|A`XNjUAa%e|<&R(ZTsR>W_1(r5SM(V0O7h>-_ zrEF94s@OR~n48;H@$K!5!<@g{^Sj-B_XBpllw#qqlv`I{r%}rv(c#3ryDv2|Q!@qM zRdH1-JWFuW3f9MaVSH1c!#!Z)g*1}hclW-;k$2tEVxC#C}etoEdTb=m!gl;$KrZ5zf zODxvL{)LzQRB}d%oW-yFyrP{_+o6Sfm+7{>AGr(`C;Zo`v7?70#lPaeV|`H_WS4&_ z`LT#wY1(jn7M|V^dEa*4zHrBONb+O3Pm%0qe!ZvD2?T))S->H7qM#xFW4Q25kJ-#D zeGkDm!I-nO+2%R2^O;4LjZ)_j9D#KTL|nLS>6lk}DU7H<)KEnR;kT#dTn@NsKzkiV z*oO0SnwJ(AzPEQYKfxiZzoRt{in>E&`Z z{74gWK6bRu7HyGrs~{*dF*D&OqSI`>yun=6D!*Z zSsa8Q?1Wm~|ZqFK=G{LA^4Ff3>h;Xrt!sfccjBY_wy~*hnLV*NE!kjraV3 zMgL;;)@LPi{JYui!egfi@>M_XHZ8=(=8PqC-kY-tx@5mg0oN#A0)qEN3?=l<*={YN ztiX29{o?n!tet1C!cv>e2fhzk$8k^G&|?2MUbtn_h!xq>$*8%qbT(677>u88Y7Qu| z?oChS6=?IWXv4ZQp`X5*wLs&)NcH9=}B8fHLBsus|5!k|98& zN!w~WC=38t?403gvn@t+WX#u%-~KTVk;L_pCEW@bIw=@IL0L1i8I6Ea(S>0HciOIG zhzOPKwcZ&7#IymQ_&I-k_7`Zle!o=V>rz`5TsOs`93PoNWdHfb={f%uwq}*q!aniW zrFB)@+4Y~DtEFT=mS*D{z0T@K{0yxe!(*r4iG3LwI@yf3a=gEJlC^UZDc5@u+kw2H zr4GJWVvN4oIV@#*XI0KRGwZHKXBBYz{4zP+PX9FVS%m0|xC|3tCl9rSm?MpYUkfjN z%YFSYU6qs~_DSodBfOC|Z$D6vC@w8zMuZW+xhTm{GCOTCU#tqNMw0fY;N0#jWw`FU zhHkkjW}%p%Rks;z`Ij)mN;M`I3FOT#_D3Be=Dg)mYZeA^-{>5QsH-D-9R{Y(>h1~( zdc!Mlkw^SKB04e%MK`Nz{>kO@tnW8b)9^%HP2h)l_vtcbm}r99>$F+>tj1kJ&xaJwkAX$4~+-ClqPB>_BNU2&u?y^GV!%Y*Rh0|He>{&F+~B(W|7L}bwfN6 zFkE)-AHh~xq++t0by#Baf+T(z6?r>v*q=zz|4gjCV0E2n6S_IEIiAgI)?+<-Bcf$R z9G@E%Z}a)xCFwaGjp*4h%do*`gPV7g_#bR8dM~rSY)skpI(!^0If)UjEM4^|boMMs z8lF-8M1PqQuT`q>wACr(+0j@=3$|zPa6@z7&QSkR`tAF?&WYyQxt~)Nhvnqy48B(6 z$g_i&2XRlfisMvoKa~7fLa#@jad-5WB&Dgra^gQ`I+n7pBs06%Nq>iRd8XjfdU)GM z7uGqyf4gti>>l?WaROc|Wnxey9+fFRk+)x1#%(Fo0j+qflz@aFRJe-s z;OXnj`_d1pF3aB+2%zxYa7g-qN6ZR^!Ri8xgC0&i4lcW4jJW~F=dCb)d#0-+4F_>M z1K!t(PhINk2NOGYmqWKdk3|~~-YW`M8frn>3;F$kgeFYG7G}lA0P;Ukm4E&r=R;Hl z5md2BxbaT>`^@{0`?vR>?%&-9-1~!{j|77)-^_OhU}OMx7P#@oRU3-Y4?~o?G$(sp z%3|O~Vb>#Mof}2S_nSQ>1rV8I+n1; zp#(SUJO6e8>yaAX!qXDoJ`4i4>wT;3qcS8Ib1&;u=!;#?)i>2yRQF5`)6`GAM8A)q z3wti@>S1~B=WsjU*SIrRow#G zI7|M|W+Ze^DUUbMsrli)C@=z0uSFZJ$~6zYx9{e|+E20&xB-B&5$KYe(0Ki3S2B9D zpzGSWxj92J4kBX6VQ3UGm`J*;i56K?fZ_mvp-L7sN@=fTo1!%Ycx>>F3O_)-SeY-h zCz%?Ts#E-yOcZOgnNR9^DD$;r?S-(_{4w%j%(bw;i0Ijc_eF-mkZkvnp4%$RVwKZu zN|xACJ&gq|YP~%svene9X86#fU-mh+iNT7;N0l z7CE{dH{=+m?G4|mX_>-A`38!-R3;iu{d3!|*SEx882n#ZLRf~R(73sAK3uBX4vD|3 zIB5RpMb=>Ku)KY|y4G+my+yIObfL6WM*hsi=RED~x27$(?@FJC-v`+VgM38_WY^q- z0>5#09leyA=V*sV>f~0iDy4-hK>I~?VF8-Zjee)Bm&^-=QjzLMyJHEn8FfBwTB@Q% zVilS9gZb8mTGiPi7#`(V{bQ0`KlV0V___UevV9R-9?D44R^UQVKlz4k* zw3Ag+8v(zLyIM07i)H4`L0|8~(tG{6lvgpnANNnstc3c?SpJ^?^$`m0MVfpr)d(?r zCJ}esZUMhj003Mh*9suS)r3~IYo?M?Nl}(p;|2sP(8?;366|#hAncx*xSvjrXK!~=lpA*zyZuI<8PDqCH)oW#?;~&1Ut;~%`vAE|CiDI_-XWRg zA+L_Sql(lrH+qGe%wgMQKg02WZhV1TE=C9qJX#RvfKEh@70 zO8B}H0F6fMA7xr71p?5&Qg^;#6vg9K}za(LV1wahGDvdLZ1k#{~`Ex1^1@s36 znBOB;yM04rmF(Ew>JWU5=kA%b|(KE)JDJ4pvSXi^Rn~ z$sy^$#mq94$stB+YcFxgCA$fL;i9Jkpg8inbLJY-Wp@lzlM34@+Q35sQ@NMFPd!|s zifH(-bY7#Pi=?LCsU0z1(-pnr=hp$%G0}DFZS8{TY{hX#R|1*0vlA#Y%}j~Ko!J`G zv1RZ|FLYY6j9Prmko-M+L_Opb&|O^s2B19fV3zrQhwrA1f9os!oHid9hxf4^LsB4* zG9A-Bn53Fsn>ZggVCj)afa&Xl7h|LFes{+Xv$d$a>fS0Fb-!4PZ`d zHUe;vE&L61m4Hhk0lpgTBLw&WV11p|Nd|==f_S<%3~a;u#%Qf((Wtd9GczUzM>V@? z=e3;LRM+&O@mxlIh23NO=KuUOzcv5Ki*~l(`}t?wwco^Jec0Y;)Bf<9wS1PnzGPV_ z^wHncSsde}<1L2vRF#g7z-#}?-Rp2qGII9tliGQcuMV3z312WX z$>mN9C6scWQauB)-bdDS7BtoAooFp5m!H?#^SYiX3yRU=ggF;LbpcG*H0ge!lbk81 ze!se!)B^yjIm44#Uq3Bl-xSp9ta6^~XCQN+NDV{vI$T^bF+1zYOzk9ZDlcbYNZ7-w zsmYX-Tws0-a~Xnw(%TfQ!qUZ>hsF%HVl;u zemF^C5{hX=&56bTRI0lNioR<%C5Ee?GAh%RWIV^FABJW!^B>o{YcSNa$6%78C!4-^ zK_3R9Gnswp1Z~7*PTjaPLfB$DxN+032oP6G*n;c$o(&NIP@uj6k^sO~Dg@Y%GC5_+ z2jeXk^BMq%F95h#MLLXJUjw9CxCIuX0}DWyWlFaV&cC8-Ud+Hlwb+#+D5oSh-Vgv@ z+H5NZ%g+Qbmo{q=fc!wx!+iH5Gn4Woar)-t(mvXbXsvCB23^+`V9O(W3yuW;^`}aN}<1dCYK3m?JOw^;jarg1z(~w^z7TVR>F{s2|#_#g~1OVv^G~M?~}wQ$}GnT(bTBD87I303wJ7RvG&P=jN&4v)9apNs84o5 zjECZE-;D%Ab(JV(E3@~1x|rl#_43fyOf0{VxSv;D0oN`|pm8%)e=3zRmE#sG}2i+-50zkjL0V?5q5SwONFq)$@*Fa}6)0#lk zRM{!%U@_n(F#;Tw3TxqE7K{vo1!e(+-GGd>fB<9=D_{t0NrdM9TokYZ$O1t73l#vs z4R8bn`rdD+`XFnbiS&~M_`n3#PGqeDBp(gHdh4a)Gdfts6Vx=@XxlL&+D3zpnq+21 z0({#_{ zu1ikBo|Za0q7?_z8=%Im-Me9e0}+{16jimmJ})Km^36UJ8SICnpT)(M8xXLG=?BMs z%k6iPTZ<;1J&-vM%%?zf)y(+puYxwl3%J>$GP_JcWj*+vE6l5#f_@R11B1Z{owc3h zp9bbsC-g!6uZW7O27kCt8nWgYGL!1;1kqg6T_l6v>MoXMIZ0m47PFPs6l$6wYtJbl zhGhiykO>CR+31r1ASIpL{77#=wmx5bFhCpF@VF1F=0WKSjPopSl7M&}Apr)#t%x8Y zS}|N`@|8tM^sBTDTQJRi*2{Dn{Akxti44_eG`0L!j-X$ji5yoNEP@Ksp%d9h8Xy1| z?zi1v3|WlpGyC-I@NGn`=GvfxU1o;k%fy4jCU*VQX_{OaSYz{U-trm?-Co1RbJg4?q0&6R*tr_QA(OKja?+vz0PeNvM5|-U&&NZ2>I!r5C(Br%boa-^sR5le4Nhal{uIDY2=tK4==%*Iko%@`uofG_DI>{pQ(9`nT*(G|W z8)e>^?TUA2x&fo7Hrc~>(Z@?s0RKEtUDPh{3JTAy8>RvBIwS>A_xR9rR3J0f$E>>r znxtXfou`3rfb439dc41%`V@L_((?>g{=Q|$-GUuWf_3hpa_Hv0RB#iFo5ciCm+>s~8d(XxPnRa{-^SJ*z zDyPSbL{nZsSiAG2^%BB0*$6ng^+O;JA)bP4dZK#y7vO8nFFI!mC8GwzdZ+O%cM-q^q1^ibFyJVWY#!ZQ_Ah#>^mf%x;Xnf`O%w@x6&pJv^GdK z+F!FvlB2FOuSn~ylf~#2yY@bqn*`z)(Dbgp@`v3s3O@?@n7*Ipp39qYF=yQkYULrp zk5l+;3IWCcpwUE4W%b>OlXc00Q$SJCoiS^cAVYDg!B^k@_xlN#MXNO<{s-uqbwU2B z%-0hmV?N{~VUG8PFE08eLUQvd`4xBvhE0000ITL1tC0000=l`=gD|9Ssd z|2_Xlez=UI2~q)oMr2GTlmfu=7Fo|(MbC{;7PirjwzaUfjn-vm60m6=^+wC%BrbMW zA2nWHjqbibQpf+z$-cC~dUtfNJma&2|H5XoH_xB1-F^AiB{#)MeE-&jG^g)L$lp@D`?Wm?0LAKQ56Hvi~^ z$^zbQiXk3ahm){2t;)&iq5fn!9-iJk)xhLr0i+t{neJKU$xNu3n%Y@Y?0%uM2LW}R zeT*ysr9ra*#sCK6G>+KQE>#Vg)@I#* zGaS4(S=!xSI~MceO%&!BlNm*%daV1|#RY<^Jlo~#u#Y3u%Mv3c9EJFxA2L!Zxp4P& zt6S=NBm46IeiM0_+|sztWnD%QkJh3Hw)6id4& zDk^_oW&wAW5s*m_5m{{$o4TJqdW$UBb5s$KHO{1`-C-xImu79Uvj5w#PqnYt(y|)!jVor0APbjfRr8J${vz|A!{lEBLHFn z81frrGBKesq64fVqJr$dHxmK}ju9?F|3&w=xZkuF1eE2-n+L*{0r?vW5=b6i$22u2 zZ~&l?Sz?NpQz!uMJsVGBoB;bDW#J4bA;aaRRUhL%jwx(#pHsGn z&i;ct$%ODxET%GtlkvHc|75n!t2Id3=Z=o`wol$H0fu%RaHXjr#-M0Z zI20%w$gYf;I4Rl@KypD4hjENjG{lO5h>BvsaA<)D6ab$9@dzZb#pNR~!T{g~ECMRP zEimDL1l(L*Q!YtG+)9r=?D@_~(N8d&7s7cD=DqUmH0jH)`xpj>L~tX>)CNhH7(fA@ zh8&lga%BRjnY1B$Y0*$_h5&Ukxot1-JYlEy13qr-KHAog`cO4xVv?B&0Dv-4U!}DM zOC`aF(c8n**NWZKhF!wYdtx+xeB778;?~b^wOIXxy?AOdl5LKs(m~I?8L@cstq=cS z%fruqUw4PafmM0lXK0Jcd$;rKpSLH!pP#?ttLW+J$;y+^qd2+~D~<}<8ngy+LRyxy zrdJiRs4T_8Q5@Y_WM#>Vv!;hiD1|{Ng+VBw9mUxW!XOrP6sJyQ;Q5+SDgHRyL@?tSsmoSJ`03%hSTUUvq)u Date: Sun, 16 Nov 2025 08:06:17 -0400 Subject: [PATCH 39/65] Particles with shaders now account for different BlendStates * particlesToDraw_CustomShader now separates particle collections based on their chosen BlendState --- Particles/GeneralParticleHandler.cs | 86 +++++++++++++++-------------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/Particles/GeneralParticleHandler.cs b/Particles/GeneralParticleHandler.cs index fe209f6950..4cf2323c8e 100644 --- a/Particles/GeneralParticleHandler.cs +++ b/Particles/GeneralParticleHandler.cs @@ -60,7 +60,7 @@ namespace CalamityMod.Particles // Collections for correctly organizing active prticles for drawing. private static Dictionary> particlesToDraw; private static Dictionary> particlesToDraw_Pixelated; - private static Dictionary> particlesToDraw_CustomShader; + private static Dictionary>> particlesToDraw_CustomShader; #endregion #region Loading and Unloading @@ -151,7 +151,7 @@ namespace CalamityMod.Particles particle.DrawLayer = manualDrawLayerOverride.Value; activeParticles.Add(particle); - AddToAssociatedDrawCollection(particle); + ReturnAssociatedDrawCollection(particle).Add(particle); particle.Type = particleIDsByTypes[particle.GetType()]; } @@ -280,7 +280,7 @@ namespace CalamityMod.Particles { if ((particle.Time >= particle.Lifetime && particle.SetLifetime) || particlesToKill.Contains(particle)) { - RemoveFromAssociatedDrawCollection(particle); + ReturnAssociatedDrawCollection(particle).Remove(particle); return true; } return false; @@ -385,32 +385,56 @@ namespace CalamityMod.Particles private static void DrawParticlesWithShaders(GeneralDrawLayer drawLayer) { - foreach (var keyValuePair in particlesToDraw_CustomShader) + foreach (var shaderDrawCollectionPair in particlesToDraw_CustomShader) { - // If there's nothing to be drawn, remove the effect from the dictionary and return. - if (keyValuePair.Value.Count == 0) + foreach (var blendStateParticleListPair in shaderDrawCollectionPair.Value) { - particlesToDraw_CustomShader.Remove(keyValuePair.Key); - return; + 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(); } - - Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullNone, keyValuePair.Key, Main.GameViewMatrix.TransformationMatrix); - - var particlesAtDrawLayer = keyValuePair.Value.Where(p => p.DrawLayer == drawLayer); - foreach (Particle particle in particlesAtDrawLayer) - { - particle.PrepareCustomShader(keyValuePair.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. - if (particle.Pixelate) + else if (particle.Pixelate) { if (particle.UseAdditiveBlend) { @@ -454,27 +478,5 @@ namespace CalamityMod.Particles } } } - - private static void AddToAssociatedDrawCollection(Particle particle) - { - if (particle.CustomShader != null) - { - if (!particlesToDraw_CustomShader.ContainsKey(particle.CustomShader)) - particlesToDraw_CustomShader[particle.CustomShader] = []; - particlesToDraw_CustomShader[particle.CustomShader].Add(particle); - } - else - { - ReturnAssociatedDrawCollection(particle).Add(particle); - } - } - - private static void RemoveFromAssociatedDrawCollection(Particle particle) - { - if (particle.CustomShader != null) - particlesToDraw_CustomShader[particle.CustomShader].Remove(particle); - else - ReturnAssociatedDrawCollection(particle).Remove(particle); - } } } From e690524a6a07dc9b23e96593c59b7c88fbfc365f Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Sun, 16 Nov 2025 11:14:18 -0500 Subject: [PATCH 40/65] Renamed "DevPaintings" folder to "Paintings" And moved both Calamity Canvas paintings to that folder --- Items/CalamityGlobalItemLoot.cs | 2 +- .../{ => Paintings}/CalamityCanvas.png | Bin .../{ => Paintings}/CalamityCanvas2023.cs | 6 +- .../{ => Paintings}/CalamityCanvas2024.cs | 6 +- .../ThankYouPainting.cs | 4 +- .../ThankYouPainting.png | Bin Items/TreasureBags/AquaticScourgeBag.cs | 2 +- Items/TreasureBags/AstrumAureusBag.cs | 2 +- Items/TreasureBags/AstrumDeusBag.cs | 2 +- Items/TreasureBags/BrimstoneElementalBag.cs | 2 +- Items/TreasureBags/CalamitasCloneBag.cs | 2 +- Items/TreasureBags/CalamitasCoffer.cs | 2 +- Items/TreasureBags/CeaselessVoidBag.cs | 2 +- Items/TreasureBags/CrabulonBag.cs | 2 +- Items/TreasureBags/CryogenBag.cs | 2 +- Items/TreasureBags/DesertScourgeBag.cs | 2 +- Items/TreasureBags/DevourerofGodsBag.cs | 2 +- Items/TreasureBags/DraedonBag.cs | 2 +- Items/TreasureBags/DragonfollyBag.cs | 2 +- Items/TreasureBags/HiveMindBag.cs | 2 +- Items/TreasureBags/LeviathanBag.cs | 2 +- Items/TreasureBags/OldDukeBag.cs | 2 +- Items/TreasureBags/PerforatorBag.cs | 2 +- Items/TreasureBags/PlaguebringerGoliathBag.cs | 2 +- Items/TreasureBags/PolterghastBag.cs | 2 +- Items/TreasureBags/ProvidenceBag.cs | 2 +- Items/TreasureBags/RavagerBag.cs | 2 +- Items/TreasureBags/SignusBag.cs | 2 +- Items/TreasureBags/SlimeGodBag.cs | 2 +- Items/TreasureBags/StormWeaverBag.cs | 2 +- Items/TreasureBags/YharonBag.cs | 2 +- ModSupport/WeakReferenceSupport.cs | 2 +- NPCs/AquaticScourge/AquaticScourgeHead.cs | 2 +- NPCs/AstrumAureus/AstrumAureus.cs | 2 +- NPCs/AstrumDeus/AstrumDeusHead.cs | 2 +- NPCs/BrimstoneElemental/BrimstoneElemental.cs | 2 +- NPCs/Bumblebirb/Dragonfolly.cs | 2 +- NPCs/CalClone/CalamitasClone.cs | 2 +- NPCs/CalamityGlobalNPCLoot.cs | 2 +- NPCs/CeaselessVoid/CeaselessVoid.cs | 2 +- NPCs/Crabulon/Crabulon.cs | 2 +- NPCs/Cryogen/Cryogen.cs | 2 +- NPCs/DesertScourge/DesertScourgeHead.cs | 2 +- NPCs/DevourerofGods/DevourerofGodsHead.cs | 2 +- NPCs/ExoMechs/Ares/AresBody.cs | 2 +- NPCs/HiveMind/HiveMind.cs | 2 +- NPCs/Leviathan/Leviathan.cs | 2 +- NPCs/OldDuke/OldDuke.cs | 2 +- NPCs/Perforator/PerforatorHive.cs | 2 +- .../PlaguebringerGoliath.cs | 2 +- NPCs/Polterghast/Polterghast.cs | 2 +- NPCs/PrimordialWyrm/PrimordialWyrmHead.cs | 2 +- .../ProfanedGuardianCommander.cs | 2 +- NPCs/Providence/Providence.cs | 2 +- NPCs/Ravager/RavagerBody.cs | 2 +- NPCs/Signus/Signus.cs | 2 +- NPCs/SlimeGod/SlimeGodCore.cs | 2 +- NPCs/StormWeaver/StormWeaverHead.cs | 2 +- NPCs/SupremeCalamitas/SupremeCalamitas.cs | 2 +- NPCs/Yharon/Yharon.cs | 2 +- TileEntities/TECanvasPainting.cs | 2 +- .../{ => Paintings}/CalamityCanvas2023Tile.cs | 92 +++++++++--------- .../CalamityCanvas2023Tile.png | Bin .../{ => Paintings}/CalamityCanvas2024Tile.cs | 88 ++++++++--------- .../CalamityCanvas2024Tile.png | Bin .../{ => Paintings}/CalamityCanvasBorder.png | Bin .../{ => Paintings}/CalamityCanvasCorner.png | Bin .../ThankYouPaintingTile.cs | 5 +- .../ThankYouPaintingTile.png | Bin UI/CanvasPaintingUI.cs | 4 +- 70 files changed, 158 insertions(+), 159 deletions(-) rename Items/Placeables/Furniture/{ => Paintings}/CalamityCanvas.png (100%) rename Items/Placeables/Furniture/{ => Paintings}/CalamityCanvas2023.cs (77%) rename Items/Placeables/Furniture/{ => Paintings}/CalamityCanvas2024.cs (77%) rename Items/Placeables/Furniture/{DevPaintings => Paintings}/ThankYouPainting.cs (97%) rename Items/Placeables/Furniture/{DevPaintings => Paintings}/ThankYouPainting.png (100%) rename Tiles/Furniture/{ => Paintings}/CalamityCanvas2023Tile.cs (73%) rename Tiles/Furniture/{ => Paintings}/CalamityCanvas2023Tile.png (100%) rename Tiles/Furniture/{ => Paintings}/CalamityCanvas2024Tile.cs (73%) rename Tiles/Furniture/{ => Paintings}/CalamityCanvas2024Tile.png (100%) rename Tiles/Furniture/{ => Paintings}/CalamityCanvasBorder.png (100%) rename Tiles/Furniture/{ => Paintings}/CalamityCanvasCorner.png (100%) rename Tiles/Furniture/{DevPaintings => Paintings}/ThankYouPaintingTile.cs (88%) rename Tiles/Furniture/{DevPaintings => Paintings}/ThankYouPaintingTile.png (100%) diff --git a/Items/CalamityGlobalItemLoot.cs b/Items/CalamityGlobalItemLoot.cs index 92b46785e8..2c47fcde82 100644 --- a/Items/CalamityGlobalItemLoot.cs +++ b/Items/CalamityGlobalItemLoot.cs @@ -4,7 +4,7 @@ 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.Furniture.Paintings; using CalamityMod.Items.Placeables.Ores; using CalamityMod.Items.Potions; using CalamityMod.Items.Weapons.Melee; 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/DevPaintings/ThankYouPainting.cs b/Items/Placeables/Furniture/Paintings/ThankYouPainting.cs similarity index 97% rename from Items/Placeables/Furniture/DevPaintings/ThankYouPainting.cs rename to Items/Placeables/Furniture/Paintings/ThankYouPainting.cs index d579d2dfa2..659e6039de 100644 --- a/Items/Placeables/Furniture/DevPaintings/ThankYouPainting.cs +++ b/Items/Placeables/Furniture/Paintings/ThankYouPainting.cs @@ -1,11 +1,11 @@ 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; -namespace CalamityMod.Items.Placeables.Furniture.DevPaintings +namespace CalamityMod.Items.Placeables.Furniture.Paintings { public class ThankYouPainting : ModItem, ILocalizedModType { diff --git a/Items/Placeables/Furniture/DevPaintings/ThankYouPainting.png b/Items/Placeables/Furniture/Paintings/ThankYouPainting.png similarity index 100% rename from Items/Placeables/Furniture/DevPaintings/ThankYouPainting.png rename to Items/Placeables/Furniture/Paintings/ThankYouPainting.png diff --git a/Items/TreasureBags/AquaticScourgeBag.cs b/Items/TreasureBags/AquaticScourgeBag.cs index 24078e605a..6059a40ce3 100644 --- a/Items/TreasureBags/AquaticScourgeBag.cs +++ b/Items/TreasureBags/AquaticScourgeBag.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.TreasureBags.MiscGrabBags; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; 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 index b56c93b350..9415993721 100644 --- a/Items/TreasureBags/BrimstoneElementalBag.cs +++ b/Items/TreasureBags/BrimstoneElementalBag.cs @@ -3,7 +3,7 @@ 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.Placeables.Furniture.Paintings; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; diff --git a/Items/TreasureBags/CalamitasCloneBag.cs b/Items/TreasureBags/CalamitasCloneBag.cs index 492019a90b..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; 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 cabe86cc17..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; 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 477e33e006..dfcf7d98dd 100644 --- a/Items/TreasureBags/DesertScourgeBag.cs +++ b/Items/TreasureBags/DesertScourgeBag.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.TreasureBags.MiscGrabBags; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; diff --git a/Items/TreasureBags/DevourerofGodsBag.cs b/Items/TreasureBags/DevourerofGodsBag.cs index f9da79f407..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; 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 8a516b2381..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; diff --git a/Items/TreasureBags/HiveMindBag.cs b/Items/TreasureBags/HiveMindBag.cs index bff6d42bfc..15ffc7f3d7 100644 --- a/Items/TreasureBags/HiveMindBag.cs +++ b/Items/TreasureBags/HiveMindBag.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/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/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 d1a2b58520..51acb197a5 100644 --- a/Items/TreasureBags/PerforatorBag.cs +++ b/Items/TreasureBags/PerforatorBag.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/PlaguebringerGoliathBag.cs b/Items/TreasureBags/PlaguebringerGoliathBag.cs index c4f16b5b5c..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; diff --git a/Items/TreasureBags/PolterghastBag.cs b/Items/TreasureBags/PolterghastBag.cs index e52a0d01c2..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; diff --git a/Items/TreasureBags/ProvidenceBag.cs b/Items/TreasureBags/ProvidenceBag.cs index 807ca04a4b..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; diff --git a/Items/TreasureBags/RavagerBag.cs b/Items/TreasureBags/RavagerBag.cs index e6159c6cb7..ea20f25040 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; diff --git a/Items/TreasureBags/SignusBag.cs b/Items/TreasureBags/SignusBag.cs index 90fc769aec..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; 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 2e114ab6e0..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; diff --git a/Items/TreasureBags/YharonBag.cs b/Items/TreasureBags/YharonBag.cs index 60ec10a868..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; diff --git a/ModSupport/WeakReferenceSupport.cs b/ModSupport/WeakReferenceSupport.cs index b117ab35fe..0131304d21 100644 --- a/ModSupport/WeakReferenceSupport.cs +++ b/ModSupport/WeakReferenceSupport.cs @@ -9,7 +9,7 @@ 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.SummonItems; using CalamityMod.Items.SummonItems.Invasion; diff --git a/NPCs/AquaticScourge/AquaticScourgeHead.cs b/NPCs/AquaticScourge/AquaticScourgeHead.cs index 59e29fc482..90ef06dcaa 100644 --- a/NPCs/AquaticScourge/AquaticScourgeHead.cs +++ b/NPCs/AquaticScourge/AquaticScourgeHead.cs @@ -8,7 +8,7 @@ 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; diff --git a/NPCs/AstrumAureus/AstrumAureus.cs b/NPCs/AstrumAureus/AstrumAureus.cs index 49002a0458..0db295170e 100644 --- a/NPCs/AstrumAureus/AstrumAureus.cs +++ b/NPCs/AstrumAureus/AstrumAureus.cs @@ -10,7 +10,7 @@ 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; diff --git a/NPCs/AstrumDeus/AstrumDeusHead.cs b/NPCs/AstrumDeus/AstrumDeusHead.cs index ff45853c87..e6a3b2f9fb 100644 --- a/NPCs/AstrumDeus/AstrumDeusHead.cs +++ b/NPCs/AstrumDeus/AstrumDeusHead.cs @@ -10,7 +10,7 @@ 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; diff --git a/NPCs/BrimstoneElemental/BrimstoneElemental.cs b/NPCs/BrimstoneElemental/BrimstoneElemental.cs index 306bc4ec15..d98501fe87 100644 --- a/NPCs/BrimstoneElemental/BrimstoneElemental.cs +++ b/NPCs/BrimstoneElemental/BrimstoneElemental.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.TreasureBags; using CalamityMod.Items.Weapons.Magic; diff --git a/NPCs/Bumblebirb/Dragonfolly.cs b/NPCs/Bumblebirb/Dragonfolly.cs index 7a0926637d..b706d67a21 100644 --- a/NPCs/Bumblebirb/Dragonfolly.cs +++ b/NPCs/Bumblebirb/Dragonfolly.cs @@ -9,7 +9,7 @@ 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.TreasureBags; diff --git a/NPCs/CalClone/CalamitasClone.cs b/NPCs/CalClone/CalamitasClone.cs index c7d6141f08..6f8ba0ac36 100644 --- a/NPCs/CalClone/CalamitasClone.cs +++ b/NPCs/CalClone/CalamitasClone.cs @@ -9,7 +9,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.Weapons.Magic; diff --git a/NPCs/CalamityGlobalNPCLoot.cs b/NPCs/CalamityGlobalNPCLoot.cs index f72367a5fa..4f0390cbe5 100644 --- a/NPCs/CalamityGlobalNPCLoot.cs +++ b/NPCs/CalamityGlobalNPCLoot.cs @@ -10,7 +10,7 @@ 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.Furniture.Paintings; using CalamityMod.Items.Potions; using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Items.SummonItems; diff --git a/NPCs/CeaselessVoid/CeaselessVoid.cs b/NPCs/CeaselessVoid/CeaselessVoid.cs index 6554662478..7f21657f82 100644 --- a/NPCs/CeaselessVoid/CeaselessVoid.cs +++ b/NPCs/CeaselessVoid/CeaselessVoid.cs @@ -6,7 +6,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; diff --git a/NPCs/Crabulon/Crabulon.cs b/NPCs/Crabulon/Crabulon.cs index 3874ca553a..0e5f0a6128 100644 --- a/NPCs/Crabulon/Crabulon.cs +++ b/NPCs/Crabulon/Crabulon.cs @@ -6,7 +6,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.Alcohol; using CalamityMod.Items.TreasureBags; diff --git a/NPCs/Cryogen/Cryogen.cs b/NPCs/Cryogen/Cryogen.cs index 854509a963..d061adf8e5 100644 --- a/NPCs/Cryogen/Cryogen.cs +++ b/NPCs/Cryogen/Cryogen.cs @@ -10,7 +10,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.Weapons.Magic; diff --git a/NPCs/DesertScourge/DesertScourgeHead.cs b/NPCs/DesertScourge/DesertScourgeHead.cs index a541ffc02a..4bbc6757cd 100644 --- a/NPCs/DesertScourge/DesertScourgeHead.cs +++ b/NPCs/DesertScourge/DesertScourgeHead.cs @@ -7,7 +7,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; diff --git a/NPCs/DevourerofGods/DevourerofGodsHead.cs b/NPCs/DevourerofGods/DevourerofGodsHead.cs index c7ec46e223..dea7b7c164 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHead.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHead.cs @@ -15,7 +15,7 @@ using CalamityMod.Items.LoreItems; using CalamityMod.Items.Materials; 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.FurnitureCosmilite; using CalamityMod.Items.Potions; diff --git a/NPCs/ExoMechs/Ares/AresBody.cs b/NPCs/ExoMechs/Ares/AresBody.cs index 3ed420b771..b0b3000a31 100644 --- a/NPCs/ExoMechs/Ares/AresBody.cs +++ b/NPCs/ExoMechs/Ares/AresBody.cs @@ -10,7 +10,7 @@ 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.TreasureBags; diff --git a/NPCs/HiveMind/HiveMind.cs b/NPCs/HiveMind/HiveMind.cs index 9edaf8464d..9d61e78cf9 100644 --- a/NPCs/HiveMind/HiveMind.cs +++ b/NPCs/HiveMind/HiveMind.cs @@ -7,7 +7,7 @@ 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; diff --git a/NPCs/Leviathan/Leviathan.cs b/NPCs/Leviathan/Leviathan.cs index d5ab8d06df..b35a1dbe4b 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; diff --git a/NPCs/OldDuke/OldDuke.cs b/NPCs/OldDuke/OldDuke.cs index 60f3d1a06e..038a7dd847 100644 --- a/NPCs/OldDuke/OldDuke.cs +++ b/NPCs/OldDuke/OldDuke.cs @@ -9,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; diff --git a/NPCs/Perforator/PerforatorHive.cs b/NPCs/Perforator/PerforatorHive.cs index e29450ac3b..30856c4c53 100644 --- a/NPCs/Perforator/PerforatorHive.cs +++ b/NPCs/Perforator/PerforatorHive.cs @@ -10,7 +10,7 @@ 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; diff --git a/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs b/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs index 5c1d720ec7..5056b4f28b 100644 --- a/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs +++ b/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs @@ -10,7 +10,7 @@ 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; diff --git a/NPCs/Polterghast/Polterghast.cs b/NPCs/Polterghast/Polterghast.cs index e55f277504..b9c2689631 100644 --- a/NPCs/Polterghast/Polterghast.cs +++ b/NPCs/Polterghast/Polterghast.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; diff --git a/NPCs/PrimordialWyrm/PrimordialWyrmHead.cs b/NPCs/PrimordialWyrm/PrimordialWyrmHead.cs index 8786ae0910..58f13e5472 100644 --- a/NPCs/PrimordialWyrm/PrimordialWyrmHead.cs +++ b/NPCs/PrimordialWyrm/PrimordialWyrmHead.cs @@ -6,7 +6,7 @@ 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; diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs b/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs index c18317d5c6..74d2195fcc 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianCommander.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.SummonItems; using CalamityMod.Items.Weapons.Typeless; diff --git a/NPCs/Providence/Providence.cs b/NPCs/Providence/Providence.cs index 5f0aeeda42..fe971ce389 100644 --- a/NPCs/Providence/Providence.cs +++ b/NPCs/Providence/Providence.cs @@ -14,7 +14,7 @@ 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.SummonItems; diff --git a/NPCs/Ravager/RavagerBody.cs b/NPCs/Ravager/RavagerBody.cs index 1807ed445f..6eea24650b 100644 --- a/NPCs/Ravager/RavagerBody.cs +++ b/NPCs/Ravager/RavagerBody.cs @@ -7,7 +7,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; diff --git a/NPCs/Signus/Signus.cs b/NPCs/Signus/Signus.cs index b1eb2b27f6..1b1c79e4a6 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; diff --git a/NPCs/SlimeGod/SlimeGodCore.cs b/NPCs/SlimeGod/SlimeGodCore.cs index 636944c343..36c88d757b 100644 --- a/NPCs/SlimeGod/SlimeGodCore.cs +++ b/NPCs/SlimeGod/SlimeGodCore.cs @@ -9,7 +9,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; diff --git a/NPCs/StormWeaver/StormWeaverHead.cs b/NPCs/StormWeaver/StormWeaverHead.cs index 1b104433df..89ec7bec83 100644 --- a/NPCs/StormWeaver/StormWeaverHead.cs +++ b/NPCs/StormWeaver/StormWeaverHead.cs @@ -8,7 +8,7 @@ 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; diff --git a/NPCs/SupremeCalamitas/SupremeCalamitas.cs b/NPCs/SupremeCalamitas/SupremeCalamitas.cs index 8d56f1e6a6..2f169574ce 100644 --- a/NPCs/SupremeCalamitas/SupremeCalamitas.cs +++ b/NPCs/SupremeCalamitas/SupremeCalamitas.cs @@ -13,7 +13,7 @@ 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; diff --git a/NPCs/Yharon/Yharon.cs b/NPCs/Yharon/Yharon.cs index 30eeb8eb29..67321609d4 100644 --- a/NPCs/Yharon/Yharon.cs +++ b/NPCs/Yharon/Yharon.cs @@ -9,7 +9,7 @@ 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; diff --git a/TileEntities/TECanvasPainting.cs b/TileEntities/TECanvasPainting.cs index da548665ae..6075654321 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; diff --git a/Tiles/Furniture/CalamityCanvas2023Tile.cs b/Tiles/Furniture/Paintings/CalamityCanvas2023Tile.cs similarity index 73% rename from Tiles/Furniture/CalamityCanvas2023Tile.cs rename to Tiles/Furniture/Paintings/CalamityCanvas2023Tile.cs index a09418f8e9..fdc7050e6a 100644 --- a/Tiles/Furniture/CalamityCanvas2023Tile.cs +++ b/Tiles/Furniture/Paintings/CalamityCanvas2023Tile.cs @@ -12,7 +12,7 @@ using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; -namespace CalamityMod.Tiles.Furniture +namespace CalamityMod.Tiles.Furniture.Paintings { public class CalamityCanvas2023Tile : ModTile { @@ -21,8 +21,8 @@ namespace CalamityMod.Tiles.Furniture public override void Load() { - border = ModContent.Request("CalamityMod/Tiles/Furniture/CalamityCanvasBorder"); - corner = ModContent.Request("CalamityMod/Tiles/Furniture/CalamityCanvasCorner"); + border = ModContent.Request("CalamityMod/Tiles/Furniture/Paintings/CalamityCanvasBorder"); + corner = ModContent.Request("CalamityMod/Tiles/Furniture/Paintings/CalamityCanvasCorner"); } public override void SetStaticDefaults() @@ -53,7 +53,7 @@ namespace CalamityMod.Tiles.Furniture public override bool RightClick(int i, int j) { Main.LocalPlayer.CancelSignsAndChests(); - TECanvasPainting cube = CalamityUtils.FindTileEntity(i, j, 5, 5); + var cube = CalamityUtils.FindTileEntity(i, j, 5, 5); if (cube != null) { CanvasPaintingUIState.ResetVars(); @@ -69,34 +69,34 @@ namespace CalamityMod.Tiles.Furniture public override void MouseOver(int i, int j) { - Main.LocalPlayer.cursorItemIconID = ModContent.ItemType(); + 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; + var t = Main.tile[i, j]; + var left = i - t.TileFrameX % (5 * 18) / 18; + var top = j - t.TileFrameY % (5 * 18) / 18; - TECanvasPainting canvas = CalamityUtils.FindTileEntity(i, j, 5, 5, 18); + var 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); + var t = Main.tile[i, j]; + var texture = TextureAssets.Tile[Type].Value; + var cube = CalamityUtils.FindTileEntity(i, j, 1, 1); - Vector2 pos = new Vector2(i * 16, j * 16) + CalamityUtils.TileDrawOffset; + var 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); + 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); // TODO: make the 0.4 in scale not a hardcoded number with seemingly no meaning @@ -111,40 +111,40 @@ namespace CalamityMod.Tiles.Furniture } 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); + var texture = border.Value; + var cornerTex = corner.Value; + var canvasID = (ushort)ModContent.TileType(); + 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 - bool drawTop = true; - bool drawLeft = true; - bool drawRight = true; - bool drawBottom = true; + var drawTop = true; + var drawLeft = true; + var drawRight = true; + var drawBottom = true; // Corners - bool drawTopLeft = false; - bool drawTopRight = false; - bool drawBottomLeft = false; - bool drawBottomRight = false; + var drawTopLeft = false; + var drawTopRight = false; + var drawBottomLeft = false; + var drawBottomRight = false; // The bottom right tile of the canvas painting - Point bottomRight = new Point(cords.X + 4, cords.Y + 4); + var 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); + 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 - 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); + 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) { @@ -158,8 +158,8 @@ namespace CalamityMod.Tiles.Furniture { 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); + 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; @@ -173,8 +173,8 @@ namespace CalamityMod.Tiles.Furniture { 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); + 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; @@ -191,9 +191,9 @@ namespace CalamityMod.Tiles.Furniture 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); + 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); + 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 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/CalamityCanvas2024Tile.cs b/Tiles/Furniture/Paintings/CalamityCanvas2024Tile.cs similarity index 73% rename from Tiles/Furniture/CalamityCanvas2024Tile.cs rename to Tiles/Furniture/Paintings/CalamityCanvas2024Tile.cs index 70fa5b30de..927ccce88b 100644 --- a/Tiles/Furniture/CalamityCanvas2024Tile.cs +++ b/Tiles/Furniture/Paintings/CalamityCanvas2024Tile.cs @@ -12,7 +12,7 @@ using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; -namespace CalamityMod.Tiles.Furniture +namespace CalamityMod.Tiles.Furniture.Paintings { // TODO: Probably make a base canvas painting class public class CalamityCanvas2024Tile : ModTile @@ -45,7 +45,7 @@ namespace CalamityMod.Tiles.Furniture public override bool RightClick(int i, int j) { Main.LocalPlayer.CancelSignsAndChests(); - TECanvasPainting cube = CalamityUtils.FindTileEntity(i, j, 5, 5); + var cube = CalamityUtils.FindTileEntity(i, j, 5, 5); if (cube != null) { CanvasPaintingUIState.ResetVars(); @@ -61,34 +61,34 @@ namespace CalamityMod.Tiles.Furniture public override void MouseOver(int i, int j) { - Main.LocalPlayer.cursorItemIconID = ModContent.ItemType(); + 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; + var t = Main.tile[i, j]; + var left = i - t.TileFrameX % (5 * 18) / 18; + var top = j - t.TileFrameY % (5 * 18) / 18; - TECanvasPainting canvas = CalamityUtils.FindTileEntity(i, j, 5, 5, 18); + var 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); + var t = Main.tile[i, j]; + var texture = TextureAssets.Tile[Type].Value; + var cube = CalamityUtils.FindTileEntity(i, j, 1, 1); - Vector2 pos = new Vector2(i * 16, j * 16) + CalamityUtils.TileDrawOffset; + var 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); + 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); // TODO: make the 0.8 in scale not a hardcoded number with seemingly no meaning @@ -103,40 +103,40 @@ namespace CalamityMod.Tiles.Furniture } 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); + var texture = CalamityCanvas2023Tile.border.Value; + var cornerTex = CalamityCanvas2023Tile.corner.Value; + var canvasID = (ushort)ModContent.TileType(); + 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 - bool drawTop = true; - bool drawLeft = true; - bool drawRight = true; - bool drawBottom = true; + var drawTop = true; + var drawLeft = true; + var drawRight = true; + var drawBottom = true; // Corners - bool drawTopLeft = false; - bool drawTopRight = false; - bool drawBottomLeft = false; - bool drawBottomRight = false; + var drawTopLeft = false; + var drawTopRight = false; + var drawBottomLeft = false; + var drawBottomRight = false; // The bottom right tile of the canvas painting - Point bottomRight = new Point(cords.X + 4, cords.Y + 4); + var 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); + 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 - 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); + 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) { @@ -150,8 +150,8 @@ namespace CalamityMod.Tiles.Furniture { 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); + 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; @@ -165,8 +165,8 @@ namespace CalamityMod.Tiles.Furniture { 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); + 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; @@ -183,9 +183,9 @@ namespace CalamityMod.Tiles.Furniture 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); + 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); + 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 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/DevPaintings/ThankYouPaintingTile.cs b/Tiles/Furniture/Paintings/ThankYouPaintingTile.cs similarity index 88% rename from Tiles/Furniture/DevPaintings/ThankYouPaintingTile.cs rename to Tiles/Furniture/Paintings/ThankYouPaintingTile.cs index 16d09fae61..bc3a2978fe 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 { diff --git a/Tiles/Furniture/DevPaintings/ThankYouPaintingTile.png b/Tiles/Furniture/Paintings/ThankYouPaintingTile.png similarity index 100% rename from Tiles/Furniture/DevPaintings/ThankYouPaintingTile.png rename to Tiles/Furniture/Paintings/ThankYouPaintingTile.png diff --git a/UI/CanvasPaintingUI.cs b/UI/CanvasPaintingUI.cs index b655d2b1a4..06778c4ba5 100644 --- a/UI/CanvasPaintingUI.cs +++ b/UI/CanvasPaintingUI.cs @@ -65,9 +65,9 @@ namespace CalamityMod.UI bool hideUI = Main.keyState.PressingShift(); - Texture2D tex = TextureAssets.Tile[ModContent.TileType()].Value; + Texture2D tex = TextureAssets.Tile[ModContent.TileType()].Value; if (p.CurrentlyViewedCanvasType == 1) - tex = TextureAssets.Tile[ModContent.TileType()].Value; + tex = TextureAssets.Tile[ModContent.TileType()].Value; // This is the length and width of the UI box, which is a square float dimension = Main.screenHeight * 0.66f; From a8df7aa127da1a7cdb769e7c2813d16ed855d4b7 Mon Sep 17 00:00:00 2001 From: doze-zoze Date: Sun, 16 Nov 2025 10:43:33 -0600 Subject: [PATCH 41/65] final cleanups --- Projectiles/Summon/SarosAura.cs | 23 +++++-------------- Projectiles/Summon/SarosEclipseBeam.cs | 22 +++++++----------- Projectiles/Summon/SarosSunfire.cs | 13 ++++------- Projectiles/Summon/SunSpiritBeam.cs | 10 +------- Projectiles/Summon/SunSpiritMinion.cs | 23 ------------------- Projectiles/Summon/VengefulSunBeam.cs | 10 +------- Projectiles/Summon/VengefulSunSpiritMinion.cs | 1 - 7 files changed, 20 insertions(+), 82 deletions(-) diff --git a/Projectiles/Summon/SarosAura.cs b/Projectiles/Summon/SarosAura.cs index 8529826e79..3601fc03e3 100644 --- a/Projectiles/Summon/SarosAura.cs +++ b/Projectiles/Summon/SarosAura.cs @@ -153,16 +153,13 @@ namespace CalamityMod.Projectiles.Summon public static Asset circle; public override bool PreDraw(ref Color lightColor) { - - //Vengeful Sun Drawing + //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); + //Sunlines Main.spriteBatch.SafeBegin(SpriteSortMode.Deferred, BatchSetting.Additive, null, Main.GameViewMatrix.TransformationMatrix, () => { - //Main.EntitySpriteDraw(ciTex, Projectile.Center - Main.screenPosition, null, Color.Gold, Main.GlobalTimeWrappedHourly, ciTex.Size() * 0.5f, 0.075f, SpriteEffects.None); - - float count = (int)((Projectile.minionSlots - 1) / 3) * 2 + 2; + int count = (int)((Projectile.minionSlots - 1) / 3) * 2 + 2; for (var i = 0; i < count; i++) { var comp = (i / count); @@ -171,18 +168,10 @@ namespace CalamityMod.Projectiles.Summon 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); } - }); - //Old sun spirit drawing - /* - var spTex = TextureAssets.Projectile[Type].Value; - var ciTex = CalamityUtils.GetTextureEfficient(ref circle, "CalamityMod/Particles/BloomRingThinLarge").Value; - */ - var ciTex = CalamityUtils.GetTextureEfficient(ref circle, "CalamityMod/Particles/BloomRingThinLarge").Value; - //Main.spriteBatch.Draw(spTex, Projectile.Center - Main.screenPosition, null, Color.White, Main.GlobalTimeWrappedHourly, spTex.Size() * 0.5f, 0.75f, SpriteEffects.None, 0); - Main.spriteBatch.SafeBegin(SpriteSortMode.Deferred, BatchSetting.Additive, null, Main.GameViewMatrix.TransformationMatrix, () => - { - int count = (int)MathHelper.Min((1 + (Projectile.minionSlots - 1) % 3), 10); + //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)); diff --git a/Projectiles/Summon/SarosEclipseBeam.cs b/Projectiles/Summon/SarosEclipseBeam.cs index 3518feb284..5e4fa5edea 100644 --- a/Projectiles/Summon/SarosEclipseBeam.cs +++ b/Projectiles/Summon/SarosEclipseBeam.cs @@ -16,11 +16,10 @@ namespace CalamityMod.Projectiles.Summon { 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.TrailCacheLength[Type] = 20; - ProjectileID.Sets.TrailingMode[Type] = 2; ProjectileID.Sets.MinionShot[Type] = true; } @@ -42,15 +41,13 @@ namespace CalamityMod.Projectiles.Summon Vector2 SarosPos => Owner.Center + Vector2.UnitY * (Owner.gfxOffY + Owner.gravDir * -24f); public override void OnSpawn(IEntitySource source) { - SoundEngine.PlaySound(SoundID.Item20, Projectile.Center); + SoundEngine.PlaySound(SoundID.DD2_BetsyFlameBreath with { Volume = 0.5f, SoundLimitBehavior = SoundLimitBehavior.IgnoreNew }, Owner.Center); Projectile.rotation = SarosPos.DirectionTo(Owner.Calamity().mouseWorld).ToRotation(); } - - Player Owner => Main.player[Projectile.owner]; - - public override void AI() { + if (Owner.miscCounter % 10 == 0) + SoundEngine.PlaySound(SoundID.DD2_BetsyFlameBreath with {Volume = 0.1f }, 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) @@ -108,21 +105,18 @@ namespace CalamityMod.Projectiles.Summon public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, PixelationPrimitiveLayer layer) { - Vector2[] pos = [SarosPos, Projectile.Center]; 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)); } - pos = posList.ToArray(); - // Render the main trail for the body for the flame. + 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); - - // Render a smaller, pure white trail in the same position to represent the glowing core of the flame. - Vector2[] fireCoreLength = pos; GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); - PrimitiveRenderer.RenderTrail(fireCoreLength, new(FireCoreWidthFunction, FireCoreColorFunction, null, true, true, GameShaders.Misc["CalamityMod:ImpFlameTrail"]), pos.Length+24); + PrimitiveRenderer.RenderTrail(pos, new(FireCoreWidthFunction, FireCoreColorFunction, null, true, true, GameShaders.Misc["CalamityMod:ImpFlameTrail"]), pos.Length+24); } } } diff --git a/Projectiles/Summon/SarosSunfire.cs b/Projectiles/Summon/SarosSunfire.cs index 63c00635d5..3965be9cca 100644 --- a/Projectiles/Summon/SarosSunfire.cs +++ b/Projectiles/Summon/SarosSunfire.cs @@ -118,10 +118,6 @@ namespace CalamityMod.Projectiles.Summon } } - public override void OnKill(int timeLeft) - { - } - public override bool? CanDamage() { return Projectile.ai[0] <= 90; @@ -129,6 +125,7 @@ namespace CalamityMod.Projectiles.Summon public override bool PreDraw(ref Color lightColor) => false; + //Prim trail based off Fryzahh's work on Faith Incinerator public float FireWidthFunction(float completion) { float width; @@ -136,7 +133,6 @@ namespace CalamityMod.Projectiles.Summon 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 @@ -172,16 +168,15 @@ namespace CalamityMod.Projectiles.Summon public Color FireCoreColorFunction(float completion) { Color mainColor = new Color(255, 191, 73); - return mainColor;// Color.Lerp(mainColor, Color.Transparent, completion); + return mainColor; } public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, PixelationPrimitiveLayer layer) { - // Render the main trail for the body for the flame. + //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); - - // Render a smaller, pure white trail in the same position to represent the glowing core of the flame. + //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/SunSpiritBeam.cs b/Projectiles/Summon/SunSpiritBeam.cs index 91ad905e32..5f7394ccd6 100644 --- a/Projectiles/Summon/SunSpiritBeam.cs +++ b/Projectiles/Summon/SunSpiritBeam.cs @@ -68,12 +68,9 @@ namespace CalamityMod.Projectiles.Summon } } - public override void OnKill(int timeLeft) - { - } - public override bool PreDraw(ref Color lightColor) => false; + //Trail based on Fryzahh's work on Faith Incinerator public float FireWidthFunction(float completion) { float width; @@ -81,13 +78,11 @@ namespace CalamityMod.Projectiles.Summon 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] ; @@ -107,7 +102,6 @@ namespace CalamityMod.Projectiles.Summon float curveRatio = 0.25f; var positions = Projectile.oldPos.ToList(); positions.RemoveAll(x => x == Vector2.Zero); - //completion *= positions.Count() / (float)ProjectileID.Sets.TrailCacheLength[Type]; if (completion < curveRatio) width = MathF.Sin(completion / curveRatio * MathHelper.PiOver2) * maxBodyWidth + curveRatio; @@ -126,11 +120,9 @@ namespace CalamityMod.Projectiles.Summon public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, PixelationPrimitiveLayer 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, true, true, GameShaders.Misc["CalamityMod:ImpFlameTrail"]), Projectile.oldPos.Length + 32); - // Render a smaller, pure white trail in the same position to represent the glowing core of the flame. 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 index 3d954d7d99..6401687169 100644 --- a/Projectiles/Summon/SunSpiritMinion.cs +++ b/Projectiles/Summon/SunSpiritMinion.cs @@ -117,16 +117,12 @@ namespace CalamityMod.Projectiles.Summon public static Asset circle; public override bool PreDraw(ref Color lightColor) { - - //Vengeful Sun Drawing 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); Main.spriteBatch.SafeBegin(SpriteSortMode.Deferred, BatchSetting.Additive, null, Main.GameViewMatrix.TransformationMatrix, () => { - //Main.EntitySpriteDraw(ciTex, Projectile.Center - Main.screenPosition, null, Color.Gold, Main.GlobalTimeWrappedHourly, ciTex.Size() * 0.5f, 0.075f, SpriteEffects.None); - float count = MathHelper.Min(Projectile.minionSlots * 2, 40); for (var i = 0; i < count; i++) { @@ -137,25 +133,6 @@ namespace CalamityMod.Projectiles.Summon 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); } }); - - //Old sun spirit drawing - /* - var spTex = TextureAssets.Projectile[Type].Value; - var ciTex = CalamityUtils.GetTextureEfficient(ref circle, "CalamityMod/Particles/BloomRingThinLarge").Value; - - Main.spriteBatch.Draw(spTex, Projectile.Center - Main.screenPosition, null, Color.White, Main.GlobalTimeWrappedHourly, spTex.Size() * 0.5f, 0.75f, SpriteEffects.None, 0); - Main.spriteBatch.SafeBegin(SpriteSortMode.Deferred, BatchSetting.Additive, null, Main.GameViewMatrix.TransformationMatrix, () => - { - - for (var i = 0; i < Projectile.minionSlots && i < 5; i++) - { - var comp = (i / (Projectile.minionSlots)); - 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.02f + 0.0025f * offset + 0.005f * i, SpriteEffects.None); - } - });*/ return false; } } diff --git a/Projectiles/Summon/VengefulSunBeam.cs b/Projectiles/Summon/VengefulSunBeam.cs index 414272b0c7..dd8c925f13 100644 --- a/Projectiles/Summon/VengefulSunBeam.cs +++ b/Projectiles/Summon/VengefulSunBeam.cs @@ -97,10 +97,6 @@ namespace CalamityMod.Projectiles.Summon Projectile.netUpdate = true; } - public override void OnKill(int timeLeft) - { - } - public override bool? CanDamage() { return Projectile.ai[0] <= 90; @@ -108,6 +104,7 @@ namespace CalamityMod.Projectiles.Summon public override bool PreDraw(ref Color lightColor) => false; + //Trail based on Fryzahh's work on Faith Incinerator public float FireWidthFunction(float completion) { float width; @@ -115,13 +112,11 @@ namespace CalamityMod.Projectiles.Summon 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]; @@ -163,11 +158,8 @@ namespace CalamityMod.Projectiles.Summon public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, PixelationPrimitiveLayer 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, true, true, GameShaders.Misc["CalamityMod:ImpFlameTrail"]), Projectile.oldPos.Length + 32); - - // Render a smaller, pure white trail in the same position to represent the glowing core of the flame. 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 index f31b44798e..c5b6e30ded 100644 --- a/Projectiles/Summon/VengefulSunSpiritMinion.cs +++ b/Projectiles/Summon/VengefulSunSpiritMinion.cs @@ -157,7 +157,6 @@ namespace CalamityMod.Projectiles.Summon color = Color.Lerp(Color.Yellow, Color.OrangeRed, completion); if (completion >= 1) color = Color.LightBlue; - //Main.EntitySpriteDraw(ciTex, Projectile.Center - Main.screenPosition, null, color, Main.GlobalTimeWrappedHourly, ciTex.Size() * 0.5f, 0.075f, SpriteEffects.None); float count = MathHelper.Min((Projectile.minionSlots-1) * 2, 40); for (var i = 0; i < count; i++) From 0b0eae72c7e1fd0b37e05e48d0a211d78d87f35d Mon Sep 17 00:00:00 2001 From: doze-zoze Date: Sun, 16 Nov 2025 11:27:47 -0600 Subject: [PATCH 42/65] oops int division fix --- Projectiles/Summon/SarosAura.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Projectiles/Summon/SarosAura.cs b/Projectiles/Summon/SarosAura.cs index 3601fc03e3..f05d8c81a4 100644 --- a/Projectiles/Summon/SarosAura.cs +++ b/Projectiles/Summon/SarosAura.cs @@ -162,7 +162,7 @@ namespace CalamityMod.Projectiles.Summon int count = (int)((Projectile.minionSlots - 1) / 3) * 2 + 2; for (var i = 0; i < count; i++) { - var comp = (i / count); + var comp = (i / (float)count); var offset = ((Main.mouseTextColor - 190) / 64f) * 8; if (i % 2 == 0) offset = 8 - offset; From 3cae725ef7a4768f45ba82a3d0bb7d33b73970b0 Mon Sep 17 00:00:00 2001 From: Flowaria Date: Sun, 16 Nov 2025 11:21:06 +0900 Subject: [PATCH 43/65] Implemented VanillaAIOverride Base type --- NPCs/CalamityGlobalNPC.cs | 46 +++++++++++++------ .../VanillaAIOverride.cs | 24 ++++++++++ 2 files changed, 55 insertions(+), 15 deletions(-) create mode 100644 NPCs/VanillaNPCAIOverrides/VanillaAIOverride.cs diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index c67677b7b3..5cebac8d25 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Reflection; using CalamityMod.Balancing; @@ -8,7 +9,6 @@ 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; @@ -20,10 +20,8 @@ using CalamityMod.Items; using CalamityMod.Items.Accessories; using CalamityMod.Items.Accessories.Vanity; using CalamityMod.Items.Armor.PlagueReaper; -using CalamityMod.Items.Potions.Alcohol; 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; @@ -56,16 +54,15 @@ using CalamityMod.NPCs.SlimeGod; using CalamityMod.NPCs.StormWeaver; using CalamityMod.NPCs.SunkenSea; using CalamityMod.NPCs.SupremeCalamitas; +using CalamityMod.NPCs.VanillaNPCAIOverrides; 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; @@ -90,6 +87,7 @@ using Terraria.GameContent.Events; using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; +using Terraria.ModLoader.IO; using Terraria.ModLoader.Utilities; using Terraria.UI.Chat; using Terraria.Utilities; @@ -267,7 +265,13 @@ namespace CalamityMod.NPCs /// public bool ProvidesProximityRage = true; + /// + /// Specify the AI Override to work with. This handles AI, SendExtraAI and ReceiveExtraAI in instaned manner. + /// + public VanillaAIOverride AIOverride = null; + // NewAI + // TODO: This should be deprecated at some point. internal const int maxAIMod = 4; public float[] newAI = new float[maxAIMod]; public int AITimer = 0; @@ -993,7 +997,7 @@ namespace CalamityMod.NPCs } #endregion - + //Apply DoT Debuffs for (var index = 0; index < npc.buffType.Count(); index++) { @@ -1001,7 +1005,7 @@ namespace CalamityMod.NPCs var debuffData = BuffDatasets.DebuffDataset[type]; if (debuffData == null || debuffData == DebuffData.Oiled) //Oiled is done after continue; - debuffData.NPCLifeRegenMethod(npc, type, ref index,ref damage); + debuffData.NPCLifeRegenMethod(npc, type, ref index, ref damage); } //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; @@ -1290,6 +1294,18 @@ namespace CalamityMod.NPCs } #endregion + #region ExtraAI + public override void SendExtraAI(NPC npc, BitWriter bitWriter, BinaryWriter binaryWriter) + { + AIOverride?.SendExtraAI(bitWriter, binaryWriter); + } + + public override void ReceiveExtraAI(NPC npc, BitReader bitReader, BinaryReader binaryReader) + { + AIOverride?.ReceiveExtraAI(bitReader, binaryReader); + } + #endregion + #region Boss Health UI Variable Setting public void DeclareBossHealthUIVariables(NPC npc) { @@ -4556,7 +4572,7 @@ namespace CalamityMod.NPCs npc.ai[3] = 0f; } - + if (warbannerBurnTimer > 0) warbannerBurnTimer--; @@ -5768,7 +5784,7 @@ namespace CalamityMod.NPCs dustLinger.scale = Main.rand.NextFloat(0.8f, 1f) * 1.5f; dustLinger.fadeIn = Main.rand.NextFloat(0.6f, 1f) * 4; dustLinger.color = Color.Lerp(color1, color2, Utils.GetLerpValue(0, maxDusts, i)); - + lastDustPos = currentDustPos; } @@ -6014,7 +6030,7 @@ namespace CalamityMod.NPCs 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)) + 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(); @@ -6335,7 +6351,7 @@ namespace CalamityMod.NPCs if (demonicFlames) DemonicFlames.DrawEffects(npc, ref drawColor); - if (burningBlood ) + if (burningBlood) BurningBlood.DrawEffects(npc, ref drawColor); if (brainRot) @@ -6375,7 +6391,7 @@ namespace CalamityMod.NPCs if (heavyBleeding) HeavyBleeding.DrawEffects(npc, ref drawColor); - + if (hyperiusFxTimer > 0) { float rate = (Main.GlobalTimeWrappedHourly * 5); @@ -6457,10 +6473,10 @@ namespace CalamityMod.NPCs 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); @@ -6755,7 +6771,7 @@ namespace CalamityMod.NPCs float drawPosX = totalLength >= 80f ? 40f : (float)(totalLength / 2); // The height of a single frame of the npc - float npcHeight = (npc.height * npc.scale)/2;//(float)(TextureAssets.Npc[npc.type].Value.Height / Main.npcFrameCount[npc.type] / 2) * npc.scale; + float npcHeight = (npc.height * npc.scale) / 2;//(float)(TextureAssets.Npc[npc.type].Value.Height / Main.npcFrameCount[npc.type] / 2) * npc.scale; // 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 + 32f; diff --git a/NPCs/VanillaNPCAIOverrides/VanillaAIOverride.cs b/NPCs/VanillaNPCAIOverrides/VanillaAIOverride.cs new file mode 100644 index 0000000000..8a0548b1d1 --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/VanillaAIOverride.cs @@ -0,0 +1,24 @@ +using System.IO; +using Terraria; +using Terraria.ModLoader; +using Terraria.ModLoader.IO; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides +{ + public abstract class VanillaAIOverride + { + public NPC NPC { get; set; } + + public abstract bool AI(Mod mod); + + public virtual void SendExtraAI(BitWriter bitWriter, BinaryWriter binaryWriter) + { + + } + + public virtual void ReceiveExtraAI(BitReader bitReader, BinaryReader binaryReader) + { + + } + } +} From c919455d78734ca9b7d45e5905b37fcfb23e9390 Mon Sep 17 00:00:00 2001 From: Flowaria Date: Sun, 16 Nov 2025 17:09:12 +0900 Subject: [PATCH 44/65] Migrated BossAI to VanillaAIOverride types --- NPCs/CalamityGlobalNPC.cs | 372 ++- NPCs/CalamityVanillaMinibossesAI.cs | 1093 -------- .../Bosses/BrainOfCthulhuAI.cs | 691 ++--- .../VanillaNPCAIOverrides/Bosses/CultistAI.cs | 964 +++---- .../Bosses/DeerclopsAI.cs | 368 +-- .../Bosses/DestroyerAI.cs | 680 ++--- .../Bosses/DreadnautilusAI.cs | 272 +- .../Bosses/DukeFishronAI.cs | 953 +++---- .../Bosses/EaterOfWorldsAI.cs | 408 +-- .../Bosses/EmpressofLightAI.cs | 581 ++-- .../Bosses/EyeOfCthulhuAI.cs | 547 ++-- NPCs/VanillaNPCAIOverrides/Bosses/GolemAI.cs | 1823 ++++++------- .../Bosses/KingSlimeAI.cs | 309 ++- .../Bosses/MoonLordAI.cs | 1060 ++++---- .../Bosses/PlanteraAI.cs | 918 +++---- .../Bosses/QueenBeeAI.cs | 476 ++-- .../Bosses/QueenSlimeAI.cs | 1172 ++++---- .../Bosses/SkeletronAI.cs | 961 +++---- .../Bosses/SkeletronPrimeAI.cs | 2362 +++++++++-------- NPCs/VanillaNPCAIOverrides/Bosses/TwinsAI.cs | 2219 ++++++++-------- .../Bosses/WallOfFleshAI.cs | 840 +++--- .../MiniBosses/IceQueenAI.cs | 282 ++ .../MiniBosses/MothronAI.cs | 459 ++++ .../MiniBosses/PumpkingAI.cs | 372 +++ .../VanillaAIOverride.cs | 10 +- 25 files changed, 10119 insertions(+), 10073 deletions(-) delete mode 100644 NPCs/CalamityVanillaMinibossesAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/MiniBosses/IceQueenAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/MiniBosses/MothronAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/MiniBosses/PumpkingAI.cs diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 5cebac8d25..50bc63a985 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -56,6 +56,7 @@ using CalamityMod.NPCs.SunkenSea; using CalamityMod.NPCs.SupremeCalamitas; using CalamityMod.NPCs.VanillaNPCAIOverrides; using CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses; +using CalamityMod.NPCs.VanillaNPCAIOverrides.MiniBosses; using CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; using CalamityMod.Packets; using CalamityMod.Particles; @@ -1283,8 +1284,173 @@ namespace CalamityMod.NPCs VulnerabilitiesAndResistances(npc); BoundNPCSafety(Mod, npc); + + AIOverride = GetVanillaAIOverrideToApply(npc); + + if (AIOverride != null) + AIOverride.NPC = npc; } + #region Vanilla AI Override Rule + public static VanillaAIOverride GetVanillaAIOverrideToApply(NPC npc) + { + // 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 BrainOfCthulhuAI.CreeperAI(); + + case NPCID.QueenBee: + return new QueenBeeAI(); + + case NPCID.SkeletronHead: + return new SkeletronAI(); + case NPCID.SkeletronHand: + return new SkeletronAI.SkeletronHandAI(); + + 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+ AI Override Per AiStyle + + if (CalamityWorld.revenge) + { + switch (npc.aiStyle) + { + + } + } + + #endregion + + return null; + } + #endregion + public override bool? CanFallThroughPlatforms(NPC npc) { // Allow the free Golem Head to pass through platforms in Rev+ @@ -3158,65 +3324,7 @@ namespace CalamityMod.NPCs 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); - - // 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) @@ -3254,157 +3362,9 @@ namespace CalamityMod.NPCs } } - 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); - } - 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.QueenSlimeMinionBlue: - return QueenSlimeAI.BuffedQueenSlimeCrystalSlimeAI(npc, Mod); - case NPCID.QueenSlimeMinionPink: - return QueenSlimeAI.BuffedQueenSlimeBouncySlimeAI(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; - } } if (CalamityWorld.revenge) 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/VanillaNPCAIOverrides/Bosses/BrainOfCthulhuAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhuAI.cs index 67541d7de9..998fa938cc 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhuAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhuAI.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { - public static class BrainOfCthulhuAI + public class BrainOfCthulhuAI : VanillaAIOverride { public const float TimeBeforeCreeperAttack = 600f; public const float CreeperTelegraphTime = 180f; @@ -20,52 +20,52 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses public static float ContactDamageMult = 1.15f; // 62 (buffed from 54) public static int BloodShotDamage = 12; // 48 - public static bool BuffedBrainofCthulhuAI(NPC npc, Mod mod) + public override bool AI(Mod mod) { // whoAmI variable - NPC.crimsonBoss = npc.whoAmI; + NPC.crimsonBoss = NPC.whoAmI; 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) + 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); + CalamityUtils.CalamityTargeting(NPC, options); } // Despawn check - bool despawn = (Main.player[npc.target].dead || !Main.player[npc.target].ZoneCrimson) && !BossRushEvent.BossRushActive; + bool despawn = (Main.player[NPC.target].dead || !Main.player[NPC.target].ZoneCrimson) && !BossRushEvent.BossRushActive; // Despawn if (despawn) { - if (npc.localAI[3] < 120f) - npc.localAI[3] += 1f; + if (NPC.localAI[3] < 120f) + NPC.localAI[3] += 1f; - if (npc.localAI[3] > 60f) - npc.velocity.Y += (npc.localAI[3] - 60f) * 0.25f; + if (NPC.localAI[3] > 60f) + NPC.velocity.Y += (NPC.localAI[3] - 60f) * 0.25f; } - else if (npc.localAI[3] > 0f) - npc.localAI[3] -= 1f; + else if (NPC.localAI[3] > 0f) + NPC.localAI[3] -= 1f; // Spawn Creepers - if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[0] == 0f) + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.localAI[0] == 0f) { - npc.localAI[0] = 1f; + 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); + 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); + 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; } @@ -74,45 +74,45 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Despawn 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, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, NPC.whoAmI, 0f, 0f, 0f, 0, 0, 0); } } // Phase 2 - if (npc.ai[0] < 0f) + if (NPC.ai[0] < 0f) { if (Main.getGoodWorld) - NPC.brainOfGravity = npc.whoAmI; + NPC.brainOfGravity = NPC.whoAmI; // Spawn gore - if (npc.localAI[2] == 0f) + if (NPC.localAI[2] == 0f) { - SoundEngine.PlaySound(SoundID.NPCHit1, npc.Center); + SoundEngine.PlaySound(SoundID.NPCHit1, NPC.Center); - npc.localAI[2] = 1f; + 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); + 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); + 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); + SoundEngine.PlaySound(SoundID.ForceRoar, NPC.Center); } // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + float lifeRatio = NPC.life / (float)NPC.lifeMax; // Phases @@ -132,7 +132,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses bool phase7 = lifeRatio < 0.1f; // Whether the fucking thing is spinning or not, dipshit - bool spinning = npc.ai[0] == -4f; + bool spinning = NPC.ai[0] == -4f; // Spin variables float spinVelocity = SpinVelocity; @@ -156,24 +156,24 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // KnockBack float baseKnockBackResist = death ? 0.1f : 0.3f; if (!phase3) - npc.knockBackResist = GetCrimsonBossKnockBack(npc, CalamityGlobalNPC.GetActivePlayerCount(), lifeRatio, baseKnockBackResist); + NPC.knockBackResist = GetCrimsonBossKnockBack(NPC, CalamityGlobalNPC.GetActivePlayerCount(), lifeRatio, baseKnockBackResist); else - npc.knockBackResist = 0f; + NPC.knockBackResist = 0f; // Gain defense while spinning - npc.defense = npc.defDefense + (spinning ? 7 : 0); + NPC.defense = NPC.defDefense + (spinning ? 7 : 0); // Take damage - npc.dontTakeDamage = false; + NPC.dontTakeDamage = false; // Target distance X - float playerLocation = npc.Center.X - Main.player[npc.target].Center.X; + float playerLocation = NPC.Center.X - Main.player[NPC.target].Center.X; // Charge if (!spinning) { // Not charging - if (npc.ai[0] != -5f) + if (NPC.ai[0] != -5f) { // Rubber band movement if (!despawn) @@ -188,9 +188,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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 * 10f : Vector2.Zero); - Vector2 idealVelocity = (destination - npc.Center).SafeNormalize(Vector2.UnitY) * nonChargeSpeed; - npc.velocity = (npc.velocity * (inertia - 1f) + idealVelocity) / inertia; + Vector2 destination = Main.player[NPC.target].Center + (death ? Main.player[NPC.target].velocity * 10f : Vector2.Zero); + Vector2 idealVelocity = (destination - NPC.Center).SafeNormalize(Vector2.UnitY) * nonChargeSpeed; + NPC.velocity = (NPC.velocity * (inertia - 1f) + idealVelocity) / inertia; } } @@ -198,45 +198,45 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses else { if (!despawn) - npc.ai[1] += 1f; + NPC.ai[1] += 1f; float chargeDistance = 960f; // 60 tile charge distance float chargeDuration = chargeDistance / chargeVelocity; float chargeGateValue = 10f; - if (npc.ai[1] < chargeGateValue) + if (NPC.ai[1] < chargeGateValue) { // Avoid cheap bullshit - npc.damage = 0; + NPC.damage = 0; } else { // Set damage - npc.damage = (int)Math.Round(npc.defDamage * ContactDamageMult); + NPC.damage = (int)Math.Round(NPC.defDamage * ContactDamageMult); } // Teleport float timeGateValue = chargeDuration + chargeGateValue; - if (npc.ai[1] >= timeGateValue) + if (NPC.ai[1] >= timeGateValue) { - npc.ai[0] = -6f; - npc.ai[1] = 0f; + 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; + NPC.localAI[1] = MathHelper.Lerp(0f, maxTeleportPhaseDurationReduction, lerpHPScalar); + NPC.netUpdate = true; } // Charge sound and velocity - else if (npc.ai[1] == chargeGateValue && !despawn) + else if (NPC.ai[1] == chargeGateValue && !despawn) { // Sound - SoundEngine.PlaySound(SoundID.ForceRoarPitched, npc.Center); + SoundEngine.PlaySound(SoundID.ForceRoarPitched, NPC.Center); // Velocity - npc.velocity = (Main.player[npc.target].Center + (death ? Main.player[npc.target].velocity * 10f : Vector2.Zero) - npc.Center).SafeNormalize(Vector2.UnitY) * chargeVelocity; + NPC.velocity = (Main.player[NPC.target].Center + (death ? Main.player[NPC.target].velocity * 10f : Vector2.Zero) - NPC.Center).SafeNormalize(Vector2.UnitY) * chargeVelocity; if (Main.getGoodWorld) - npc.velocity *= 1.15f; + NPC.velocity *= 1.15f; } } } @@ -245,18 +245,18 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (spinning) { // Avoid cheap bullshit - npc.damage = 0; + NPC.damage = 0; // Charge sound - if (npc.ai[2] == 0f) + if (NPC.ai[2] == 0f) { - SoundEngine.PlaySound(SoundID.ForceRoar, npc.Center); + SoundEngine.PlaySound(SoundID.ForceRoar, NPC.Center); if (Main.zenithWorld) { if (!Main.dedServ) { - if (!Main.LocalPlayer.dead && Main.LocalPlayer.active && Vector2.Distance(Main.LocalPlayer.Center, npc.Center) < CalamityGlobalNPC.CatchUpDistance350Tiles) + if (!Main.LocalPlayer.dead && Main.LocalPlayer.active && Vector2.Distance(Main.LocalPlayer.Center, NPC.Center) < CalamityGlobalNPC.CatchUpDistance350Tiles) Main.LocalPlayer.AddBuff(BuffID.Confused, 90); } } @@ -264,29 +264,29 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Velocity float velocity = MathHelper.TwoPi / spinRadius; - npc.velocity = npc.velocity.RotatedBy(-(double)velocity * npc.ai[1]); + NPC.velocity = NPC.velocity.RotatedBy(-(double)velocity * NPC.ai[1]); - npc.ai[2] += 1f; + NPC.ai[2] += 1f; - float timer = (death ? 20f : 30f) + npc.ai[3]; + float timer = (death ? 20f : 30f) + NPC.ai[3]; // Move the brain away from the target in order to ensure fairness - if (npc.ai[2] >= timer - 5f) + if (NPC.ai[2] >= timer - 5f) { float minChargeDistance = 640f; // 40 tile distance - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) < minChargeDistance) + 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; + NPC.ai[2] -= 1f; + NPC.velocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * -chargeVelocity; if (death) - npc.velocity *= 1.2f; + NPC.velocity *= 1.2f; if (Main.getGoodWorld) - npc.velocity *= 1.15f; + NPC.velocity *= 1.15f; } } // Charge at target - if (npc.ai[2] >= timer) + if (NPC.ai[2] >= timer) { // Shoot projectiles from 4 directions, alternating between diagonal and cardinal float bloodShotVelocity = death ? 7f : 6f; @@ -301,16 +301,16 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (phase4) { - bool alternativeFire = npc.ai[3] % 2f == 0f; + 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); + 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) { @@ -360,8 +360,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - 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); + 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; @@ -387,7 +387,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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, BloodShotDamage, 0f, Main.myPlayer); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 10f, perturbedSpeed, type, BloodShotDamage, 0f, Main.myPlayer); Main.projectile[proj].timeLeft = 600; if (!canHit2) Main.projectile[proj].tileCollide = false; @@ -395,55 +395,55 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Complete stop - npc.velocity *= 0f; + NPC.velocity *= 0f; - 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; } } // Pick teleport location - else if (npc.ai[0] == -1f || npc.ai[0] == -6f) + else if (NPC.ai[0] == -1f || NPC.ai[0] == -6f) { // Set damage - npc.damage = (int)Math.Round(npc.defDamage * ContactDamageMult); + NPC.damage = (int)Math.Round(NPC.defDamage * ContactDamageMult); if (Main.netMode != NetmodeID.MultiplayerClient) { // Go to phase 3 and spin - if (phase3 && npc.ai[0] == -1f) + if (phase3 && NPC.ai[0] == -1f) { // Avoid cheap bullshit - npc.damage = 0; + 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; + 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 ? 22 : 30) : (death ? 45 : 60); - npc.ai[3] = Main.rand.Next(maxRandomTime) + 1; - npc.localAI[1] = 0f; - npc.alpha = 0; - npc.netUpdate = true; + NPC.ai[3] = Main.rand.Next(maxRandomTime) + 1; + NPC.localAI[1] = 0f; + NPC.alpha = 0; + NPC.netUpdate = true; } if (!despawn) - npc.localAI[1] += 1f; + NPC.localAI[1] += 1f; - float teleportGateValue = npc.ai[0] == -6f ? 270f : 210f; - if (npc.localAI[1] >= teleportGateValue) + float teleportGateValue = NPC.ai[0] == -6f ? 270f : 210f; + if (NPC.localAI[1] >= teleportGateValue) { - npc.localAI[1] = 0f; - + NPC.localAI[1] = 0f; + CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; options.aggroRatio = -1f; options.finishThemOff = true; - CalamityUtils.CalamityTargeting(npc, options); + CalamityUtils.CalamityTargeting(NPC, options); int numTeleportTries = 0; int maxTeleportTries = 100; @@ -454,8 +454,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses do { numTeleportTries++; - teleportTileX = (int)Main.player[npc.target].Center.X / 16; - teleportTileY = (int)Main.player[npc.target].Center.Y / 16; + teleportTileX = (int)Main.player[NPC.target].Center.X / 16; + teleportTileY = (int)Main.player[NPC.target].Center.Y / 16; int minX = 14; int maxX = 17; @@ -494,13 +494,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (numTeleportTries > maxTeleportTries || !WorldGen.SolidTile(teleportTileX, teleportTileY)) { // Avoid cheap bullshit - npc.damage = 0; + 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(); + NPC.ai[3] = 0f; + NPC.ai[0] = NPC.ai[0] == -6f ? -7f : -2f; + NPC.ai[1] = teleportTileX; + NPC.ai[2] = teleportTileY; + NPC.ForceNetUpdate(); break; } @@ -516,25 +516,25 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Teleport and turn invisible - else if (npc.ai[0] == -2f || npc.ai[0] == -7f) + else if (NPC.ai[0] == -2f || NPC.ai[0] == -7f) { // Avoid cheap bullshit - npc.damage = 0; + NPC.damage = 0; - npc.velocity *= 0.9f; + NPC.velocity *= 0.9f; if (Main.netMode != NetmodeID.SinglePlayer) - npc.ai[3] += 15f; + NPC.ai[3] += 15f; else - npc.ai[3] += 25f; + NPC.ai[3] += 25f; - if (npc.ai[3] >= 255f) + 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; + 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++) @@ -545,53 +545,53 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses bool creeperCanTeleport = creeper.ai[0] == 0f; if (creeperCanTeleport) { - creeper.position.X = npc.position.X; - creeper.position.Y = npc.position.Y; + creeper.position.X = NPC.position.X; + creeper.position.Y = NPC.position.Y; } } } - npc.ForceNetUpdate(); + NPC.ForceNetUpdate(); } - npc.alpha = (int)npc.ai[3]; + NPC.alpha = (int)NPC.ai[3]; } // Become visible - else if (npc.ai[0] == -3f || npc.ai[0] == -8f) + else if (NPC.ai[0] == -3f || NPC.ai[0] == -8f) { // Avoid cheap bullshit - npc.damage = 0; + NPC.damage = 0; if (Main.netMode != NetmodeID.SinglePlayer) - npc.ai[3] -= 15f; + NPC.ai[3] -= 15f; else - npc.ai[3] -= 25f; + NPC.ai[3] -= 25f; - if (npc.ai[3] <= 0f) + if (NPC.ai[3] <= 0f) { - if (npc.ai[0] == -8f) + if (NPC.ai[0] == -8f) { - npc.velocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * spinVelocity; + 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; + NPC.ai[0] = -4f; + NPC.ai[1] = playerLocation < 0 ? 1f : -1f; + NPC.ai[2] = 0f; int maxRandomTime = phase7 ? (death ? 22 : 30) : (death ? 45 : 60); - npc.ai[3] = Main.rand.Next(maxRandomTime) + 1; + 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.ai[3] = 0f; + NPC.ai[2] = 0f; + NPC.ai[1] = 0f; + NPC.ai[0] = -1f; } - npc.ForceNetUpdate(); + NPC.ForceNetUpdate(); } - npc.alpha = (int)npc.ai[3]; + NPC.alpha = (int)NPC.ai[3]; } } @@ -599,7 +599,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses else { // Avoid cheap bullshit - npc.damage = 0; + NPC.damage = 0; // Creeper count int creeperCount = NPC.CountNPCS(NPCID.Creeper); @@ -615,25 +615,25 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Go to phase 2 if (phase2) { - npc.ai[0] = -1f; - npc.localAI[1] = 0f; - npc.alpha = 0; - + 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); + CalamityUtils.CalamityTargeting(NPC, options); - npc.netUpdate = true; + 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; + 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 ? 1.9f : 1.5f) + velocityScale; // This used to be 4f in death. Yeah if (Main.getGoodWorld) @@ -641,35 +641,35 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (targetDistancePhase1 < maxMoveVelocity) { - npc.velocity.X = targetXDistPhase1; - npc.velocity.Y = targetYDistPhase1; + NPC.velocity.X = targetXDistPhase1; + NPC.velocity.Y = targetYDistPhase1; } else { targetDistancePhase1 = maxMoveVelocity / targetDistancePhase1; - npc.velocity.X = targetXDistPhase1 * targetDistancePhase1; - npc.velocity.Y = targetYDistPhase1 * targetDistancePhase1; + NPC.velocity.X = targetXDistPhase1 * targetDistancePhase1; + NPC.velocity.Y = targetYDistPhase1 * targetDistancePhase1; } } // Pick a teleport location - if (npc.ai[0] == 0f) + if (NPC.ai[0] == 0f) { if (Main.netMode != NetmodeID.MultiplayerClient) { if (!despawn) - npc.localAI[1] += (death ? 2f : 1f) + velocityScale; + NPC.localAI[1] += (death ? 2f : 1f) + velocityScale; - if (npc.localAI[1] >= (death ? 570f : 360f)) + if (NPC.localAI[1] >= (death ? 570f : 360f)) { // Teleport location - npc.localAI[1] = 0f; + NPC.localAI[1] = 0f; CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; options.aggroRatio = -1f; options.finishThemOff = true; - CalamityUtils.CalamityTargeting(npc, options); - + CalamityUtils.CalamityTargeting(NPC, options); + int phase1TeleportTries = 0; int maxTeleportTries = 100; int phase1TeleportTileX; @@ -677,8 +677,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses do { phase1TeleportTries++; - phase1TeleportTileX = (int)Main.player[npc.target].Center.X / 16; - phase1TeleportTileY = (int)Main.player[npc.target].Center.Y / 16; + phase1TeleportTileX = (int)Main.player[NPC.target].Center.X / 16; + phase1TeleportTileY = (int)Main.player[NPC.target].Center.Y / 16; int min = 28; int max = 30; @@ -693,12 +693,12 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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))) + 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; + NPC.ai[0] = 1f; + NPC.ai[1] = phase1TeleportTileX; + NPC.ai[2] = phase1TeleportTileY; + NPC.netUpdate = true; break; } } @@ -708,19 +708,19 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Turn invisible and teleport - else if (npc.ai[0] == 1f) + else if (NPC.ai[0] == 1f) { // Avoid cheap bullshit - npc.damage = 0; + NPC.damage = 0; - npc.alpha += 25; - if (npc.alpha >= 255) + 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; + 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++) @@ -731,8 +731,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses bool creeperCanTeleport = creeper.ai[0] == 0f; if (creeperCanTeleport) { - creeper.position.X = npc.position.X; - creeper.position.Y = npc.position.Y; + creeper.position.X = NPC.position.X; + creeper.position.Y = NPC.position.Y; } } } @@ -740,16 +740,16 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Become visible - else if (npc.ai[0] == 2f) + else if (NPC.ai[0] == 2f) { // Avoid cheap bullshit - npc.damage = 0; + NPC.damage = 0; - npc.alpha -= 25; - if (npc.alpha <= 0) + NPC.alpha -= 25; + if (NPC.alpha <= 0) { - npc.alpha = 0; - npc.ai[0] = 0f; + NPC.alpha = 0; + NPC.ai[0] = 0f; } } } @@ -757,187 +757,190 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses return false; } - public static bool BuffedCreeperAI(NPC npc, Mod mod) + public class CreeperAI : VanillaAIOverride { - // Despawn if Brain is gone - if (NPC.crimsonBoss < 0) + public override bool AI(Mod mod) { - npc.active = false; - npc.netUpdate = true; - return false; - } - - 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); - - 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; - 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; - - // 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++) + // Despawn if Brain is gone + if (NPC.crimsonBoss < 0) { - 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 ? 10f : 8f) + chargeAggressionScale; - if (brainIsInPhase2) - { - float velocityFloor = Main.npc[NPC.crimsonBoss].velocity.Length() + velocity * 0.5f; - if (velocity < velocityFloor) - velocity = velocityFloor; + NPC.active = false; + NPC.netUpdate = true; + return false; } - float maxDistanceFromBrain = 90f; - if (brainDistance > maxDistanceFromBrain) + 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); + + 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; + if (death && brainIsInPhase2) { - 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); + 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(); - // Increase speed - if (npc.velocity.Length() < velocity) - npc.velocity *= 1.05f; + // 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; - // 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) + // Give off blood dust before charging + float beginTelegraphGateValue = TimeBeforeCreeperAttack - CreeperTelegraphTime; + bool showTelegraph = NPC.ai[1] >= beginTelegraphGateValue || NPC.ai[0] == 1f; + if (showTelegraph) { - 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 ? 8f : 6f) + chargeAggressionScale; - float returnToBrainGateValue = 1f; - if (!brainIsInPhase2) - { - // Set damage - npc.damage = (int)Math.Round(npc.defDamage * ContactDamageMult); - - 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) + 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++) { - targetDirection *= chargeVelocity + 6f; - npc.velocity = (npc.velocity * 49f + targetDirection) / 50f; + 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; } - 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 ? 800f : 600f; - returnToBrainGateValue = chargeDistance / chargeVelocity; } - npc.ai[1] += 1f; - if (npc.ai[1] >= returnToBrainGateValue || brainIsInPhase2) + // Stay near Brain + if (NPC.ai[0] == 0f) { // Avoid cheap bullshit - npc.damage = 0; + NPC.damage = 0; - // Shoot blood shots - if (Vector2.Distance(npc.Center, Main.player[npc.target].Center) > 160f && npc.ai[2] == 0f) + 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 ? 10f : 8f) + chargeAggressionScale; + if (brainIsInPhase2) { - 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 proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, projectileVelocity, projectileType, BloodShotDamage, 0f, Main.myPlayer); - Main.projectile[proj].timeLeft = 600; - if (!canHit) - Main.projectile[proj].tileCollide = false; - } - npc.ai[2] = 1f; + float velocityFloor = Main.npc[NPC.crimsonBoss].velocity.Length() + velocity * 0.5f; + if (velocity < velocityFloor) + velocity = velocityFloor; } - if (brainIsNotTeleportingOrCharging) + float maxDistanceFromBrain = 90f; + if (brainDistance > maxDistanceFromBrain) { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; + 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; } } - } - return false; + // Charge + else + { + // Always fully visible while charging + NPC.alpha = 0; + + float chargeVelocity = (death ? 8f : 6f) + chargeAggressionScale; + float returnToBrainGateValue = 1f; + if (!brainIsInPhase2) + { + // Set damage + NPC.damage = (int)Math.Round(NPC.defDamage * ContactDamageMult); + + 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 ? 800f : 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 proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileVelocity, projectileType, BloodShotDamage, 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 int GetBrainOfCthuluCreepersCountRevDeath() diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/CultistAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/CultistAI.cs index 9c2853f6ba..ca70a4de96 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/CultistAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/CultistAI.cs @@ -11,7 +11,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { - public static class CultistAI + public class CultistAI : VanillaAIOverride { // Vanilla values public static int CloneFireballDamage = 18; // 72 @@ -20,12 +20,12 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses public static int LightningDamage = 30; // 120 public static int DoomDamage = 45; // 180 (Also fixes Master Mode scaling) - public static bool BuffedCultistAI(NPC npc, Mod mod) + 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[] { @@ -35,11 +35,11 @@ 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 death = CalamityWorld.death || BossRushEvent.BossRushActive; @@ -52,7 +52,7 @@ 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; @@ -89,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)) + if (!Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) { calamityGlobalNPC.newAI[0] += 1f; if (calamityGlobalNPC.newAI[0] >= 120f) @@ -124,136 +124,136 @@ 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; } // 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; - Main.projectile[(int)npc.ai[2]].ai[1] = -1f; - Main.projectile[(int)npc.ai[2]].netUpdate = true; + NPC.netUpdate = true; + 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: @@ -305,11 +305,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; } @@ -320,17 +320,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); } @@ -351,7 +351,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; @@ -361,84 +361,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); } @@ -453,55 +453,55 @@ 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); + Projectile.NewProjectile(NPC.GetSource_FromAI(), iceMistDirection, iceMistVelocity, ProjectileID.CultistBossIceMist, iceMistDamage, 0f, Main.myPlayer, 0f, 1f); } } - 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); } @@ -518,58 +518,58 @@ 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, CloneFireballDamage, 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 = Vector2.Normalize(player.Center - NPC.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); + Projectile.NewProjectile(NPC.GetSource_FromAI(), fireballDirection, fireballVelocity, 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); } @@ -584,59 +584,59 @@ 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); } @@ -647,7 +647,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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++) @@ -666,13 +666,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 { @@ -683,157 +683,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) { - 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); } @@ -848,17 +848,17 @@ 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); + Vector2 ancientLightShootDirection = NPC.Center + new Vector2(NPC.direction * 30, 12f); float scaleFactor = death ? 6f : 4f; float ancientLightSpread = MathHelper.ToRadians(15f); @@ -869,35 +869,35 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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); + 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] >= (4 + 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) { 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); } @@ -905,9 +905,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (ancientDoomAmt > 2) ancientDoomAmt = 2; - 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) { @@ -917,8 +917,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses for (int i = 0; i < ancientDoomLimit; 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); + 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 @@ -926,9 +926,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // 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; + 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; @@ -949,7 +949,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (notInsideTiles) { - NPC.NewNPC(npc.GetSource_FromAI(), ancientDoomSpawnX * 16 + 8, ancientDoomSpawnY * 16 + 8, NPCID.AncientDoom, 0, npc.whoAmI); + NPC.NewNPC(NPC.GetSource_FromAI(), ancientDoomSpawnX * 16 + 8, ancientDoomSpawnY * 16 + 8, NPCID.AncientDoom, 0, NPC.whoAmI); break; } } @@ -959,260 +959,266 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - npc.ai[1] += 1f; - if (npc.ai[1] >= 64f) + NPC.ai[1] += 1f; + if (NPC.ai[1] >= 64f) { - 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; + NPC.velocity *= 0.96f; } + else + { + NPC.velocity = Vector2.Zero; + NPC.position = NPC.oldPosition; + + // Kill after 4 seconds + NPC.ai[1] += 1f; + if (NPC.ai[1] >= 240f) + { + 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; + } + 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 = (int)Math.Round(NPC.defDamage * PrimordialWyrmHead.LightDamageMult); + } + } + + 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; } - - 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) - { - // 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 = (int)Math.Round(npc.defDamage * PrimordialWyrmHead.LightDamageMult); - } - } - - 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) + public class AncientDoomAI : VanillaAIOverride { - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - 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()) + 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 = death ? 2 : 1; + float splitProjVelocity = death ? 4.5f : 3f; - if (phase2 || death) - rateOfChange++; + // 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 (phase4 || death) - rateOfChange++; + 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; - 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()) + 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()) { - float aiGateValue = Main.npc[(int)npc.ai[0]].Calamity().newAI[2] - 30f; - int ancientDoomScale = (int)(aiGateValue / 120f); - dist += ancientDoomScale * 45; + 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; } - 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; - } + else + kill = true; - 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.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.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) + if (phase3) { - int totalProjectiles = Main.getGoodWorld ? 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++) + 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()) { - Vector2 doomProjRotate = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, doomProjRotate, type, damage, 0f, Main.myPlayer); + 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 = Main.getGoodWorld ? 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; - } + 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 8fba6d9d83..ee16e8e2e2 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/DeerclopsAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/DeerclopsAI.cs @@ -12,7 +12,7 @@ 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; @@ -31,14 +31,14 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses public static int IceSpikeDamage = 16; // 64 (buffed from 52) public static int HandDamage = 13; // 52 (buffed from 40) - public static bool BuffedDeerclopsAI(NPC npc, Mod mod) + 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 death = CalamityWorld.death || BossRushEvent.BossRushActive; @@ -48,25 +48,25 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses int iceSpike = ProjectileID.DeerclopsIceSpike; int shadowHand = ProjectileID.InsanityShadowHostile; - 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); + 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); + 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) @@ -78,10 +78,10 @@ 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; @@ -107,68 +107,68 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses shouldDrawEnrageBorder = CalamityWorld.revenge || CalamityWorld.death; // Set the last deerclops position (used only for post-death border shenanigans) - lastDeerclopsPosition = npc.Center; + 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 the player enters the shadows if (Main.netMode != NetmodeID.MultiplayerClient && hasTargetBeenInRange) - SpawnBorderShadowHands(npc, lifeRatio, shadowHand, HandDamage, death); + 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; @@ -182,29 +182,29 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // 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) + 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; + 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; + NPC.SyncExtraAI(); + NPC.netUpdate = true; break; } - if (Math.Abs(distanceFromTarget2.X) < iceSpikesDistanceGateValue && useEitherIceSpikeAttack && npc.velocity.Y == 0f && useFrontIceSpikeAttack) + 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; + 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; + NPC.SyncExtraAI(); + NPC.netUpdate = true; break; } } @@ -215,33 +215,33 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float rubbleGateValue = death ? 160f : 200f; if (!doNotUseRubble) { - bool useRubbleAttack = npc.ai[1] >= rubbleGateValue; - if (npc.velocity.Y == 0f && npc.velocity.X != 0f && useRubbleAttack) + 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; + 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; + NPC.SyncExtraAI(); + NPC.netUpdate = true; break; } } float shadowHandGateValue = death ? 60f : 75f; - bool useShadowHandAttack = npc.ai[1] >= shadowHandGateValue; - if (npc.velocity.Y == 0f && npc.velocity.X == 0f && useShadowHandAttack) + bool useShadowHandAttack = NPC.ai[1] >= shadowHandGateValue; + 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; + NPC.velocity.X = 0f; + NPC.ai[0] = 5f; + NPC.ai[1] = 0f; + NPC.localAI[1] = 0f; calamityGlobalNPC.newAI[0] -= 1f; calamityGlobalNPC.newAI[1] = 0f; - npc.SyncExtraAI(); - npc.netUpdate = true; + NPC.SyncExtraAI(); + NPC.netUpdate = true; break; } @@ -249,39 +249,39 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // 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) + 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; + 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; + 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; + 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; @@ -290,25 +290,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); } @@ -318,14 +318,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, DebrisDamage, 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; @@ -333,20 +333,20 @@ 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 ? 11 : 9) + (int)MathHelper.Lerp(0f, 7f, 1f - lifeRatio); @@ -359,16 +359,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) * 550f, actualVelocity * velocityMultiplier * -1f, shadowHand, HandDamage, 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; @@ -376,17 +376,17 @@ 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; @@ -394,20 +394,20 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // 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 totalProjectiles = (death ? 20 : 16) + (int)MathHelper.Lerp(0f, 7f, 1f - lifeRatio); @@ -420,16 +420,16 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { 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); + 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; @@ -437,61 +437,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; @@ -499,32 +499,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; @@ -532,24 +532,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; } @@ -558,7 +558,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Movement - Movement(npc, lifeRatio, haltMovement, goHome, death); + Movement(NPC, lifeRatio, haltMovement, goHome, death); return false; } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs index 1dbf0d7888..d5fcdee407 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs @@ -1,6 +1,5 @@ using System; using CalamityMod.Events; -using CalamityMod.NPCs.NormalNPCs; using CalamityMod.Particles; using CalamityMod.Projectiles.Boss; using CalamityMod.World; @@ -14,7 +13,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { - public static class DestroyerAI + public class DestroyerAI : VanillaAIOverride { public const float DRIncreaseTime = 600f; public const float DeathModeLaserBreathGateValue = 800f; @@ -39,13 +38,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Rev+ exclusive public static int LaserDamage = 25; // 100 (buffed); Applies to all Rev+ lasers - public static bool BuffedDestroyerAI(NPC npc, Mod mod) + 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) @@ -69,14 +68,14 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); 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; @@ -113,41 +112,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; + 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 - if (npc.type > NPCID.TheDestroyer) + if (NPC.type > NPCID.TheDestroyer) { bool shouldDespawn = true; for (int i = 0; i < Main.maxNPCs; i++) @@ -160,17 +159,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; + NPC.life = 0; + NPC.HitEffect(0, 10.0); + NPC.checkDead(); + NPC.active = false; } } @@ -179,7 +178,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Calculate aggression based on how many broken segments there are float brokenSegmentAggressionMultiplier = 1f; - if (npc.type == NPCID.TheDestroyer) + if (NPC.type == NPCID.TheDestroyer) { int numProbeSegments = 0; for (int i = 0; i < Main.maxNPCs; i++) @@ -236,25 +235,25 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses turnSpeed *= 1.2f; } - bool probeLaunched = npc.ai[2] == 1f; + bool probeLaunched = NPC.ai[2] == 1f; - if (npc.type == NPCID.TheDestroyer) + 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; + 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 @@ -265,7 +264,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Fire lasers - if (npc.type == NPCID.TheDestroyerBody) + if (NPC.type == NPCID.TheDestroyerBody) { bool ableToFireLaser = calamityGlobalNPC.destroyerLaserColor != -1; @@ -287,13 +286,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses break; } - npc.SyncDestroyerLaserColor(); + NPC.SyncDestroyerLaserColor(); } if (probeLaunched && ableToFireLaser) { calamityGlobalNPC.destroyerLaserColor = -1; - npc.SyncDestroyerLaserColor(); + NPC.SyncDestroyerLaserColor(); } // Laser rate of fire @@ -305,7 +304,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { // Sync newAI every 20 frames for the new telegraph if (calamityGlobalNPC.newAI[0] % 20f == 10f && ableToFireLaser) - npc.SyncExtraAI(); + NPC.SyncExtraAI(); } Color telegraphColor = Color.Transparent; @@ -325,7 +324,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (calamityGlobalNPC.newAI[0] == shootProjectileTime - LaserTelegraphTime) { Particle telegraph = new DestroyerReticleTelegraph( - npc, + NPC, telegraphColor, 1.5f, 0.15f, @@ -336,7 +335,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (calamityGlobalNPC.newAI[0] == shootProjectileTime - SparkTelegraphTime) { Particle spark = new DestroyerSparkTelegraph( - npc, + NPC, telegraphColor * 2f, Color.White, 3f, @@ -352,7 +351,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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) + 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); @@ -360,24 +359,24 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Controls the fire rate getting slower as health lowers if (!death) { - if (npc.localAI[3] == 0f && phase3) + if (NPC.localAI[3] == 0f && phase3) { - npc.localAI[3] = 1f; - npc.SyncVanillaLocalAI(); - laserShootTimeBonus -= npc.ai[0] * 2f; + NPC.localAI[3] = 1f; + NPC.SyncVanillaLocalAI(); + laserShootTimeBonus -= NPC.ai[0] * 2f; } - else if (npc.localAI[3] == 1f && startFlightPhase) + else if (NPC.localAI[3] == 1f && startFlightPhase) { - npc.localAI[3] = 2f; - npc.SyncVanillaLocalAI(); - laserShootTimeBonus -= npc.ai[0] * 2f; + NPC.localAI[3] = 2f; + NPC.SyncVanillaLocalAI(); + laserShootTimeBonus -= NPC.ai[0] * 2f; } } calamityGlobalNPC.newAI[0] = laserShootTimeBonus; - npc.SyncExtraAI(); - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); + 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)) { // Laser speed float projectileSpeed = death ? 5f : 4f; @@ -400,47 +399,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; + 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, LaserDamage.CalculateMechDamage(), 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(); + NPC.SyncDestroyerLaserColor(); } } if (!death) { calamityGlobalNPC.destroyerLaserColor = -1; - npc.SyncDestroyerLaserColor(); + NPC.SyncDestroyerLaserColor(); } } } - 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; @@ -464,7 +463,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; @@ -477,15 +476,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++) { @@ -506,9 +505,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(); @@ -522,7 +521,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float telegraphProgress = 0f; if (calamityGlobalNPC.destroyerLaserColor != -1) { - if (npc.type == NPCID.TheDestroyer && spitLaserSpreads) + if (NPC.type == NPCID.TheDestroyer && spitLaserSpreads) { float telegraphGateValue = DeathModeLaserBreathGateValue - LaserTelegraphTime; if (calamityGlobalNPC.newAI[0] > telegraphGateValue) @@ -544,7 +543,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses telegraphProgress = MathHelper.Clamp((calamityGlobalNPC.newAI[0] - telegraphGateValue) / LaserTelegraphTime, 0f, 1f); } } - else if (npc.type == NPCID.TheDestroyerBody) + else if (NPC.type == NPCID.TheDestroyerBody) { float shootProjectileTime = (CalamityWorld.death || BossRushEvent.BossRushActive) ? 400f : 450f; float telegraphGateValue = shootProjectileTime - LaserTelegraphTime; @@ -569,32 +568,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 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; @@ -605,14 +604,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 { @@ -627,10 +626,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; @@ -638,58 +637,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) @@ -697,8 +696,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); @@ -712,27 +711,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; } } @@ -740,110 +739,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 Death - if (npc.type == NPCID.TheDestroyer && death && !flyAtTarget) + if (NPC.type == NPCID.TheDestroyer && death && !flyAtTarget) { - if (npc.Distance(player.Center) > 2000f) - npc.velocity += (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * 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(); @@ -851,199 +850,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; return false; } - public static bool BuffedProbeAI(NPC npc, Mod mod) + public class ProbeAI : VanillaAIOverride { - 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) + public override bool AI(Mod mod) { - 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) + 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) { - Vector2 idealVelocity = npc.SafeDirectionTo(targetData.Center) * velocity; - npc.SimpleFlyMovement(-idealVelocity, acceleration); + 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 - npc.velocity *= deceleration; - } - - for (int i = 0; i < Main.maxNPCs; i++) - { - 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)) + if (NPC.Distance(targetData.Center) < 160f) { - otherProbeDist = otherProbeDist.SafeNormalize(Vector2.UnitY); - otherProbeDist *= -0.1f; - npc.velocity += otherProbeDist; - Main.npc[i].velocity -= otherProbeDist; + Vector2 idealVelocity = NPC.SafeDirectionTo(targetData.Center) * velocity; + NPC.SimpleFlyMovement(-idealVelocity, acceleration); + } + else + NPC.velocity *= deceleration; + } + + for (int i = 0; i < Main.maxNPCs; i++) + { + 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.ai[3] != 0f) - { - if (NPC.IsMechQueenUp) + if (NPC.ai[3] != 0f) { - 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) + if (NPC.IsMechQueenUp) { - 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 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) { - npc.dontTakeDamage = false; - if (npc.ai[3] > 0f) - npc.netUpdate = true; + mechdusaProbe = NPC.FindFirstNPC(NPCID.TheDestroyer); + NPC.ai[2] = mechdusaProbe; + NPC.netUpdate = true; + } - npc.ai[3] = 0f; + 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 { - Vector2 spinningpoint = nPC2.Center + tileConvertedPosition; - spinningpoint = spinningpoint.RotatedBy(nPC2.rotation, nPC2.Center); - npc.Center = spinningpoint; - npc.velocity = nPC.velocity; - npc.dontTakeDamage = true; + 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.dontTakeDamage = false; + if (NPC.ai[3] > 0f) + NPC.netUpdate = true; - npc.ai[3] = 0f; + 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.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) + NPC.localAI[0] = 0f; + if (targetData.Type != 0 && Collision.CanHit(NPC.position, NPC.width, NPC.height, targetData.Position, targetData.Width, targetData.Height)) { - 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) + int type = ProjectileID.PinkLaser; + int totalProjectiles = 1; + Vector2 projectileVelocity = (targetData.Center - NPC.Center).SafeNormalize(Vector2.UnitY) * velocity; + if (NPC.IsMechQueenUp) { - case 0: - break; - case 1: - velocityMultiplier = 0.95f; - break; - case 2: - velocityMultiplier = 0.9f; - break; + Vector2 v = targetData.Center - NPC.Center - targetData.Velocity * 20f; + projectileVelocity = v.SafeNormalize(Vector2.UnitY) * 8f; } - Vector2 laserVelocity = projectileVelocity * velocityMultiplier; - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + laserVelocity.SafeNormalize(Vector2.UnitY) * 50f, laserVelocity, type, ProbeLaserDamage.CalculateMechDamage(), 0f, Main.myPlayer); + 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, ProbeLaserDamage.CalculateMechDamage(), 0f, Main.myPlayer); + } + + NPC.netUpdate = true; } - - 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; } - - 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; } } } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/DreadnautilusAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/DreadnautilusAI.cs index b97169ace4..36c0ca8597 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/DreadnautilusAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/DreadnautilusAI.cs @@ -9,9 +9,9 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { - public static class DreadnautilusAI + public class DreadnautilusAI : VanillaAIOverride { - public static bool BuffedDreadnautilusAI(NPC npc, Mod mod) + public override bool AI(Mod mod) { // Death Mode bool bool death = CalamityWorld.death; @@ -29,102 +29,102 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses int maxBloodSquids = death ? 3 : 2; // Spawn effect - if (npc.localAI[0] == 0f) + if (NPC.localAI[0] == 0f) { - npc.localAI[0] = 1f; - npc.alpha = 255; + NPC.localAI[0] = 1f; + NPC.alpha = 255; if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.ai[0] = -1f; - npc.netUpdate = true; + NPC.ai[0] = -1f; + NPC.netUpdate = true; } } // Create dust - if (npc.ai[0] != -1f && Main.rand.NextBool(4)) + 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); + 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; + dust.velocity += NPC.velocity * 0.3f; + NPC.position -= NPC.netOffset; } // Get a target - if (npc.target == Main.maxPlayers) + if (NPC.target == Main.maxPlayers) { - npc.TargetClosest(); - npc.ai[2] = npc.direction; + 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(); + 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(); + NPCAimedTarget nPCAimedTarget = NPC.GetTargetData(); if (Main.dayTime || !Main.bloodMoon) nPCAimedTarget = default(NPCAimedTarget); // Attacks and shit int attackType = -1; - switch ((int)npc.ai[0]) + switch ((int)NPC.ai[0]) { // Spawn effects case -1: { - npc.velocity *= 0.98f; - int spawnFaceDirection = Math.Sign(nPCAimedTarget.Center.X - npc.Center.X); + NPC.velocity *= 0.98f; + int spawnFaceDirection = Math.Sign(nPCAimedTarget.Center.X - NPC.Center.X); if (spawnFaceDirection != 0) { - npc.direction = spawnFaceDirection; - npc.spriteDirection = -npc.direction; + NPC.direction = spawnFaceDirection; + NPC.spriteDirection = -NPC.direction; } - if (npc.localAI[1] == 0f && npc.alpha < 100) + if (NPC.localAI[1] == 0f && NPC.alpha < 100) { - npc.localAI[1] = 1f; + 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; + 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; + NPC.position -= NPC.netOffset; } } - if (npc.ai[2] > 5f) + if (NPC.ai[2] > 5f) { - npc.velocity.Y = -2.5f; - npc.alpha -= 10; - if (Collision.SolidCollision(npc.position, npc.width, npc.height)) + 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; + NPC.alpha += 15; + if (NPC.alpha > 150) + NPC.alpha = 150; } - if (npc.alpha < 0) - npc.alpha = 0; + if (NPC.alpha < 0) + NPC.alpha = 0; } - npc.ai[2] += 1f; - if (npc.ai[2] >= 50f) + 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; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; } break; @@ -133,42 +133,42 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // 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 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); + 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) + 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) + if (NPC.spriteDirection != NPC.direction) { - npc.spriteDirection = npc.direction; - npc.rotation = 0f - npc.rotation; + 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) + NPC.rotation = NPC.rotation.AngleTowards(faceTargetDirection, 0.02f); + NPC.ai[1] += 1f; + if (NPC.ai[1] > phaseSwitchPhaseTime) { - int attackPicker = (int)npc.ai[3]; + 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); + SoundEngine.PlaySound(SoundID.Item170, NPC.Center); attackType = 2; } else { - SoundEngine.PlaySound(SoundID.Item170, npc.Center); + SoundEngine.PlaySound(SoundID.Item170, NPC.Center); attackType = 1; } } @@ -179,28 +179,28 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // 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) + 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) + bool shouldStartCharge = NPC.ai[1] < dashChargeUpPhaseTime; + if (NPC.spriteDirection != NPC.direction && shouldStartCharge) { - npc.spriteDirection = npc.direction; - npc.rotation = 0f - npc.rotation; + NPC.spriteDirection = NPC.direction; + NPC.rotation = 0f - NPC.rotation; chargeFaceDirection = 0f - chargeFaceDirection; } - if (npc.ai[1] < dashChargeUpPhaseTime) + if (NPC.ai[1] < dashChargeUpPhaseTime) { - if (npc.ai[1] == dashChargeUpPhaseTime - 1f) - SoundEngine.PlaySound(SoundID.Item172, npc.Center); + 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); + 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(); @@ -209,21 +209,21 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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; + NPC.position -= NPC.netOffset; } - else if (npc.ai[1] < dashChargeUpPhaseTime + dashPhaseTime) + 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); + 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.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; + 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; + NPC.ai[1] = dashChargeUpPhaseTime + dashPhaseTime * 0.9f; } for (int m = 0; m < 4; m++) @@ -236,11 +236,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses chargeBloodDust.position -= mouthDirection5 * 100f; } - npc.position -= npc.netOffset; + NPC.position -= NPC.netOffset; } - npc.ai[1] += 1f; - if (npc.ai[1] >= dashChargeUpPhaseTime + dashPhaseTime) + NPC.ai[1] += 1f; + if (NPC.ai[1] >= dashChargeUpPhaseTime + dashPhaseTime) attackType = 0; break; @@ -249,24 +249,24 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // 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) + 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) + if (NPC.spriteDirection != NPC.direction) { - npc.spriteDirection = npc.direction; - npc.rotation = 0f - npc.rotation; + 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.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); + 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); @@ -279,14 +279,14 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses bloodProjChargeUpDust.noGravity = true; } - npc.position -= npc.netOffset; + NPC.position -= NPC.netOffset; } - else if (npc.ai[1] < bloodSpitChargeUpPhaseTime + bloodSpitPhaseTime) + 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); + 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++) @@ -304,7 +304,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if ((int)bloodProjShootTimer == 0) { // Recoil away with each spit - npc.velocity += mouthDirection3 * -8f; + NPC.velocity += mouthDirection3 * -8f; // Spawn dust with each spit for (int j = 0; j < 20; j++) @@ -324,20 +324,20 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses int spread = death ? 35 : 30; float rotation = MathHelper.ToRadians(spread); Vector2 initialProjectileVelocity = mouthDirection3 * 10f; - int damage = npc.GetAttackDamage_ForProjectiles(30f, 25f); + 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); + Projectile.NewProjectile(NPC.GetSource_FromAI(), mouthPosition3 - mouthDirection3 * 5f, initialProjectileVelocity + perturbedSpeed, ProjectileID.BloodNautilusShot, damage, 0f, Main.myPlayer); } } } - npc.position -= npc.netOffset; + NPC.position -= NPC.netOffset; } - npc.ai[1] += 1f; - if (npc.ai[1] >= bloodSpitChargeUpPhaseTime + bloodSpitPhaseTime) + NPC.ai[1] += 1f; + if (NPC.ai[1] >= bloodSpitChargeUpPhaseTime + bloodSpitPhaseTime) attackType = 0; break; @@ -346,35 +346,35 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Spawn Blood Squids case 3: { - npc.direction = (npc.Center.X < nPCAimedTarget.Center.X) ? 1 : (-1); + NPC.direction = (NPC.Center.X < nPCAimedTarget.Center.X) ? 1 : (-1); float targetAngle = 0f; - npc.spriteDirection = npc.direction; - if (npc.ai[1] < bloodSquidPhaseTime) + 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; + 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); + 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); + 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; + NPC.position -= NPC.netOffset; } - if (npc.ai[1] == 10f || (death && npc.ai[1] == 20f) || npc.ai[1] == 30f) - BloodNautilus_CallForHelp(npc); + 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) + NPC.ai[1] += 1f; + if (NPC.ai[1] >= bloodSquidPhaseTime) attackType = 0; break; @@ -384,19 +384,19 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // 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(); + 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; + NPC.ai[2] = NPC.direction; else - npc.ai[3] += 1f; + NPC.ai[3] += 1f; } // Always set this to false because it's fucking stupid - npc.reflectsProjectiles = false; + NPC.reflectsProjectiles = false; return false; } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/DukeFishronAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/DukeFishronAI.cs index c40345c259..3f33e6802b 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/DukeFishronAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/DukeFishronAI.cs @@ -9,42 +9,42 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { - public static class DukeFishronAI + public class DukeFishronAI : VanillaAIOverride { // Vanilla values public static float Phase2ContactDamageMult = 1.436f; // 201 public static float Phase3ContactDamageMult = 1.315f; // 184 - public static bool BuffedDukeFishronAI(NPC npc, Mod mod) + 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 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 - npc.damage = npc.defDamage; + NPC.damage = NPC.defDamage; if (phase3AI) { - npc.damage = (int)Math.Round(npc.defDamage * Phase3ContactDamageMult); - npc.defense = 0; + NPC.damage = (int)Math.Round(NPC.defDamage * Phase3ContactDamageMult); + NPC.defense = 0; } else if (phase2AI) { - npc.damage = (int)Math.Round(npc.defDamage * Phase2ContactDamageMult); - 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; @@ -119,30 +119,30 @@ 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 @@ -153,11 +153,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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) ? 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) @@ -174,8 +174,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses bubbleSpinPhaseDivisor = 1; bubbleSpinBubbleVelocity = 15f; - npc.damage *= 2; - npc.defense = npc.defDefense * 3; + NPC.damage *= 2; + NPC.defense = NPC.defDefense * 3; } if (death) @@ -197,150 +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] = -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; + 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) { // Disable contact damage while spawning - npc.damage = 0; + 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) { // 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 || Main.zenithWorld) + 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: @@ -355,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; } @@ -373,222 +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 - 40; + 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) { // 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) { // 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) { // 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) { // 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) { // 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 || Main.zenithWorld) + 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: @@ -599,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; } @@ -617,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; } } @@ -641,228 +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) { // 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) { // 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 * (Main.getGoodWorld ? (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) { // 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) { // 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) { // 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 || Main.zenithWorld) + 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: @@ -884,7 +884,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } else { - switch ((int)npc.ai[3]) + switch ((int)NPC.ai[3]) { case 0: case 2: @@ -905,266 +905,269 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // 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 - 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) { // 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; } - npc.ai[2] += 1f; - if (npc.ai[2] >= chargeTime) + 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) { // Disable contact damage during the teleporting phase - npc.damage = 0; + 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 = 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++) - { - 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); - } + 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; + } - return false; + 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++) + { + if (i != NPC.whoAmI && Main.npc[i].active && Main.npc[i].type == NPC.type) + { + 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; + } + } + } + + 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.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; + } } } } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/EaterOfWorldsAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/EaterOfWorldsAI.cs index 7aade7a6d2..71945eabe4 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/EaterOfWorldsAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/EaterOfWorldsAI.cs @@ -11,7 +11,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { - public static class EaterOfWorldsAI + public class EaterOfWorldsAI : VanillaAIOverride { private const float ProjectileTelegraphDuration = 30f; private const int TotalDeathModeWorms = 4; @@ -23,28 +23,28 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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 - public static bool BuffedEaterofWorldsAI(NPC npc, Mod mod) + public override bool AI(Mod mod) { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + 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)); + 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) || Main.getGoodWorld) + 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 (Main.getGoodWorld && 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); + 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(); @@ -74,39 +74,39 @@ 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 - ProjectileTelegraphDuration) + if (NPC.localAI[1] > vileSpitGateValue - ProjectileTelegraphDuration) { Vector2 dustCenter = vileSpitShootLocation + Main.rand.NextVector2CircularEdge(5f, 5f); - Dust dust = Dust.NewDustDirect(dustCenter, 1, 1, DustID.CorruptGibs, 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) { @@ -116,9 +116,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float showTelegraphGateValue = timer - ProjectileTelegraphDuration; - if (Collision.CanHitLine(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) + if (Collision.CanHitLine(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1)) { - if (npc.justHit && death && calamityGlobalNPC.newAI[0] < showTelegraphGateValue) + if (NPC.justHit && death && calamityGlobalNPC.newAI[0] < showTelegraphGateValue) { calamityGlobalNPC.newAI[0] += 10f; if (calamityGlobalNPC.newAI[0] > showTelegraphGateValue) @@ -132,19 +132,19 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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 = Utils.DirectionTo(npc.Center, Main.player[npc.target].Center) * 7f + (npc.velocity * 0.5f); + 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(), npc.Center + npc.velocity, cursedFlameDirection, type, FireballDamage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + NPC.velocity, cursedFlameDirection, type, FireballDamage, 0f, Main.myPlayer); } } 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; @@ -155,23 +155,23 @@ 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 / TotalDeathModeWorms) : totalSegments); @@ -185,7 +185,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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; @@ -195,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) @@ -315,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) @@ -326,9 +326,9 @@ 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); + 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; @@ -380,8 +380,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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) @@ -390,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; @@ -404,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; @@ -427,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?) @@ -442,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) @@ -500,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); @@ -512,7 +512,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses targetPosY *= timeToReachTarget; // Despawn - bool shouldDespawn = npc.type == NPCID.EaterofWorldsHead && (Main.player[npc.target].dead || !Main.player[npc.target].ZoneCorrupt || !Main.player[npc.target].ZoneCrimson) && !BossRushEvent.BossRushActive; + 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; @@ -527,16 +527,16 @@ 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); @@ -545,75 +545,75 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } if (Main.dedServ) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, npc.whoAmI); + 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 @@ -623,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 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; } } } @@ -649,63 +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; - if (npc.type == NPCID.EaterofWorldsHead || (npc.type != NPCID.EaterofWorldsHead && Main.npc[(int)npc.ai[1]].alpha >= 85)) + 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(npc.position, npc.width, npc.height, DustID.Demonite, 0f, 0f, 100, default, 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); + SyncCalamityNPCAIArrayPacket.Send(NPC); } return false; diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/EmpressofLightAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/EmpressofLightAI.cs index 8c426944d4..a406f01494 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/EmpressofLightAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/EmpressofLightAI.cs @@ -10,7 +10,12 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { - public static class EmpressofLightAI + public static class EmpressOfLightAIUtils + { + public static int CalculateDamageForEnrage(this int damage) => NPC.ShouldEmpressBeEnraged() ? damage * 2 : damage; + } + + public class EmpressofLightAI : VanillaAIOverride { // NOTE: This is applied to all difficulties, in CalamityPlayerHitHurt public static float EverlastingRainbowTrailDamageMult = 0.75f; @@ -31,27 +36,25 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // 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 static int CalculateDamageForEnrage(this int damage) => NPC.ShouldEmpressBeEnraged() ? damage * 2 : damage; - - public static bool BuffedEmpressofLightAI(NPC npc, Mod mod) + public override bool AI(Mod mod) { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); // Difficulty bools. 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(); @@ -63,13 +66,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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 = !BossRushEvent.BossRushActive && dayTimeEnrage; + NPC.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive && dayTimeEnrage; Vector2 rainbowStreakDistance = new Vector2(-150f, -250f); Vector2 everlastingRainbowDistance = new Vector2(0f, -350f); @@ -113,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; @@ -171,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) @@ -179,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(); @@ -209,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; @@ -252,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) @@ -272,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) @@ -306,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) @@ -331,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; @@ -347,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; @@ -361,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) @@ -374,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() && !BossRushEvent.BossRushActive) + if (NPC.AI_120_HallowBoss_IsGenuinelyEnraged() && !BossRushEvent.BossRushActive) { if (!Main.dayTime) despawnFlag = true; @@ -387,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; @@ -408,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 = 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 = 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()); @@ -441,32 +444,32 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.netMode != NetmodeID.MultiplayerClient) { - 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) { - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + randomStreakOffset, -rainbowStreakVelocity, projectileType, projectileDamage, 0f, Main.myPlayer, npc.target, 1f - ai3); + 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; @@ -500,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) @@ -534,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) @@ -556,7 +559,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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; @@ -564,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]; @@ -584,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; @@ -608,22 +611,22 @@ 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 = Main.getGoodWorld ? 30f : death ? (dayTimeEnrage ? 22f : 15f) : (dayTimeEnrage ? 18f : 13f); @@ -657,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); } } @@ -670,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; @@ -685,7 +688,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses case 6: // Avoid cheap bullshit. - npc.damage = 0; + NPC.damage = 0; // Increase durability. calamityGlobalNPC.DR = shouldBeInPhase2ButIsStillInPhase1 ? 0.99f : 0.575f; @@ -695,20 +698,20 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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 = 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) @@ -716,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; @@ -735,7 +738,7 @@ 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; @@ -747,21 +750,21 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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; @@ -783,7 +786,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses calamityGlobalNPC.newAI[1] += 1f; // Sync the Calamity AI variables. - npc.SyncExtraAI(); + NPC.SyncExtraAI(); switch (randomLanceWallType) { @@ -839,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; @@ -870,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; @@ -882,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 = 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()); @@ -923,7 +926,7 @@ 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); + 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; } @@ -931,41 +934,41 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // 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; // 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); + 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(); @@ -973,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; @@ -989,34 +992,34 @@ 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; @@ -1024,29 +1027,29 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // 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++) @@ -1059,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; @@ -1078,15 +1081,15 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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]; @@ -1105,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; @@ -1125,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) @@ -1147,8 +1150,8 @@ 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 = boltDamage; @@ -1156,10 +1159,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses Vector2 vector = new Vector2(0f, (death ? -24f : -22f) - (phase3 ? ((death ? 6f : 4f) * streakHomeTime) : 0f)).RotatedBy(MathHelper.TwoPi * streakHomeTime); if (Main.netMode != NetmodeID.MultiplayerClient) { - 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); + 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; @@ -1171,22 +1174,22 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // 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; @@ -1195,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; @@ -1214,7 +1217,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses bool shouldDespawn = false; if (!trueDespawnFlag) { - if (npc.AI_120_HallowBoss_IsGenuinelyEnraged() && !BossRushEvent.BossRushActive) + if (NPC.AI_120_HallowBoss_IsGenuinelyEnraged() && !BossRushEvent.BossRushActive) { if (!Main.dayTime) shouldDespawn = true; @@ -1228,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; @@ -1257,41 +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); + 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 4156e5d6d5..8654176889 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,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { - public static class EyeOfCthulhuAI + public class EyeOfCthulhuAI : VanillaAIOverride { private const float ProjectileOffset = 50f; @@ -20,14 +19,14 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses public static float Phase3ContactDamageMult = 1.8f; // 54 (buffed from 40) public static int BloodShotDamage = 8; // 32 - public static bool BuffedEyeofCthulhuAI(NPC npc, Mod mod) + public override bool AI(Mod mod) { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); - Lighting.AddLight(npc.Center, 0.5f, 0.5f, 0.5f); + 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 death = CalamityWorld.death || BossRushEvent.BossRushActive; @@ -46,19 +45,19 @@ 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)); + 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; - 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); - 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,69 +66,69 @@ 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 || 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) { float hoverSpeed = death ? 9.5f + 7f * (1f - lifeRatio) : 7f; float hoverAcceleration = death ? 0.2f + 0.15f * (1f - lifeRatio) : 0.15f; @@ -141,38 +140,38 @@ 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 ? 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; + 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) @@ -182,7 +181,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { if (spawnServant) { - int eye = NPC.NewNPC(npc.GetSource_FromAI(), (int)servantSpawnCenter.X, (int)servantSpawnCenter.Y, NPCID.ServantofCthulhu); + 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) @@ -191,7 +190,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses else { int projType = ProjectileID.BloodNautilusShot; - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + servantSpawnVelocity.SafeNormalize(Vector2.UnitY) * ProjectileOffset, servantSpawnVelocity * 2f, projType, BloodShotDamage, 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; } } @@ -204,22 +203,22 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } } - else if (npc.ai[1] == 1f) + else if (NPC.ai[1] == 1f) { - npc.rotation = eyeRotation; + NPC.rotation = eyeRotation; float additionalVelocityPerCharge = 2f; - float chargeSpeed = (death ? 10.5f : 8f) + npc.ai[3] * additionalVelocityPerCharge; + 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) { int chargeDelay = death ? (75 - (int)Math.Round(30f * (1f - lifeRatio))) : 95; if (Main.getGoodWorld) @@ -227,88 +226,88 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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) { 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) { - 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) { - 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) { 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 ? 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 servantSpawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)servantSpawnCenter.X, (int)servantSpawnCenter.Y, NPCID.ServantofCthulhu); + 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; @@ -320,59 +319,59 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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; + 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) { 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); - 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) { @@ -397,19 +396,19 @@ 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; + NPC.ai[2] += 1f; if (death) { float projectileGateValue = lifeRatio < 0.5f ? 40f : 60f; - if (npc.ai[2] % projectileGateValue == 0f && shootProjectile) + if (NPC.ai[2] % projectileGateValue == 0f && shootProjectile) { - Vector2 projectileVelocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * servantAndProjectileVelocity * 2f; - Vector2 projectileSpawnCenter = npc.Center + projectileVelocity; + Vector2 projectileVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * servantAndProjectileVelocity * 2f; + Vector2 projectileSpawnCenter = NPC.Center + projectileVelocity; if (Main.netMode != NetmodeID.MultiplayerClient) { int type = ProjectileID.BloodNautilusShot; @@ -419,7 +418,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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); + 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; } } @@ -428,90 +427,90 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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) { - SoundEngine.PlaySound(SoundID.ForceRoar, npc.Center); - npc.rotation = eyeRotation; + SoundEngine.PlaySound(SoundID.ForceRoar, NPC.Center); + NPC.rotation = eyeRotation; float additionalVelocityPerCharge = 3f; - float chargeSpeed = (death ? 12f : 10f) + ((death ? 10f : 3.5f) * (phase2LifeRatio - lifeRatio)) + npc.ai[3] * additionalVelocityPerCharge; - 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) { 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) { 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) { - 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) { - 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) { float speedBoost = death ? 10f * (phase3LifeRatio - lifeRatio) : 7f * (phase3LifeRatio - lifeRatio); 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)) @@ -519,99 +518,99 @@ 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) { - 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) { - 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) { - 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) { float offset = death ? 540f : 600f; float speedBoost = death ? 15f * (phase3LifeRatio - lifeRatio) : 5f * (phase3LifeRatio - lifeRatio); @@ -621,17 +620,17 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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) + 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; } - 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) { @@ -639,20 +638,20 @@ 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; + Vector2 servantSpawnVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * servantAndProjectileVelocity; + Vector2 servantSpawnCenter = NPC.Center + servantSpawnVelocity.SafeNormalize(Vector2.UnitY) * ProjectileOffset; int maxServants = death ? (finalPhaseDeath ? 1 : penultimatePhaseDeath ? 2 : 3) : (finalPhaseRev ? 2 : 4); bool spawnServant = NPC.CountNPCS(NPCID.ServantofCthulhu) < maxServants; @@ -663,13 +662,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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, NPCID.ServantofCthulhu); + 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; @@ -679,7 +678,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses else if (!Main.getGoodWorld) { int projType = ProjectileID.BloodNautilusShot; - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + servantSpawnVelocity.SafeNormalize(Vector2.UnitY) * ProjectileOffset, servantSpawnVelocity * 2f, projType, BloodShotDamage, 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; } @@ -693,7 +692,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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; } } @@ -701,29 +700,29 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } 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: @@ -734,54 +733,54 @@ 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) { if (Main.netMode != NetmodeID.MultiplayerClient) { float speedBoost = death ? 15f * (phase3LifeRatio - lifeRatio) : 5f * (phase3LifeRatio - lifeRatio); float chargeSpeed = (death ? 23f : 18f) + speedBoost; - npc.velocity = npc.SafeDirectionTo(Main.player[npc.target].Center) * chargeSpeed; + 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) { - 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) { - 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[2] = 0f; - npc.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[1] = 0f; } } } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/GolemAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/GolemAI.cs index fcbbdc7270..869321cc5d 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/GolemAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/GolemAI.cs @@ -11,22 +11,22 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { - public static class GolemAI + public class GolemAI : VanillaAIOverride { // 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 static bool BuffedGolemAI(NPC npc, Mod mod) + 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 death = CalamityWorld.death || BossRushEvent.BossRushActive; @@ -35,30 +35,30 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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; - 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); + 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 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) @@ -72,35 +72,35 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.getGoodWorld) enrage = true; - npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive && (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; + 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) { @@ -117,7 +117,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; @@ -126,7 +126,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; @@ -138,7 +138,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; @@ -147,7 +147,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; @@ -159,66 +159,66 @@ 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; + 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 ? 1.5f : 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; + NPC.ai[1] += 6f; } } 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) + 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 (npc.ai[3] == 0f) - npc.ai[3] = (death ? !leftFistAlive && !rightFistAlive : !headAlive) ? Main.rand.Next(1, 2+1) : 1f; + if (NPC.ai[3] == 0f) + NPC.ai[3] = (death ? !leftFistAlive && !rightFistAlive : !headAlive) ? Main.rand.Next(1, 2 + 1) : 1f; - switch ((int)npc.ai[3]) + switch ((int)NPC.ai[3]) { default: case 0: @@ -242,13 +242,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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.00275f : enrage ? 0.0025f : 0.00175f; @@ -259,25 +259,25 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (speedMult > speedMultLimit) speedMult = speedMultLimit; - if (Main.player[npc.target].position.Y < npc.Bottom.Y) - npc.velocity.Y = ((turboEnrage ? -15.5f : -11.75f) + (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.noTileCollide = true; - npc.ai[2] += 1f; + NPC.ai[2] += 1f; float jumpVelocity = death ? 26f : 21f; if (enrage) jumpVelocity *= 1.25f; @@ -286,30 +286,30 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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) + 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; + 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; + 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) + if (NPC.velocity.Y == 0f) { - npc.velocity = center - npc.Center; - npc.velocity = npc.velocity.SafeNormalize(Vector2.Zero); - npc.velocity *= jumpVelocity; + 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 distanceBelowTarget = NPC.position.Y - (Main.player[NPC.target].position.Y + 80f); float speedMult = 1f; float multiplier = turboEnrage ? 0.0025f : enrage ? 0.002f : 0.0015f; @@ -320,49 +320,49 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (speedMult > speedMultLimit) speedMult = speedMultLimit; - if (Main.player[npc.target].position.Y < npc.Bottom.Y) - npc.velocity.Y *= speedMult; + if (Main.player[NPC.target].position.Y < NPC.Bottom.Y) + NPC.velocity.Y *= speedMult; } else - npc.velocity.Y *= 0.95f; + 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; } @@ -373,7 +373,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { 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()) @@ -384,10 +384,10 @@ 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; } @@ -399,7 +399,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses int type = ProjectileID.Fireball; int damage = FireballDamage; - Vector2 destination = new Vector2(npc.Center.X, npc.Center.Y - 100f) - npc.Center; + Vector2 destination = new Vector2(NPC.Center.X, NPC.Center.Y - 100f) - NPC.Center; destination.Normalize(); destination *= projectileVelocity; int totalFireballsPerSide = 3; @@ -411,64 +411,64 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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); + 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.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) + 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; + NPC.velocity.X *= NPC.ai[2] == 1f ? 0.5f : 0.8f; - if (npc.Bottom.Y < Main.player[npc.target].position.Y || npc.ai[2] == 1f) + if (NPC.Bottom.Y < Main.player[NPC.target].position.Y || NPC.ai[2] == 1f) { 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.velocity.Y += fallSpeed; + NPC.velocity.Y += fallSpeed; } } else { 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.direction < 0) + NPC.velocity.X -= velocityXChange; + else if (NPC.direction > 0) + NPC.velocity.X += velocityXChange; float velocityBoost = death ? 5.75f * (1f - (lifeRatio / 2)) : 4f * (1f - (lifeRatio / 2)); float velocityXCap = (death ? 6f : 4f) + velocityBoost; if (enrage) velocityXCap *= 3f; - float playerLocation = npc.Center.X - Main.player[npc.target].Center.X; + 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; + if (NPC.velocity.X < -velocityXCap) + NPC.velocity.X = -velocityXCap; + if (NPC.velocity.X > velocityXCap) + NPC.velocity.X = velocityXCap; } - CustomGravity(npc.ai[2] == 1f); + CustomGravity(NPC.ai[2] == 1f); } } @@ -482,890 +482,899 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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(); + if (NPC.golemBoss < 0) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.StrikeInstantKill(); - return false; - } + return false; + } - if (npc.alpha > 0) - { - npc.alpha -= 10; - if (npc.alpha < 0) - npc.alpha = 0; - } + 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); + // 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]; + NPC golem = Main.npc[NPC.golemBoss]; + Player player = Main.player[NPC.target]; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + 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; + // 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; + Tile tile = Framing.GetTileSafely(targetTilePosX, targetTilePosY); + if (tile.WallType == WallID.LihzahrdBrickUnsafe) + enrage = false; + else + turboEnrage = Main.getGoodWorld; + } else turboEnrage = Main.getGoodWorld; - } - else - turboEnrage = Main.getGoodWorld; - if (Main.getGoodWorld) - enrage = true; + if (Main.getGoodWorld) + enrage = true; - float aggression = turboEnrage ? 3f : enrage ? 2f : death ? 1.7f : 1f; + float aggression = turboEnrage ? 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) - { - 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) - { - 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) - { - 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, 228, 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) - { - 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; - 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) + 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; - npc.ai[0] = 0f; - } - } - else - { - if (npc.ai[0] != 3f) - return false; + NPC.damage = 0; - // Set damage - npc.damage = npc.defDamage; + NPC.noTileCollide = true; - 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; + float fistSpeed = 28f; + fistSpeed *= (aggression + 3f) / 4f; + if (fistSpeed > 48f) + fistSpeed = 48f; - 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 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(); - - 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++) + float fistRestDistance = distanceFromRestPosition; + if (fistRestDistance < 12f + fistSpeed) { - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), projectileFirePos, fireballVelocity * (1f / (i + 1)), type, damage, 0f, Main.myPlayer); - Main.projectile[proj].timeLeft = 225; + 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) + { + 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) + { + 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, 228, largeRandDustRecoil); + dust.fadeIn = 1.5f; + dust.scale = 0.5f; + if (Main.getGoodWorld) + dust.noLight = true; + + dust.noGravity = true; + } } - 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) + if (NPC.ai[1] >= 30f) { - for (int i = 0; i < 2; i++) + // 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++) { - 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) + for (int k = (int)(NPC.position.Y / 16f) - 1; (float)k < (NPC.position.Y + (float)NPC.width) / 16f + 1f; k++) { - 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; + if (Main.tile[j, k].TileType == TileID.Torches) + { + Main.tile[j, k].Get().HasTile = false; + if (Main.dedServ) + NetMessage.SendTileSquare(-1, j, k); + } } } } - else if (npc.localAI[1] != 0f) + + NPC.ai[1] += 1f; + if (NPC.ai[1] == 1f) + SoundEngine.PlaySound(SoundID.Item14, NPC.Center); + + if (Main.rand.NextBool()) { - 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; + 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; + } - 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); + 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; - extraLaserTargetDist = extraLaserSpeed / extraLaserTargetDist; - extraLaserTargetX *= extraLaserTargetDist; - extraLaserTargetY *= extraLaserTargetDist; + 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; - Vector2 laserVelocity = new Vector2(extraLaserTargetX, extraLaserTargetY); + 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 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) + { + 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; + } + } + } + } + + // Special laser spread attack + else if (NPC.ai[0] == 2f || NPC.ai[0] == 3f) + { + 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(), projectileFirePos + laserVelocity.SafeNormalize(Vector2.UnitY) * 40f, laserVelocity, projType, dmg, 0f, Main.myPlayer); + 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; + NPC.netUpdate = true; } } - } - } - // Special laser spread attack - else if (npc.ai[0] == 2f || npc.ai[0] == 3f) - { - 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) + // Do another attack in the opposite direction in Death Mode + if (death && NPC.ai[0] == 2f && NPC.ai[1] >= endTime) { - 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.ai[0] = 3f; + NPC.ai[1] = 0f; + NPC.localAI[1] = -NPC.localAI[1]; + NPC.netUpdate = true; + } - npc.netUpdate = true; + if (NPC.ai[1] >= endTime + 30) + { + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; } } - // Do another attack in the opposite direction in Death Mode - if (death && npc.ai[0] == 2f && npc.ai[1] >= endTime) + // Laser fire if arms are dead + if ((!leftFistAlive && !rightFistAlive) || death || Main.getGoodWorld) { - npc.ai[0] = 3f; - npc.ai[1] = 0f; - npc.localAI[1] = -npc.localAI[1]; - npc.netUpdate = true; + if (NPC.ai[0] <= 1f) + NPC.ai[0] = 1f; } - - if (npc.ai[1] >= endTime + 30) - { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.netUpdate = true; - } - } - - // Laser fire if arms are dead - if ((!leftFistAlive && !rightFistAlive) || death || Main.getGoodWorld) - { - if (npc.ai[0] <= 1f) - npc.ai[0] = 1f; - } - else - 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) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - npc.StrikeInstantKill(); + else + NPC.ai[0] = 0f; 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) + public class HeadFreeAI : VanillaAIOverride + { + public override bool AI(Mod mod) { - int targetTilePosX = (int)Main.player[npc.target].Center.X / 16; - int targetTilePosY = (int)Main.player[npc.target].Center.Y / 16; + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); - Tile tile = Framing.GetTileSafely(targetTilePosX, targetTilePosY); - if (tile.WallType == WallID.LihzahrdBrickUnsafe) - enrage = false; + // 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 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 turboEnrage = Main.getGoodWorld; - } - else - turboEnrage = Main.getGoodWorld; - if (Main.getGoodWorld) - enrage = true; + if (Main.getGoodWorld) + enrage = true; - // Float through tiles or not - npc.noTileCollide = !Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1) || phase2 || turboEnrage; + // 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[0] = 3f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = PosDelay; - calamityGlobalNPC.newAI[3] = 0; - npc.netUpdate = true; - npc.SyncExtraAI(); - } - - // 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) + // Immediately trigger the laser spread attack at phase transition thresholds + if (phase2 && NPC.ai[0] == 0f || phase3 && NPC.ai[0] == 1f) { + NPC.ai[0] = 3f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = PosDelay; calamityGlobalNPC.newAI[3] = 0; - npc.ai[0] = 3f; - npc.ai[1] = 0f; - npc.ai[3] = PosDelay; + NPC.netUpdate = true; + NPC.SyncExtraAI(); } - // Four positions around target - if (!(phase3 || turboEnrage)) + // Move to new location + float maxDistanceDiagonal = 360f; + float maxDistanceStraight = 480f; + if (NPC.ai[3] <= 0f) { - if (phase2) + NPC.ai[3] = PosDelay; + calamityGlobalNPC.newAI[3] += phase2 ? 1 : 0; + if (calamityGlobalNPC.newAI[3] >= 7) { - // 0 is top left, then goes counter-clockwise - switch ((int)(calamityGlobalNPC.newAI[3] % 4)) + calamityGlobalNPC.newAI[3] = 0; + NPC.ai[0] = 3f; + NPC.ai[1] = 0f; + NPC.ai[3] = PosDelay; + } + + // Four positions around target + if (!(phase3 || turboEnrage)) + { + if (phase2) { - 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; + // 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; } } - // Above target - else - { - calamityGlobalNPC.newAI[0] = Main.rand.NextFloat(-150f, 150f); - calamityGlobalNPC.newAI[1] = -maxDistanceStraight * 0.85f; - } + NPC.netSpam = 5; + NPC.SyncExtraAI(); + NPC.ForceNetUpdate(); } - npc.netSpam = 5; - npc.SyncExtraAI(); - npc.ForceNetUpdate(); - } + float positioningInc = enrage ? 6f : phase3 ? 2.5f : phase2 ? 1.8f : 1f; + NPC.ai[3] -= positioningInc; - 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) + // Move in a circle around the player in final phase + if (phase3 || turboEnrage) { - // 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); + 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; + } - for (int i = -1; i <= 1; i += 2) + 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) { - 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; + // 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); - npc.netUpdate = true; + 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; + // 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) + // 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 + NPC.ai[2] += 1f; + + int laserGateValue = (int)(PosDelay / positioningInc); + if (canFireProjectiles && Main.netMode != NetmodeID.MultiplayerClient && ((NPC.ai[2] - calamityGlobalNPC.newAI[2]) % (laserGateValue / 2) == 0f)) { - 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 numLasers = 2; + for (int i = 0; i < numLasers; i++) + { + Vector2 freeHeadProjSpawn = new Vector2(NPC.Center.X, NPC.Center.Y - 20f * NPC.scale); + freeHeadProjSpawn.X += 14f * NPC.scale * (i == 1).ToDirectionInt(); - 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); + float freeHeadProjSpeed = 7f + (5f * (1f - golemLifeRatio)); + Vector2 laserVelocity = Main.player[NPC.target].Center - freeHeadProjSpawn; + laserVelocity = laserVelocity.SafeNormalize(Vector2.UnitY) * freeHeadProjSpeed; + + 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; + } } - // Death fires 2 bolts, Rev fires just 1 - if (npc.ai[1] >= fireballStartTime + (death ? 40 : 10)) + if (!Main.getGoodWorld) { - 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(); + 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; } - - // Lasers - npc.ai[2] += 1f; - - int laserGateValue = (int)(PosDelay / positioningInc); - if (canFireProjectiles && Main.netMode != NetmodeID.MultiplayerClient && ((npc.ai[2] - calamityGlobalNPC.newAI[2]) % (laserGateValue / 2) == 0f)) - { - int numLasers = 2; - for (int i = 0; i < numLasers; i++) - { - Vector2 freeHeadProjSpawn = new Vector2(npc.Center.X, npc.Center.Y - 20f * npc.scale); - freeHeadProjSpawn.X += 14f * npc.scale * (i == 1).ToDirectionInt(); - - float freeHeadProjSpeed = 7f + (5f * (1f - golemLifeRatio)); - Vector2 laserVelocity = Main.player[npc.target].Center - freeHeadProjSpawn; - laserVelocity = laserVelocity.SafeNormalize(Vector2.UnitY) * freeHeadProjSpeed; - - 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; - } - } - - 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; } } } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/KingSlimeAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/KingSlimeAI.cs index c0c501dff7..067177d219 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,20 +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) { - float lifeRatio = npc.life / (float)npc.lifeMax; + float lifeRatio = NPC.life / (float)NPC.lifeMax; float lifeRatio2 = lifeRatio; float teleportScale = 1f; bool teleporting = false; bool teleported = false; - npc.aiAction = 0; + NPC.aiAction = 0; float teleportScaleSpeed = 2f; if (Main.getGoodWorld) { @@ -43,21 +42,21 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses bool redCrystalAlive = NPC.AnyNPCs(ModContent.NPCType()); // npc.Calamity().newAI[0] as a flag for Ruby spawn state: 0f = can spawn, 1f = spawned - bool rubySpawnedForCurrentPhase = npc.Calamity().newAI[0] == 1f; + bool rubySpawnedForCurrentPhase = NPC.Calamity().newAI[0] == 1f; - int setDamage = npc.defDamage; // Defined externally - npc.defense = npc.defDefense; + int setDamage = NPC.defDamage; // Defined externally + NPC.defense = NPC.defDefense; if (rubySpawnPhaseActive && !redCrystalAlive && !rubySpawnedForCurrentPhase) { - npc.Calamity().newAI[0] = 1f; - npc.SyncExtraAI(); + NPC.Calamity().newAI[0] = 1f; + NPC.SyncExtraAI(); - Vector2 vector = npc.Center + new Vector2(-40f, -(float)npc.height / 2) * npc.scale; + 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); + 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()) @@ -67,163 +66,163 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - SoundEngine.PlaySound(SpawnCrystalSound with { Volume = 2f }, npc.Center); + SoundEngine.PlaySound(SpawnCrystalSound with { Volume = 2f }, 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; + 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 if (rubySpawnedForCurrentPhase && !rubySpawnPhaseActive) { - npc.Calamity().newAI[0] = 0f; - npc.SyncExtraAI(); + 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 = (death ? 0.1f : 0f) + (!redCrystalAlive ? 0.1f : 0f); - npc.velocity.Y += fallSpeedBonus; + 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) { - 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; } // Closer to activating teleport - if (npc.ai[2] < teleportGateValue) + 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 (NPC.ai[1] == 5f || NPC.ai[1] == 6f) { - if (Math.Abs(npc.velocity.X) > 0.1f) + 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; + 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) { - 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, DustID.TintableDust, npc.velocity.X, npc.velocity.Y, 150, 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 *= 0.5f; } @@ -231,72 +230,72 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Post-teleport - else if (npc.ai[1] == 6f) + else if (NPC.ai[1] == 6f) { - npc.damage = 0; + NPC.damage = 0; teleporting = true; - npc.aiAction = 0; + NPC.aiAction = 0; float teleportRate = redCrystalAlive ? 1f : 2f; if (death) teleportRate *= 2f; - 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, DustID.TintableDust, npc.velocity.X, npc.velocity.Y, 150, 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 *= 2f; } } - npc.noTileCollide = false; + NPC.noTileCollide = false; // Jump - if (npc.velocity.Y == 0f) + if (NPC.velocity.Y == 0f) { - 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] += 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) { - 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; @@ -306,43 +305,43 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses bool deathModeRapidHops = death && lifeRatio < 0.2f; if (deathModeRapidHops) - npc.ai[1] = 2f; + NPC.ai[1] = 2f; - if (npc.ai[1] == 3f) + if (NPC.ai[1] == 3f) { - 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; + 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 ? 7.65f : death ? 6.25f : 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; if (!deathModeRapidHops) - npc.ai[1] += 1f; + NPC.ai[1] += 1f; } else { - npc.velocity.Y = -8f * speedMult; - npc.velocity.X += (phase2 ? (death ? 5.75f : 5f) : 4f) * npc.direction; - npc.ai[0] = -60f; - npc.ai[1] += 1f; + 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.2f; + NPC.velocity.X *= 1.2f; - npc.noTileCollide = true; + NPC.noTileCollide = true; } - else if (npc.ai[0] >= -30f) - npc.aiAction = 1; + else if (NPC.ai[0] >= -30f) + NPC.aiAction = 1; } } - else if (npc.target < Main.maxPlayers) // Velocity factoring + else if (NPC.target < Main.maxPlayers) // Velocity factoring { float jumpVelocityLimit = redCrystalAlive ? 3f : 4.5f; if (death) @@ -350,38 +349,38 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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 += (death ? 0.25f : 0.2f) * npc.direction; + NPC.velocity.X += (death ? 0.25f : 0.2f) * NPC.direction; if (death) - npc.velocity.X += 0.25f * npc.direction; + NPC.velocity.X += 0.25f * NPC.direction; } else { - npc.velocity.X *= 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, DustID.TintableDust, npc.velocity.X, npc.velocity.Y, 255, 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 *= 0.5f; - if (npc.life <= 0) + if (NPC.life <= 0) return false; // Adjust size based on max health @@ -396,23 +395,23 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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; } 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++) { @@ -431,7 +430,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npcType = NPCID.GreenSlime; break; case 1: - npcType = Main.player[npc.target].ZoneJungle ? NPCID.JungleSlime : Main.player[npc.target].ZoneSnow ? NPCID.IceSlime : NPCID.BlueSlime; + npcType = Main.player[NPC.target].ZoneJungle ? NPCID.JungleSlime : Main.player[NPC.target].ZoneSnow ? NPCID.IceSlime : NPCID.BlueSlime; break; case 2: npcType = Main.raining ? NPCID.UmbrellaSlime : NPCID.BlueSlime; @@ -446,7 +445,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npcType = NPCID.YellowSlime; break; case 6: - npcType = Main.player[npc.target].ZoneJungle ? NPCID.SpikedJungleSlime : Main.player[npc.target].ZoneSnow ? NPCID.SpikedIceSlime : NPCID.SlimeSpiked; + npcType = Main.player[NPC.target].ZoneJungle ? NPCID.SpikedJungleSlime : Main.player[NPC.target].ZoneSnow ? NPCID.SpikedIceSlime : NPCID.SlimeSpiked; break; } @@ -457,7 +456,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { if (Main.rand.NextBool()) { - npcType = Main.player[npc.target].ZoneJungle ? NPCID.SpikedJungleSlime : Main.player[npc.target].ZoneSnow ? NPCID.SpikedIceSlime : NPCID.SlimeSpiked; + npcType = Main.player[NPC.target].ZoneJungle ? NPCID.SpikedJungleSlime : Main.player[NPC.target].ZoneSnow ? NPCID.SpikedIceSlime : NPCID.SlimeSpiked; } } @@ -468,11 +467,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npcType = NPCID.RainbowSlime; 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); + 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; diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/MoonLordAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/MoonLordAI.cs index 56d27c4c26..5ba3fc0e7e 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/MoonLordAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/MoonLordAI.cs @@ -13,7 +13,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // 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 static class MoonLordAI + public class MoonLordAI : VanillaAIOverride { public static readonly SoundStyle DeathrayChargeSound = new("CalamityMod/Sounds/Custom/MoonLordLaserCharge"); @@ -31,14 +31,14 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Vanilla values (GFB) public static int MoonBoulderDamage = 70; // 280 - public static bool BuffedMoonLordAI(NPC npc, Mod mod) + public override bool AI(Mod mod) { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + 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)) { @@ -63,24 +63,24 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.getGoodWorld) aggressionLevel = 6; - if (npc.type == NPCID.MoonLordCore) - BuffedMoonLordCoreAI(npc, aggressionLevel); - else if (npc.type == NPCID.MoonLordHead) - BuffedMoonLordHeadAI(npc, aggressionLevel); - else if (npc.type == NPCID.MoonLordHand) - BuffedMoonLordHandAI(npc, aggressionLevel); - else if (npc.type == NPCID.MoonLordFreeEye) - BuffedTrueEyeAI(npc); - else if (npc.type == NPCID.MoonLordLeechBlob) - BuffedMoonLeechBlobAI(npc); + 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 static void BuffedMoonLordCoreAI(NPC npc, int aggressionLevel) + public void BuffedMoonLordCoreAI(int aggressionLevel) { // Play a random Moon Lord sound - if (npc.ai[0] != -1f && npc.ai[0] != 2f && Main.rand.NextBool(200)) + if (NPC.ai[0] != -1f && NPC.ai[0] != 2f && Main.rand.NextBool(200)) { SoundStyle voiceSound = Utils.SelectRandom(Main.rand, [ @@ -92,70 +92,70 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses SoundID.Zombie98, SoundID.Zombie99 ]); - SoundEngine.PlaySound(voiceSound, npc.Center); + SoundEngine.PlaySound(voiceSound, NPC.Center); } // Start the AI - if (npc.localAI[3] == 0f) + if (NPC.localAI[3] == 0f) { - npc.netUpdate = true; - npc.localAI[3] = 1f; - npc.ai[0] = -1f; + NPC.netUpdate = true; + NPC.localAI[3] = 1f; + NPC.ai[0] = -1f; } // Teleport when target gets too far - if (npc.ai[0] == -2f) + if (NPC.ai[0] == -2f) { - npc.dontTakeDamage = true; + NPC.dontTakeDamage = true; - npc.ai[1] += 1f; - if (npc.ai[1] == 30f) - SoundEngine.PlaySound(SoundID.Zombie92, npc.Center); + 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) + MoonlordDeathDrama.RequestLight(NPC.ai[1] / 30f, NPC.Center); - if (npc.ai[1] == 60f) + if (NPC.ai[1] == 60f) { - npc.ai[1] = 0f; - npc.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[0] = 0f; } } // Spawn head and hands - if (npc.ai[0] == -1f) + if (NPC.ai[0] == -1f) { - npc.dontTakeDamage = true; + NPC.dontTakeDamage = true; - npc.ai[1] += 1f; - if (npc.ai[1] == 30f) - SoundEngine.PlaySound(SoundID.Zombie92, npc.Center); + 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) + MoonlordDeathDrama.RequestLight(NPC.ai[1] / 30f, NPC.Center); - if (npc.ai[1] == 60f) + if (NPC.ai[1] == 60f) { - npc.ai[1] = 0f; - npc.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[0] = 0f; - if (Main.netMode != NetmodeID.MultiplayerClient && npc.type == NPCID.MoonLordCore) + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.type == NPCID.MoonLordCore) { - npc.netUpdate = true; + NPC.netUpdate = true; for (int i = 0; i < 2; i++) { - int handSpawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X + i * 800 - 400, (int)npc.Center.Y - 100, NPCID.MoonLordHand, npc.whoAmI); + 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].ai[3] = NPC.whoAmI; Main.npc[handSpawn].netUpdate = true; - npc.localAI[i] = handSpawn; + NPC.localAI[i] = handSpawn; } - 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; + 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; + 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. @@ -163,30 +163,30 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // 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) + if (Main.npc[(int)NPC.localAI[0]].Calamity().newAI[0] == 1f) trueEyesThatShouldBeActive++; - if (Main.npc[(int)npc.localAI[1]].Calamity().newAI[0] == 1f) + if (Main.npc[(int)NPC.localAI[1]].Calamity().newAI[0] == 1f) trueEyesThatShouldBeActive++; - if (Main.npc[(int)npc.localAI[2]].Calamity().newAI[0] == 1f) + 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; + 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) + if (NPC.ai[0] == 0f) { - npc.dontTakeDamage = true; - npc.TargetClosest(false); + NPC.dontTakeDamage = true; + NPC.TargetClosest(false); - Vector2 targetDistance = Main.player[npc.target].Center - npc.Center; + Vector2 targetDistance = Main.player[NPC.target].Center - NPC.Center; if (targetDistance.Length() > 20f) { float velocity = 9.25f; @@ -213,60 +213,60 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses break; } // Move slower if the head is doing the phantasmal deathray - if (Main.npc[(int)npc.localAI[2]].ai[0] == 1f) + 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); + 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) + 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) + 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) + 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) + 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; + 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) + if (Main.npc[(int)NPC.localAI[0]].Calamity().newAI[0] != 1f) coreIsOpen = false; - if (Main.npc[(int)npc.localAI[1]].Calamity().newAI[0] != 1f) + if (Main.npc[(int)NPC.localAI[1]].Calamity().newAI[0] != 1f) coreIsOpen = false; - if (Main.npc[(int)npc.localAI[2]].Calamity().newAI[0] != 1f) + 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; + NPC.ai[0] = 1f; + NPC.dontTakeDamage = false; + NPC.netUpdate = true; } } } // Fly near target, take damage - else if (npc.ai[0] == 1f) + else if (NPC.ai[0] == 1f) { - npc.dontTakeDamage = false; - npc.TargetClosest(false); + NPC.dontTakeDamage = false; + NPC.TargetClosest(false); - Vector2 targetDistanceVulnerable = Main.player[npc.target].Center - npc.Center; + Vector2 targetDistanceVulnerable = Main.player[NPC.target].Center - NPC.Center; if (targetDistanceVulnerable.Length() > 20f) { float velocity = 9.25f; @@ -293,29 +293,29 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses break; } // Move slower if the head is doing the phantasmal deathray - if (Main.npc[(int)npc.localAI[2]].ai[0] == 1f) + 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); + 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) + else if (NPC.ai[0] == 2f) { - npc.dontTakeDamage = true; - npc.Calamity().ShouldCloseHPBar = true; - npc.velocity = new Vector2(npc.direction, -0.5f); + 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); + 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) + if (NPC.ai[1] == 60f) { foreach (Projectile projectile in Main.ActiveProjectiles) { @@ -336,10 +336,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Dust and smoke effects - if (npc.ai[1] % 3f == 0f && npc.ai[1] < 580f && npc.ai[1] > 60f) + 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; + Vector2 dustPos = NPC.Center + randPositionOffset; Point dustPosTileCoords = dustPos.ToTileCoordinates(); bool inOpenSpace = WorldGen.InWorld(dustPosTileCoords.X, dustPosTileCoords.Y, 0) && !WorldGen.SolidTile(dustPosTileCoords.X, dustPosTileCoords.Y); @@ -359,10 +359,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - for (float k = 0f; k < npc.ai[1] / 60f; k++) + 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; + Vector2 smokePos = NPC.Center + randPosOffset; Point smokePosTileCoords = smokePos.ToTileCoordinates(); bool smokeOpenSpace = WorldGen.InWorld(smokePosTileCoords.X, smokePosTileCoords.Y, 0) && !WorldGen.SolidTile(smokePosTileCoords.X, smokePosTileCoords.Y); @@ -377,10 +377,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Explosion effects - if (npc.ai[1] % 15f == 0f && npc.ai[1] < 480f && npc.ai[1] >= 90f && Main.netMode != NetmodeID.MultiplayerClient) + 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; + Vector2 npcOffset = NPC.Center + randomOffset; Point npcOffsetTileCoords = npcOffset.ToTileCoordinates(); bool inOpenSpace = WorldGen.InWorld(npcOffsetTileCoords.X, npcOffsetTileCoords.Y, 0) && !WorldGen.SolidTile(npcOffsetTileCoords.X, npcOffsetTileCoords.Y); @@ -388,22 +388,22 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { 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); + 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] == 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] >= 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) + 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(); + 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) @@ -416,27 +416,27 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - 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; } } // Despawn effects - else if (npc.ai[0] == 3f) + 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.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); + 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) + if (NPC.ai[1] == 40f) { foreach (Projectile projectile in Main.ActiveProjectiles) { @@ -463,7 +463,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - if (npc.ai[1] >= 60f) + if (NPC.ai[1] >= 60f) { // Despawn all the other parts first foreach (NPC n in Main.ActiveNPCs) @@ -476,9 +476,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - 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); NPC.LunarApocalypseIsUp = false; if (Main.dedServ) @@ -489,7 +489,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // 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); + 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) @@ -503,37 +503,37 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } if (!preventDespawn) { - npc.ai[0] = 3f; - npc.ai[1] = 0f; - npc.netUpdate = true; + 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) + 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; + 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; + 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) + if (Main.npc[(int)NPC.localAI[0]].active) { - Main.npc[(int)npc.localAI[0]].position += teleportOffset; - Main.npc[(int)npc.localAI[0]].netUpdate = true; + 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) + if (Main.npc[(int)NPC.localAI[1]].active) { - Main.npc[(int)npc.localAI[1]].position += teleportOffset; - Main.npc[(int)npc.localAI[1]].netUpdate = true; + 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) + if (Main.npc[(int)NPC.localAI[2]].active) { - Main.npc[(int)npc.localAI[2]].position += teleportOffset; - Main.npc[(int)npc.localAI[2]].netUpdate = true; + 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) @@ -547,29 +547,29 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - public static void BuffedMoonLordHeadAI(NPC npc, int aggressionLevel) + public void BuffedMoonLordHeadAI(int aggressionLevel) { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); // Despawn - if (!Main.npc[(int)npc.ai[3]].active || Main.npc[(int)npc.ai[3]].type != NPCID.MoonLordCore) + 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; + NPC.life = 0; + NPC.HitEffect(0, 10.0); + NPC.active = false; } // Trigger Daybreak projectiles - if (npc.localAI[3] == 13f && !npc.dontTakeDamage) - npc.PopAllAttachedProjectilesAndTakeDamageForThem(); + if (NPC.localAI[3] == 13f && !NPC.dontTakeDamage) + NPC.PopAllAttachedProjectilesAndTakeDamageForThem(); // Variables - npc.dontTakeDamage = npc.localAI[3] >= 15f; + NPC.dontTakeDamage = NPC.localAI[3] >= 15f; if (calamityGlobalNPC.newAI[0] == 1f) - npc.dontTakeDamage = true; + NPC.dontTakeDamage = true; - npc.velocity = Vector2.Zero; - npc.Center = Main.npc[(int)npc.ai[3]].Center - Vector2.UnitY * 400f; + 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; @@ -577,29 +577,29 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses int eyeAnimationCheck = 0; // Invulnerable - if (npc.ai[0] >= 0f || npc.ai[0] == -2f) + 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 (NPC.ai[0] == -2f) { if (calamityGlobalNPC.newAI[0] != 1f) calamityGlobalNPC.newAI[0] = 1f; - npc.life = npc.lifeMax; - npc.netUpdate = true; - npc.dontTakeDamage = true; + NPC.life = NPC.lifeMax; + NPC.netUpdate = true; + NPC.dontTakeDamage = true; } // Go to death animation - if (Main.npc[(int)npc.ai[3]].ai[0] == 2f) + if (Main.npc[(int)NPC.ai[3]].ai[0] == 2f) { - npc.ai[0] = -3f; + NPC.ai[0] = -3f; return; } // Set up attacks - float ai0CrossCheck = npc.ai[0]; - npc.ai[1] += 1f; + float ai0CrossCheck = NPC.ai[0]; + NPC.ai[1] += 1f; int attackIncrement = 0; int totalAttackTimer = 0; @@ -612,7 +612,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses while (attackIncrement < 5) { phaseAttackTime = NPC.MoonLordAttacksArray[0, 2, 1, attackIncrement]; - if (phaseAttackTime + totalAttackTimer > npc.ai[1]) + if (phaseAttackTime + totalAttackTimer > NPC.ai[1]) break; totalAttackTimer += phaseAttackTime; @@ -622,42 +622,42 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (attackIncrement == 5) { attackIncrement = 0; - npc.ai[1] = 0f; + 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; + NPC.ai[0] = NPC.MoonLordAttacksArray[0, 2, 0, attackIncrement]; + attackTimer = (int)NPC.ai[1] - totalAttackTimer; - if (npc.ai[0] != ai0CrossCheck) - npc.netUpdate = true; + if (NPC.ai[0] != ai0CrossCheck) + NPC.netUpdate = true; } // Death animation behavior - if (npc.ai[0] == -3f) + if (NPC.ai[0] == -3f) { - npc.dontTakeDamage = true; - npc.rotation = MathHelper.Lerp(npc.rotation, MathHelper.Pi / 12f, 0.07f); + 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; + 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; + if (NPC.localAI[2] < 14f) + NPC.localAI[2] += 1f; } // Setup phase for deathray and leech attacks - else if (npc.ai[0] == 0f) + else if (NPC.ai[0] == 0f) { eyeAnimationCheck = 3; - npc.TargetClosest(false); + NPC.TargetClosest(false); - Vector2 targetDist = Main.player[npc.target].Center - npc.Center + Vector2.UnitY * 22f; + Vector2 targetDist = Main.player[NPC.target].Center - NPC.Center + Vector2.UnitY * 22f; float deathrayTravelDist = targetDist.Length() / 500f; if (deathrayTravelDist > 1f) deathrayTravelDist = 1f; @@ -666,38 +666,38 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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 + 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 (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; + 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); + 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; - + 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.velocity = Utils.DirectionTo(deathrayDustRotation, NPC.Center) * 0.35f * (10f - deathrayDustAmt * 2f); deathrayDust.noGravity = true; - deathrayDust.customData = npc; + deathrayDust.customData = NPC; } } } @@ -735,30 +735,30 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Fire the deathray if (attackTimer == 180f && Main.netMode != NetmodeID.MultiplayerClient) { - npc.TargetClosest(false); - Vector2 deathrayRotationSpeed = Utils.DirectionTo(npc.Center, Main.player[npc.target].Center); + 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; + 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; + 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]; + 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] + 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 { @@ -766,16 +766,16 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses calamityGlobalNPC.newAI[1] = 0f; // Reset pupil draw location - npc.localAI[1] -= 0.07f; - if (npc.localAI[1] < 0f) + NPC.localAI[1] -= 0.07f; + if (NPC.localAI[1] < 0f) { - 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); + 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); } } } @@ -785,7 +785,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Moon Leech thing - else if (npc.ai[0] == 2f) + else if (NPC.ai[0] == 2f) { mouthAnimationCheck = 2; eyeAnimationCheck = 3; @@ -794,13 +794,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Spawn the leech tongue(s) if (attackTimer == 0f && Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 leechSpawnPos = npc.Center + mouthOffset; + 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); + 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); } } } @@ -812,8 +812,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { 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); + 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; } } @@ -821,15 +821,15 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Phantasmal Bolts - else if (npc.ai[0] == 3f) + else if (NPC.ai[0] == 3f) { if (attackTimer == 1f) { - npc.TargetClosest(false); - npc.netUpdate = true; + NPC.TargetClosest(false); + NPC.netUpdate = true; } - Vector2 aimDirection = Main.player[npc.target].Center - npc.Center; + Vector2 aimDirection = Main.player[NPC.target].Center - NPC.Center; bool shootFirstBolt = attackTimer == phaseAttackTime - 14f; bool shootSecondBolt = attackTimer == phaseAttackTime - 7f; bool shootThirdBolt = attackTimer == phaseAttackTime; @@ -837,10 +837,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { // Higher aggression gives the phantasmal bolts predictive aim case 6: - aimDirection = Main.player[npc.target].Center + Main.player[npc.target].velocity * 30f - npc.Center; + 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; + aimDirection = Main.player[NPC.target].Center + Main.player[NPC.target].velocity * 20f - NPC.Center; break; case 4: break; @@ -858,18 +858,18 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // 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; + 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); + 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]); + Vector2 boltDirection = Utils.Vector2FromElipse(NPC.localAI[0].ToRotationVector2(), eyeSizeVector * NPC.localAI[1]); float velocity = 6.25f; switch (aggressionLevel) @@ -894,89 +894,89 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses Vector2 boltVelocity = Vector2.Normalize(aimDirection) * velocity; int type = ProjectileID.PhantasmalBolt; - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + boltDirection, boltVelocity, type, BoltDamage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + boltDirection, boltVelocity, type, BoltDamage, 0f, Main.myPlayer); } } // 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 (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; // 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; + 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 static void BuffedMoonLordHandAI(NPC npc, int aggressionLevel) + public void BuffedMoonLordHandAI(int aggressionLevel) { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + 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) + 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; + NPC.life = 0; + NPC.HitEffect(0, 10.0); + NPC.active = false; } // Variables - bool isLeftHand = npc.ai[2] == 0f; + bool isLeftHand = NPC.ai[2] == 0f; float handFaceDirection = -isLeftHand.ToDirectionInt(); - npc.spriteDirection = (int)handFaceDirection; + NPC.spriteDirection = (int)handFaceDirection; // Trigger Daybreak projectiles - if (npc.frameCounter == 19.0 && !npc.dontTakeDamage) - npc.PopAllAttachedProjectilesAndTakeDamageForThem(); + if (NPC.frameCounter == 19.0 && !NPC.dontTakeDamage) + NPC.PopAllAttachedProjectilesAndTakeDamageForThem(); - npc.dontTakeDamage = npc.frameCounter >= 21.0; + NPC.dontTakeDamage = NPC.frameCounter >= 21.0; if (calamityGlobalNPC.newAI[0] == 1f) - npc.dontTakeDamage = true; + NPC.dontTakeDamage = true; Vector2 eyeSizeVector = new Vector2(30f, 66f); - Vector2 coreCenter = Main.npc[(int)npc.ai[3]].Center; + 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; + 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 (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 (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; + NPC.life = NPC.lifeMax; + NPC.netUpdate = true; + NPC.dontTakeDamage = true; } // Set up attacks - float ai0CrossCheck = npc.ai[0]; - npc.ai[1] += 1f; + float ai0CrossCheck = NPC.ai[0]; + NPC.ai[1] += 1f; int handType = isLeftHand ? 0 : 1; int attackIncrement = 0; int totalAttackTimer = 0; @@ -990,7 +990,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses while (attackIncrement < 5) { phaseAttackTime = NPC.MoonLordAttacksArray[0, handType, 1, attackIncrement]; - if (phaseAttackTime + totalAttackTimer > npc.ai[1]) + if (phaseAttackTime + totalAttackTimer > NPC.ai[1]) break; totalAttackTimer += (int)phaseAttackTime; @@ -1000,35 +1000,35 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (attackIncrement == 5) { attackIncrement = 0; - npc.ai[1] = 0f; + 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; + 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) + if (NPC.ai[0] == -2f) { handFrameCheck = 0; - npc.dontTakeDamage = true; - npc.velocity = Main.npc[(int)npc.ai[3]].velocity; + NPC.dontTakeDamage = true; + NPC.velocity = Main.npc[(int)NPC.ai[3]].velocity; } // Move - else if (npc.ai[0] == 0f) + 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; + 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; + Vector2 handMovementDirection = handMovementVector - NPC.Center; if (handMovementDirection.Length() > 20f) { @@ -1059,15 +1059,15 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } handMovementDirection *= velocity; - Vector2 currentVelocity = npc.velocity; + Vector2 currentVelocity = NPC.velocity; if (handMovementDirection != Vector2.Zero) - npc.SimpleFlyMovement(handMovementDirection, 0.3f); - npc.velocity = Vector2.Lerp(currentVelocity, npc.velocity, 0.5f); + NPC.SimpleFlyMovement(handMovementDirection, 0.3f); + NPC.velocity = Vector2.Lerp(currentVelocity, NPC.velocity, 0.5f); } } // Phantasmal Eyes - else if (npc.ai[0] == 1f) + else if (NPC.ai[0] == 1f) { handFrameCheck = 0; float divisor = 6f; @@ -1096,20 +1096,20 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (handAttackTimer >= 56) { - npc.localAI[1] -= 0.07f; - if (npc.localAI[1] < 0f) - npc.localAI[1] = 0f; + 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; + 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(); + NPC.localAI[0] = new Vector2(MathF.Cos(handPauseDirection) * eyeSizeVector.X, MathF.Sin(handPauseDirection) * eyeSizeVector.Y).ToRotation(); // Spawn phantasmal eyes if (handAttackTimer % divisor == 0f) @@ -1134,32 +1134,32 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses break; } - 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 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); + 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; + 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(MathF.Cos(handPauseDirection) * eyeSizeVector.X, MathF.Sin(handPauseDirection) * eyeSizeVector.Y).ToRotation(); + NPC.localAI[0] = new Vector2(MathF.Cos(handPauseDirection) * eyeSizeVector.X, MathF.Sin(handPauseDirection) * eyeSizeVector.Y).ToRotation(); } } // Phantasmal Spheres - else if (npc.ai[0] == 2f) + else if (NPC.ai[0] == 2f) { // 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; + NPC.localAI[1] -= 0.05f; + if (NPC.localAI[1] < 0f) + NPC.localAI[1] = 0f; Vector2 sphereHandDirection = coreCenter + new Vector2(320f * handFaceDirection, -110f); Vector2 sphereHandDirectionMaxBound = new Vector2(400f * handFaceDirection, -60f); @@ -1191,7 +1191,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (handAttackTimer < 30f) { // Set the hand's velocity for moving away from the body - Vector2 sphereHandTravelVelocity = sphereHandDirection - npc.Center; + Vector2 sphereHandTravelVelocity = sphereHandDirection - NPC.Center; if (sphereHandTravelVelocity != Vector2.Zero) { Vector2 sphereHandTravelDist = Vector2.Normalize(sphereHandTravelVelocity); @@ -1220,7 +1220,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses break; } - npc.velocity = Vector2.SmoothStep(npc.velocity, sphereHandTravelDist * Math.Min(velocity, sphereHandTravelVelocity.Length()), 0.2f); + NPC.velocity = Vector2.SmoothStep(NPC.velocity, sphereHandTravelDist * Math.Min(velocity, sphereHandTravelVelocity.Length()), 0.2f); } } else if (handAttackTimer < 210f) @@ -1261,12 +1261,12 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, sphereFireDirection, ProjectileID.PhantasmalSphere, SphereDamage, 1f, Main.myPlayer, 0f, NPC.whoAmI); Main.projectile[proj].timeLeft = 1200; } // Set the hand's velocity for moving away from the body - Vector2 handSmoothMovement = Vector2.SmoothStep(sphereHandDirection, sphereHandDirection + sphereHandDirectionMaxBound, (handAttackTimer - 30f) / 180f) - npc.Center; + Vector2 handSmoothMovement = Vector2.SmoothStep(sphereHandDirection, sphereHandDirection + sphereHandDirectionMaxBound, (handAttackTimer - 30f) / 180f) - NPC.Center; if (handSmoothMovement != Vector2.Zero) { Vector2 handSmoothMoveNormalize = handSmoothMovement; @@ -1296,24 +1296,24 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses break; } - npc.velocity = Vector2.Lerp(npc.velocity, handSmoothMoveNormalize * Math.Min(velocity, handSmoothMovement.Length()), 0.5f); + 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.velocity *= velocityMultiplier; + NPC.velocity *= velocityMultiplier; } else if (handAttackTimer < 287f) { handFrameCheck = 1; - npc.velocity *= velocityMultiplier; + NPC.velocity *= velocityMultiplier; } else if (handAttackTimer < 292f) { handFrameCheck = 2; - npc.velocity *= velocityMultiplier; + NPC.velocity *= velocityMultiplier; } else if (handAttackTimer < 300f) { @@ -1323,8 +1323,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (handAttackTimer == 292f && Main.netMode != NetmodeID.MultiplayerClient) { // 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); + 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 = 2f; switch (aggressionLevel) @@ -1353,7 +1353,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses sphereVelocity *= velocity; foreach (Projectile sp in Main.ActiveProjectiles) { - if (sp.type == ProjectileID.PhantasmalSphere && sp.ai[1] == npc.whoAmI && sp.ai[0] != -1f) + if (sp.type == ProjectileID.PhantasmalSphere && sp.ai[1] == NPC.whoAmI && sp.ai[0] != -1f) { sp.ai[0] = -1f; sp.velocity = sphereVelocity; @@ -1362,7 +1362,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - Vector2 handPauseSmoothSpeed = Vector2.SmoothStep(sphereHandDirection, sphereHandDirection + sphereHandDirectionMaxBound, 1f - (handAttackTimer - 270f) / 30f) - npc.Center; + Vector2 handPauseSmoothSpeed = Vector2.SmoothStep(sphereHandDirection, sphereHandDirection + sphereHandDirectionMaxBound, 1f - (handAttackTimer - 270f) / 30f) - NPC.Center; if (handPauseSmoothSpeed != Vector2.Zero) { Vector2 handPauseDirection = handPauseSmoothSpeed; @@ -1392,7 +1392,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses break; } - npc.velocity = Vector2.Lerp(npc.velocity, handPauseDirection * Math.Min(velocity, handPauseSmoothSpeed.Length()), 0.1f); + NPC.velocity = Vector2.Lerp(NPC.velocity, handPauseDirection * Math.Min(velocity, handPauseSmoothSpeed.Length()), 0.1f); } } else @@ -1400,7 +1400,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses handFrameCheck = 3; // Make the hand return back to being close to the body - Vector2 handReturnSmoothSpeed = sphereHandDirection - npc.Center; + Vector2 handReturnSmoothSpeed = sphereHandDirection - NPC.Center; if (handReturnSmoothSpeed != Vector2.Zero) { Vector2 handReturnDirection = handReturnSmoothSpeed; @@ -1430,21 +1430,21 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses break; } - npc.velocity = Vector2.SmoothStep(npc.velocity, handReturnDirection * Math.Min(velocity, handReturnSmoothSpeed.Length()), 0.2f); + NPC.velocity = Vector2.SmoothStep(NPC.velocity, handReturnDirection * Math.Min(velocity, handReturnSmoothSpeed.Length()), 0.2f); } } } // Phantasmal Bolts - else if (npc.ai[0] == 3f) + else if (NPC.ai[0] == 3f) { if (handAttackTimer == 0f) { - npc.TargetClosest(false); - npc.netUpdate = true; + NPC.TargetClosest(false); + NPC.netUpdate = true; } - Vector2 aimDirection = Main.player[npc.target].Center - npc.Center; + Vector2 aimDirection = Main.player[NPC.target].Center - NPC.Center; bool shootFirstBolt = handAttackTimer == phaseAttackTime - 14f; bool shootSecondBolt = handAttackTimer == phaseAttackTime - 7f; bool shootThirdBolt = handAttackTimer == phaseAttackTime; @@ -1452,10 +1452,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { // Higher aggression gives the phantasmal bolts predictive aim case 6: - aimDirection = Main.player[npc.target].Center + Main.player[npc.target].velocity * 30f - npc.Center; + 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; + aimDirection = Main.player[NPC.target].Center + Main.player[NPC.target].velocity * 20f - NPC.Center; break; case 4: break; @@ -1473,18 +1473,18 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // 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; + 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); + 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]); + Vector2 boltShootDirection = Utils.Vector2FromElipse(NPC.localAI[0].ToRotationVector2(), eyeSizeVector * NPC.localAI[1]); float velocity = 6.25f; switch (aggressionLevel) @@ -1508,7 +1508,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } Vector2 boltShootSpeed = Vector2.Normalize(aimDirection) * velocity; - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + boltShootDirection, boltShootSpeed, ProjectileID.PhantasmalBolt, BoltDamage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + boltShootDirection, boltShootSpeed, ProjectileID.PhantasmalBolt, BoltDamage, 0f, Main.myPlayer); } } @@ -1522,50 +1522,50 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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; + 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) + if (handFrameTimer > NPC.frameCounter) { - double handFrameControl = npc.frameCounter; - npc.frameCounter = handFrameControl + 1.0; + double handFrameControl = NPC.frameCounter; + NPC.frameCounter = handFrameControl + 1.0; } - if (handFrameTimer < npc.frameCounter) + if (handFrameTimer < NPC.frameCounter) { - double handFrameControl = npc.frameCounter; - npc.frameCounter = handFrameControl - 1.0; + 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; + if (NPC.frameCounter < 0.0) + NPC.frameCounter = 0.0; + if (NPC.frameCounter > 21.0) + NPC.frameCounter = 21.0; } - public static void BuffedTrueEyeAI(NPC npc) + public void BuffedTrueEyeAI() { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); // Despawn if the main boss is dying. - if (Main.npc[(int)npc.ai[3]].ai[0] == 2f) + if (Main.npc[(int)NPC.ai[3]].ai[0] == 2f) { - npc.HitEffect(0, 9999.0); - npc.active = false; + 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); + 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.whoAmI != NPC.whoAmI && n.type == NPC.type) { n.ai[0] = 0f; n.ai[1] = 0f; @@ -1575,7 +1575,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses n.localAI[2] = 0f; calamityGlobalNPC.newAI[0] = 1f; calamityGlobalNPC.newAI[1] = 0f; - npc.netUpdate = true; + NPC.netUpdate = true; eyesSynced++; if (eyesSynced >= eyeCount) @@ -1588,21 +1588,21 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } if (Main.rand.NextBool(420)) - SoundEngine.PlaySound(Main.rand.NextBool() ? SoundID.Zombie100 : SoundID.Zombie101, npc.Center); + 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) + 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; + 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; + 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. @@ -1612,7 +1612,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses while (attackIncrement < 10) { phaseAttackTime = NPC.MoonLordAttacksArray2[1, attackIncrement]; - if (phaseAttackTime + totalAttackTimer > npc.ai[1]) + if (phaseAttackTime + totalAttackTimer > NPC.ai[1]) break; totalAttackTimer += (int)phaseAttackTime; @@ -1622,106 +1622,106 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (attackIncrement == 10) { attackIncrement = 0; - npc.ai[1] = 0f; + 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; + NPC.ai[0] = NPC.MoonLordAttacksArray2[0, attackIncrement]; + float secondAttackTimer = (int)NPC.ai[1] - totalAttackTimer; - if (npc.ai[0] != ai0CrossCheck) - npc.netUpdate = true; + if (NPC.ai[0] != ai0CrossCheck) + NPC.netUpdate = true; // Completely unused state as far as I can tell. - if (npc.ai[0] == -1f) + if (NPC.ai[0] == -1f) { - npc.ai[1] += 1f; - if (npc.ai[1] > 180f) - npc.ai[1] = 0f; + NPC.ai[1] += 1f; + if (NPC.ai[1] > 180f) + NPC.ai[1] = 0f; float localAI2Lerp; - if (npc.ai[1] < 60f) + if (NPC.ai[1] < 60f) { localAI2Lerp = 0.75f; - npc.localAI[0] = 0f; + 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; + 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) + else if (NPC.ai[1] < 120f) { localAI2Lerp = 1f; - if (npc.localAI[1] < 0.5f) - npc.localAI[1] += 0.025f; + if (NPC.localAI[1] < 0.5f) + NPC.localAI[1] += 0.025f; - npc.localAI[0] += 0.209439516f; + 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[1] -= 0.05f; + if (NPC.localAI[1] < 0f) + NPC.localAI[1] = 0f; } - npc.localAI[2] = MathHelper.Lerp(npc.localAI[2], localAI2Lerp, 0.3f); + NPC.localAI[2] = MathHelper.Lerp(NPC.localAI[2], localAI2Lerp, 0.3f); } // Move towards the target. - if (npc.ai[0] == 0f) + if (NPC.ai[0] == 0f) { - npc.TargetClosest(false); + NPC.TargetClosest(false); - Vector2 v7 = Main.player[npc.target].Center - npc.Center; + 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; + 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); + 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; + Vector2 freeEyeTargetCenter = Main.player[NPC.target].Center; + Vector2 freeEyeTargetDistance = Utils.SafeNormalize(freeEyeTargetCenter - NPC.Center, Vector2.Zero) * velocity; - if (Vector2.Distance(npc.Center, freeEyeTargetCenter) > 300f) + 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; + 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; + 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 (n.whoAmI != NPC.whoAmI && n.type == NPC.type) { - if (Vector2.Distance(npc.Center, n.Center) < 150f) + if (Vector2.Distance(NPC.Center, n.Center) < 150f) { - if (npc.position.X < n.position.X) - npc.velocity.X -= freeEyeAccel; + if (NPC.position.X < n.position.X) + NPC.velocity.X -= freeEyeAccel; else - npc.velocity.X += freeEyeAccel; + NPC.velocity.X += freeEyeAccel; - if (npc.position.Y < n.position.Y) - npc.velocity.Y -= freeEyeAccel; + if (NPC.position.Y < n.position.Y) + NPC.velocity.Y -= freeEyeAccel; else - npc.velocity.Y += freeEyeAccel; + NPC.velocity.Y += freeEyeAccel; } } } @@ -1729,60 +1729,60 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Phantasmal bolts. - if (npc.ai[0] == 1f) + if (NPC.ai[0] == 1f) { if (secondAttackTimer == 0f) { - npc.TargetClosest(false); - npc.netUpdate = true; + NPC.TargetClosest(false); + NPC.netUpdate = true; } // Slow down before firing. - npc.velocity *= 0.95f; - if (npc.velocity.Length() < 1f) - npc.velocity = Vector2.Zero; + NPC.velocity *= 0.95f; + if (NPC.velocity.Length() < 1f) + NPC.velocity = Vector2.Zero; - Vector2 aimDirection = Main.player[npc.target].Center - npc.Center; + 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; + 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); + 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); + NPC.localAI[2] = MathHelper.Lerp(NPC.localAI[2], 0.4f, 0.2f); if (secondAttackTimer == phaseAttackTime - 35f) - SoundEngine.PlaySound(SoundID.NPCDeath6, npc.Center); + 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]); + 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); + 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) + 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[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.localAI[2] = MathHelper.Lerp(NPC.localAI[2], 0.4f, 0.2f); - npc.velocity *= 0.8f; - if (npc.velocity.Length() < 1f) - npc.velocity = Vector2.Zero; + 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) @@ -1827,13 +1827,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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); + 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); + Dust trueEyeDust = Dust.NewDustDirect(NPC.Center + freeEyeRotation - Vector2.One * 4f, 0, 0, DustID.Vortex, 0f, 0f); trueEyeDust.velocity += freeEyeRotation / 15f; trueEyeDust.noGravity = true; } @@ -1842,15 +1842,15 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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); + 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 (!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); + 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); } } } @@ -1861,29 +1861,29 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // 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); + 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; + 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) + if (sp.type == type && sp.ai[1] == NPC.whoAmI && sp.ai[0] != -1f) { - sp.velocity += npc.velocity; + sp.velocity += NPC.velocity; sp.netUpdate = true; } } } // 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); + 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; } @@ -1891,19 +1891,19 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Actually launch the spheres. if (secondAttackTimer < 120f) { - SoundEngine.PlaySound(SoundID.Zombie102, npc.Center); + SoundEngine.PlaySound(SoundID.Zombie102, NPC.Center); if (secondAttackTimer == 105f) - npc.netUpdate = true; + NPC.netUpdate = true; float velocity = 12f; - Vector2 trueEyeSphereVelocity = (npc.ai[2] - MathHelper.PiOver2).ToRotationVector2() * velocity; - npc.velocity = trueEyeSphereVelocity * 2f; + Vector2 trueEyeSphereVelocity = (NPC.ai[2] - MathHelper.PiOver2).ToRotationVector2() * velocity; + NPC.velocity = trueEyeSphereVelocity * 2f; // Set damage and velocity. foreach (Projectile sp in Main.ActiveProjectiles) { - if (sp.type == type && sp.ai[1] == npc.whoAmI && sp.ai[0] != -1f) + if (sp.type == type && sp.ai[1] == NPC.whoAmI && sp.ai[0] != -1f) { sp.ai[0] = -1f; sp.damage = TrueEyeSphereDamage; @@ -1915,104 +1915,104 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses return; } - npc.velocity *= 0.92f; - npc.rotation = npc.rotation.AngleLerp(0f, 0.2f); + NPC.velocity *= 0.92f; + NPC.rotation = NPC.rotation.AngleLerp(0f, 0.2f); } } // Phantasmal eyes. - else if (npc.ai[0] == 3f) + 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[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.localAI[2] = MathHelper.Lerp(NPC.localAI[2], 0.4f, 0.2f); - npc.velocity *= 0.9f; - if (npc.velocity.Length() < 1f) - npc.velocity = Vector2.Zero; + NPC.velocity *= 0.9f; + if (NPC.velocity.Length() < 1f) + NPC.velocity = Vector2.Zero; } else if (secondAttackTimer < 45f) { - npc.localAI[0] = 0f; + 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; + 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.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[1] -= 0.07f; + if (NPC.localAI[1] < 0f) + NPC.localAI[1] = 0f; - npc.localAI[2] = MathHelper.Lerp(npc.localAI[2], 1f, 0.2f); + 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; + 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.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; + 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]; + 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); + 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 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); + 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) + else if (NPC.ai[0] == 4f) { if (secondAttackTimer == 0f) { - npc.TargetClosest(false); - npc.netUpdate = true; + 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[2] = MathHelper.Lerp(NPC.localAI[2], 1f, 0.2f); - npc.localAI[1] -= 0.05f; - if (npc.localAI[1] < 0f) - npc.localAI[1] = 0f; + 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; + NPC.velocity *= 0.95f; + if (NPC.velocity.Length() < 1f) + NPC.velocity = Vector2.Zero; // Dust telegraph if (secondAttackTimer >= 60f) @@ -2022,11 +2022,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { float dustScale = j % 2 == 1 ? 1.65f : 0.8f; - Vector2 trueEyeDustDirection = npc.Center + Main.rand.NextFloat(MathHelper.TwoPi).ToRotationVector2() * eyeSizeVector / 2f; + 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.velocity = Vector2.Normalize(NPC.Center - trueEyeDustDirection) * 0.35f * (10f - dustAmt * 2f); trueEyeDust.noGravity = true; - trueEyeDust.customData = npc; + trueEyeDust.customData = NPC; } } } @@ -2041,65 +2041,65 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (secondAttackTimer == 180f && Main.netMode != NetmodeID.MultiplayerClient) { // 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) + if (Main.npc[(int)Main.npc[(int)NPC.ai[3]].localAI[2]].ai[0] == 1f) calamityGlobalNPC.newAI[1] *= 1.5f; - npc.TargetClosest(false); + NPC.TargetClosest(false); - Vector2 deathrayTargetDist = Utils.DirectionTo(npc.Center, Main.player[npc.target].Center); + 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; + 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; } - npc.localAI[1] += 0.05f; - if (npc.localAI[1] > 1f) - npc.localAI[1] = 1f; + 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]; + 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; + 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; + NPC.localAI[1] -= 0.07f; + if (NPC.localAI[1] < 0f) + NPC.localAI[1] = 0f; } } } - public static void BuffedMoonLeechBlobAI(NPC npc) + public void BuffedMoonLeechBlobAI() { // Variables Vector2 mouthMovement = Vector2.UnitY * 216f; - int headIndex = (int)Math.Abs(npc.ai[0]) - 1; - int leechTongue = (int)npc.ai[1]; + 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; + 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) + NPC.ai[2] += 1f; + if (NPC.ai[2] >= 180f) { if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -2178,31 +2178,31 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Die after healing. - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.active = false; + NPC.life = 0; + NPC.HitEffect(0, 10.0); + NPC.active = false; return; } // 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); + 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); // Dust effects - Vector2 basePos = -Vector2.UnitY * npc.height / 2f; + 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); + 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; + leechDust.customData = NPC; } - basePos = -Vector2.UnitY * npc.height / 6f; + 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); + 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; + Main.dust[leechDust2].customData = NPC; } } } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/PlanteraAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/PlanteraAI.cs index 84c7cc0ef4..cd5ccb60af 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/PlanteraAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/PlanteraAI.cs @@ -11,7 +11,7 @@ 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; @@ -43,18 +43,18 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses public static int GreenCloudDamage = 24; // 96 public static float DashDamageMult = 1.25f; // 175 - public static bool BuffedPlanteraAI(NPC npc, Mod mod) + public override bool AI(Mod mod) { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + 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; @@ -65,24 +65,24 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses bool phase3 = lifeRatio < 0.35f; bool phase4 = lifeRatio < 0.2f; - npc.damage = (int)Math.Round(ContactDamageCorrection * (phase2 ? Phase2ContactDamageMult : 1f)); + NPC.damage = (int)Math.Round(ContactDamageCorrection * (phase2 ? Phase2ContactDamageMult : 1f)); // Variables and target bool enrage = false; bool despawn = false; // Check for Jungle - bool surface = !BossRushEvent.BossRushActive && 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; @@ -91,23 +91,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 @@ -141,21 +141,21 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float chargeDeceleration = phase4 ? 0.92f : phase3 ? 0.95f : 0.96f; // Enrage if target is on the surface - if (!BossRushEvent.BossRushActive && (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 = 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; @@ -194,17 +194,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)); @@ -220,15 +220,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 = shootThornBall ? ThornBallDamage : shootPoisonSeed ? PoisonSeedDamage : PinkSeedDamage; - 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; if (useNewGatlingAttackVariant) { @@ -257,7 +257,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 @@ -276,7 +276,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); } } } @@ -285,32 +285,32 @@ 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(); @@ -319,7 +319,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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; @@ -332,22 +332,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, GreenCloudDamage, 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 @@ -357,17 +357,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 @@ -379,8 +379,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { float projectileSpeed = 9f; int projectileType = ModContent.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; @@ -392,25 +392,25 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.GetSource_FromAI(), adjustProjectileShootLocation ? npc.Center : spawnOffset, projectileVelocity * projectileSpeed, projectileType, GasBulbDamage, 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) { - npc.velocity *= chargeDeceleration; + NPC.velocity *= chargeDeceleration; float timeToDecelerateDecrement = phase4 ? 1.5f : 1f; - npc.ai[3] -= timeToDecelerateDecrement; - if (npc.ai[3] <= StopChargeGateValue) + NPC.ai[3] -= timeToDecelerateDecrement; + if (NPC.ai[3] <= StopChargeGateValue) { 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 (!secondCharge) { @@ -423,7 +423,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); } } } @@ -433,16 +433,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) { - npc.damage = (int)Math.Round(ContactDamageCorrection * Phase2ContactDamageMult * DashDamageMult); + 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(); 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; @@ -454,66 +454,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, GasBulbDamage, 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 { // 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) { // 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; } @@ -526,7 +526,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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; @@ -539,14 +539,14 @@ 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, GasBulbDamage, 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 @@ -575,15 +575,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 { @@ -592,64 +592,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 ? 40f : 60f; - if (npc.localAI[1] >= shootProjectileGateValue) + if (NPC.localAI[1] >= shootProjectileGateValue) { - npc.localAI[1] = 0f; + NPC.localAI[1] = 0f; bool shootThornBall = false; if (useNewGatlingAttackVariant) @@ -674,8 +674,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses int projectileType = shootThornBall ? ProjectileID.ThornBall : shootPoisonSeed ? ProjectileID.PoisonSeedPlantera : ProjectileID.SeedPlantera; float projectileSpeed = death ? 16f : 14f; 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; + 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; @@ -690,7 +690,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; } @@ -702,32 +702,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; + NPC.localAI[0] = 2f; int totalTentacles = death ? 11 : 8; if (Main.getGoodWorld) 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) { @@ -737,7 +737,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; } } @@ -749,8 +749,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) { @@ -760,33 +760,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; - 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; @@ -811,7 +811,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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 ? 73 : 74; Vector2 dustVelocity = perturbedSpeed * projectileSpeed; @@ -823,7 +823,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } if (Main.netMode != NetmodeID.MultiplayerClient) - 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) @@ -848,14 +848,14 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { type = ProjectileID.ThornBall; damage = ThornBallDamage; - Vector2 spawnOffset = npc.Center + projectileVelocity * 50f; + 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); } } } @@ -864,13 +864,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; } } } @@ -880,7 +880,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; @@ -889,7 +889,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 @@ -897,40 +897,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); + 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; + 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; @@ -942,334 +942,340 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses return false; } - public static bool BuffedPlanterasHookAI(NPC npc, Mod mod) + public class HookAI : VanillaAIOverride { - // Variables - bool enrage = false; - bool despawn = false; - bool death = CalamityWorld.death || enrage; - - // Despawn if Plantera is gone - if (NPC.plantBoss < 0) + public override bool AI(Mod mod) { - if (Main.netMode != NetmodeID.MultiplayerClient) - npc.StrikeInstantKill(); + // Variables + bool enrage = false; + bool despawn = false; + bool death = CalamityWorld.death || enrage; - 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 && !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; - } - - // 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 ? 4f * (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) + // Despawn if Plantera is gone + if (NPC.plantBoss < 0) { - 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); - } + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.StrikeInstantKill(); + + return false; } - // Pick a location to move to - if (npc.localAI[0] <= 0f) + // 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 && !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)) { - // Reset timer - npc.localAI[0] = Main.rand.Next(300, 601); + NPC.localAI[0] -= 4f; + enrage = true; + } - // Pick location - bool hookCanMove = false; - int hookMoveTries = 0; - while (!hookCanMove && hookMoveTries <= 1000) + // 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 ? 4f * (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) { - 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) + foreach (NPC n in Main.ActiveNPCs) { - 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 (n.whoAmI != NPC.whoAmI && n.type == NPC.type && (n.velocity.X != 0f || n.velocity.Y != 0f)) + NPC.localAI[0] = Main.rand.Next(60, 301); } + } - if (despawn) + // 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) { - targetTilePosX = (int)Main.npc[NPC.plantBoss].position.X / 16; - targetTilePosY = (int)(Main.npc[NPC.plantBoss].position.Y + 400f) / 16; - } + hookMoveTries++; - 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); + 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); - try - { - if (WorldGen.SolidTile(hookTileX, hookTileY) || (Main.tile[hookTileX, hookTileY].WallType > 0 && (hookMoveTries > 500 || lifeRatio < 0.5f))) + 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 { - 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) + // Movement to new location + if (NPC.ai[0] > 0f && NPC.ai[1] > 0f) { - if (Main.netMode != NetmodeID.MultiplayerClient && Main.getGoodWorld && npc.localAI[3] == 1f) + // 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) { - npc.localAI[3] = 0f; - WorldGen.SpawnPlanteraThorns(npc.Center); + 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; } - 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; } - // 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; } - - return false; } - public static bool BuffedPlanterasTentacleAI(NPC npc, Mod mod) + public class TentacleAI : VanillaAIOverride { - 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)) + public override bool AI(Mod mod) { - Dust dust = Dust.NewDustDirect(npc.position, npc.width, npc.height, DustID.JungleSpore, 0f, 0f, 250, default, 0.4f); - dust.fadeIn = 0.7f; - } + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + // Emit light + Lighting.AddLight((int)(NPC.Center.X / 16f), (int)(NPC.Center.Y / 16f), 0.2f, 0.4f, 0.1f); - 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) - { - if (npc.localAI[0] > 0f) + // Spore dust + if (Main.rand.NextBool(10)) { - npc.localAI[0] = 0f; - npc.SyncExtraAI(); + Dust dust = Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, DustID.JungleSpore, 0f, 0f, 250, default, 0.4f); + dust.fadeIn = 0.7f; } - } - else if (npc.localAI[0] < extendTime) - { - 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) + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + if (Main.getGoodWorld) { - npc.ai[0] = Main.rand.Next(-maxOffset, maxOffset + 1); - npc.ai[1] = Main.rand.Next(-maxOffset, maxOffset + 1); - npc.netUpdate = true; + if (Main.rand.NextBool(5)) + NPC.reflectsProjectiles = true; + else + NPC.reflectsProjectiles = false; } - } - // 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); + // Die if Plantera is gone + if (NPC.plantBoss < 0) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.StrikeInstantKill(); - if (death) - { - tentacleAcceleration *= 1.2f; - extendedDistanceFromPlantera *= 1.1f; - tentacleDistance *= 1.2f; - deceleration *= 0.75f; - } + return false; + } - if (Main.getGoodWorld) - tentacleAcceleration += 4f; + // Set Plantera to a variable + int plantBoss = NPC.plantBoss; - // Fast retraction - if (planteraIsCharging) - { - tentacleAcceleration *= 2f; - deceleration *= 0.5f; - } + // 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) + { + if (NPC.localAI[0] > 0f) + { + NPC.localAI[0] = 0f; + NPC.SyncExtraAI(); + } + } + else if (NPC.localAI[0] < extendTime) + { + 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 = 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; + } - // 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; } } } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/QueenBeeAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/QueenBeeAI.cs index 52a77a6819..8c3203650f 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/QueenBeeAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/QueenBeeAI.cs @@ -13,24 +13,24 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { - public static class QueenBeeAI + public class QueenBeeAI : VanillaAIOverride { // Vanilla values public static int StingerDamage = 11; // 44; Also applies to GFB stinger replacements - public static bool BuffedQueenBeeAI(NPC npc, Mod mod) + 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 death = CalamityWorld.death || BossRushEvent.BossRushActive; bool enrage = !BossRushEvent.BossRushActive; - int targetTileX = (int)Main.player[npc.target].Center.X / 16; - int targetTileY = (int)Main.player[npc.target].Center.Y / 16; + 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) @@ -38,12 +38,12 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float maxEnrageScale = 2f; float enrageScale = death ? 0.5f : 0f; - if ((npc.position.Y / 16f) < Main.worldSurface && enrage) + if ((NPC.position.Y / 16f) < Main.worldSurface && enrage) { calamityGlobalNPC.CurrentlyEnraged = true; enrageScale += 1f; } - if (!Main.player[npc.target].ZoneJungle && enrage) + if (!Main.player[NPC.target].ZoneJungle && enrage) { calamityGlobalNPC.CurrentlyEnraged = true; enrageScale += 1f; @@ -56,7 +56,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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; @@ -125,83 +125,83 @@ 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] != 7f) + 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] = 7f; + 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[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] == 7f) + 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 ? (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; @@ -211,18 +211,18 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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) @@ -230,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]; @@ -250,23 +250,23 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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; @@ -277,39 +277,39 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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.7f : phase2 ? 0.6f : 0.5f) + 0.25f * enrageScale; @@ -324,78 +324,78 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // 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 (enrageScale > 0f) @@ -404,18 +404,18 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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 = 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); + 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) { @@ -460,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) @@ -475,57 +475,57 @@ 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.48f : 0.24f; @@ -534,33 +534,33 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (death) 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; @@ -569,35 +569,35 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (death) 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 = 9 * enrageScale; - if (npc.ai[1] > beeSpawnCheck) + 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); @@ -643,8 +643,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - 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); + 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) @@ -654,42 +654,42 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } 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 = death ? 3f : 5f; - if (npc.ai[2] > numSpawns || (beeLimitReached && hornetLimitReached)) + 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; @@ -703,19 +703,19 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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) @@ -724,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; @@ -733,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, StingerDamage, 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; @@ -742,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, StingerDamage, 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; } @@ -752,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; @@ -827,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.35f : 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) @@ -847,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; @@ -865,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, StingerDamage, 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; @@ -877,33 +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 ? 140f : 180f; - if (npc.ai[1] >= phaseLimit + idleTime) + 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(); + NPC.ForceNetUpdate(); return false; } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/QueenSlimeAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/QueenSlimeAI.cs index 8a63745597..04e40a86a0 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/QueenSlimeAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/QueenSlimeAI.cs @@ -10,7 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { - public static class QueenSlimeAI + public class QueenSlimeAI : VanillaAIOverride { // Vanilla values public static int SmallGelDamage = Main.masterMode ? 20 : 17; // 68 @@ -18,13 +18,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses public static int LargeGelDamage = 30; // 120 public static int SlamDamage = 40; // 160 - public static bool BuffedQueenSlimeAI(NPC npc, Mod mod) + public override bool AI(Mod mod) { // Difficulty bools 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; @@ -34,64 +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 (NPC.ai[0] == 1f || NPC.ai[0] == 2f) { - if (Math.Abs(npc.velocity.X) > 0.1f) + 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; + 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; @@ -106,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; } } @@ -121,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; } } } @@ -132,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; + NPC.ai[1] += 1f; int idleTime = death ? 30 : 40; if (phase2) 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; + NPC.rotation = 0f; + NPC.ai[1] += 1f; float teleportEndTime = death ? 15f : 20f; - slimeScale = MathHelper.Clamp(npc.ai[1] / teleportEndTime, 0f, 1f); + 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 @@ -302,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; } @@ -313,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; + NPC.rotation = 0f; + NPC.ai[1] += 1f; float teleportTime = death ? 30f : 40f; - slimeScale = MathHelper.Clamp((teleportTime - npc.ai[1]) / teleportTime, 0f, 1f); + 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) @@ -349,27 +349,27 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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, LargeGelDamage, 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 @@ -379,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; } @@ -391,33 +391,33 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses case 3: // Faster fall - if (npc.velocity.Y > 0f) - npc.velocity.Y += 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 = death ? 6f : 5f; - npc.ai[1] += timerIncrement; + 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; @@ -425,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 += (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 = -(death ? 8f : 6f) * speedMult; - npc.velocity.X += (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 = -(death ? 10f : 8f) * speedMult; - npc.velocity.X += (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 = 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 += (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 *= 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; } } @@ -501,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) @@ -519,13 +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; - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Bottom, Vector2.Zero, type, SlamDamage, 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) @@ -533,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; @@ -541,25 +541,25 @@ 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, SlamDamage, 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; - 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, SpikeDamage, 0f, Main.myPlayer, 0f, -2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, perturbedSpeed, type, SpikeDamage, 0f, Main.myPlayer, 0f, -2f); } if (phase5) @@ -569,7 +569,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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, SpikeDamage, 0f, Main.myPlayer, 0f, -2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, perturbedSpeed, type, SpikeDamage, 0f, Main.myPlayer, 0f, -2f); } } } @@ -577,76 +577,76 @@ 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 += death ? 1.75f : 1.5f; + 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; Vector2 velocityIncrease = death ? (Vector2.UnitY * 4f) : Vector2.Zero; @@ -656,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, SpikeDamage, 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 *= 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; @@ -713,19 +713,19 @@ 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) @@ -738,7 +738,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses int type = ProjectileID.QueenSlimeGelAttack; 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++) @@ -747,7 +747,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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, LargeGelDamage, 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; } } @@ -761,7 +761,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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, LargeGelDamage, 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; } } @@ -778,111 +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, LargeGelDamage, 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 = 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; + 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 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) @@ -904,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; @@ -988,343 +988,349 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.rotation = -0.5f; } - public static bool BuffedQueenSlimeCrystalSlimeAI(NPC npc, Mod mod) + public class CrystalSlimeAI : VanillaAIOverride { - 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]) + public override bool AI(Mod mod) { - 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) + 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 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) { - 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; + NPC.ai[0] = -40f; + if (NPC.velocity.Y == 0f) + NPC.velocity.X *= 0.9f; + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.localAI[0] == 0f) + { + 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; + } + } + } + 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) + num21 *= 2f; + else if (num23 > 250f) + num21 *= 1.5f; + + num19 *= num21; + num20 *= num21; + NPC.localAI[0] = 50f; 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; + Vector2 spikeVelocity = new Vector2(num19, num20) * (death ? 0.8f : 0.5f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), center, spikeVelocity, type, SpikeDamage, 0f, Main.myPlayer); } } } - 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) + + if (NPC.ai[2] > 1f) + NPC.ai[2] -= 1f; + + if (NPC.wet) { - float num23 = num21; - npc.ai[0] = -40f; - if (npc.velocity.Y == 0f) - npc.velocity.X *= 0.9f; + if (NPC.collideY) + NPC.velocity.Y = -2f; - if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[0] == 0f) + if (NPC.velocity.Y < 0f && NPC.ai[3] == NPC.position.X) { - 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) - 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) * (death ? 0.8f : 0.5f); - Projectile.NewProjectile(npc.GetSource_FromAI(), center, spikeVelocity, type, SpikeDamage, 0f, Main.myPlayer); + NPC.direction *= -1; + NPC.ai[2] = 200f; } - } - } - if (npc.ai[2] > 1f) - npc.ai[2] -= 1f; + if (NPC.velocity.Y > 0f) + NPC.ai[3] = NPC.position.X; - if (npc.wet) - { - if (npc.collideY) - npc.velocity.Y = -2f; + if (NPC.velocity.Y > 2f) + NPC.velocity.Y *= 0.9f; - if (npc.velocity.Y < 0f && npc.ai[3] == npc.position.X) - { - npc.direction *= -1; - npc.ai[2] = 200f; + NPC.velocity.Y -= 0.5f; + if (NPC.velocity.Y < -4f) + NPC.velocity.Y = -4f; + + if (NPC.ai[2] == 1f) + CalamityUtils.CalamityTargeting(NPC, default); } - 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.aiAction = 0; + if (NPC.ai[2] == 0f) { - npc.direction *= -1; - npc.ai[2] = 200f; + NPC.ai[0] = -100f; + NPC.ai[2] = 1f; + CalamityUtils.CalamityTargeting(NPC, default); } - 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) + if (NPC.velocity.Y == 0f) { - npc.netUpdate = true; - if (npc.ai[2] == 1f) - CalamityUtils.CalamityTargeting(npc, default); + 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 (num34 == 3) + if (NPC.ai[3] == NPC.position.X) { - 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; + NPC.direction *= -1; + NPC.ai[2] = 200f; } - else + + 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.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; + 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 BuffedQueenSlimeBouncySlimeAI(NPC npc, Mod mod) + public class BouncySlimeAI : VanillaAIOverride { - 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]) + 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) * (death ? 0.8f : 0.5f); - Projectile.NewProjectile(npc.GetSource_FromAI(), center2, pinkBallVelocity, type, SmallGelDamage, 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] += (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) + if (NPC.velocity.Y < 0f && NPC.ai[3] == NPC.position.X) { - 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; + 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 += (death ? 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 bf984fce54..7dad437e73 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs @@ -9,7 +9,7 @@ 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; @@ -22,14 +22,14 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses public static float SpinDamageMult = 1.3f; // 91 public static int SkullDamage = 17; // 68; Also applies to crossbones - public static bool BuffedSkeletronAI(NPC npc, Mod mod) + public override bool AI(Mod mod) { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + 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; @@ -54,95 +54,95 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses bool phase5 = lifeRatio < phase5LifeRatio; // Set defense - npc.defense = npc.defDefense; - npc.damage = npc.defDamage; + 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() && !BossRushEvent.BossRushActive && 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 @@ -210,7 +210,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses moveAwayVelocity *= 2f; // Hand DR, scale DR up if the hands are still alive as Skeletron's HP lowers - npc.chaseable = handsDead; + 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; @@ -221,47 +221,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; // 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, SkullDamage, 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; } @@ -271,19 +271,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) || phase4) ? 0.5f : 0f) - (handsDead ? 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 + int ai3 = (int)NPC.ai[3]; // 0 to 30, and -60 - if (npc.localAI[0] == 1f && 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; @@ -301,9 +301,9 @@ 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; } } @@ -316,35 +316,35 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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; } } // Teleport - if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[0] == 0f && npc.ai[1] != 1f && calamityGlobalNPC.newAI[2] != 0f && calamityGlobalNPC.newAI[3] != 0f) + 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.velocity = Vector2.Zero; + NPC.Center = new Vector2(calamityGlobalNPC.newAI[2], calamityGlobalNPC.newAI[3]); + 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) && npc.ai[1] == 0f && !phase4) + if ((handsDead) && NPC.ai[1] == 0f && !phase4) { float skullProjFrequency = phase2 ? (48f - (death ? 10f * (1f - lifeRatio) : 0f)) : 60f; if (Main.getGoodWorld) @@ -353,37 +353,37 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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 ? 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 skullProjectile = Projectile.NewProjectile(npc.GetSource_FromAI(), skullFiringPos, skullProjDirection, type, SkullDamage, 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, SkullDamage, 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) { calamityGlobalNPC.newAI[1] += 1f; float chargePhaseChangeRateBoost = phase5 ? (death ? 24f : 8f) : phase4 ? (death ? 6f : 4f) : ((death ? 4.5f : 3f) * ((1f - lifeRatio) / (1f - phase4LifeRatio))); @@ -391,33 +391,33 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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 ? 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; + 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; + NPC.localAI[2] += 1f; if (hasMovedForcedDistance || !phase3) { - npc.ai[2] = 0f; - npc.ai[1] = 1f; - npc.localAI[0] = 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; } } @@ -428,13 +428,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float deceleration = Main.getGoodWorld ? 0.83f : death ? 0.86f : 0.89f; 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.2f; - float maxVelocity = (npc.ai[2] - moveAwayGateValue) * (moveAwayVelocity * 0.002f); + float maxVelocity = (NPC.ai[2] - moveAwayGateValue) * (moveAwayVelocity * 0.002f); if (phase5) maxVelocity *= phase5Multiplier; @@ -444,92 +444,92 @@ 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; + NPC.SyncMotionToServer(); } // 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; // Force net updates every frame during this movement to avoid despawning in multiplayer // I'm doing this because npc.ai[2] changes every frame and that's used to calculate Skeletron's velocity here - npc.ForceNetUpdate(); + NPC.ForceNetUpdate(); 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) { 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); @@ -544,16 +544,16 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { 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); @@ -565,30 +565,30 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - npc.defense = npc.defDefense - 10; - npc.damage = (int)Math.Round(npc.defDamage * SpinDamageMult); + 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); + 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) + if (NPC.ai[2] >= dashPhaseTime) { if (Main.getGoodWorld) { @@ -596,16 +596,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); @@ -615,25 +615,25 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - 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 @@ -665,73 +665,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) * 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; } - 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; } } @@ -739,324 +739,327 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses return false; } - public static bool BuffedSkeletronHandAI(NPC npc, Mod mod) + public class SkeletronHandAI : VanillaAIOverride { - 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) + public override bool AI(Mod mod) { - calamityGlobalNPC.newAI[1] += 1f; - if (calamityGlobalNPC.newAI[1] % 15f == 0f) - npc.SyncExtraAI(); + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); - npc.damage = 0; - } - else - npc.damage = npc.defDamage; + 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]].ai[3] == -60f) - { - if (Main.netMode != NetmodeID.MultiplayerClient) + 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) { - // 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; - } + calamityGlobalNPC.newAI[1] += 1f; + if (calamityGlobalNPC.newAI[1] % 15f == 0f) + NPC.SyncExtraAI(); - // New location - npc.Center = Main.npc[(int)npc.ai[1]].Center; - npc.velocity = Vector2.Zero; - npc.netUpdate = true; + NPC.damage = 0; } - } + else + NPC.damage = NPC.defDamage; - 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) + NPC.spriteDirection = -(int)NPC.ai[0]; + + if (Main.npc[(int)NPC.ai[1]].ai[3] == -60f) { - npc.life = -1; - npc.HitEffect(0, 10.0); - npc.active = false; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // 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; + } } - } - 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) - { - 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) + float skeletronLifeRatio = 1f; + if (!Main.npc[(int)NPC.ai[1]].active || Main.npc[(int)NPC.ai[1]].aiStyle != NPCAIStyleID.SkeletronHead) { - 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.ai[2] += 10f; + if (NPC.ai[2] > 50f || !Main.dedServ) { - 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; + 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) - { - 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; } public static void RevengeanceDungeonGuardianAI(NPC npc) diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronPrimeAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronPrimeAI.cs index 1954a9222d..8c7f6b633a 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronPrimeAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronPrimeAI.cs @@ -2,20 +2,16 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Events; -using CalamityMod.NPCs.NormalNPCs; using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; -using Terraria.Chat; -using Terraria.GameContent.Achievements; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { - public static class SkeletronPrimeAI + public class SkeletronPrimeAI : VanillaAIOverride { // Vanilla values public static int SpinDamageMult = 2; // 158 @@ -25,59 +21,59 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses public static int SkullDamage = 22; // 88 public static int RocketDamage = 30; // 120 - public static bool BuffedSkeletronPrimeAI(NPC npc, Mod mod) + public override bool AI(Mod mod) { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + 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); + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); calamityGlobalNPC.newAI[1] = 1f; if (Main.netMode != NetmodeID.MultiplayerClient) { - int arm = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.PrimeCannon, npc.whoAmI); + 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].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); + 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].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); + 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[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); + 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].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(); + NPC.netUpdate = true; + NPC.SyncExtraAI(); } // Check if arms are alive @@ -106,94 +102,94 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses sawAlive = true; } bool allArmsDead = !cannonAlive && !laserAlive && !viceAlive && !sawAlive; - npc.chaseable = allArmsDead; + NPC.chaseable = allArmsDead; - npc.defense = npc.defDefense; - npc.damage = npc.defDamage; + NPC.defense = NPC.defDefense; + NPC.damage = NPC.defDamage; // Phases bool phase2 = lifeRatio < 0.66f; bool phase3 = lifeRatio < 0.33f; // 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() && !BossRushEvent.BossRushActive && 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[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; + 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) { // Start other phases; if arms are dead, start with spin phase 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))) + 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; - 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.SyncVanillaLocalAI(); } - npc.ai[2] = 0f; - npc.ai[1] = shouldSpinAround ? 5f : 1f; - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - 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 = death ? (0.125f + 0.05f * (1f - lifeRatio)) : 0.1f; float accelerationMult = 1f; @@ -220,7 +216,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; @@ -228,65 +224,65 @@ 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 = npc.defDefense * 2; - npc.damage = npc.defDamage * SpinDamageMult; + 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 = death ? 15 : 12; float radians = MathHelper.TwoPi / totalProjectiles; @@ -300,38 +296,38 @@ 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, LaserDamage.CalculateMechDamage(), 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 = death ? 8f : 6f; @@ -353,24 +349,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; @@ -378,13 +374,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; @@ -395,21 +391,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; @@ -417,13 +413,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; } } @@ -431,7 +427,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Despawning - if (npc.ai[1] == 3f) + if (NPC.ai[1] == 3f) { if (NPC.IsMechQueenUp) { @@ -449,36 +445,36 @@ 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) { - npc.ai[2] += 1f; + NPC.ai[2] += 1f; - npc.rotation = npc.velocity.X / 50f; + NPC.rotation = NPC.velocity.X / 50f; float skullSpawnDivisor = death ? 15f - (float)Math.Round(3f * (1f - lifeRatio)) : 15f; float totalSkulls = 12f; @@ -487,45 +483,45 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // 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; @@ -538,76 +534,76 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses int type = ProjectileID.Skull; - int enragedSkulls = Projectile.NewProjectile(npc.GetSource_FromAI(), headCenter.X, headCenter.Y + 30f, enragedHeadSkullTargetX, enragedHeadSkullTargetY, type, SkullDamage.CalculateMechDamage(), 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) + if (NPC.localAI[0] >= totalSkulls) { - 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) { - npc.rotation = npc.velocity.X / 15f; + NPC.rotation = NPC.velocity.X / 15f; float flightVelocity = death ? 25f : 18f; float flightAcceleration = 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 = 12f; float totalMissiles = 10f; - npc.ai[2] += 1f; - if (npc.ai[2] % missileSpawnDivisor == 0f) + 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 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); + 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; } } } @@ -617,560 +613,66 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses return false; } - public static bool BuffedPrimeLaserAI(NPC npc, Mod mod) + public class PrimeLaserAI : VanillaAIOverride { - 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); - - // 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) + public override bool AI(Mod mod) { - npc.ai[2] += 10f; - if (npc.ai[2] > 50f || !Main.dedServ) + 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); + + // 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; - } - } - - CalamityGlobalNPC.primeLaser = npc.whoAmI; - - // 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; - } - - // 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 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 (!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.ai[2] += 10f; + if (NPC.ai[2] > 50f || !Main.dedServ) { - 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); + NPC.life = -1; + NPC.HitEffect(0, 10.0); + NPC.active = false; } } - } - // 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; + CalamityGlobalNPC.primeLaser = NPC.whoAmI; - float timeLimit = 135f; - float timeMult = 1.882075f; - if (!cannonAlive) - timeLimit *= timeMult; - if (!viceAlive) - timeLimit *= timeMult; - if (!sawAlive) - timeLimit *= timeMult; - - if (npc.ai[3] >= timeLimit) + // Check if arms are alive + bool cannonAlive = false; + bool viceAlive = false; + bool sawAlive = false; + if (CalamityGlobalNPC.primeCannon != -1) { - npc.target = Main.npc[(int)npc.ai[1]].target; - npc.localAI[0] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; + 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; } - 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) + // Inflict 0 damage for 3 seconds after spawning + float timeToNotAttack = 180f; + bool dontAttack = NPC.Calamity().newAI[2] < timeToNotAttack; + if (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; - } + NPC.Calamity().newAI[2] += 1f; + if (NPC.Calamity().newAI[2] >= timeToNotAttack) + NPC.SyncExtraAI(); } - } - return false; - } + bool normalLaserRotation = NPC.localAI[1] % 2f == 0f; - public static bool BuffedPrimeCannonAI(NPC npc, 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 static bool BuffedPrimeViceAI(NPC npc, 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) - { + // Movement float acceleration = death ? 0.385f : 0.25f; float accelerationMult = 1f; if (!cannonAlive) @@ -1178,11 +680,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses acceleration += 0.025f; accelerationMult += 0.5f; } - if (!laserAlive) - { + if (!viceAlive) acceleration += 0.025f; - accelerationMult += 0.5f; - } if (!sawAlive) acceleration += 0.025f; if (death) @@ -1191,76 +690,491 @@ 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; } + 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) @@ -1281,100 +1195,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) { - float chargeVelocity = 16f; + // Despawn if head is despawning + 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; 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) - { - if (npc.position.Y > Main.player[npc.target].position.Y || npc.velocity.Y < 0f) + // 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; + + 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) @@ -1384,226 +1448,83 @@ 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) - { - 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) - 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 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); - - 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; - } - - if (npc.ai[2] == 99f) - { - float acceleration = death ? 0.385f : 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; } + } + 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) @@ -1624,174 +1545,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) - { - 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; + if (NPC.velocity.X < -topVelocity) + NPC.velocity.X = -topVelocity; } } - - else if (npc.ai[2] == 2f) - { - 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) { - float chargeVelocity = 11f; + 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) - 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 = 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; - } - } + 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; - return false; + 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) + { + 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; + } + } + + else if (NPC.ai[2] == 2f) + { + if (NPC.position.Y > Main.player[NPC.target].position.Y || NPC.velocity.Y < 0f) + NPC.ai[2] = 3f; + } + + else + { + if (NPC.ai[2] == 4f) + { + float chargeVelocity = 11f; + if (!cannonAlive) + chargeVelocity += 1.5f; + if (!laserAlive) + chargeVelocity += 1.5f; + if (!viceAlive) + chargeVelocity += 1.5f; + if (death) + chargeVelocity *= 1.25f; + + 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 = death ? 0.125f : 0.08f; + float deceleration = death ? 0.6f : 0.8f; + + if (NPC.velocity.X > sawArmOtherChargeTargetX) + { + if (NPC.velocity.X > 0f) + NPC.velocity.X *= deceleration; + + NPC.velocity.X -= acceleration; + } + if (NPC.velocity.X < sawArmOtherChargeTargetX) + { + if (NPC.velocity.X < 0f) + NPC.velocity.X *= deceleration; + + NPC.velocity.X += acceleration; + } + if (NPC.velocity.Y > sawArmOtherChargeTargetY) + { + if (NPC.velocity.Y > 0f) + NPC.velocity.Y *= deceleration; + + NPC.velocity.Y -= acceleration; + } + if (NPC.velocity.Y < sawArmOtherChargeTargetY) + { + if (NPC.velocity.Y < 0f) + NPC.velocity.Y *= deceleration; + + NPC.velocity.Y += acceleration; + } + + NPC.ai[3] += 1f; + if (NPC.justHit) + NPC.ai[3] += 2f; + + if (NPC.ai[3] >= 600f) + { + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + } + + 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.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 63dc7c9b45..9a3b183b73 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; @@ -40,428 +39,360 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses return damage; } - public static bool BuffedRetinazerAI(NPC npc, Mod mod) + public class RetinazerAI : VanillaAIOverride { - 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) + public override bool AI(Mod mod) { - CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; - options.aggroRatio = -1f; - CalamityUtils.CalamityTargeting(npc, options); - } + 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].timeLeft - 1 > npc.timeLeft) - npc.timeLeft = Main.npc[i].timeLeft - 1; + CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; + options.aggroRatio = -1f; + CalamityUtils.CalamityTargeting(NPC, options); } - } - // Phase HP ratios - float phase2LifeRatio = death ? 0.85f : 0.7f; - float finalPhaseLifeRatio = death ? 0.4f : 0.25f; + // Percent life remaining + float lifeRatio = NPC.life / (float)NPC.lifeMax; - // Movement variables - float phase1MaxSpeedIncrease = death ? 2f : 4f; - float phase1MaxAccelerationIncrease = death ? 0.025f : 0.05f; - float phase1MaxChargeSpeedIncrease = death ? 3f : 6f; + // Easier to send info to Spazmatism + CalamityGlobalNPC.laserEye = NPC.whoAmI; - // Phase duration variables - float phase1MaxLaserPhaseDurationDecrease = death ? 120f : 300f; + // Check for Spazmatism + bool spazAlive = false; + if (CalamityGlobalNPC.fireEye != -1) + spazAlive = Main.npc[CalamityGlobalNPC.fireEye].active; - // Phase checks - bool phase2 = lifeRatio < phase2LifeRatio; - bool finalPhase = lifeRatio < finalPhaseLifeRatio; + // 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; - 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); - } + float hoverRotation = hoverDestination.ToRotation() + MathHelper.PiOver2; + if (hoverRotation < 0f) + hoverRotation += MathHelper.TwoPi; + else if (hoverRotation > MathHelper.TwoPi) + hoverRotation -= MathHelper.TwoPi; - npc.reflectsProjectiles = false; + float rotationRate = 0.15f; + NPC.rotation = NPC.rotation.AngleTowards(hoverRotation, rotationRate); - // Despawn - if ((Main.player[npc.target].dead || Main.IsItDay()) && !BossRushEvent.BossRushActive) - { - npc.velocity.Y -= 0.04f; - if (npc.timeLeft > 10) + if (Main.rand.NextBool(5)) { - npc.timeLeft = 10; - return false; + 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; } - } - else if (npc.ai[0] == 0f) - { - if (npc.ai[1] == 0f) + if (Main.netMode != NetmodeID.MultiplayerClient && !Main.player[NPC.target].dead && NPC.timeLeft < 10) { - float maxVelocity = (death ? 9.45f : 8.25f); - float acceleration = (death ? 0.13f : 0.115f); - - if (death) + for (int i = 0; i < Main.maxNPCs; i++) { - maxVelocity += phase1MaxSpeedIncrease * ((1f - lifeRatio) / (1f - phase2LifeRatio)) / 2; - acceleration += phase1MaxAccelerationIncrease * ((1f - lifeRatio) / (1f - phase2LifeRatio)) / 2; + 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; } + } - if (Main.getGoodWorld) + // Phase HP ratios + float phase2LifeRatio = 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; + + // 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 *= 1.15f; - acceleration *= 1.15f; + NPC.timeLeft = 10; + return false; } + } - 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) + else if (NPC.ai[0] == 0f) + { + if (NPC.ai[1] == 0f) { - maxVelocity = 14f; + float maxVelocity = (death ? 9.45f : 8.25f); + float acceleration = (death ? 0.13f : 0.115f); - 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 (death) { - npc.ai[3] += 1f; - if (Main.getGoodWorld) - npc.ai[3] += 0.5f; + maxVelocity += phase1MaxSpeedIncrease * ((1f - lifeRatio) / (1f - phase2LifeRatio)) / 2; + acceleration += phase1MaxAccelerationIncrease * ((1f - lifeRatio) / (1f - phase2LifeRatio)) / 2; } - if (npc.ai[3] >= laserGateValue) + if (Main.getGoodWorld) { - npc.ai[3] = 0f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - float laserSpeed = death ? 11.4f : 10.5f; - - 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); - } + maxVelocity *= 1.15f; + acceleration *= 1.15f; } - } - } - else if (npc.ai[1] == 1f) - { - npc.rotation = hoverRotation; + 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); - float chargeSpeed = death ? 18f : 15f; - if (death) - chargeSpeed += phase1MaxChargeSpeedIncrease * ((1f - lifeRatio) / (1f - phase2LifeRatio)) / 2; - 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) - { - npc.ai[2] += 1f; - float decelerateGateValue = (death ? 36f : 32f) + (death ? 6f * ((1f - lifeRatio) / (1f - phase2LifeRatio)) : 0f); - if (npc.ai[2] >= decelerateGateValue) - { - 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 ? 1.5f * ((1f - lifeRatio) / (1f - phase2LifeRatio)) : 0f); - if (npc.ai[2] >= delayBeforeChargingAgain) - { - npc.ai[3] += 1f; - npc.ai[2] = 0f; - - npc.rotation = hoverRotation; - - float totalCharges = death ? 6f : 5f; - - if (npc.ai[3] >= totalCharges) + if (NPC.IsMechQueenUp) { - npc.ai[1] = 0f; - npc.ai[3] = 0f; + 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); + 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 = death ? 11.4f : 10.5f; + + 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); + } + } + } + } + + else if (NPC.ai[1] == 1f) + { + NPC.rotation = hoverRotation; + + float chargeSpeed = death ? 18f : 15f; + if (death) + chargeSpeed += phase1MaxChargeSpeedIncrease * ((1f - lifeRatio) / (1f - phase2LifeRatio)) / 2; + 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) + { + NPC.ai[2] += 1f; + float decelerateGateValue = (death ? 36f : 32f) + (death ? 6f * ((1f - lifeRatio) / (1f - phase2LifeRatio)) : 0f); + if (NPC.ai[2] >= decelerateGateValue) + { + 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.ai[1] = 1f; - } - } + NPC.rotation = NPC.velocity.ToRotation() - MathHelper.PiOver2; - // 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) - { - 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; - } - - 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 delayBeforeChargingAgain = (death ? 48f : 56f) - (death ? 1.5f * ((1f - lifeRatio) / (1f - phase2LifeRatio)) : 0f); + if (NPC.ai[2] >= delayBeforeChargingAgain) { - int type = ProjectileID.DeathLaser; + NPC.ai[3] += 1f; + NPC.ai[2] = 0f; - 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); - } - } - } + NPC.rotation = hoverRotation; - 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); + float totalCharges = death ? 6f : 5f; - if (!Main.dedServ) - { - for (int i = 0; i < 2; i++) + if (NPC.ai[3] >= totalCharges) { - 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); + NPC.ai[1] = 0f; + NPC.ai[3] = 0f; + + CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; + options.aggroRatio = -1f; + CalamityUtils.CalamityTargeting(NPC, options); } + else + NPC.ai[1] = 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; - if (CalamityGlobalNPC.fireEye != -1) - { - 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; - } - - npc.chaseable = !spazInPhase1; - - 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) - { - float maxVelocity = death ? 10.85f + 1.75f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 9.5f; - float acceleration = death ? 0.1975f + 0.025f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0.175f; - - if (Main.getGoodWorld) - { - maxVelocity *= 1.15f; - acceleration *= 1.15f; } - 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); - - if (NPC.IsMechQueenUp) + // Enter phase 2 + if (phase2) { - maxVelocity = 14f; + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; - 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); + CalamityUtils.CalamityTargeting(NPC, options); - npc.netUpdate = true; + NPC.netUpdate = true; + } + } + + else if (NPC.ai[0] == 1f || NPC.ai[0] == 2f) + { + 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; } - npc.rotation = (Main.player[npc.target].Center - npc.Center).ToRotation() - MathHelper.PiOver2; + NPC.rotation += NPC.ai[2]; - if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.ai[1] += 1f; + if (death && NPC.ai[2] >= 0.2f) { - npc.localAI[1] += 1f + (death ? ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) / 2 : 0f); - if (npc.localAI[1] >= (spazAlive ? 52f : 26f)) + if (NPC.ai[1] % 10f == 0f) { - if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) + SoundEngine.PlaySound(SoundID.Item33, NPC.Center); + if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.localAI[1] = 0f; - - float laserSpeed = 10f; int type = ProjectileID.DeathLaser; - 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); + 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); } } } + + 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 (npc.ai[1] == 1f) + // If in phase 2 but Spaz isn't + bool spazInPhase1 = false; + if (CalamityGlobalNPC.fireEye != -1) + { + 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; + } + + NPC.chaseable = !spazInPhase1; + + 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) { float maxVelocity = death ? 10.85f + 1.75f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 9.5f; - float acceleration = death ? 0.295f + 0.075f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0.25f; + float acceleration = death ? 0.1975f + 0.025f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0.175f; if (Main.getGoodWorld) { @@ -470,564 +401,381 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } 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); + 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); - npc.rotation = (Main.player[npc.target].Center - npc.Center).ToRotation() - MathHelper.PiOver2; + 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 = 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 + (death ? ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) / 2 : 0f); - if (npc.localAI[1] > (spazAlive ? 20f : 10f)) + NPC.localAI[1] += 1f + (death ? ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) / 2 : 0f); + if (NPC.localAI[1] >= (spazAlive ? 52f : 26f)) { - 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 (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; + NPC.localAI[1] = 0f; - float laserSpeed = 9f; + float laserSpeed = 10f; int type = ProjectileID.DeathLaser; - int damage = (int)Math.Round(RedLaserDamage.CalculateMechDamage() * RapidFireDamageMult); - 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); + 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); } } } - - npc.ai[2] += spazAlive ? 1f : 1.5f; - if (npc.ai[2] >= (death ? 150f : 180f) - (death ? 25f * ((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) - { - // Set rotation and velocity - npc.rotation = hoverRotation; - - float chargeSpeed = (death ? 25f : 22f) + (death ? 3.25f * ((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) - { - 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.5f : 6f) * (spazAlive ? 1f : 1.5f); - int type = ModContent.ProjectileType(); - int damage = HomingDartDamage.CalculateMechDamage(); - - // 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 * (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 ? 19.8f : 18f) + (death ? 2.5f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); - float chargeAcceleration = (death ? 0.495f : 0.45f) + (death ? 0.1f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); - - 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; - } - } - } - } - - return false; - } - - public static bool BuffedSpazmatismAI(NPC npc, 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++) - { - 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; - } - } - - // Phase HP ratios - float phase2LifeRatio = death ? 0.85f : 0.7f; - float finalPhaseLifeRatio = death ? 0.4f : 0.25f; - - // 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; - - // 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) - { - npc.timeLeft = 10; - return false; - } - } - - // Phase 1 - else if (npc.ai[0] == 0f) - { - // Cursed fireball phase - if (npc.ai[1] == 0f) - { - // Velocity - float maxVelocity = death ? 13.8f : 12f; - float acceleration = death ? 0.46f : 0.4f; - - if (death) - { - maxVelocity += phase1MaxSpeedIncrease * ((1f - lifeRatio) / (1f - phase2LifeRatio)) / 2; - acceleration += phase1MaxAccelerationIncrease * ((1f - lifeRatio) / (1f - phase2LifeRatio)) / 2; - } - - if (Main.getGoodWorld) - { - maxVelocity *= 1.15f; - acceleration *= 1.15f; - } - - 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); - - 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 = 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; } else { - // Fire cursed flame every half second - if (!Main.player[npc.target].dead) + if (NPC.ai[1] == 1f) { - npc.ai[3] += 1f; + float maxVelocity = death ? 10.85f + 1.75f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 9.5f; + float acceleration = death ? 0.295f + 0.075f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0.25f; + if (Main.getGoodWorld) - npc.ai[3] += 0.4f; - } + { + maxVelocity *= 1.15f; + acceleration *= 1.15f; + } - if (npc.ai[3] >= 30f) - { - npc.ai[3] = 0f; + 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) { - float cursedFireballSpeed = death ? 15.9f : 15f; - int type = ProjectileID.CursedFlameHostile; + NPC.localAI[1] += 1f + (death ? ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) / 2 : 0f); + if (NPC.localAI[1] > (spazAlive ? 20f : 10f)) + { + 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; - 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); + float laserSpeed = 9f; + int type = ProjectileID.DeathLaser; + int damage = (int)Math.Round(RedLaserDamage.CalculateMechDamage() * RapidFireDamageMult); + + 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); + } + } + } + + NPC.ai[2] += spazAlive ? 1f : 1.5f; + if (NPC.ai[2] >= (death ? 150f : 180f) - (death ? 25f * ((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) + { + // Set rotation and velocity + NPC.rotation = hoverRotation; + + float chargeSpeed = (death ? 25f : 22f) + (death ? 3.25f * ((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) + { + 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.5f : 6f) * (spazAlive ? 1f : 1.5f); + int type = ModContent.ProjectileType(); + int damage = HomingDartDamage.CalculateMechDamage(); + + // 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 * (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 ? 19.8f : 18f) + (death ? 2.5f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); + float chargeAcceleration = (death ? 0.495f : 0.45f) + (death ? 0.1f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); + + 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; } } } } - // Charging phase - else if (npc.ai[1] == 1f) + 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) { - // Rotation and velocity - npc.rotation = hoverRotation; - - float chargeSpeed = death ? 20.4f + 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 ? 18f : 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; - } - } - - // Transition phase - else if (npc.ai[0] == 1f || npc.ai[0] == 2f) - { - 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; - } - else - { - npc.ai[2] -= 0.005f; - if (npc.ai[2] < 0f) - npc.ai[2] = 0f; + CalamityUtils.CalamityTargeting(NPC, options); } - // Spin around like a moron while flinging blood and gore everywhere - 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) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = npc.ai[1] % 20f == 0f ? ProjectileID.CursedFlameHostile : ModContent.ProjectileType(); + // Easier to send info to Retinazer + CalamityGlobalNPC.fireEye = NPC.whoAmI; - 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) - { - 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; + // 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)) { - 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; + 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; } - npc.chaseable = !retInPhase1; - - // 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) + // Despawn Twins at the same time + if (Main.netMode != NetmodeID.MultiplayerClient && !Main.player[NPC.target].dead && NPC.timeLeft < 10) { - float maxVelocity = 7.1f + (death ? 0.8f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); - float acceleration = 0.118f + (death ? 0.02f * ((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) + for (int i = 0; i < Main.maxNPCs; i++) { - // Boost speed if too far from target - if (distanceFromDestination > distanceFromTarget) - maxVelocity += MathHelper.Lerp(0f, 6f, MathHelper.Clamp((distanceFromDestination - distanceFromTarget) / 1000f, 0f, 1f)); + 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; + } + } + + // Phase HP ratios + float phase2LifeRatio = death ? 0.85f : 0.7f; + float finalPhaseLifeRatio = death ? 0.4f : 0.25f; + + // 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; + + // 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) + { + NPC.timeLeft = 10; + return false; + } + } + + // Phase 1 + else if (NPC.ai[0] == 0f) + { + // Cursed fireball phase + if (NPC.ai[1] == 0f) + { + // Velocity + float maxVelocity = death ? 13.8f : 12f; + float acceleration = death ? 0.46f : 0.4f; + + if (death) + { + maxVelocity += phase1MaxSpeedIncrease * ((1f - lifeRatio) / (1f - phase2LifeRatio)) / 2; + acceleration += phase1MaxAccelerationIncrease * ((1f - lifeRatio) / (1f - phase2LifeRatio)) / 2; + } if (Main.getGoodWorld) { @@ -1035,305 +783,562 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses acceleration *= 1.15f; } - npc.SimpleFlyMovement(idealVelocity * maxVelocity, acceleration); - } + 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); - // 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) + 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); - if (Main.netMode != NetmodeID.MultiplayerClient) + // 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) { - npc.localAI[1] += 1f; - if (npc.localAI[1] > 2f) + // 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; - npc.localAI[1] = 0f; + NPC.ai[3] += 1f; + if (Main.getGoodWorld) + NPC.ai[3] += 0.4f; + } - 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(); + if (NPC.ai[3] >= 30f) + { + NPC.ai[3] = 0f; - 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) + if (Main.netMode != NetmodeID.MultiplayerClient) { - 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); + 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); } } } } - if (NPC.IsMechQueenUp) + // Charging phase + else if (NPC.ai[1] == 1f) { - maxVelocity = 14f; + // Rotation and velocity + NPC.rotation = hoverRotation; - 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 ? 22.8f : 18f) + (death ? 1.5f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); + float chargeSpeed = death ? 20.4f + 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.velocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitX * direction) * chargeSpeed; - npc.ai[1] = 2f; - - return false; + NPC.ai[1] = 2f; } - - if (npc.ai[1] == 2f) + else if (NPC.ai[1] == 2f) { - npc.ai[2] += retAlive ? 1f : 1.25f; + NPC.ai[2] += 1f; - float chargeTime = 30f - (death ? 3f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); - - // Slow down - if (npc.ai[2] >= chargeTime) + float timeBeforeSlowDown = death ? 18f : 10f; + if (NPC.ai[2] >= timeBeforeSlowDown) { - float deceleration = 0.85f - (death ? 0.1f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); - npc.velocity *= deceleration; + // 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; + 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; + NPC.rotation = NPC.velocity.ToRotation() - MathHelper.PiOver2; - // Charges 5 times - if (npc.ai[2] >= chargeTime * 1.6f) + // Charge 8 times + float chargeTime = death ? 35f : 25f; + if (NPC.ai[2] >= chargeTime) { - npc.ai[3] += 1f; - npc.ai[2] = 0f; + // Reset AI array and go to cursed fireball phase + NPC.ai[3] += 1f; + NPC.ai[2] = 0f; - npc.rotation = hoverRotation; + NPC.rotation = hoverRotation; - float totalCharges = 5f; - if (npc.ai[3] >= totalCharges) + 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; - return false; + NPC.ai[1] = 0f; + NPC.ai[3] = 0f; } - - npc.ai[1] = 1f; + else + NPC.ai[1] = 1f; } } - // Crazy charge - else if (npc.ai[1] == 3f) + // Enter phase 2 + if (phase2) { - // 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)) + // 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; + } + } + + // Transition phase + else if (NPC.ai[0] == 1f || NPC.ai[0] == 2f) + { + 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; + } + 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) { - npc.ai[1] = retAlive ? 0f : 5f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int type = NPC.ai[1] % 20f == 0f ? ProjectileID.CursedFlameHostile : ModContent.ProjectileType(); - if (npc.ai[1] == 0f) - npc.localAI[1] = -20f; + 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; + } + } + } - npc.ForceNetUpdate(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); + + 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 + 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.8f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); + float acceleration = 0.118f + (death ? 0.02f * ((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); } - // Set charging velocity - else if (Main.netMode != NetmodeID.MultiplayerClient) + // 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) { - // Velocity - float spazmatismPhase3ChargeSpeed = (death ? 23f : 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; + NPC.ai[1] = finalPhase ? 5f : 1f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + } - Vector2 distanceVector = Main.player[npc.target].Center - npc.Center; - npc.velocity = distanceVector.SafeNormalize(Vector2.UnitY) * spazmatismPhase3ChargeSpeed; - - if (retAlive) + // 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.Distance(Main.player[npc.target].Center) < 100f) + NPC.localAI[2] = 0f; + SoundEngine.PlaySound(SoundID.Item34, NPC.Center); + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.localAI[1] += 1f; + if (NPC.localAI[1] > 2f) { - if (Math.Abs(npc.velocity.X) > Math.Abs(npc.velocity.Y)) + 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) { - 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); + 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 (death) + 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 ? 22.8f : 18f) + (death ? 1.5f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); + 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 projectileSpeed = spazmatismPhase3ChargeSpeed * 0.5f; - int type = (!retAlive && npc.ai[3] % 2f == 0f) ? ModContent.ProjectileType() : ProjectileID.CursedFlameHostile; + float deceleration = 0.85f - (death ? 0.1f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); + NPC.velocity *= deceleration; - Vector2 projectileVelocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * projectileSpeed; - int numProj = 3; - int spread = 15; - float rotation = MathHelper.ToRadians(spread); + 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; - for (int i = 0; i < numProj; i++) + // 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) { - 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] = 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 ? 23f : 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); } } - 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) + // Take 3 seconds to get in position, then charge + if (NPC.ai[2] >= (retAlive ? 180f : 135f) - (death ? 45f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f)) { - 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); + NPC.ai[1] = 3f; + NPC.ai[2] = -1f; + NPC.ai[3] = 0f; } - } - // 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); } - - npc.ForceNetUpdate(false); } } - } - return false; + return false; + } } } } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/WallOfFleshAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/WallOfFleshAI.cs index b5e374ff31..8e7fde87ff 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/WallOfFleshAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/WallOfFleshAI.cs @@ -9,7 +9,7 @@ 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; @@ -20,26 +20,26 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses public static int LaserDamage = 15; // 60 (modified to be always at maximum Expert damage and does not scale) public static int SickleDamage = 22; // 88 - public static bool BuffedWallofFleshAI(NPC npc, Mod mod) + public override bool AI(Mod mod) { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + 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); @@ -54,12 +54,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); @@ -70,7 +70,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); @@ -81,49 +81,49 @@ 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] += 1f; + NPC.ai[1] += 1f; if (phase2) - npc.ai[1] += 1f; + NPC.ai[1] += 1f; if (phase3) - npc.ai[1] += 1f; + NPC.ai[1] += 1f; if (Main.getGoodWorld) - npc.ai[1] += 9f; + 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 proj = Projectile.NewProjectile(npc.GetSource_FromAI(), projectileSpawn, projectileVelocity, ProjectileID.DemonSickle, SickleDamage, 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; } @@ -131,20 +131,20 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // 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) @@ -210,18 +210,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; @@ -244,10 +244,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); } } @@ -274,18 +274,18 @@ 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; 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); deathModeVelocityBoost = MathHelper.Lerp(0f, 4f, lerpAmount); } @@ -312,85 +312,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) @@ -420,7 +420,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.rand.NextBool(chance)) { - int maxHungriesBasedOnHP = (int)Math.Round(MathHelper.Lerp(death ? 2f : 1f, death ? 6f : 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; @@ -466,7 +466,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; } } @@ -475,20 +475,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; @@ -500,7 +500,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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; } } @@ -508,373 +508,379 @@ 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 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; } - public static bool BuffedWallofFleshEyeAI(NPC npc, Mod mod) + public class EyeAI : VanillaAIOverride { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - - // 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.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.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; - 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; + 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; + 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 (!deathModeDetach) - 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; + } + + float shootBoost = fireEnragedLasers ? (death ? 5f : 4f) : (death ? 3f : 3f * (1f - lifeRatio)); + NPC.localAI[1] += 1f + shootBoost; + + if (NPC.localAI[2] == 0f) + { + if (NPC.localAI[1] > LaserShootGateValue) + { + NPC.localAI[2] = 1f; + NPC.localAI[1] = 0f; + } + } + else if (NPC.localAI[1] > 45f && (canHit || deathModeDetach) && !charging) + { + NPC.localAI[1] = 0f; + NPC.localAI[2] += 1f; + if (NPC.localAI[2] >= TotalLasersPerBarrage + 1f) + NPC.localAI[2] = 0f; + + if (shouldFireLasers) + { + float velocity = (fireEnragedLasers ? 3f : 4f) + shootBoost; + int projectileType = ProjectileID.EyeLaser; + + 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, LaserDamage, 0f, Main.myPlayer, 1f, 0f); + Main.projectile[proj].timeLeft = 900; + + if (!canHit) + Main.projectile[proj].tileCollide = false; + } } } - else if (npc.localAI[1] > 45f && (canHit || deathModeDetach) && !charging) - { - npc.localAI[1] = 0f; - npc.localAI[2] += 1f; - if (npc.localAI[2] >= TotalLasersPerBarrage + 1f) - npc.localAI[2] = 0f; - if (shouldFireLasers) - { - float velocity = (fireEnragedLasers ? 3f : 4f) + shootBoost; - int projectileType = ProjectileID.EyeLaser; - - 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, LaserDamage, 0f, Main.myPlayer, 1f, 0f); - Main.projectile[proj].timeLeft = 900; - - if (!canHit) - Main.projectile[proj].tileCollide = false; - } - } + return false; } - - return false; } } } 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..fdc0e682e2 --- /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, 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; + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/MiniBosses/PumpkingAI.cs b/NPCs/VanillaNPCAIOverrides/MiniBosses/PumpkingAI.cs new file mode 100644 index 0000000000..ff5423bf93 --- /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 != 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; + } + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/VanillaAIOverride.cs b/NPCs/VanillaNPCAIOverrides/VanillaAIOverride.cs index 8a0548b1d1..e51ed6b185 100644 --- a/NPCs/VanillaNPCAIOverrides/VanillaAIOverride.cs +++ b/NPCs/VanillaNPCAIOverrides/VanillaAIOverride.cs @@ -9,7 +9,15 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides { public NPC NPC { get; set; } - public abstract bool AI(Mod mod); + public virtual bool AI(Mod mod) + { + return true; + } + + public virtual void PostAI(Mod mod) + { + + } public virtual void SendExtraAI(BitWriter bitWriter, BinaryWriter binaryWriter) { From 22765e84f77da29f51d1acac84478c963c2d689f Mon Sep 17 00:00:00 2001 From: Flowaria Date: Sun, 16 Nov 2025 19:21:41 +0900 Subject: [PATCH 45/65] Migrated NormalAI to VanillaAIOverride type --- NPCs/CalamityGlobalNPC.cs | 1255 +- .../Bosses/SkeletronAI.cs | 71 +- .../RegularEnemies/DemonEyeAI.cs | 132 +- .../RegularEnemies/RevengeanceAndDeathAI.cs | 11500 ---------------- .../RevengeanceAndDeaths/AncientVisionAI.cs | 275 + .../RevengeanceAndDeaths/AngryNimbusAI.cs | 89 + .../RevengeanceAndDeaths/AntlionAI.cs | 152 + .../RevengeanceAndDeaths/BatAI.cs | 371 + .../RevengeanceAndDeaths/BigMimicAI.cs | 383 + .../RevengeanceAndDeaths/BlazingWheelAI.cs | 98 + .../RevengeanceAndDeaths/CasterAI.cs | 493 + .../RevengeanceAndDeaths/CoriteAI.cs | 360 + .../RevengeanceAndDeaths/FighterAI.cs | 3498 +++++ .../RevengeanceAndDeaths/FlowInvaderAI.cs | 60 + .../RevengeanceAndDeaths/FlyingAI.cs | 717 + .../RevengeanceAndDeaths/FlyingFishAI.cs | 261 + .../RevengeanceAndDeaths/FlyingWeaponAI.cs | 83 + .../GraniteElementalAI.cs | 208 + .../RevengeanceAndDeaths/HerplingAI.cs | 310 + .../RevengeanceAndDeaths/HoveringAI.cs | 503 + .../RevengeanceAndDeaths/JellyfishAI.cs | 232 + .../RevengeanceAndDeaths/MartianProbeAI.cs | 124 + .../RevengeanceAndDeaths/MimicAI.cs | 137 + .../RevengeanceAndDeaths/MothronEggAI.cs | 70 + .../RevengeanceAndDeaths/PlantAI.cs | 213 + .../RevengeanceAndDeathAI.cs | 63 + .../RevengeanceAndDeaths/SmallStarCellAI.cs | 65 + .../RevengeanceAndDeaths/SpiderAI.cs | 266 + .../RevengeanceAndDeaths/SpikeBallAI.cs | 92 + .../RevengeanceAndDeaths/SporeAI.cs | 67 + .../RevengeanceAndDeaths/StarCellAI.cs | 306 + .../RevengeanceAndDeaths/SwimmingAI.cs | 239 + .../RevengeanceAndDeaths/TeslaTurretAI.cs | 127 + .../RevengeanceAndDeaths/TortoiseAI.cs | 591 + .../RevengeanceAndDeaths/UnicornAI.cs | 502 + .../RevengeanceAndDeaths/WormAI.cs | 897 ++ .../RegularEnemies/SlimeAI.cs | 136 +- .../VanillaAIOverride.cs | 5 +- 38 files changed, 12653 insertions(+), 12298 deletions(-) delete mode 100644 NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeathAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/AncientVisionAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/AngryNimbusAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/AntlionAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/BatAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/BigMimicAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/BlazingWheelAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/CasterAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/CoriteAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/FighterAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/FlowInvaderAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/FlyingAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/FlyingFishAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/FlyingWeaponAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/GraniteElementalAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/HerplingAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/HoveringAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/JellyfishAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/MartianProbeAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/MimicAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/MothronEggAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/PlantAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/RevengeanceAndDeathAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/SmallStarCellAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/SpiderAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/SpikeBallAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/SporeAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/StarCellAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/SwimmingAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/TeslaTurretAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/TortoiseAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/UnicornAI.cs create mode 100644 NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/WormAI.cs diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 50bc63a985..dd64c02bc3 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -1346,6 +1346,8 @@ namespace CalamityMod.NPCs return new SkeletronAI(); case NPCID.SkeletronHand: return new SkeletronAI.SkeletronHandAI(); + case NPCID.DungeonGuardian: + return new SkeletronAI.DungeonGuardianAI(); case NPCID.Deerclops: return new DeerclopsAI(); @@ -1435,13 +1437,625 @@ namespace CalamityMod.NPCs #endregion - #region Rev+ AI Override Per AiStyle + #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()) + { + 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; } } @@ -3324,8 +3938,6 @@ namespace CalamityMod.NPCs if (NPC.LunarApocalypseIsUp) PillarEventProgressionEdit(npc); - - // Servant of Cthulhu light if (npc.type == NPCID.ServantofCthulhu) Lighting.AddLight(npc.Center, 0.2f, 0.2f, 0.2f); @@ -3362,630 +3974,9 @@ namespace CalamityMod.NPCs } } - if (CalamityWorld.revenge || BossRushEvent.BossRushActive) - { + #region Fairies Edit - } - - 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.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 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); - } - 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.FungiBulb) - return RevengeanceAndDeathAI.BuffedPlantAI(npc, Mod); - - if (npc.type == NPCID.FungiSpore || npc.type == NPCID.Spore) - return RevengeanceAndDeathAI.BuffedSporeAI(npc, Mod); - - // Fairies don't run away and are immune to damage while wearing Fairy Boots. + //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)) { npc.TargetClosest(); @@ -4079,6 +4070,13 @@ namespace CalamityMod.NPCs } } + #endregion + + if (AIOverride != null) + { + return AIOverride.AI(Mod); + } + return true; } #endregion @@ -4443,9 +4441,6 @@ namespace CalamityMod.NPCs default: break; } - - if (CalamityWorld.revenge && npc.type == NPCID.DungeonGuardian) - SkeletronAI.RevengeanceDungeonGuardianAI(npc); } #endregion @@ -4921,6 +4916,8 @@ namespace CalamityMod.NPCs break; } } + + AIOverride?.PostAI(Mod); } #endregion diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs index 7dad437e73..988883791b 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs @@ -1062,46 +1062,55 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - public static void RevengeanceDungeonGuardianAI(NPC npc) + public class DungeonGuardianAI : VanillaAIOverride { - Player target = Main.player[npc.target]; - if (npc.ai[1] != 3f) + public override bool AI(Mod mod) { - 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) + return true; + } + + public override void PostAI(Mod mod) + { + Player target = Main.player[NPC.target]; + if (NPC.ai[1] != 3f) { - if (npc.localAI[1]++ % 60f == 59f) + 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) { - Vector2 source = npc.Center; - if (Collision.CanHit(source, 1, 1, target.Center, target.width, target.height)) + if (NPC.localAI[1]++ % 60f == 59f) { - 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; + 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; + } } } } } } + } } 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 f9722a2b14..0000000000 --- a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeathAI.cs +++ /dev/null @@ -1,11500 +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 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, 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; - - 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; - } - #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; - - // 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; - } - #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 = 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; - } - #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..6327bacc97 --- /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, 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; + } + } +} 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..65f7e6ff2b --- /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 > 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 override bool AI(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 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, 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; + } + } +} 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..718ab3f0d5 --- /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, 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; + } + } +} 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..611c2eb2eb --- /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 > 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; + } + } +} 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..9ac4ff850c --- /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 != 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; + } + } +} 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 f167f0e5c5..76ff14d407 100644 --- a/NPCs/VanillaNPCAIOverrides/RegularEnemies/SlimeAI.cs +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/SlimeAI.cs @@ -10,7 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies { - public static class SlimeAI + public class SlimeAI : VanillaAIOverride { public static void ChooseRandomItem(out int dropItem) { @@ -86,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 *= 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; @@ -121,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; } @@ -154,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; } @@ -168,18 +168,18 @@ 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(); + var source = NPC.GetSource_FromAI(); if (distanceFromTarget < 120f) { for (int i = 0; i < 5; i++) @@ -188,7 +188,7 @@ 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; @@ -197,8 +197,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies } else { - 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); + 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; @@ -218,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) @@ -293,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; } diff --git a/NPCs/VanillaNPCAIOverrides/VanillaAIOverride.cs b/NPCs/VanillaNPCAIOverrides/VanillaAIOverride.cs index e51ed6b185..065e632b75 100644 --- a/NPCs/VanillaNPCAIOverrides/VanillaAIOverride.cs +++ b/NPCs/VanillaNPCAIOverrides/VanillaAIOverride.cs @@ -9,10 +9,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides { public NPC NPC { get; set; } - public virtual bool AI(Mod mod) - { - return true; - } + public abstract bool AI(Mod mod); public virtual void PostAI(Mod mod) { From c326c0446d88170f7263bf6afbdb9e3b1b85374e Mon Sep 17 00:00:00 2001 From: Flowaria Date: Sun, 16 Nov 2025 19:46:25 +0900 Subject: [PATCH 46/65] Added CalamityVanillaAIOverrideNPC --- NPCs/CalamityGlobalNPC.cs | 806 ---------------- NPCs/CalamityVanillaAIOverrideNPC.cs | 865 ++++++++++++++++++ .../VanillaAIOverride.cs | 9 + Utilities/GeneralExtensionUtils.cs | 1 + 4 files changed, 875 insertions(+), 806 deletions(-) create mode 100644 NPCs/CalamityVanillaAIOverrideNPC.cs diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index dd64c02bc3..a058d88d82 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; using System.Reflection; using CalamityMod.Balancing; @@ -30,7 +29,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; @@ -54,9 +52,7 @@ using CalamityMod.NPCs.SlimeGod; using CalamityMod.NPCs.StormWeaver; using CalamityMod.NPCs.SunkenSea; using CalamityMod.NPCs.SupremeCalamitas; -using CalamityMod.NPCs.VanillaNPCAIOverrides; using CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses; -using CalamityMod.NPCs.VanillaNPCAIOverrides.MiniBosses; using CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; using CalamityMod.Packets; using CalamityMod.Particles; @@ -88,7 +84,6 @@ using Terraria.GameContent.Events; using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; -using Terraria.ModLoader.IO; using Terraria.ModLoader.Utilities; using Terraria.UI.Chat; using Terraria.Utilities; @@ -266,11 +261,6 @@ namespace CalamityMod.NPCs /// public bool ProvidesProximityRage = true; - /// - /// Specify the AI Override to work with. This handles AI, SendExtraAI and ReceiveExtraAI in instaned manner. - /// - public VanillaAIOverride AIOverride = null; - // NewAI // TODO: This should be deprecated at some point. internal const int maxAIMod = 4; @@ -1285,786 +1275,9 @@ namespace CalamityMod.NPCs BoundNPCSafety(Mod, npc); - AIOverride = GetVanillaAIOverrideToApply(npc); - if (AIOverride != null) - AIOverride.NPC = npc; } - #region Vanilla AI Override Rule - public static VanillaAIOverride GetVanillaAIOverrideToApply(NPC npc) - { - // 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 BrainOfCthulhuAI.CreeperAI(); - - case NPCID.QueenBee: - return new QueenBeeAI(); - - case NPCID.SkeletronHead: - return new SkeletronAI(); - case NPCID.SkeletronHand: - return new SkeletronAI.SkeletronHandAI(); - 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()) - { - 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 - public override bool? CanFallThroughPlatforms(NPC npc) { // Allow the free Golem Head to pass through platforms in Rev+ @@ -2074,18 +1287,6 @@ namespace CalamityMod.NPCs } #endregion - #region ExtraAI - public override void SendExtraAI(NPC npc, BitWriter bitWriter, BinaryWriter binaryWriter) - { - AIOverride?.SendExtraAI(bitWriter, binaryWriter); - } - - public override void ReceiveExtraAI(NPC npc, BitReader bitReader, BinaryReader binaryReader) - { - AIOverride?.ReceiveExtraAI(bitReader, binaryReader); - } - #endregion - #region Boss Health UI Variable Setting public void DeclareBossHealthUIVariables(NPC npc) { @@ -4072,11 +3273,6 @@ namespace CalamityMod.NPCs #endregion - if (AIOverride != null) - { - return AIOverride.AI(Mod); - } - return true; } #endregion @@ -4916,8 +4112,6 @@ namespace CalamityMod.NPCs break; } } - - AIOverride?.PostAI(Mod); } #endregion diff --git a/NPCs/CalamityVanillaAIOverrideNPC.cs b/NPCs/CalamityVanillaAIOverrideNPC.cs new file mode 100644 index 0000000000..01aaee5f1b --- /dev/null +++ b/NPCs/CalamityVanillaAIOverrideNPC.cs @@ -0,0 +1,865 @@ +using System.IO; +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.MiniBosses; +using CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; +using CalamityMod.World; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ModLoader.IO; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.NPCs; + +public sealed class CalamityVanillaAIOverrideNPC : GlobalNPC +{ + /// + /// Specify the AI Override to work with. This handles AI, SendExtraAI and ReceiveExtraAI in instaned manner. + /// + public VanillaAIOverride AIOverride = null; + + #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; + + // 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 BrainOfCthulhuAI.CreeperAI(); + + case NPCID.QueenBee: + return new QueenBeeAI(); + + case NPCID.SkeletronHead: + return new SkeletronAI(); + case NPCID.SkeletronHand: + return new SkeletronAI.SkeletronHandAI(); + 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()) + { + 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 + + public override void SetDefaults(NPC npc) + { + AIOverride = GetVanillaAIOverrideToApply(npc); + + if (AIOverride != null) + AIOverride.NPC = npc; + } + + #region Hooks + + public override bool PreAI(NPC npc) + { + if (AIOverride != null) + { + return AIOverride.AI(Mod); + } + + return base.PreAI(npc); + } + + public override void PostAI(NPC npc) + { + AIOverride?.PostAI(Mod); + } + + public override void SendExtraAI(NPC npc, BitWriter bitWriter, BinaryWriter binaryWriter) + { + AIOverride?.SendExtraAI(bitWriter, binaryWriter); + } + + public override void ReceiveExtraAI(NPC npc, BitReader bitReader, BinaryReader binaryReader) + { + AIOverride?.ReceiveExtraAI(bitReader, binaryReader); + } + + #endregion +} diff --git a/NPCs/VanillaNPCAIOverrides/VanillaAIOverride.cs b/NPCs/VanillaNPCAIOverrides/VanillaAIOverride.cs index 065e632b75..721c9715bf 100644 --- a/NPCs/VanillaNPCAIOverrides/VanillaAIOverride.cs +++ b/NPCs/VanillaNPCAIOverrides/VanillaAIOverride.cs @@ -25,5 +25,14 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides { } + + /// + /// 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/Utilities/GeneralExtensionUtils.cs b/Utilities/GeneralExtensionUtils.cs index 412bbb784a..e362fa0f54 100644 --- a/Utilities/GeneralExtensionUtils.cs +++ b/Utilities/GeneralExtensionUtils.cs @@ -11,6 +11,7 @@ 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 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(); From 5c692ee6363a1adee0f66505c5c104c1346b0817 Mon Sep 17 00:00:00 2001 From: Flowaria Date: Sun, 16 Nov 2025 20:36:14 +0900 Subject: [PATCH 47/65] Added Safe-guard for AIOverride Desync --- NPCs/CalamityVanillaAIOverrideNPC.cs | 68 ++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 3 deletions(-) diff --git a/NPCs/CalamityVanillaAIOverrideNPC.cs b/NPCs/CalamityVanillaAIOverrideNPC.cs index 01aaee5f1b..41d5a5ad6d 100644 --- a/NPCs/CalamityVanillaAIOverrideNPC.cs +++ b/NPCs/CalamityVanillaAIOverrideNPC.cs @@ -1,4 +1,7 @@ -using System.IO; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; using CalamityMod.Events; using CalamityMod.NPCs.AcidRain; using CalamityMod.NPCs.Astral; @@ -26,6 +29,8 @@ public sealed class CalamityVanillaAIOverrideNPC : GlobalNPC /// public VanillaAIOverride AIOverride = null; + public static Dictionary NetIDLookup = []; + #region Clone Logic public override bool InstancePerEntity => true; @@ -826,6 +831,18 @@ public sealed class CalamityVanillaAIOverrideNPC : GlobalNPC } #endregion + public override void SetStaticDefaults() + { + NetIDLookup.Clear(); + + int uniqueID = 1; + foreach (var type in ReflectionHelper.GetEveryModsTypes().OrderBy(t => t.FullName)) + { + NetIDLookup[type] = uniqueID; + uniqueID++; + } + } + public override void SetDefaults(NPC npc) { AIOverride = GetVanillaAIOverrideToApply(npc); @@ -851,14 +868,59 @@ public sealed class CalamityVanillaAIOverrideNPC : GlobalNPC AIOverride?.PostAI(Mod); } + public static int GetNetID(VanillaAIOverride aiOverride) + { + if (aiOverride == null) + return 0; + + if (!NetIDLookup.TryGetValue(aiOverride.GetType(), out var netID)) + return 0; + + return netID; + } + + public static VanillaAIOverride GetNewInstanceFromNetID(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) { - AIOverride?.SendExtraAI(bitWriter, binaryWriter); + if (AIOverride != null && NetIDLookup.TryGetValue(AIOverride.GetType(), out int netID)) + { + binaryWriter.Write7BitEncodedInt(netID); + AIOverride.SendExtraAI(bitWriter, binaryWriter); + } + else + { + binaryWriter.Write((byte)0); + } } public override void ReceiveExtraAI(NPC npc, BitReader bitReader, BinaryReader binaryReader) { - AIOverride?.ReceiveExtraAI(bitReader, binaryReader); + var netID = binaryReader.Read7BitEncodedInt(); + var localNetID = GetNetID(AIOverride); + if (localNetID == netID) + { + AIOverride?.ReceiveExtraAI(bitReader, binaryReader); + } + else if (netID != 0) + { + CalamityMod.Instance.Logger.Error($"Client AIOverride type is different from Server! [{localNetID} <-> {netID}]. Restored with Default Instance!"); + AIOverride = GetNewInstanceFromNetID(netID, npc); + AIOverride?.ReceiveExtraAI(bitReader, binaryReader); + } } #endregion From 3557019db308aabc341718c7fadb61def1a43ef6 Mon Sep 17 00:00:00 2001 From: Flowaria Date: Sun, 16 Nov 2025 20:44:00 +0900 Subject: [PATCH 48/65] Fixed Few Old Instance of RevAI Override --- NPCs/AstrumAureus/AstrumAureus.cs | 12 ++++++++---- NPCs/CalamityVanillaAIOverrideNPC.cs | 2 +- NPCs/NormalNPCs/BucketZombie.cs | 12 ------------ NPCs/NormalNPCs/SuperDummyNPC.cs | 6 +++++- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/NPCs/AstrumAureus/AstrumAureus.cs b/NPCs/AstrumAureus/AstrumAureus.cs index 0db295170e..b7ed5d4d8b 100644 --- a/NPCs/AstrumAureus/AstrumAureus.cs +++ b/NPCs/AstrumAureus/AstrumAureus.cs @@ -1,7 +1,7 @@ -using System.Collections.Generic; +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; @@ -25,7 +25,6 @@ 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; @@ -61,6 +60,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; @@ -117,6 +118,9 @@ namespace CalamityMod.NPCs.AstrumAureus NPC.scale = 0.7f; if (Main.zenithWorld) NPC.scale = 1.5f; + + ZenithSeedMimicAI = new RevengeanceAndDeathAI.MimicAI(); + ZenithSeedMimicAI.NPC = NPC; } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -300,7 +304,7 @@ namespace CalamityMod.NPCs.AstrumAureus slimePhase = 1; } } - RevengeanceAndDeathAI.BuffedMimicAI(NPC, Mod); + ZenithSeedMimicAI.AI(Mod); NPC.noGravity = false; NPC.noTileCollide = false; return; diff --git a/NPCs/CalamityVanillaAIOverrideNPC.cs b/NPCs/CalamityVanillaAIOverrideNPC.cs index 41d5a5ad6d..1b9595d68c 100644 --- a/NPCs/CalamityVanillaAIOverrideNPC.cs +++ b/NPCs/CalamityVanillaAIOverrideNPC.cs @@ -277,7 +277,7 @@ public sealed class CalamityVanillaAIOverrideNPC : GlobalNPC break; case NPCAIStyleID.Fighter: - if (npc.type == NPCType() || + if (npc.type == NPCType() || npc.type == NPCType() || npc.type == NPCType() || npc.type == NPCType()) { return new RevengeanceAndDeathAI.FighterAI(); diff --git a/NPCs/NormalNPCs/BucketZombie.cs b/NPCs/NormalNPCs/BucketZombie.cs index 2321ab6522..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; @@ -38,16 +36,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.Calamity().VulnerableToSickness = true; } - 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) { bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] diff --git a/NPCs/NormalNPCs/SuperDummyNPC.cs b/NPCs/NormalNPCs/SuperDummyNPC.cs index d910753482..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() { @@ -31,6 +32,9 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.knockBackResist = 0f; NPC.netAlways = true; NPC.aiStyle = NPCAIStyleID.FaceClosestPlayer; + + ZenithSeedMimicAI = new RevengeanceAndDeathAI.MimicAI(); + ZenithSeedMimicAI.NPC = NPC; } public override void SendExtraAI(BinaryWriter writer) @@ -52,7 +56,7 @@ namespace CalamityMod.NPCs.NormalNPCs if (deathCounter >= 6000) { NPC.damage = NPC.lifeMax; - RevengeanceAndDeathAI.BuffedMimicAI(NPC, Mod); + ZenithSeedMimicAI.AI(Mod); return false; } } From b8f9430140f621a116f6d22d31729221d0c96ef6 Mon Sep 17 00:00:00 2001 From: Flowaria Date: Sun, 16 Nov 2025 21:05:42 +0900 Subject: [PATCH 49/65] Oopsie --- NPCs/CalamityVanillaAIOverrideNPC.cs | 4 +-- Utilities/ReflectionHelper.cs | 54 +++++++++++++++++++--------- 2 files changed, 40 insertions(+), 18 deletions(-) diff --git a/NPCs/CalamityVanillaAIOverrideNPC.cs b/NPCs/CalamityVanillaAIOverrideNPC.cs index 1b9595d68c..3c7d5e79dd 100644 --- a/NPCs/CalamityVanillaAIOverrideNPC.cs +++ b/NPCs/CalamityVanillaAIOverrideNPC.cs @@ -836,11 +836,11 @@ public sealed class CalamityVanillaAIOverrideNPC : GlobalNPC NetIDLookup.Clear(); int uniqueID = 1; - foreach (var type in ReflectionHelper.GetEveryModsTypes().OrderBy(t => t.FullName)) + ReflectionHelper.IterateCalamityTypesSorted(action: type => { NetIDLookup[type] = uniqueID; uniqueID++; - } + }); } public override void SetDefaults(NPC npc) diff --git a/Utilities/ReflectionHelper.cs b/Utilities/ReflectionHelper.cs index e1aff58a66..6071bcad71 100644 --- a/Utilities/ReflectionHelper.cs +++ b/Utilities/ReflectionHelper.cs @@ -3,13 +3,8 @@ 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.Core; namespace CalamityMod { @@ -68,6 +63,25 @@ namespace CalamityMod return ModLoader.Mods.SelectMany(mod => AssemblyManager.GetLoadableTypes(mod.Code)); } + public static bool IsSubclass(Type baseType, Type type, bool includeBaseType) + { + return type.IsSubclassOf(baseType) && !type.IsAbstract && (!includeBaseType && type != baseType); + } + + public static void IterateEveryModsTypesSorted(bool includeBaseType = false, Action action = null) + { + // WHY???? + if (action is null) + return; + + Type baseType = typeof(T); + var types = GetEveryModsTypes().Where(t => IsSubclass(baseType, t, includeBaseType)).OrderBy(t => t.FullName); + foreach (var type in types) + { + action.Invoke(type); + } + } + public static void IterateEveryModsTypes(bool includeBaseType = false, Action action = null) { // WHY???? @@ -75,13 +89,10 @@ namespace CalamityMod 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); - } + action.Invoke(type); } } @@ -90,6 +101,20 @@ namespace CalamityMod return AssemblyManager.GetLoadableTypes(CalamityMod.Instance.Code); } + public static void IterateCalamityTypesSorted(bool includeBaseType = false, Action action = null) + { + // WHY???? + if (action is null) + return; + + Type baseType = typeof(T); + var types = GetCalamityTypes().Where(t => IsSubclass(baseType, t, includeBaseType)).OrderBy(t => t.FullName); + foreach (var type in types) + { + action.Invoke(type); + } + } + public static void IterateCalamityTypes(bool includeBaseType = false, Action action = null) { // WHY???? @@ -97,13 +122,10 @@ namespace CalamityMod return; Type baseType = typeof(T); - var types = GetCalamityTypes(); + var types = GetCalamityTypes().Where(t => IsSubclass(baseType, t, includeBaseType)); foreach (var type in types) { - if (type.IsSubclassOf(baseType) && !type.IsAbstract && (!includeBaseType && type != baseType)) - { - action.Invoke(type); - } + action.Invoke(type); } } } From 08e01d28e7111fb86b2625caf853de8dcc65454d Mon Sep 17 00:00:00 2001 From: Flowaria Date: Sun, 16 Nov 2025 21:07:36 +0900 Subject: [PATCH 50/65] Fixing few oversights --- NPCs/CalamityVanillaAIOverrideNPC.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NPCs/CalamityVanillaAIOverrideNPC.cs b/NPCs/CalamityVanillaAIOverrideNPC.cs index 3c7d5e79dd..69cbb70412 100644 --- a/NPCs/CalamityVanillaAIOverrideNPC.cs +++ b/NPCs/CalamityVanillaAIOverrideNPC.cs @@ -836,7 +836,7 @@ public sealed class CalamityVanillaAIOverrideNPC : GlobalNPC NetIDLookup.Clear(); int uniqueID = 1; - ReflectionHelper.IterateCalamityTypesSorted(action: type => + ReflectionHelper.IterateEveryModsTypes(action: type => { NetIDLookup[type] = uniqueID; uniqueID++; @@ -917,7 +917,7 @@ public sealed class CalamityVanillaAIOverrideNPC : GlobalNPC } else if (netID != 0) { - CalamityMod.Instance.Logger.Error($"Client AIOverride type is different from Server! [{localNetID} <-> {netID}]. Restored with Default Instance!"); + CalamityMod.Instance.Logger.Warn($"Client AIOverride type is different from Server! [{localNetID} <-> {netID}]. Restored with Default Instance!"); AIOverride = GetNewInstanceFromNetID(netID, npc); AIOverride?.ReceiveExtraAI(bitReader, binaryReader); } From f9d474ab54f9ead3f6c3db979404b9585395e117 Mon Sep 17 00:00:00 2001 From: Flowaria Date: Sun, 16 Nov 2025 23:17:04 +0900 Subject: [PATCH 51/65] Fixing Unwanted Resync On NPC Death --- NPCs/CalamityVanillaAIOverrideNPC.cs | 53 +++++++++++++++++++--------- 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/NPCs/CalamityVanillaAIOverrideNPC.cs b/NPCs/CalamityVanillaAIOverrideNPC.cs index 69cbb70412..f6bf2f1848 100644 --- a/NPCs/CalamityVanillaAIOverrideNPC.cs +++ b/NPCs/CalamityVanillaAIOverrideNPC.cs @@ -31,6 +31,8 @@ public sealed class CalamityVanillaAIOverrideNPC : GlobalNPC public static Dictionary NetIDLookup = []; + public const int InvalidNetID = 0; + #region Clone Logic public override bool InstancePerEntity => true; @@ -60,6 +62,9 @@ public sealed class CalamityVanillaAIOverrideNPC : GlobalNPC 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(); @@ -868,18 +873,28 @@ public sealed class CalamityVanillaAIOverrideNPC : GlobalNPC AIOverride?.PostAI(Mod); } + #endregion + + #region Networking + public static int GetNetID(VanillaAIOverride aiOverride) { if (aiOverride == null) - return 0; + return InvalidNetID; if (!NetIDLookup.TryGetValue(aiOverride.GetType(), out var netID)) - return 0; + return InvalidNetID; return netID; } - public static VanillaAIOverride GetNewInstanceFromNetID(int netID, NPC ownerNPC) + 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; @@ -896,31 +911,35 @@ public sealed class CalamityVanillaAIOverrideNPC : GlobalNPC public override void SendExtraAI(NPC npc, BitWriter bitWriter, BinaryWriter binaryWriter) { - if (AIOverride != null && NetIDLookup.TryGetValue(AIOverride.GetType(), out int netID)) + // 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) { - binaryWriter.Write7BitEncodedInt(netID); - AIOverride.SendExtraAI(bitWriter, binaryWriter); + AIOverride = null; + binaryWriter.Write7BitEncodedInt(InvalidNetID); + return; } - else + + if (!TryGetNetID(AIOverride, out var netID)) { - binaryWriter.Write((byte)0); + binaryWriter.Write7BitEncodedInt(InvalidNetID); + return; } + + binaryWriter.Write7BitEncodedInt(netID); + AIOverride.SendExtraAI(bitWriter, binaryWriter); } public override void ReceiveExtraAI(NPC npc, BitReader bitReader, BinaryReader binaryReader) { - var netID = binaryReader.Read7BitEncodedInt(); + var remoteNetID = binaryReader.Read7BitEncodedInt(); var localNetID = GetNetID(AIOverride); - if (localNetID == netID) + if (localNetID != remoteNetID) { - AIOverride?.ReceiveExtraAI(bitReader, binaryReader); - } - else if (netID != 0) - { - CalamityMod.Instance.Logger.Warn($"Client AIOverride type is different from Server! [{localNetID} <-> {netID}]. Restored with Default Instance!"); - AIOverride = GetNewInstanceFromNetID(netID, npc); - AIOverride?.ReceiveExtraAI(bitReader, binaryReader); + AIOverride = GetNewInstanceOrNullFromNetID(remoteNetID, npc); } + + AIOverride?.ReceiveExtraAI(bitReader, binaryReader); } #endregion From 03c385dd2242535f22c61f88e6e047a3e4a3a707 Mon Sep 17 00:00:00 2001 From: Flowaria Date: Sun, 16 Nov 2025 23:26:04 +0900 Subject: [PATCH 52/65] Organize DreadnautilusAI as Miniboss --- .../{Bosses => MiniBosses}/DreadnautilusAI.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename NPCs/VanillaNPCAIOverrides/{Bosses => MiniBosses}/DreadnautilusAI.cs (99%) diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/DreadnautilusAI.cs b/NPCs/VanillaNPCAIOverrides/MiniBosses/DreadnautilusAI.cs similarity index 99% rename from NPCs/VanillaNPCAIOverrides/Bosses/DreadnautilusAI.cs rename to NPCs/VanillaNPCAIOverrides/MiniBosses/DreadnautilusAI.cs index 36c0ca8597..ffbe94e885 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/DreadnautilusAI.cs +++ b/NPCs/VanillaNPCAIOverrides/MiniBosses/DreadnautilusAI.cs @@ -7,7 +7,7 @@ using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; -namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.MiniBosses { public class DreadnautilusAI : VanillaAIOverride { From 8a27e63e10bfe8eac15babb6cc09f30aa5e511b6 Mon Sep 17 00:00:00 2001 From: Big E Date: Sun, 16 Nov 2025 13:20:40 -0500 Subject: [PATCH 53/65] + Fixed Transformation Accessories not appearing on other player in Multiplayer --- Items/BaseItems/TransformationAccessory.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Items/BaseItems/TransformationAccessory.cs b/Items/BaseItems/TransformationAccessory.cs index f43eb7c235..d61fb17bf3 100644 --- a/Items/BaseItems/TransformationAccessory.cs +++ b/Items/BaseItems/TransformationAccessory.cs @@ -90,8 +90,8 @@ namespace CalamityMod.Items.BaseItems internal TransformationAccessory currentTransformation = null; internal TransformationAccessory previousTransformation = null; - int previousHighest = -1; - int currentHighest = -1; + internal int previousHighest = -1; + internal int currentHighest = -1; public int Type { @@ -126,8 +126,8 @@ namespace CalamityMod.Items.BaseItems private void Reset(Player p) { - previousHighest = currentHighest; - currentHighest = -1; + p.Transformation().previousHighest = p.Transformation().currentHighest; + p.Transformation().currentHighest = -1; if (p.Transformation().currentTransformation != null && !p.Transformation().currentTransformation.IsForced) { @@ -139,17 +139,17 @@ namespace CalamityMod.Items.BaseItems 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 (currentHighest < itemSlot) - currentHighest = itemSlot; + if (self.Transformation().currentHighest < itemSlot) + self.Transformation().currentHighest = itemSlot; - if (self.Transformation().currentTransformation != null && itemSlot == previousHighest) // last item slot, can set equip slots to our transformation if one is equipped + 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); From bfd30e7dba27814bc046b47bc3f2ba2cf13675db Mon Sep 17 00:00:00 2001 From: Big E Date: Sun, 16 Nov 2025 13:25:55 -0500 Subject: [PATCH 54/65] + Made the transformation reset function static --- Items/BaseItems/TransformationAccessory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Items/BaseItems/TransformationAccessory.cs b/Items/BaseItems/TransformationAccessory.cs index d61fb17bf3..dc76f2aaff 100644 --- a/Items/BaseItems/TransformationAccessory.cs +++ b/Items/BaseItems/TransformationAccessory.cs @@ -124,7 +124,7 @@ namespace CalamityMod.Items.BaseItems } } - private void Reset(Player p) + private static void Reset(Player p) { p.Transformation().previousHighest = p.Transformation().currentHighest; p.Transformation().currentHighest = -1; From 6f7a7bead78f7965491ccd7d6733de566a66ce17 Mon Sep 17 00:00:00 2001 From: doze-zoze Date: Sun, 16 Nov 2025 12:32:21 -0600 Subject: [PATCH 55/65] saros balance also fixed critter shampoo applying sometimes but not others. It doesn't apply at all currently since I'm not sure how to do it right --- Items/Weapons/Summon/SarosPossession.cs | 2 +- Projectiles/Summon/SarosAura.cs | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Items/Weapons/Summon/SarosPossession.cs b/Items/Weapons/Summon/SarosPossession.cs index a030e24c03..f765b703cd 100644 --- a/Items/Weapons/Summon/SarosPossession.cs +++ b/Items/Weapons/Summon/SarosPossession.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Summon { Item.width = 44; Item.height = 48; - Item.damage = 60; + Item.damage = 66; Item.mana = 10; Item.useAnimation = Item.useTime = 24; Item.useStyle = ItemUseStyleID.Swing; diff --git a/Projectiles/Summon/SarosAura.cs b/Projectiles/Summon/SarosAura.cs index f05d8c81a4..9fa4c87c29 100644 --- a/Projectiles/Summon/SarosAura.cs +++ b/Projectiles/Summon/SarosAura.cs @@ -2,9 +2,12 @@ using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using rail; using ReLogic.Content; using Terraria; +using Terraria.DataStructures; using Terraria.GameContent; +using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon @@ -153,12 +156,13 @@ namespace CalamityMod.Projectiles.Summon 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); - //Sunlines + Main.spriteBatch.SafeBegin(SpriteSortMode.Deferred, BatchSetting.Additive, null, Main.GameViewMatrix.TransformationMatrix, () => { + //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); + //Sunlines int count = (int)((Projectile.minionSlots - 1) / 3) * 2 + 2; for (var i = 0; i < count; i++) { From 67fdbeb25a95de110fcb7960992cd5fa73d908fb Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Sun, 16 Nov 2025 13:42:56 -0500 Subject: [PATCH 56/65] SSO September-October --- .../Furniture/Paintings/AmidiasPainting.cs | 19 ++++ .../Furniture/Paintings/AmidiasPainting.png | Bin 0 -> 1488 bytes .../Mods.CalamityMod.Items.Placeables.hjson | 81 ++++++++++-------- .../Paintings/AmidiasPaintingTile.cs | 34 ++++++++ .../Paintings/AmidiasPaintingTile.png | Bin 0 -> 4884 bytes 5 files changed, 98 insertions(+), 36 deletions(-) create mode 100644 Items/Placeables/Furniture/Paintings/AmidiasPainting.cs create mode 100644 Items/Placeables/Furniture/Paintings/AmidiasPainting.png create mode 100644 Tiles/Furniture/Paintings/AmidiasPaintingTile.cs create mode 100644 Tiles/Furniture/Paintings/AmidiasPaintingTile.png diff --git a/Items/Placeables/Furniture/Paintings/AmidiasPainting.cs b/Items/Placeables/Furniture/Paintings/AmidiasPainting.cs new file mode 100644 index 0000000000..d0457c7b26 --- /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.sellPrice(silver: 40); + } + } +} diff --git a/Items/Placeables/Furniture/Paintings/AmidiasPainting.png b/Items/Placeables/Furniture/Paintings/AmidiasPainting.png new file mode 100644 index 0000000000000000000000000000000000000000..2d555e093f6701267b0e1078ab632c05cc287a4c GIT binary patch literal 1488 zcmV;>1uy!EP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D1!YM@K~z{r)!5B% zTvr*#@z1?;=f(5lv12>2W5*>)(}q?}+NMqGrmb4BpdyG$l@L-9s}`|9ASA?sKL8{a zNC+gvhBZi~q8lpI($K1<3iLfylVUXqapJ@t$BAEN#^bqn?q%WP(EJ6N-}0PC=lsrB z&pGEgCphxuakr|%n;UK=1rwuHeCN>vIDKgulRJm8)@);=8)LXy#`R_!rF?{>mm&;9 z>=>+Iwb@3i(?xZlhya9PupJpE3F@^9manfPigMdlDg#9fL;?PBw$WGQ{(L$>SQtfE znL#q#KvW+^K8jG=eGTnKghLbKm|XZ9k~qQXea~U;z1J~#q=2kb#kGYxl4c9m!NMu% zF8CkhT+qXVyIVMYWu;HZ{pjoW<9BauA_$6z#-BrX=evj=>SF)qFg|+iB!>4^kOa?T zc*h>((l#!<`yvWMXOVQ;xc8wMoXV~sND}1UJOEe!j;K(CtcNUK!xMYkc>lsJpL1U@ zmt|>|rGiY5_2Nb^Zsb>I@~bn+TrZjH9X~pA{OC+=EUJw~4ux4Q%xd{kC10w9 zxqO(*hfyhvN@1=L<_d9=Y;EeB&E0DHJm;RiZwh}sS3{U9L17x<$Z;f53+do23cH37 zw{An!+=GG9G79xP*3MnSX8jxrm5ZnrHnH+?9rs`FrO16Rfhc4jL##*0{ z`}QOI@uyD;+vKvb2a!AaeWdFNvatz78%-2@>u9$V6ml)Z%@(rC7_veYS!EbO6d;(N zNBQ<~bl!g%(fJoZdc#V#fql`ZSZK$6LhioF8qTz)5tW9J-17sB%zOnKYcb;4( z_6fP;hbHmH;uLcE3VPK8NXMT+IWcdKu{HqA}JcX=U zMsMd7g5|5oHU5og`DFy+8&=XL9vS@v(wN3_iNF+$ZE7-9Lg4TX!Ir zAA}%}G#ErW@=c`4Jd(ys*!RG*SPH&`VzrEXIgf5TLE4Rx&b^4$B`A~+BG5r@?F0nD zHu)^>A{TCAZ~lEO_RTrBRnPtYgHgx|+pC!#?cze=d&q(fN*p0JiGU#@3+m4G^Z(c#IUPZ6Fxm`sU3q4dXzko|?ojxJAb+^7WJBdZM+cVo1g;-T_u_|?g0FxS4F&+GkkbQ%)} z2C!!`M6%k%T9U)rGXcV@=aH61wkE>QpZG1VucR2As9p$`1@6i@;_NVH_bFDMOq? zsk(-r4E+=%lQkTDatc8%!s1+rSKeB}zux{BpIu$=6LMQO#BIBVFt($<-95j!j7~Sf zV5PL(d-mcYhH7PW;~2A-mhsr(+wsx)1ylw~SZ{40%`()hWn5gmhFZCZcBhN{|NWSZ qR7*Iuu-Yf&ZXE>yY`MCn$^93(2NbgoV<^A?0000 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' - ''' -} - AquaticScourgeRelic: { DisplayName: Aquatic Scourge Relic Tooltip: A glimpse into what could have been... @@ -771,16 +745,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: @@ -901,6 +865,51 @@ 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' + ''' +} + +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: "" 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 0000000000000000000000000000000000000000..b2f4c1b913103653c36aeb22bdde3ee0da858fad GIT binary patch literal 4884 zcmV+v6YK1WP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D5~)citxcOWG)=mfmbMlwMUhoxaUEm?fnhiYm{CLo2Vqo19Dx~R6xoEM zqR67SfZ$Qt%2H?%D72)dY11@I)6yi}l4iNd-Jbd5`@U)Owjl+XbLI~Bd(J&?-tG53 zH~05_e(Q6uSv+TwPaImXxZ8^ zV&6aSAHVIdZyA6S=S;8w^QKlD^g18GIQ8uQiD4!7@g z{aA8+4ff@Xc3trKLAgOWqun38&qt66!SVPQYaBj;;|XFkIsWknUV001jLII2$|!$s z91HK4SCf+?d}L}lFeLevF8~zHwj=%gCfSQX>1Rz#60Kk^ViUAl%Oa-9v z&!-uHX=gkwCZzQoo7kakMw;%1mI9F3vm5|=U(wb>bK{E!pl;@|2W6CTLjaV}0Q)h@ zN6zcZG8_;``S2MPt2lbZ@k}ZKfE)V=0Gn3dWB}$Kd6Na`b{hf6KQjVA!FX*mo<8M8 zqX4A)2LVX!=mB8ex9>Lq$KL-X3$Xi7uj%?J*8wnL!SMhz|NQp=MEW#7lDz<=isu2a zVflpy;K*xUvH-o!PXe&>Io&to>n8)Sd#5xtRIc%q%@L#ehorl!zwkrN6!%_f0n%|% z*2ISZ7+9}utmza05}gm~yw!Mo_>7u9_hbuT(~@JY80w?c-2}jSA3Yon;w$7Bl_fZU zQNFiv^P`$;^UFTuT{?1#H8C-5^XeZMfElM~E;l{0ExogKfAM13s=l^<04fG#YbZ^f3$IF3?<^sBZ-zT=!i7%I7QqpsZXP8Ah7j-71E?a_gxE;IQL< zAVxJx(+lU$1i8hg~qCjj82WIJEm)daw<-#@1DTzS3)D4bdZz@Al|07Nz@ zF3S(=|C8#vPjW(N>i-E2fl>1M4n!#c&5e(1 z4nFmH3*aQWbvpb40Li7YL9qg9?7gRb9e_txJrBU`-}w#z{q2f3j=kb579c)DI<&Wa zHvoyQs{tsRt#J-+Q^p~jCk-w+Od9{frKJX-_NrD3P>}v60L3+8Ky;&+yz22k0`Lzv zUJk&Gr(XiV#dpZd{L6Q5FaT4(cZmfU>e7smUZv+2NB&v+gJN=MKwh8EC?6Zv=>Ow0 z%10)X0w6Ugo8~jh_xk*dN)ImN7?nc~Ieakjo^6!%0;86umt>=ky-x>XlH&}?whUE1 z1wgWRF9276?i>L2cFUIi=(=kF*xj(r09*GnOX9V zrY$Z6VC!mmM-8`B%SN5?qy^|n-3Gw1A2|wunrX7FcU~x4dHzj`(>`?c5di$M`8fdI zIR91yP<7e479h1+?%MWH0hn^d zc@`kunFl~#k1`TulsPaq20(hEyd#^EH)cdUS{^<|3_s;53y=uueZ-5N1t3{eu`eoa`GPVW zPE49^jhOE2Qr6m4xJ1Pa-B(a98!bow6;N36%h(jclXsR0hTE zRi?r5vhX%D9)OmWUp4?UPWh__8qrK(cPZXsa0>t-yHWe2AjhZ=7~VHV)y@5^1;|YO zoKDRAxVEk$b+>gh0O=ZUj?a?~a^BtsK+7*@O3vA9Wb35Bq$hYi1u1z)fgb-h%#+ElQ7{tbNDR)pT0BJz`wT-BV=i&Un!RBQibh_n* zZGL#EY|E*?6Qc@cb8O8l0McR4$axGZEEnU41~iWJF4@qQJ7w$YE~vKv;Tf6fJIbSK-Za9AKmTtZl=NI2?pgesrEyfKFYP+#s@ltrx8vx{$iczs@#Z#|*ca{N|d-)~{5Kk2VkSP=cOk6gKlov4h zwk0H+W23TpZT~gS0MvYIKpLFXbMum7O2uqFFO-qIgg3tJe^VVQ6O)(Odhdb}a>61m z#Y)Z-_r&-2Y8!dUixYcS>O!x6w_)`k#HdAz$M!*Te8dJ{f?Q@I`!Ob?3dVmJfKWsl zYaCC5t;du%RSBJXX}blmB_rop-+S{?TR6MCI?@i!?a87Uu%FjA?c=|-0Eu?hi`)}$ z)OO3;0GO25ZZry-o;c0`Og}?C6R9ck?$Rr60w7$ao(X%HDznZG^>~;;X>M}ynE8@J)EU5UGPC7})L32j)9>FB_8bjZs} zr(q}wLrF4DAsMF-x2qGkOW6TXhQLW=psyYJ+Ho3I;54iN$LMva@SbP3ti^0ui`%5Tu5f3Vx@!1>Fvez_Tn}*;x;uBu3w{9>&t{&U&h4iG4cA~ z-R~Q6jLIR096o>;Gc!?Ktsd>s5RAO7QIC11{A>WspzKd7PZ>`f^=JS&sMpgEF=oW4p0~Td;#$$Q0I+DXb+F-$N+A z2OD35jjth9HJMb^WNb8w_4?6033^4!^>QMI%%+3GlV?KS%Nb@9Kqjx4OkOeRahCKr z3r!E|74e?h7*C!TWySKd2o3cQE`x zwQTL6WorlPTDykl$M*zJb4{`xlWZT>Xd5ZRM#=~!$_XXPNv^n-0L%o@3P_B zZRI#@e_p03;H<2H@OJ zo?`)aL{+zH&Qtb2Iz@eSzur#rg3z?Z*>~$ zetJIG-bHUl3 z<|(_KPN}l%9QLmO81Mdcf3xnNr;gL!WnTthXY&&V;F3$fVF8Z#kUCqd3gz*wc~x2I zzFo>%4-{4b(6L?fyD3)u@#wvm7=V8~N9&`iCMpgqFO(){Vj4$%gRh#dLS{Aj=W15I3Ol_TDB3ySodp@bM=y)6H#r~lIc9KJ~FtTGv$ zj})kGmtU&;lPy1o9HX)y2QVtwg;Y{|766%~=K56JTPKuIy{fh4DKToMG83_=H1|_W zrBM$xoCg2}l5gVbB1-$+K(kaAYP(w%-p^ltrv;cfUW`5GoX-Hz(V@P+vJz=-X_+zz zt6p9Oz@jCK0hm!e(EvR2((4w$c)b-bzNnrAyiCZlfs+8({;GO1oE|YG6Or7eXU>pq zIo``mw301E#^P|t8W>APhF^<`r)oDuR@)lC!5yz z^nXCEuP^&CCZqC8kJFW&ml7>duY|Swj5nj>E~b5OmWGNEkK^P^3r%-;=quY*ZSNIkYiN#WB7yeBVj)> z_K{yaf&AhLl-A9sv~E6ylV?*nc{b(K=TSagedPe)rpK34z{g?sSJ%CJ0JDHYt9&A3G2b&M4d1r*?oe?T4CsA2BiK(?U zOs%bLk=H6 z9N_i&@G}#W=3WRuVS(a=s%rIeSClE9x&7v^8h~%!aF+$B*ro3tI%c*yQ}2FKnds$x zk^}N`G6RZRoTwsjKW_0WvzcOfkLf8>0H~d!_^h_f>t!F3UEAFxuW)>+X7Qh0r3&v^ z-+#seG)0dDpu0sq;ckmEBW|y@sfnuCngOq8-0FQcJ#qYq@ytvqe!Be{eJ@07o4mUx z*H;5j>a8-FGgad|Vxhd!x?}G#0Ka(XUJJ0gLGNQIDKECWPnn3OW#5Nf?|Js)07eDl zsMF4se_t_PpXsSfr3o)SqMX;Ycm2@-Jo3}aEP(CQYWBReJh1hhieG-R`v<_j^+%vy z1=s7H*!Y67)%$uKJXnu`rDAe^rMH$hrg*MzNO4I~k#1Z29W{q9{P!jc(7V~o1@2X5 z#fO{FTHT@fTE`V`P)~e%ycp8_kQN))T-9v>PHwvrfJ;x;O!LtF>Q!HIf*AkNQ#5n9 z;gM^3D;B9|Vt4BgEx^-{s`qbwT$z-Nw;JUy_vyQya-FhSjxp;|7k%Yg0FIw01}vB( z2JGD>O|ARbg9c#rut&GCzGE7y1Q=T$#S?0DV37xvSbCvVaB>@EJRzKw$j=!GDhxe^s zw%qF%OiE5>yw*)&B&X#k(+$8WbB?kA$IX%#TQ^?}TynCqGV4~#<{W*h-d_;IjB5Or z1?b+PVRf$Y`vHZo+@UOft{#=;7}G|Lh3z~041h1^z2bu|r)q+1T`rEwa*WET;BQ*^ z*uU3|gZ!Gy{+ajv;olcL?;jsaPVl+G^Zt0BZP;Ph@3%05&kf4)5tJAFO^x7vWBs3e zjP`3lK?LRGyuK{O0bbu&8aS5b1vMkM?<4q}(d76D-tS{9IX*@kM-V}V2j%z(K6kYL zQ*b<^UFRcsKF6pm!!V=XD-PAG84Ec%BjJ02K5~r868sPTu2g|h5kT?)0000 Date: Sun, 16 Nov 2025 14:55:22 -0500 Subject: [PATCH 57/65] Fixed compiler errors from graphic branch merge --- Projectiles/Summon/SarosEclipseBeam.cs | 3 ++- Projectiles/Summon/SarosSunfire.cs | 3 ++- Projectiles/Summon/SunSpiritBeam.cs | 3 ++- Projectiles/Summon/VengefulSunBeam.cs | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Projectiles/Summon/SarosEclipseBeam.cs b/Projectiles/Summon/SarosEclipseBeam.cs index 5e4fa5edea..3daab84071 100644 --- a/Projectiles/Summon/SarosEclipseBeam.cs +++ b/Projectiles/Summon/SarosEclipseBeam.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using CalamityMod.Enums; using CalamityMod.Graphics.Primitives; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -103,7 +104,7 @@ namespace CalamityMod.Projectiles.Summon return Color.Black * MathF.Pow(1 - completion, 0.5f); } - public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, PixelationPrimitiveLayer layer) + 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. diff --git a/Projectiles/Summon/SarosSunfire.cs b/Projectiles/Summon/SarosSunfire.cs index 3965be9cca..082e53b32a 100644 --- a/Projectiles/Summon/SarosSunfire.cs +++ b/Projectiles/Summon/SarosSunfire.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using CalamityMod.Enums; using CalamityMod.Graphics.Primitives; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -171,7 +172,7 @@ namespace CalamityMod.Projectiles.Summon return mainColor; } - public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, PixelationPrimitiveLayer layer) + public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, GeneralDrawLayer layer) { //Flame body GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak")); diff --git a/Projectiles/Summon/SunSpiritBeam.cs b/Projectiles/Summon/SunSpiritBeam.cs index 5f7394ccd6..f94a544ac7 100644 --- a/Projectiles/Summon/SunSpiritBeam.cs +++ b/Projectiles/Summon/SunSpiritBeam.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Enums; using CalamityMod.Graphics.Primitives; using CalamityMod.Particles; using Microsoft.Xna.Framework; @@ -118,7 +119,7 @@ namespace CalamityMod.Projectiles.Summon return Color.Lerp(fullBodyColor, Color.White, 0.175f) * Projectile.Opacity; } - public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, PixelationPrimitiveLayer layer) + 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); diff --git a/Projectiles/Summon/VengefulSunBeam.cs b/Projectiles/Summon/VengefulSunBeam.cs index dd8c925f13..22d49d0e69 100644 --- a/Projectiles/Summon/VengefulSunBeam.cs +++ b/Projectiles/Summon/VengefulSunBeam.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Enums; using CalamityMod.Graphics.Primitives; using CalamityMod.Particles; using Microsoft.Xna.Framework; @@ -156,7 +157,7 @@ namespace CalamityMod.Projectiles.Summon return fullBodyColor; } - public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, PixelationPrimitiveLayer layer) + 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); From 0e422de13af7915f5a9bb3ba09f991fa4e07e45b Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Thu, 13 Nov 2025 16:49:16 -0500 Subject: [PATCH 58/65] Restrict Hognar to Black Cats and Silver Cats --- NPCs/CalamityGlobalTownNPC.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NPCs/CalamityGlobalTownNPC.cs b/NPCs/CalamityGlobalTownNPC.cs index e76d91bf1a..b3d8b52b76 100644 --- a/NPCs/CalamityGlobalTownNPC.cs +++ b/NPCs/CalamityGlobalTownNPC.cs @@ -351,13 +351,13 @@ namespace CalamityMod.NPCs "Lucerne", // <@!271954788676141066> (lord_lucerne) "Milo", // <@!401849201597874179> (maskedmilo) "Octo", // <@!796112889353994281> (octolinggrimm) - "Hognar the Wicked", // <@!766511001356468237> (xzier_tengal) }; private static readonly string[] TownCatSiameseNames = null; private static readonly string[] TownCatBlackNames = { "Bear", // <@!183424826407518208> (lilac_vrt_olligoci) "Storm", // <@!620383533516718085> (airwaveslr) + "Hognar the Wicked", // <@!766511001356468237> (xzier_tengal) }; private static readonly string[] TownCatOrangeTabbyNames = { @@ -370,6 +370,7 @@ namespace CalamityMod.NPCs private static readonly string[] TownCatSilverNames = { "Archie", // <@!303022375191183360> (jackshiz) + "Hognar the Wicked", // <@!766511001356468237> (xzier_tengal) }; private static readonly string[] TownCatWhiteNames = null; From e97d31cd20284c09881f7afad11f7afc2af59afb Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Sun, 16 Nov 2025 16:38:16 -0500 Subject: [PATCH 59/65] Expert items are now Expert exclusive again following overwhelming dev vote 1. The following items are no longer available in Classic: Royal Gel, Shield of Cthulhu, Worm Scarf, Brain of Confusion, Bone Helm, Hive Backpack, Bone Glove, Volatile Gelatin, Mechanical Cart pieces, Spore Sac, Shiny Stone, Shrimpy Truffle, Soaring Insignia, Gravity Globe, Suspicious Looking Tentacle, Celestial Starboard 2. The following items are no longer available in Classic: Ocean Crest, Fungal Clump, Rotten Brain, Bloody Worm Tooth, Mana Polarizer, Soul of Cryogen, Aquatic Emblem, Flame-Licked Shell, Void of Calamity, Interstellar Stompers, Leviathan Ambergris, Toxic Heart, Blood Pact, Hide of Astrum Deus, Dynamo Stem Cells, Warbanner of the Righteous, Blazing Core, Arc Flash Ring, The Evolution, Spectral Veil, Affliction, Old Duke's Scales, Nebulous Core, Yharim's Gift, Calamity (item), Draedon's Heart 3. Fixed an issue where Thank You dropped twice from Eater of Worlds. --- NPCs/AquaticScourge/AquaticScourgeHead.cs | 3 +- NPCs/AstrumAureus/AstrumAureus.cs | 3 +- NPCs/AstrumDeus/AstrumDeusHead.cs | 3 +- NPCs/BrimstoneElemental/BrimstoneElemental.cs | 3 +- NPCs/Bumblebirb/Dragonfolly.cs | 3 +- NPCs/CalClone/CalamitasClone.cs | 3 +- NPCs/CalamityGlobalNPCLoot.cs | 79 ++++++++++--------- NPCs/CeaselessVoid/CeaselessVoid.cs | 3 +- NPCs/Crabulon/Crabulon.cs | 3 +- NPCs/Cryogen/Cryogen.cs | 3 +- NPCs/DesertScourge/DesertScourgeHead.cs | 3 +- NPCs/DevourerofGods/DevourerofGodsHead.cs | 3 +- NPCs/ExoMechs/Ares/AresBody.cs | 3 +- NPCs/HiveMind/HiveMind.cs | 3 +- NPCs/Leviathan/Leviathan.cs | 3 +- NPCs/OldDuke/OldDuke.cs | 3 +- NPCs/Perforator/PerforatorHive.cs | 3 +- .../PlaguebringerGoliath.cs | 3 +- NPCs/Polterghast/Polterghast.cs | 3 +- .../ProfanedGuardianCommander.cs | 10 ++- NPCs/Providence/Providence.cs | 3 +- NPCs/Ravager/RavagerBody.cs | 3 +- NPCs/Signus/Signus.cs | 3 +- NPCs/SlimeGod/SlimeGodCore.cs | 3 +- NPCs/StormWeaver/StormWeaverHead.cs | 3 +- NPCs/SupremeCalamitas/SupremeCalamitas.cs | 3 +- NPCs/Yharon/Yharon.cs | 3 +- 27 files changed, 98 insertions(+), 66 deletions(-) diff --git a/NPCs/AquaticScourge/AquaticScourgeHead.cs b/NPCs/AquaticScourge/AquaticScourgeHead.cs index 90ef06dcaa..883e0fb931 100644 --- a/NPCs/AquaticScourge/AquaticScourgeHead.cs +++ b/NPCs/AquaticScourge/AquaticScourgeHead.cs @@ -689,7 +689,8 @@ 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); } diff --git a/NPCs/AstrumAureus/AstrumAureus.cs b/NPCs/AstrumAureus/AstrumAureus.cs index b7ed5d4d8b..a4693e2652 100644 --- a/NPCs/AstrumAureus/AstrumAureus.cs +++ b/NPCs/AstrumAureus/AstrumAureus.cs @@ -1309,7 +1309,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)); diff --git a/NPCs/AstrumDeus/AstrumDeusHead.cs b/NPCs/AstrumDeus/AstrumDeusHead.cs index e6a3b2f9fb..b9ab4e8182 100644 --- a/NPCs/AstrumDeus/AstrumDeusHead.cs +++ b/NPCs/AstrumDeus/AstrumDeusHead.cs @@ -974,7 +974,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 diff --git a/NPCs/BrimstoneElemental/BrimstoneElemental.cs b/NPCs/BrimstoneElemental/BrimstoneElemental.cs index d98501fe87..35a898ecc0 100644 --- a/NPCs/BrimstoneElemental/BrimstoneElemental.cs +++ b/NPCs/BrimstoneElemental/BrimstoneElemental.cs @@ -897,7 +897,8 @@ 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); diff --git a/NPCs/Bumblebirb/Dragonfolly.cs b/NPCs/Bumblebirb/Dragonfolly.cs index b706d67a21..b9a6da5101 100644 --- a/NPCs/Bumblebirb/Dragonfolly.cs +++ b/NPCs/Bumblebirb/Dragonfolly.cs @@ -1248,7 +1248,8 @@ namespace CalamityMod.NPCs.Bumblebirb normalOnly.Add(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); // Vanity diff --git a/NPCs/CalClone/CalamitasClone.cs b/NPCs/CalClone/CalamitasClone.cs index 6f8ba0ac36..6e90520411 100644 --- a/NPCs/CalClone/CalamitasClone.cs +++ b/NPCs/CalClone/CalamitasClone.cs @@ -1036,7 +1036,8 @@ 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(), DropHelper.NormalWeaponDropRateFraction); diff --git a/NPCs/CalamityGlobalNPCLoot.cs b/NPCs/CalamityGlobalNPCLoot.cs index 4f0390cbe5..011d9d01e1 100644 --- a/NPCs/CalamityGlobalNPCLoot.cs +++ b/NPCs/CalamityGlobalNPCLoot.cs @@ -1127,8 +1127,8 @@ 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, DropHelper.NormalWeaponDropRateInt)); @@ -1149,8 +1149,8 @@ namespace CalamityMod.NPCs 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(), DropHelper.NormalWeaponDropRateFraction); @@ -1171,15 +1171,12 @@ 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); @@ -1203,8 +1200,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); @@ -1253,8 +1250,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); @@ -1276,8 +1273,9 @@ 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)); + // 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 @@ -1311,8 +1309,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); @@ -1411,12 +1409,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 @@ -1438,8 +1436,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); @@ -1479,8 +1477,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); + // 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); @@ -1506,8 +1505,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); @@ -1564,8 +1563,8 @@ 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); @@ -1617,9 +1616,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); @@ -1714,8 +1714,8 @@ 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 npcLoot.AddNormalOnly(ModContent.ItemType(), 10); @@ -1788,8 +1788,8 @@ namespace CalamityMod.NPCs } 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); @@ -1851,12 +1851,13 @@ namespace CalamityMod.NPCs } 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); diff --git a/NPCs/CeaselessVoid/CeaselessVoid.cs b/NPCs/CeaselessVoid/CeaselessVoid.cs index 7f21657f82..3f22fc8e57 100644 --- a/NPCs/CeaselessVoid/CeaselessVoid.cs +++ b/NPCs/CeaselessVoid/CeaselessVoid.cs @@ -764,7 +764,8 @@ namespace CalamityMod.NPCs.CeaselessVoid normalOnly.Add(DropHelper.PerPlayer(ItemType(), 1, 10, 12)); // Equipment - normalOnly.Add(DropHelper.PerPlayer(ItemType())); + // 16NOV2025: Ozzatron: item has been chosen as the "Expert gatekept" item for this Calamity boss + // normalOnly.Add(DropHelper.PerPlayer(ItemType())); // Vanity normalOnly.Add(ItemType(), 7); diff --git a/NPCs/Crabulon/Crabulon.cs b/NPCs/Crabulon/Crabulon.cs index 0e5f0a6128..41158c61b7 100644 --- a/NPCs/Crabulon/Crabulon.cs +++ b/NPCs/Crabulon/Crabulon.cs @@ -1185,7 +1185,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); diff --git a/NPCs/Cryogen/Cryogen.cs b/NPCs/Cryogen/Cryogen.cs index d061adf8e5..63ce720037 100644 --- a/NPCs/Cryogen/Cryogen.cs +++ b/NPCs/Cryogen/Cryogen.cs @@ -1381,7 +1381,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); } diff --git a/NPCs/DesertScourge/DesertScourgeHead.cs b/NPCs/DesertScourge/DesertScourgeHead.cs index 4bbc6757cd..8d50de290d 100644 --- a/NPCs/DesertScourge/DesertScourgeHead.cs +++ b/NPCs/DesertScourge/DesertScourgeHead.cs @@ -995,7 +995,8 @@ 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); } diff --git a/NPCs/DevourerofGods/DevourerofGodsHead.cs b/NPCs/DevourerofGods/DevourerofGodsHead.cs index dea7b7c164..e039bf5035 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHead.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHead.cs @@ -2570,7 +2570,8 @@ namespace CalamityMod.NPCs.DevourerofGods 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 diff --git a/NPCs/ExoMechs/Ares/AresBody.cs b/NPCs/ExoMechs/Ares/AresBody.cs index b0b3000a31..34d62e6a3e 100644 --- a/NPCs/ExoMechs/Ares/AresBody.cs +++ b/NPCs/ExoMechs/Ares/AresBody.cs @@ -1650,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 diff --git a/NPCs/HiveMind/HiveMind.cs b/NPCs/HiveMind/HiveMind.cs index 9d61e78cf9..16e9d8986b 100644 --- a/NPCs/HiveMind/HiveMind.cs +++ b/NPCs/HiveMind/HiveMind.cs @@ -1350,7 +1350,8 @@ namespace CalamityMod.NPCs.HiveMind // 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); diff --git a/NPCs/Leviathan/Leviathan.cs b/NPCs/Leviathan/Leviathan.cs index b35a1dbe4b..8e51696358 100644 --- a/NPCs/Leviathan/Leviathan.cs +++ b/NPCs/Leviathan/Leviathan.cs @@ -867,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); } diff --git a/NPCs/OldDuke/OldDuke.cs b/NPCs/OldDuke/OldDuke.cs index 038a7dd847..4ba61aec24 100644 --- a/NPCs/OldDuke/OldDuke.cs +++ b/NPCs/OldDuke/OldDuke.cs @@ -2098,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); diff --git a/NPCs/Perforator/PerforatorHive.cs b/NPCs/Perforator/PerforatorHive.cs index 30856c4c53..de4c592c7f 100644 --- a/NPCs/Perforator/PerforatorHive.cs +++ b/NPCs/Perforator/PerforatorHive.cs @@ -686,7 +686,8 @@ namespace CalamityMod.NPCs.Perforator // 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); diff --git a/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs b/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs index 5056b4f28b..3c1ddadae8 100644 --- a/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs +++ b/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs @@ -1354,7 +1354,8 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath 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); diff --git a/NPCs/Polterghast/Polterghast.cs b/NPCs/Polterghast/Polterghast.cs index b9c2689631..3b5e659e2b 100644 --- a/NPCs/Polterghast/Polterghast.cs +++ b/NPCs/Polterghast/Polterghast.cs @@ -992,7 +992,8 @@ 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, 20, 25)); diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs b/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs index 74d2195fcc..9d1b8fc89c 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs @@ -23,7 +23,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; @@ -1199,7 +1199,13 @@ namespace CalamityMod.NPCs.ProfanedGuardians { npcLoot.Add(ModContent.ItemType(), 4); npcLoot.Add(ModContent.ItemType(), 7); - npcLoot.Add(ModContent.ItemType(), 4); + + // 16NOV2025: Ozzatron: item has been chosen as the "Expert gatekept" item for this Calamity boss + // npcLoot.Add(ModContent.ItemType(), 4); + LeadingConditionRule expert = npcLoot.DefineConditionalDropSet(new Conditions.IsExpert()); + expert.Add(ModContent.ItemType(), 4); + npcLoot.Add(expert); + npcLoot.Add(ModContent.ItemType(), 10); npcLoot.Add(ModContent.ItemType()); npcLoot.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 1, 15, 20, 20, 25)); diff --git a/NPCs/Providence/Providence.cs b/NPCs/Providence/Providence.cs index fe971ce389..5794954d51 100644 --- a/NPCs/Providence/Providence.cs +++ b/NPCs/Providence/Providence.cs @@ -2028,7 +2028,8 @@ 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, 50, 60); diff --git a/NPCs/Ravager/RavagerBody.cs b/NPCs/Ravager/RavagerBody.cs index 6eea24650b..bd7552cf28 100644 --- a/NPCs/Ravager/RavagerBody.cs +++ b/NPCs/Ravager/RavagerBody.cs @@ -1014,7 +1014,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())); diff --git a/NPCs/Signus/Signus.cs b/NPCs/Signus/Signus.cs index 1b1c79e4a6..21b8a4b2bf 100644 --- a/NPCs/Signus/Signus.cs +++ b/NPCs/Signus/Signus.cs @@ -924,7 +924,8 @@ namespace CalamityMod.NPCs.Signus 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); diff --git a/NPCs/SlimeGod/SlimeGodCore.cs b/NPCs/SlimeGod/SlimeGodCore.cs index 36c88d757b..a63f26c58d 100644 --- a/NPCs/SlimeGod/SlimeGodCore.cs +++ b/NPCs/SlimeGod/SlimeGodCore.cs @@ -754,7 +754,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); diff --git a/NPCs/StormWeaver/StormWeaverHead.cs b/NPCs/StormWeaver/StormWeaverHead.cs index 89ec7bec83..26d5966777 100644 --- a/NPCs/StormWeaver/StormWeaverHead.cs +++ b/NPCs/StormWeaver/StormWeaverHead.cs @@ -981,7 +981,8 @@ 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, 10, 12)); diff --git a/NPCs/SupremeCalamitas/SupremeCalamitas.cs b/NPCs/SupremeCalamitas/SupremeCalamitas.cs index 2f169574ce..cc8becde11 100644 --- a/NPCs/SupremeCalamitas/SupremeCalamitas.cs +++ b/NPCs/SupremeCalamitas/SupremeCalamitas.cs @@ -3542,7 +3542,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); diff --git a/NPCs/Yharon/Yharon.cs b/NPCs/Yharon/Yharon.cs index 67321609d4..b90ee34476 100644 --- a/NPCs/Yharon/Yharon.cs +++ b/NPCs/Yharon/Yharon.cs @@ -2987,7 +2987,8 @@ namespace CalamityMod.NPCs.Yharon normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType(), 1, 35, 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())); normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); } From 879e4924ae0b2c78acc972927f4c244c2e9e2393 Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <142704082+CongratsIsTrash@users.noreply.github.com> Date: Sun, 16 Nov 2025 16:55:27 -0500 Subject: [PATCH 60/65] Warbanner of the Righteous is a guaranteed drop --- NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs b/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs index 9d1b8fc89c..fb99a5576a 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs @@ -1201,9 +1201,9 @@ namespace CalamityMod.NPCs.ProfanedGuardians npcLoot.Add(ModContent.ItemType(), 7); // 16NOV2025: Ozzatron: item has been chosen as the "Expert gatekept" item for this Calamity boss - // npcLoot.Add(ModContent.ItemType(), 4); + // npcLoot.Add(ModContent.ItemType(), 1); LeadingConditionRule expert = npcLoot.DefineConditionalDropSet(new Conditions.IsExpert()); - expert.Add(ModContent.ItemType(), 4); + expert.Add(ModContent.ItemType(), 1); npcLoot.Add(expert); npcLoot.Add(ModContent.ItemType(), 10); From cbd2d2c96a898a65abf65f3a25d0802162d02da9 Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <142704082+CongratsIsTrash@users.noreply.github.com> Date: Sun, 16 Nov 2025 17:13:32 -0500 Subject: [PATCH 61/65] Updated Ravager bag drops to account for Blood Pact being the new Expert item Flesh Totem is now a 33/50 drop --- Items/TreasureBags/RavagerBag.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Items/TreasureBags/RavagerBag.cs b/Items/TreasureBags/RavagerBag.cs index ea20f25040..3acad9e6e1 100644 --- a/Items/TreasureBags/RavagerBag.cs +++ b/Items/TreasureBags/RavagerBag.cs @@ -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()); From dd834b182c95bbcf1714566be148c6501834318e Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Sun, 16 Nov 2025 17:22:26 -0500 Subject: [PATCH 62/65] Restored Expert rarity for Expert exclusive items --- Items/Accessories/Affliction.cs | 1 + Items/Accessories/AquaticEmblem.cs | 1 + Items/Accessories/ArcFlashRing.cs | 1 + Items/Accessories/BlazingCore.cs | 1 + Items/Accessories/BloodPact.cs | 1 + Items/Accessories/BloodyWormTooth.cs | 1 + Items/Accessories/Calamity.cs | 1 + Items/Accessories/DraedonsHeart.cs | 1 + Items/Accessories/DynamoStemCells.cs | 1 + Items/Accessories/FlameLickedShell.cs | 1 + Items/Accessories/FungalClump.cs | 1 + Items/Accessories/HideofAstrumDeus.cs | 1 + Items/Accessories/InterstellarStompers.cs | 1 + Items/Accessories/LeviathanAmbergris.cs | 1 + Items/Accessories/ManaPolarizer.cs | 1 + Items/Accessories/NebulousCore.cs | 1 + Items/Accessories/OceanCrest.cs | 1 + Items/Accessories/OldDukeScales.cs | 1 + Items/Accessories/RottenBrain.cs | 1 + Items/Accessories/SpectralVeil.cs | 1 + Items/Accessories/TheEvolution.cs | 1 + Items/Accessories/ToxicHeart.cs | 1 + Items/Accessories/VoidofCalamity.cs | 1 + Items/Accessories/WarbanneroftheRighteous.cs | 1 + Items/Accessories/Wings/SoulofCryogen.cs | 1 + Items/Accessories/YharimsGift.cs | 3 ++- Items/CalamityGlobalItem.cs | 6 +++--- 27 files changed, 30 insertions(+), 4 deletions(-) diff --git a/Items/Accessories/Affliction.cs b/Items/Accessories/Affliction.cs index be8a8b917a..443bffa212 100644 --- a/Items/Accessories/Affliction.cs +++ b/Items/Accessories/Affliction.cs @@ -19,6 +19,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/AquaticEmblem.cs b/Items/Accessories/AquaticEmblem.cs index 7171d7c9d2..caca886525 100644 --- a/Items/Accessories/AquaticEmblem.cs +++ b/Items/Accessories/AquaticEmblem.cs @@ -15,6 +15,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) diff --git a/Items/Accessories/ArcFlashRing.cs b/Items/Accessories/ArcFlashRing.cs index ab5618118d..3599b8c00c 100644 --- a/Items/Accessories/ArcFlashRing.cs +++ b/Items/Accessories/ArcFlashRing.cs @@ -18,6 +18,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/BlazingCore.cs b/Items/Accessories/BlazingCore.cs index d77f390a86..4bdcef3fcf 100644 --- a/Items/Accessories/BlazingCore.cs +++ b/Items/Accessories/BlazingCore.cs @@ -35,6 +35,7 @@ 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) diff --git a/Items/Accessories/BloodPact.cs b/Items/Accessories/BloodPact.cs index deb11f3734..739dbe82c0 100644 --- a/Items/Accessories/BloodPact.cs +++ b/Items/Accessories/BloodPact.cs @@ -16,6 +16,7 @@ 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) diff --git a/Items/Accessories/BloodyWormTooth.cs b/Items/Accessories/BloodyWormTooth.cs index aeb23ca680..f81bb96832 100644 --- a/Items/Accessories/BloodyWormTooth.cs +++ b/Items/Accessories/BloodyWormTooth.cs @@ -16,6 +16,7 @@ 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) diff --git a/Items/Accessories/Calamity.cs b/Items/Accessories/Calamity.cs index 0b60fcda8f..14c7c7566f 100644 --- a/Items/Accessories/Calamity.cs +++ b/Items/Accessories/Calamity.cs @@ -33,6 +33,7 @@ namespace CalamityMod.Items.Accessories Item.rare = ModContent.RarityType(); Item.value = CalamityGlobalItem.RarityVioletBuyPrice; Item.accessory = true; + Item.expert = true; } public override void UpdateVanity(Player player) diff --git a/Items/Accessories/DraedonsHeart.cs b/Items/Accessories/DraedonsHeart.cs index 0177e7f04c..66d5d7aa9a 100644 --- a/Items/Accessories/DraedonsHeart.cs +++ b/Items/Accessories/DraedonsHeart.cs @@ -45,6 +45,7 @@ namespace CalamityMod.Items.Accessories Item.defense = 20; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; Item.rare = ModContent.RarityType(); + Item.expert = true; } public override void UpdateAccessory(Player player, bool hideVisual) diff --git a/Items/Accessories/DynamoStemCells.cs b/Items/Accessories/DynamoStemCells.cs index 4885c220ef..730a23181a 100644 --- a/Items/Accessories/DynamoStemCells.cs +++ b/Items/Accessories/DynamoStemCells.cs @@ -28,6 +28,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/FlameLickedShell.cs b/Items/Accessories/FlameLickedShell.cs index 4cf105a720..39b31a175b 100644 --- a/Items/Accessories/FlameLickedShell.cs +++ b/Items/Accessories/FlameLickedShell.cs @@ -26,6 +26,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) diff --git a/Items/Accessories/FungalClump.cs b/Items/Accessories/FungalClump.cs index b7a5cb048e..b244204a94 100644 --- a/Items/Accessories/FungalClump.cs +++ b/Items/Accessories/FungalClump.cs @@ -20,6 +20,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/HideofAstrumDeus.cs b/Items/Accessories/HideofAstrumDeus.cs index cb4e4dba87..7185fcd33b 100644 --- a/Items/Accessories/HideofAstrumDeus.cs +++ b/Items/Accessories/HideofAstrumDeus.cs @@ -20,6 +20,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) 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/LeviathanAmbergris.cs b/Items/Accessories/LeviathanAmbergris.cs index 29b3f78836..9b2c6f2057 100644 --- a/Items/Accessories/LeviathanAmbergris.cs +++ b/Items/Accessories/LeviathanAmbergris.cs @@ -18,6 +18,7 @@ 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) 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/NebulousCore.cs b/Items/Accessories/NebulousCore.cs index 103e179a93..f4cea457eb 100644 --- a/Items/Accessories/NebulousCore.cs +++ b/Items/Accessories/NebulousCore.cs @@ -19,6 +19,7 @@ namespace CalamityMod.Items.Accessories Item.accessory = true; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; Item.rare = ModContent.RarityType(); + Item.expert = true; } public override void Update(ref float gravity, ref float maxFallSpeed) 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/OldDukeScales.cs b/Items/Accessories/OldDukeScales.cs index 0a7355d763..cbe4f9314f 100644 --- a/Items/Accessories/OldDukeScales.cs +++ b/Items/Accessories/OldDukeScales.cs @@ -23,6 +23,7 @@ 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) diff --git a/Items/Accessories/RottenBrain.cs b/Items/Accessories/RottenBrain.cs index d48784a538..01a644c84f 100644 --- a/Items/Accessories/RottenBrain.cs +++ b/Items/Accessories/RottenBrain.cs @@ -19,6 +19,7 @@ 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) 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/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/ToxicHeart.cs b/Items/Accessories/ToxicHeart.cs index da800d501b..5981c7e279 100644 --- a/Items/Accessories/ToxicHeart.cs +++ b/Items/Accessories/ToxicHeart.cs @@ -21,6 +21,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) diff --git a/Items/Accessories/VoidofCalamity.cs b/Items/Accessories/VoidofCalamity.cs index adbefc4037..0bbdbe026a 100644 --- a/Items/Accessories/VoidofCalamity.cs +++ b/Items/Accessories/VoidofCalamity.cs @@ -18,6 +18,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/WarbanneroftheRighteous.cs b/Items/Accessories/WarbanneroftheRighteous.cs index a2ba0a5298..fb469a4bb3 100644 --- a/Items/Accessories/WarbanneroftheRighteous.cs +++ b/Items/Accessories/WarbanneroftheRighteous.cs @@ -42,6 +42,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/Wings/SoulofCryogen.cs b/Items/Accessories/Wings/SoulofCryogen.cs index 14aedb1d51..f9f009b438 100644 --- a/Items/Accessories/Wings/SoulofCryogen.cs +++ b/Items/Accessories/Wings/SoulofCryogen.cs @@ -29,6 +29,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) diff --git a/Items/Accessories/YharimsGift.cs b/Items/Accessories/YharimsGift.cs index 2d0096cb73..919e4a0b4c 100644 --- a/Items/Accessories/YharimsGift.cs +++ b/Items/Accessories/YharimsGift.cs @@ -18,10 +18,11 @@ namespace CalamityMod.Items.Accessories { Item.width = 20; Item.height = 22; - Item.defense = 12; // 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.expert = true; } public override void UpdateAccessory(Player player, bool hideVisual) diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 84e7a6ee9f..fe36457f50 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -262,8 +262,8 @@ namespace CalamityMod.Items if (item.type == ItemID.Zenith) 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: @@ -288,7 +288,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) From 31f7c4b5898d9dea5d51a350747afc1753bb8364 Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Sun, 16 Nov 2025 18:13:55 -0500 Subject: [PATCH 63/65] SSO September-October is obtainable --- Items/Placeables/Furniture/Paintings/AmidiasPainting.cs | 2 +- NPCs/CalamityGlobalTownNPC.cs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Items/Placeables/Furniture/Paintings/AmidiasPainting.cs b/Items/Placeables/Furniture/Paintings/AmidiasPainting.cs index d0457c7b26..e0225466c7 100644 --- a/Items/Placeables/Furniture/Paintings/AmidiasPainting.cs +++ b/Items/Placeables/Furniture/Paintings/AmidiasPainting.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Placeables.Furniture.Paintings Item.DefaultToPlaceableTile(ModContent.TileType()); Item.width = 52; Item.height = 34; - Item.value = Item.sellPrice(silver: 40); + Item.value = Item.buyPrice(gold: 1); } } } diff --git a/NPCs/CalamityGlobalTownNPC.cs b/NPCs/CalamityGlobalTownNPC.cs index b3d8b52b76..74f80155f6 100644 --- a/NPCs/CalamityGlobalTownNPC.cs +++ b/NPCs/CalamityGlobalTownNPC.cs @@ -14,6 +14,7 @@ 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; @@ -1236,7 +1237,8 @@ namespace CalamityMod.NPCs 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) From 882e205d02ce59961f93123a8d9717510fe849a7 Mon Sep 17 00:00:00 2001 From: Nathanael Overton Date: Sun, 16 Nov 2025 20:35:59 -0500 Subject: [PATCH 64/65] Damagetype fix on a UCG proj --- Projectiles/Magic/AerSigilMissile.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Projectiles/Magic/AerSigilMissile.cs b/Projectiles/Magic/AerSigilMissile.cs index f58b2ccb57..c3fa5fdccb 100644 --- a/Projectiles/Magic/AerSigilMissile.cs +++ b/Projectiles/Magic/AerSigilMissile.cs @@ -49,7 +49,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.width = 40; Projectile.height = 40; Projectile.friendly = true; - Projectile.DamageType = DamageClass.MeleeNoSpeed; + Projectile.DamageType = DamageClass.Magic; Projectile.ignoreWater = true; Projectile.tileCollide = true; Projectile.penetrate = 1; From 47f84326aaf26e9566a3349cba69ec566b648a4d Mon Sep 17 00:00:00 2001 From: Listentowind <2926669682@qq.com> Date: Mon, 17 Nov 2025 14:45:43 +0800 Subject: [PATCH 65/65] clean removed loc entry --- Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson index df88751a5d..b78a858638 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson @@ -241,7 +241,6 @@ SandMark.DisplayName: Mark SandnadoMinion.DisplayName: Sandnado SandTornado.DisplayName: Tornado SarosAura.DisplayName: Saros Aura -SarosMicrosun.DisplayName: Saros Microsun SarosSunfire.DisplayName: Saros Sunfire SeashineSwordProj.DisplayName: Seashine Sword SeekerSummonProj.DisplayName: Soul Seeker @@ -274,9 +273,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