diff --git a/NPCs/NormalNPCs/KingSlimeJewelEmerald.png b/NPCs/NormalNPCs/KingSlimeJewelEmerald.png new file mode 100644 index 0000000000..ce97f974b7 Binary files /dev/null and b/NPCs/NormalNPCs/KingSlimeJewelEmerald.png differ diff --git a/NPCs/NormalNPCs/KingSlimeJewelFlash.png b/NPCs/NormalNPCs/KingSlimeJewelFlash.png new file mode 100644 index 0000000000..86950b1323 Binary files /dev/null and b/NPCs/NormalNPCs/KingSlimeJewelFlash.png differ diff --git a/NPCs/NormalNPCs/KingSlimeJewelRuby.cs b/NPCs/NormalNPCs/KingSlimeJewelRuby.cs index 4124af61d1..10356de218 100644 --- a/NPCs/NormalNPCs/KingSlimeJewelRuby.cs +++ b/NPCs/NormalNPCs/KingSlimeJewelRuby.cs @@ -1,18 +1,26 @@ -using CalamityMod.CalPlayer; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using CalamityMod.CalPlayer; using CalamityMod.Events; +using CalamityMod.Graphics.Primitives; +using CalamityMod.Particles; using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.Audio; +using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; +using static System.Net.Mime.MediaTypeNames; namespace CalamityMod.NPCs.NormalNPCs { public class KingSlimeJewelRuby : ModNPC { - public override string Texture => "CalamityMod/NPCs/NormalNPCs/KingSlimeJewel"; + public static readonly SoundStyle ShatterSound = new SoundStyle("CalamityMod/Sounds/NPCKilled/CrownJewelShatter"); private const int BoltShootGateValue = 60; private const int BoltShootGateValue_Death = 75; @@ -50,7 +58,7 @@ namespace CalamityMod.NPCs.NormalNPCs if (!CalamityPlayer.areThereAnyDamnBosses) { NPC.life = 0; - NPC.HitEffect(); + OnKill(); NPC.active = false; NPC.netUpdate = true; return; @@ -131,21 +139,14 @@ namespace CalamityMod.NPCs.NormalNPCs projVector.X *= projLength; projVector.Y *= projLength; - for (int dusty = 0; dusty < 10; dusty++) + for (int i = 0; i < 6; i++) { - Vector2 dustVel = projVector; - dustVel.Normalize(); - int ruby = Dust.NewDust(NPC.Center, NPC.width, NPC.height, DustID.GemRuby, dustVel.X, dustVel.Y, 100, default, 2f); - Main.dust[ruby].velocity *= 1.5f; - Main.dust[ruby].noGravity = true; - if (Main.rand.NextBool()) - { - Main.dust[ruby].scale = 0.5f; - Main.dust[ruby].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } + GeneralParticleHandler.SpawnParticle(new PointParticle(NPC.Center, new Vector2(Main.rand.NextFloat(20), 0).RotatedByRandom(MathHelper.TwoPi), false, 10, Main.rand.NextFloat(0.5f, 1.5f), Color.Red)); + GeneralParticleHandler.SpawnParticle(new PointParticle(NPC.Center, new Vector2(Main.rand.NextFloat(10), 0).RotatedByRandom(MathHelper.TwoPi), false, 10, Main.rand.NextFloat(0.5f, 1.5f), Color.Pink)); } SoundEngine.PlaySound(SoundID.Item8, NPC.Center); + SoundEngine.PlaySound(ShatterSound.WithPitchOffset(-0.75f).WithVolumeScale(0.4f), NPC.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -168,17 +169,46 @@ namespace CalamityMod.NPCs.NormalNPCs } } + public override void OnKill() + { + for (int i = 0; i < 6; i++) + { + GeneralParticleHandler.SpawnParticle(new PointParticle(NPC.Center, new Vector2(Main.rand.NextFloat(20), 0).RotatedByRandom(MathHelper.TwoPi), false, 10, Main.rand.NextFloat(0.5f, 1.5f), Color.Red)); + GeneralParticleHandler.SpawnParticle(new PointParticle(NPC.Center, new Vector2(Main.rand.NextFloat(10), 0).RotatedByRandom(MathHelper.TwoPi), false, 10, Main.rand.NextFloat(0.5f, 1.5f), Color.HotPink)); + } + + float start = Main.rand.NextFloat(MathHelper.TwoPi); + for (int i = 0; i < 3; i++) + { + GeneralParticleHandler.SpawnParticle(new CustomSprite(NPC.Center, new Vector2(0, -2).RotatedByRandom(start + MathHelper.ToRadians(20f)).RotatedBy(MathHelper.ToRadians(i * 125)), 120, "CalamityMod/Particles/KingSlimeRubyShards", 1f, new Color(255, 255, 255), Main.rand.NextFloat(0.2f, 0.6f), frameCount: 3, frame: i)); + } + SoundEngine.PlaySound(ShatterSound, NPC.Center); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Color col = Color.Red; + Color flashCol = Color.HotPink; + + float alph = 0f; + + float colorTelegraphGateValue = (BossRushEvent.BossRushActive ? BoltShootGateValue_BossRush : (CalamityWorld.death ? BoltShootGateValue_Death : BoltShootGateValue)) - LightTelegraphDuration; + + if (NPC.ai[0] > colorTelegraphGateValue) + alph = MathHelper.Lerp(0f, 1f, (NPC.ai[0] - colorTelegraphGateValue) / LightTelegraphDuration); + + Asset tex = ModContent.Request(Texture); + Asset tex2 = ModContent.Request("CalamityMod/NPCs/NormalNPCs/KingSlimeJewelFlash"); + + Main.EntitySpriteDraw(tex.Value, NPC.Center - Main.screenPosition, tex.Frame(), Color.White, NPC.rotation, tex.Frame().Center(), 1f, SpriteEffects.None); + Main.EntitySpriteDraw(tex2.Value, NPC.Center - Main.screenPosition, tex2.Frame(), Color.Lerp(col, flashCol, alph).MultiplyRGBA(new Color(alph, alph, alph, 0f)), NPC.rotation, tex2.Frame().Center(), alph * 1.2f, SpriteEffects.None); + + return false; + } + public override Color? GetAlpha(Color drawColor) { - Color initialColor = new Color(175, 100, 100); - Color newColor = initialColor; - Color finalColor = new Color(255, 150, 150); - float colorTelegraphGateValue = (BossRushEvent.BossRushActive ? BoltShootGateValue_BossRush : CalamityWorld.death ? BoltShootGateValue_Death : BoltShootGateValue) - LightTelegraphDuration; - if (NPC.ai[0] > colorTelegraphGateValue) - newColor = Color.Lerp(initialColor, finalColor, (NPC.ai[0] - colorTelegraphGateValue) / LightTelegraphDuration); - newColor.A = (byte)(255 * NPC.Opacity); - - return newColor; + return Color.White; } public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) @@ -190,37 +220,9 @@ namespace CalamityMod.NPCs.NormalNPCs public override void HitEffect(NPC.HitInfo hit) { - int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GemRuby, hit.HitDirection, -1f, 0, default, 1f); - Main.dust[dust].noGravity = true; - - if (NPC.life <= 0) + for (int i = 0; i < 6; i++) { - NPC.position = NPC.Center; - NPC.width = NPC.height = 45; - NPC.position.X = NPC.position.X - (NPC.width / 2); - NPC.position.Y = NPC.position.Y - (NPC.height / 2); - - for (int i = 0; i < 2; i++) - { - int rubyDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GemRuby, 0f, 0f, 100, default, 2f); - Main.dust[rubyDust].velocity *= 3f; - Main.dust[rubyDust].noGravity = true; - if (Main.rand.NextBool()) - { - Main.dust[rubyDust].scale = 0.5f; - Main.dust[rubyDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - - for (int j = 0; j < 10; j++) - { - int rubyDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GemRuby, 0f, 0f, 100, default, 3f); - Main.dust[rubyDust2].noGravity = true; - Main.dust[rubyDust2].velocity *= 5f; - rubyDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GemRuby, 0f, 0f, 100, default, 2f); - Main.dust[rubyDust2].noGravity = true; - Main.dust[rubyDust2].velocity *= 2f; - } + GeneralParticleHandler.SpawnParticle(new PointParticle(NPC.Center, new Vector2(Main.rand.NextFloat(10), 0).RotatedByRandom(MathHelper.TwoPi), false, 10, Main.rand.NextFloat(0.5f, 1.5f), Color.Red)); } } } diff --git a/NPCs/NormalNPCs/KingSlimeJewelRuby.png b/NPCs/NormalNPCs/KingSlimeJewelRuby.png new file mode 100644 index 0000000000..f94f29c1af Binary files /dev/null and b/NPCs/NormalNPCs/KingSlimeJewelRuby.png differ diff --git a/NPCs/NormalNPCs/KingSlimeJewelSapphire.cs b/NPCs/NormalNPCs/KingSlimeJewelSapphire.cs index 01939954f6..5b7df08800 100644 --- a/NPCs/NormalNPCs/KingSlimeJewelSapphire.cs +++ b/NPCs/NormalNPCs/KingSlimeJewelSapphire.cs @@ -1,9 +1,12 @@ using System; using CalamityMod.CalPlayer; using CalamityMod.Events; +using CalamityMod.Particles; using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -13,8 +16,6 @@ namespace CalamityMod.NPCs.NormalNPCs { public class KingSlimeJewelSapphire : ModNPC { - public override string Texture => "CalamityMod/NPCs/NormalNPCs/KingSlimeJewel"; - private const int BuffDustGateValue = 60; private const float LightTelegraphDuration = 45f; @@ -49,7 +50,7 @@ namespace CalamityMod.NPCs.NormalNPCs if (!CalamityPlayer.areThereAnyDamnBosses) { NPC.life = 0; - NPC.HitEffect(); + OnKill(); NPC.active = false; NPC.netUpdate = true; return; @@ -184,6 +185,24 @@ namespace CalamityMod.NPCs.NormalNPCs } } + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Color col = Color.BlueViolet; + Color flashCol = Color.LightSkyBlue; + + NPC.localAI[1]++; + + float alph = 0.4f + (float)(Math.Sin(NPC.localAI[1] / 30f) * 0.4f); + + Asset tex = ModContent.Request(Texture); + Asset tex2 = ModContent.Request("CalamityMod/NPCs/NormalNPCs/KingSlimeJewelFlash"); + + Main.EntitySpriteDraw(tex.Value, NPC.Center - Main.screenPosition, tex.Frame(), Color.White, NPC.rotation, tex.Frame().Center(), 1f, SpriteEffects.None); + Main.EntitySpriteDraw(tex2.Value, NPC.Center - Main.screenPosition, tex2.Frame(), Color.Lerp(col, flashCol, alph).MultiplyRGBA(new Color(alph, alph, alph, 0f)), NPC.rotation, tex2.Frame().Center(), alph * 1.2f, SpriteEffects.None); + + return false; + } + public override Color? GetAlpha(Color drawColor) { Color initialColor = new Color(100, 100, 175); @@ -202,6 +221,22 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.lifeMax = (int)(NPC.lifeMax * balance); } + public override void OnKill() + { + for (int i = 0; i < 6; i++) + { + GeneralParticleHandler.SpawnParticle(new PointParticle(NPC.Center, new Vector2(Main.rand.NextFloat(20), 0).RotatedByRandom(MathHelper.TwoPi), false, 10, Main.rand.NextFloat(0.5f, 1.5f), Color.BlueViolet)); + GeneralParticleHandler.SpawnParticle(new PointParticle(NPC.Center, new Vector2(Main.rand.NextFloat(10), 0).RotatedByRandom(MathHelper.TwoPi), false, 10, Main.rand.NextFloat(0.5f, 1.5f), Color.LightSkyBlue)); + } + + float start = Main.rand.NextFloat(MathHelper.TwoPi); + for (int i = 0; i < 3; i++) + { + GeneralParticleHandler.SpawnParticle(new CustomSprite(NPC.Center, new Vector2(0, -2).RotatedByRandom(start + MathHelper.ToRadians(20f)).RotatedBy(MathHelper.ToRadians(i * 125)), 120, "CalamityMod/Particles/KingSlimeSapphireShards", 1f, new Color(255, 255, 255), Main.rand.NextFloat(0.2f, 0.6f), frameCount: 3, frame: i)); + } + SoundEngine.PlaySound(KingSlimeJewelRuby.ShatterSound, NPC.Center); + } + public override bool CheckActive() => false; public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/NormalNPCs/KingSlimeJewelSapphire.png b/NPCs/NormalNPCs/KingSlimeJewelSapphire.png new file mode 100644 index 0000000000..275d2722fa Binary files /dev/null and b/NPCs/NormalNPCs/KingSlimeJewelSapphire.png differ diff --git a/Particles/CustomSprite.cs b/Particles/CustomSprite.cs new file mode 100644 index 0000000000..8ce2493fd4 --- /dev/null +++ b/Particles/CustomSprite.cs @@ -0,0 +1,83 @@ +using System; +using System.Threading; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ModLoader; +using static CalamityMod.Projectiles.Rogue.FinalDawnFlame; + +namespace CalamityMod.Particles +{ + public class CustomSprite : Particle + { + bool addBlend = false; + bool important = false; + bool AffectedByGravity = false; + + string Tex = ""; + int frames = 1; + int currentFrame = 0; + + int Timer = 0; + + float maxGravity = 0f; + + public override bool SetLifetime => true; + public override bool UseCustomDraw => true; + public override bool UseAdditiveBlend => false; + public override bool Important => important; + public override string Texture => "CalamityMod/Particles/CuteStars"; + public override int FrameVariants => frames; + + public CustomSprite(Vector2 relativePosition, Vector2 velocity, int lifetime, string tex, float scale, Color color, float grav = 0f, bool AddativeBlend = true, bool needed = false, int frameCount = 0, int frame = 0) + { + maxGravity = grav; + Position = relativePosition; + Velocity = velocity; + Scale = scale; + Lifetime = lifetime; + addBlend = AddativeBlend; + important = needed; + Color = color; + Tex = tex; + frames = frameCount; + currentFrame = frame; + } + + public override void Update() + { + + Position += Velocity; + + if (addBlend) Color.A = 0; + else Color.A = 255; + + Timer++; + + if (Timer > Lifetime - 20) + { + Scale *= 0.9f; + } + + Velocity *= 0.85f; + if (maxGravity != 0f) + { + if (Velocity.Length() < maxGravity) + { + Velocity.X *= 0.94f; + Velocity.Y += maxGravity / 10f; + } + } + } + + public override void CustomDraw(SpriteBatch spriteBatch) + { + Asset tex = ModContent.Request(Tex); + + Rectangle fr = tex.Frame(1, frames, 0, currentFrame); + + Main.EntitySpriteDraw(tex.Value, Position - Main.screenPosition, fr, Color.White, Rotation, new Vector2(tex.Width() / 2, tex.Height() / frames / 2), Scale, SpriteEffects.None); + } + } +} diff --git a/Particles/KingSlimeEmeraldShards.png b/Particles/KingSlimeEmeraldShards.png new file mode 100644 index 0000000000..f16784085c Binary files /dev/null and b/Particles/KingSlimeEmeraldShards.png differ diff --git a/Particles/KingSlimeRubyShards.png b/Particles/KingSlimeRubyShards.png new file mode 100644 index 0000000000..e25207c646 Binary files /dev/null and b/Particles/KingSlimeRubyShards.png differ diff --git a/Particles/KingSlimeSapphireShards.png b/Particles/KingSlimeSapphireShards.png new file mode 100644 index 0000000000..9145e3d5a8 Binary files /dev/null and b/Particles/KingSlimeSapphireShards.png differ diff --git a/Sounds/NPCKilled/CrownJewelShatter.ogg b/Sounds/NPCKilled/CrownJewelShatter.ogg new file mode 100644 index 0000000000..daf9d97177 Binary files /dev/null and b/Sounds/NPCKilled/CrownJewelShatter.ogg differ