diff --git a/Gores/HauntedChum/ChumBone1.png b/Gores/HauntedChum/ChumBone1.png new file mode 100644 index 0000000000..86bff0e329 Binary files /dev/null and b/Gores/HauntedChum/ChumBone1.png differ diff --git a/Gores/HauntedChum/ChumBone2.png b/Gores/HauntedChum/ChumBone2.png new file mode 100644 index 0000000000..58961d2094 Binary files /dev/null and b/Gores/HauntedChum/ChumBone2.png differ diff --git a/Gores/HauntedChum/HauntedChum.png b/Gores/HauntedChum/HauntedChum.png new file mode 100644 index 0000000000..11b9e1f220 Binary files /dev/null and b/Gores/HauntedChum/HauntedChum.png differ diff --git a/Gores/HauntedChum/HauntedChumMouth.png b/Gores/HauntedChum/HauntedChumMouth.png new file mode 100644 index 0000000000..6fa25c049e Binary files /dev/null and b/Gores/HauntedChum/HauntedChumMouth.png differ diff --git a/NPCs/SunkenSea/FesteringRemains.cs b/NPCs/SunkenSea/FesteringRemains.cs index 5548a484b0..01a01e7f70 100644 --- a/NPCs/SunkenSea/FesteringRemains.cs +++ b/NPCs/SunkenSea/FesteringRemains.cs @@ -141,6 +141,10 @@ namespace CalamityMod.NPCs.SunkenSea { Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, hit.HitDirection, -1f, 0, default, 1f); } + if (NPC.life <= 0) + { + SoundEngine.PlaySound(SoundID.DD2_SkeletonHurt with { Volume = 0.8f, Pitch = 1.2f }, NPC.position); + } } public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) diff --git a/NPCs/SunkenSea/HauntedChum.cs b/NPCs/SunkenSea/HauntedChum.cs index f16a3340f8..a05c2bc863 100644 --- a/NPCs/SunkenSea/HauntedChum.cs +++ b/NPCs/SunkenSea/HauntedChum.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using CalamityMod.BiomeManagers; using CalamityMod.DataStructures; using CalamityMod.Items.Placeables.Banners; @@ -9,6 +10,7 @@ using ReLogic.Content; using Terraria; using Terraria.Audio; using Terraria.GameContent; +using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; @@ -52,6 +54,7 @@ namespace CalamityMod.NPCs.SunkenSea } Player target = Main.player[NPC.target]; NPC body = Main.npc[(int)NPC.ai[3]]; + // Create a chain if (Segments == null || Segments.Count < 10) { Segments = new List(10); @@ -169,33 +172,75 @@ namespace CalamityMod.NPCs.SunkenSea } for (int i = 0; i < 2; i++) { - int dustPos = NPC.spriteDirection == 1 ? 0 : 10; + int dustPos = NPC.spriteDirection == 1 ? -10 : 0; Dust.NewDust(new Vector2(NPC.Center.X + dustPos, NPC.position.Y + NPC.height / 4), 0, NPC.height / 2, DustID.Blood, -NPC.spriteDirection * Main.rand.NextFloat(4f, 5f), Main.rand.NextFloat(-3, 3), Scale: Main.rand.NextFloat(0.6f, 1f)); } + // Update the chain Segments[0].oldPosition = Segments[0].position; - Segments[0].position = body.Center + new Vector2(body.direction * 10, 8); + Segments[0].position = body.Center + new Vector2(body.spriteDirection * 20, 8); Segments[Segments.Count - 1].oldPosition = Segments[Segments.Count - 1].position; Segments[Segments.Count - 1].position = body.active ? NPC.Center : body.Center; - Segments = VerletSimulatedSegment.SimpleSimulation(Segments, 10, loops: 100, gravity: 0.3f); + Segments = VerletSimulatedSegment.SimpleSimulation(Segments, 10, loops: 1, gravity: 0.3f); NPC.netUpdate = true; NPC.netSpam = 0; } + public PrimitiveTrail GutTrail; + + public PrimitiveTrail GutBGTrail; + internal float WidthFunction(float completionRatio) + { + return MathHelper.Clamp(((float)Math.Cos(completionRatio * 60)) + 2, 1, 2) / 2; + } + + internal Color ColorFunction(float completionRatio) + { + return (int)(completionRatio * 100) % 2 == 0 ? new Color(69, 52, 0) : new Color(); + } + + internal float BackgroundWidthFunction(float completionRatio) => WidthFunction(completionRatio) * 3f; + + internal Color BackgroundColorFunction(float completionRatio) + { + return Color.Black; + } + public override void HitEffect(NPC.HitInfo hit) { for (int k = 0; k < 5; k++) { Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Sandnado, hit.HitDirection, -1f, 0, default, 1f); } + if (NPC.life <= 0) + { + // Drop a bone gore for each bone + if (Segments != null && Segments.Count > 0) + { + for (int i = 0; i < Segments.Count; i++) + { + VerletSimulatedSegment v = Segments[i]; + int goreType = i < Segments.Count / 2 ? Mod.Find("ChumBone2").Type : Mod.Find("ChumBone1").Type; + if (Main.netMode != NetmodeID.Server) + { + Gore.NewGorePerfect(NPC.GetSource_Death(), v.position, new Vector2(Main.rand.NextFloat(-2, 2), -6), goreType); + } + } + } + if (Main.netMode != NetmodeID.Server) + { + Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("HauntedChum").Type, 1f); + Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("HauntedChumMouth").Type, 1f); + } + } } public override bool CheckActive() { - return !(Main.npc[(int)NPC.ai[3]].active && Main.npc[(int)NPC.ai[3]].type == ModContent.NPCType()); + return !(Main.npc[(int)NPC.ai[3]].active && Main.npc[(int)NPC.ai[3]].type == ModContent.NPCType()); } public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) @@ -204,8 +249,23 @@ namespace CalamityMod.NPCs.SunkenSea if (NPC.spriteDirection == 1) spriteEffects = SpriteEffects.FlipHorizontally; + // Draw the chain's flesh + if (GutTrail is null) + GutTrail = new PrimitiveTrail(WidthFunction, ColorFunction); + if (GutBGTrail is null) + GutBGTrail = new PrimitiveTrail(BackgroundWidthFunction, BackgroundColorFunction); + + List points = new List(); + for (int i = 0; i < Segments.Count; i++) + { + points.Add(Segments[i].position); + } + + GutBGTrail.Draw(points, -Main.screenPosition, 75); + GutTrail.Draw(points, -Main.screenPosition, 75); + NPC body = Main.npc[(int)NPC.ai[3]]; - // Draw a physiques chain + // Draw a chain of bones if (body != null && body.active && body.type == ModContent.NPCType()) { if (Segments == null || Segments.Count <= 0) @@ -245,6 +305,7 @@ namespace CalamityMod.NPCs.SunkenSea spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); } + // Draw the chum itself and its jaw, rotated by localai[0] Texture2D texture = TextureAssets.Npc[NPC.type].Value; Vector2 origin = new Vector2(texture.Width / 2, texture.Height / 2); Vector2 jawOrigin = new Vector2(NPC.spriteDirection == 1? jawTexture.Width - 22 : 22, 4); diff --git a/Particles/ChumBone.cs b/Particles/ChumBone.cs index eaca016a2a..88838070b4 100644 --- a/Particles/ChumBone.cs +++ b/Particles/ChumBone.cs @@ -1,6 +1,8 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.Audio; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Particles @@ -41,6 +43,13 @@ namespace CalamityMod.Particles { Velocity.Y = 0; } + if (Time == Lifetime) + { + for (int i = 0; i < 4; i++) + { + Dust.NewDust(Position, 10, 10, DustID.Bone, Main.rand.NextFloat(-4, 4), Main.rand.NextFloat(-4, 4)); + } + } } public override void CustomDraw(SpriteBatch spriteBatch)