From fd8635816495e252ca4f1d1a44d8df7e594c947b Mon Sep 17 00:00:00 2001 From: Memes Date: Sun, 17 Mar 2024 02:49:06 +0100 Subject: [PATCH] Added a telegraph to Destroyer. 1. Added a telegraph to Destroyer's lasers. 2. Added two new particles related to Destroyer's telegraph. --- .../Bosses/DestroyerAI.cs | 76 ++++++++++++++++++ Particles/DestroyerReticleTelegraph.cs | 53 ++++++++++++ Particles/DestroyerReticleTelegraph.png | Bin 0 -> 4529 bytes Particles/DestroyerSparkTelegraph.cs | 59 ++++++++++++++ 4 files changed, 188 insertions(+) create mode 100644 Particles/DestroyerReticleTelegraph.cs create mode 100644 Particles/DestroyerReticleTelegraph.png create mode 100644 Particles/DestroyerSparkTelegraph.cs diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs index c2ffacd734..bc5814d247 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs @@ -1,6 +1,7 @@ using System; using CalamityMod.Events; using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.Particles; using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -18,6 +19,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses public const float DRIncraeseTime = 600f; public const float DeathModeLaserBreathGateValue = 600f; public const float LaserTelegraphTime = 120f; + public const float SparkTelegraphTime = 30f; public const float FlightPhaseGateValue = 900f; public const float FlightPhaseResetGateValue = FlightPhaseGateValue * 2f; private const float Phase4FlightPhaseTimerSetValue = FlightPhaseGateValue * 0.5f; @@ -483,6 +485,43 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (calamityGlobalNPC.newAI[0] % 20f == 0f && ableToFireLaser) npc.SyncExtraAI(); + Color telegraphColor = Color.Transparent; + switch (calamityGlobalNPC.destroyerLaserColor) + { + case 0: + telegraphColor = Color.Red; + break; + case 1: + telegraphColor = Color.Green; + break; + case 2: + telegraphColor = Color.Cyan; + break; + } + + if (calamityGlobalNPC.newAI[0] == shootProjectileGateValue - LaserTelegraphTime) + { + Particle telegraph = new DestroyerReticleTelegraph( + npc, + telegraphColor, + 1.5f, + 0.15f, + (int)LaserTelegraphTime); + GeneralParticleHandler.SpawnParticle(telegraph); + } + + if (calamityGlobalNPC.newAI[0] == shootProjectileGateValue - SparkTelegraphTime) + { + Particle spark = new DestroyerSparkTelegraph( + npc, + telegraphColor * 2f, + Color.White, + 3f, + 30, + Main.rand.NextFloat(MathHelper.ToRadians(3f)) * Main.rand.NextBool().ToDirectionInt()); + GeneralParticleHandler.SpawnParticle(spark); + } + // Shoot lasers // Shoot nothing if probe has been launched if (calamityGlobalNPC.newAI[0] >= shootProjectileGateValue && ableToFireLaser) @@ -1186,6 +1225,43 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.localAI[0] % 20f == 0f && ableToFireLaser) npc.SyncVanillaLocalAI(); + Color telegraphColor = Color.Transparent; + switch (npc.Calamity().destroyerLaserColor) + { + case 0: + telegraphColor = Color.Red; + break; + case 1: + telegraphColor = Color.Green; + break; + case 2: + telegraphColor = Color.Cyan; + break; + } + + if (npc.localAI[0] == shootProjectileGateValue - LaserTelegraphTime) + { + Particle telegraph = new DestroyerReticleTelegraph( + npc, + telegraphColor, + 1.5f, + 0.15f, + (int)LaserTelegraphTime); + GeneralParticleHandler.SpawnParticle(telegraph); + } + + if (npc.localAI[0] == shootProjectileGateValue - SparkTelegraphTime) + { + Particle spark = new DestroyerSparkTelegraph( + npc, + telegraphColor * 2f, + Color.White, + 3f, + 30, + Main.rand.NextFloat(MathHelper.ToRadians(3f)) * Main.rand.NextBool().ToDirectionInt()); + GeneralParticleHandler.SpawnParticle(spark); + } + if (npc.localAI[0] >= shootProjectileGateValue && ableToFireLaser) { int numProbeSegments = 0; diff --git a/Particles/DestroyerReticleTelegraph.cs b/Particles/DestroyerReticleTelegraph.cs new file mode 100644 index 0000000000..fdfec7f1e6 --- /dev/null +++ b/Particles/DestroyerReticleTelegraph.cs @@ -0,0 +1,53 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; +using static CalamityMod.CalamityUtils; + +namespace CalamityMod.Particles +{ + public class DestroyerReticleTelegraph : Particle + { + public override string Texture => "CalamityMod/Particles/DestroyerReticleTelegraph"; + public override bool UseAdditiveBlend => true; + public override bool SetLifetime => true; + public override bool UseCustomDraw => true; + public override bool Important => true; + + private NPC NPCToFollow; + private float OriginalScale; + private float FinalScale; + private float Opacity; + private int RotationDirection; + + public DestroyerReticleTelegraph(NPC npcToFollow, Color color, float originalScale, float finalScale, int lifeTime) + { + NPCToFollow = npcToFollow; + Color = color; + OriginalScale = originalScale; + Scale = originalScale; + FinalScale = finalScale; + Lifetime = lifeTime; + RotationDirection = Main.rand.NextBool().ToDirectionInt(); + } + + public override void Update() + { + float pulseProgress = PiecewiseAnimation(LifetimeCompletion, [new(EasingType.PolyOut, 0f, 0f, 1f, 4)]); + Scale = MathHelper.Lerp(OriginalScale, FinalScale, pulseProgress); + Opacity = pulseProgress; + Rotation += MathHelper.ToRadians(8f) * (1f - pulseProgress) * RotationDirection; + + if (NPCToFollow != null && NPCToFollow.active && !Main.tile[NPCToFollow.Center.ToSafeTileCoordinates()].IsTileSolid()) + Position = NPCToFollow.Center; + else + Kill(); + } + + public override void CustomDraw(SpriteBatch spriteBatch) + { + Texture2D tex = ModContent.Request(Texture).Value; + spriteBatch.Draw(tex, Position - Main.screenPosition, null, Color * Opacity, Rotation, tex.Size() / 2f, Scale, SpriteEffects.None, 0); + } + } +} diff --git a/Particles/DestroyerReticleTelegraph.png b/Particles/DestroyerReticleTelegraph.png new file mode 100644 index 0000000000000000000000000000000000000000..d8a1f4b1424d3a7eaf37d583c116a543661f1d59 GIT binary patch literal 4529 zcmeHKdvp}l8K3Y-LNFmDsYV*;Fwv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`SUg|pZ!6waAV3~n^~yttRKakxN|G-b2`QlKrm z3Q2Z3>{DV~1eE%rj!-LDpt@G*-TiAgV>mum53~h>lHnwSCnaM@jOb66&`ykjY>SES z=uxZ#h8!_)Ucv^CE_f0W$)m7eFBt0&`RQMWAJPSijyf5UzN2!D$~7VdMg$(Mu2H#0 zq`-*4qt*3)lPhEJG6h2LA5aWlm8M-TD1_InRPWEroyfP^cgGvMH$lq;$yFyK$iy7& zNjcs9$PH*rQ{0}iw7-v?j98{!?YKb0tMp>Gv$R_6>N$I0GBQ2AEZ+Id*N0A-rl))s zN=fZYE&T1#SrZp7eBiZzb@h%P*K~fil%55f?1J>H_~VIYx;49C)!4Y+I3%faTk(y5 z@BhVO|Ez1{-(S>XIBP-Cz>H)NkUp8N7E3(t@%Ktgvtu29hFN96Fu#KsF35qlNu7AU$@Ngj ROsG8KE}QRsWzK`E{sT>cP-OrB literal 0 HcmV?d00001 diff --git a/Particles/DestroyerSparkTelegraph.cs b/Particles/DestroyerSparkTelegraph.cs new file mode 100644 index 0000000000..6af1f925e2 --- /dev/null +++ b/Particles/DestroyerSparkTelegraph.cs @@ -0,0 +1,59 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Particles +{ + public class DestroyerSparkTelegraph : Particle + { + public override string Texture => "CalamityMod/Particles/Sparkle2"; + public override bool UseAdditiveBlend => true; + public override bool UseCustomDraw => true; + public override bool SetLifetime => true; + public override bool Important => true; + + private NPC NPCToFollow; + private float Spin; + private float Opacity; + private Color Bloom; + private float BloomScale; + + public DestroyerSparkTelegraph(NPC npcToFollow, Color color, Color bloom, float scale, int lifeTime, float rotationSpeed = 0f, float bloomScale = 1f) + { + NPCToFollow = npcToFollow; + Color = color; + Bloom = bloom; + Scale = scale; + Lifetime = lifeTime; + Spin = rotationSpeed; + BloomScale = bloomScale; + Rotation = Main.rand.NextFloat(MathHelper.TwoPi); + } + + public override void Update() + { + Opacity = MathF.Sin(LifetimeCompletion * MathHelper.Pi); + Rotation += Spin * ((Velocity.X > 0) ? 1f : -1f); + + if (NPCToFollow != null && NPCToFollow.active && !Main.tile[NPCToFollow.Center.ToSafeTileCoordinates()].IsTileSolid()) + Position = NPCToFollow.Center; + else + Kill(); + } + + public override void CustomDraw(SpriteBatch spriteBatch) + { + Texture2D starTexture = ModContent.Request(Texture).Value; + Texture2D bloomTexture = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + + // Ajust the bloom's texture to be the same size as the star's. + float properBloomSize = (float)starTexture.Height / (float)bloomTexture.Height; + + spriteBatch.Draw(bloomTexture, Position - Main.screenPosition, null, Bloom * Opacity * 0.5f, 0, bloomTexture.Size() / 2f, Scale * BloomScale * properBloomSize, SpriteEffects.None, 0); + spriteBatch.Draw(starTexture, Position - Main.screenPosition, null, Color * Opacity * 0.5f, Rotation + MathHelper.PiOver4, starTexture.Size() / 2f, Scale * 0.75f, SpriteEffects.None, 0); + spriteBatch.Draw(starTexture, Position - Main.screenPosition, null, Color * Opacity, Rotation, starTexture.Size() / 2f, Scale, SpriteEffects.None, 0); + } + } +}