diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index c384caf6f7..6844a21b77 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -52,6 +52,7 @@ using CalamityMod.Projectiles.Ranged; using CalamityMod.Projectiles.Rogue; using CalamityMod.Projectiles.Summon; using CalamityMod.Projectiles.Typeless; +using CalamityMod.Skies; using CalamityMod.Tiles; using CalamityMod.UI; using CalamityMod.World; diff --git a/CalamityLists.cs b/CalamityLists.cs index 889f28a527..4538123523 100644 --- a/CalamityLists.cs +++ b/CalamityLists.cs @@ -2546,7 +2546,7 @@ namespace CalamityMod NPCType(), NPCType(), NPCType(), - NPCType() + NPCType() }; bossMinionList = new List() diff --git a/ExtraTextures/CalamitasCinder.png b/ExtraTextures/CalamitasCinder.png new file mode 100644 index 0000000000..191dd23b73 Binary files /dev/null and b/ExtraTextures/CalamitasCinder.png differ diff --git a/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker.png b/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker.png deleted file mode 100644 index 2754ddfc96..0000000000 Binary files a/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker.png and /dev/null differ diff --git a/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker2.png b/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker2.png deleted file mode 100644 index 5c18ad17c9..0000000000 Binary files a/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker2.png and /dev/null differ diff --git a/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker3.png b/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker3.png deleted file mode 100644 index d6fbc15b0e..0000000000 Binary files a/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker3.png and /dev/null differ diff --git a/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker_Gore1.png b/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker_Gore1.png new file mode 100644 index 0000000000..4009972a78 Binary files /dev/null and b/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker_Gore1.png differ diff --git a/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker_Gore2.png b/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker_Gore2.png new file mode 100644 index 0000000000..52719a2fe3 Binary files /dev/null and b/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker_Gore2.png differ diff --git a/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker_Gore3.png b/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker_Gore3.png new file mode 100644 index 0000000000..60e920cd32 Binary files /dev/null and b/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker_Gore3.png differ diff --git a/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker_Gore4.png b/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker_Gore4.png new file mode 100644 index 0000000000..3e9bf7b6b2 Binary files /dev/null and b/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker_Gore4.png differ diff --git a/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker_Gore5.png b/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker_Gore5.png new file mode 100644 index 0000000000..e7d3579972 Binary files /dev/null and b/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker_Gore5.png differ diff --git a/Gores/SupremeCalamitas/BrimstoneHeart_Gore1.png b/Gores/SupremeCalamitas/BrimstoneHeart_Gore1.png new file mode 100644 index 0000000000..491063f204 Binary files /dev/null and b/Gores/SupremeCalamitas/BrimstoneHeart_Gore1.png differ diff --git a/Gores/SupremeCalamitas/BrimstoneHeart_Gore2.png b/Gores/SupremeCalamitas/BrimstoneHeart_Gore2.png new file mode 100644 index 0000000000..cb35235480 Binary files /dev/null and b/Gores/SupremeCalamitas/BrimstoneHeart_Gore2.png differ diff --git a/Gores/SupremeCalamitas/SepulcherArm_Gore.png b/Gores/SupremeCalamitas/SepulcherArm_Gore.png new file mode 100644 index 0000000000..fb7678cb5e Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherArm_Gore.png differ diff --git a/Gores/SupremeCalamitas/SepulcherBody1_Gore1.png b/Gores/SupremeCalamitas/SepulcherBody1_Gore1.png new file mode 100644 index 0000000000..cc91d0b99b Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherBody1_Gore1.png differ diff --git a/Gores/SupremeCalamitas/SepulcherBody1_Gore2.png b/Gores/SupremeCalamitas/SepulcherBody1_Gore2.png new file mode 100644 index 0000000000..8d735724fc Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherBody1_Gore2.png differ diff --git a/Gores/SupremeCalamitas/SepulcherBody1_Gore3.png b/Gores/SupremeCalamitas/SepulcherBody1_Gore3.png new file mode 100644 index 0000000000..3f01d98028 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherBody1_Gore3.png differ diff --git a/Gores/SupremeCalamitas/SepulcherBody1_Gore4.png b/Gores/SupremeCalamitas/SepulcherBody1_Gore4.png new file mode 100644 index 0000000000..75e2bb2043 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherBody1_Gore4.png differ diff --git a/Gores/SupremeCalamitas/SepulcherBody1_Gore5.png b/Gores/SupremeCalamitas/SepulcherBody1_Gore5.png new file mode 100644 index 0000000000..206ff5884f Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherBody1_Gore5.png differ diff --git a/Gores/SupremeCalamitas/SepulcherBody1_Gore6.png b/Gores/SupremeCalamitas/SepulcherBody1_Gore6.png new file mode 100644 index 0000000000..1503860b0e Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherBody1_Gore6.png differ diff --git a/Gores/SupremeCalamitas/SepulcherBody1_Gore7.png b/Gores/SupremeCalamitas/SepulcherBody1_Gore7.png new file mode 100644 index 0000000000..7f91f058e8 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherBody1_Gore7.png differ diff --git a/Gores/SupremeCalamitas/SepulcherBody1_Gore8.png b/Gores/SupremeCalamitas/SepulcherBody1_Gore8.png new file mode 100644 index 0000000000..08f213b100 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherBody1_Gore8.png differ diff --git a/Gores/SupremeCalamitas/SepulcherBody1_Gore9.png b/Gores/SupremeCalamitas/SepulcherBody1_Gore9.png new file mode 100644 index 0000000000..5909b57a8f Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherBody1_Gore9.png differ diff --git a/Gores/SupremeCalamitas/SepulcherBody2_Gore1.png b/Gores/SupremeCalamitas/SepulcherBody2_Gore1.png new file mode 100644 index 0000000000..66ad61c1c4 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherBody2_Gore1.png differ diff --git a/Gores/SupremeCalamitas/SepulcherBody2_Gore2.png b/Gores/SupremeCalamitas/SepulcherBody2_Gore2.png new file mode 100644 index 0000000000..a0afe9c2c6 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherBody2_Gore2.png differ diff --git a/Gores/SupremeCalamitas/SepulcherBody2_Gore3.png b/Gores/SupremeCalamitas/SepulcherBody2_Gore3.png new file mode 100644 index 0000000000..c51e0c6e39 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherBody2_Gore3.png differ diff --git a/Gores/SupremeCalamitas/SepulcherBody2_Gore4.png b/Gores/SupremeCalamitas/SepulcherBody2_Gore4.png new file mode 100644 index 0000000000..27c13b1f12 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherBody2_Gore4.png differ diff --git a/Gores/SupremeCalamitas/SepulcherBody2_Gore5.png b/Gores/SupremeCalamitas/SepulcherBody2_Gore5.png new file mode 100644 index 0000000000..56369887b4 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherBody2_Gore5.png differ diff --git a/Gores/SupremeCalamitas/SepulcherBody2_Gore6.png b/Gores/SupremeCalamitas/SepulcherBody2_Gore6.png new file mode 100644 index 0000000000..a558507804 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherBody2_Gore6.png differ diff --git a/Gores/SupremeCalamitas/SepulcherBody2_Gore7.png b/Gores/SupremeCalamitas/SepulcherBody2_Gore7.png new file mode 100644 index 0000000000..840e976c65 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherBody2_Gore7.png differ diff --git a/Gores/SupremeCalamitas/SepulcherForearm_Gore1.png b/Gores/SupremeCalamitas/SepulcherForearm_Gore1.png new file mode 100644 index 0000000000..8aebfc14ea Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherForearm_Gore1.png differ diff --git a/Gores/SupremeCalamitas/SepulcherForearm_Gore2.png b/Gores/SupremeCalamitas/SepulcherForearm_Gore2.png new file mode 100644 index 0000000000..6272a4257c Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherForearm_Gore2.png differ diff --git a/Gores/SupremeCalamitas/SepulcherHand_Gore1.png b/Gores/SupremeCalamitas/SepulcherHand_Gore1.png new file mode 100644 index 0000000000..1481801d09 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherHand_Gore1.png differ diff --git a/Gores/SupremeCalamitas/SepulcherHand_Gore2.png b/Gores/SupremeCalamitas/SepulcherHand_Gore2.png new file mode 100644 index 0000000000..e0534c6502 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherHand_Gore2.png differ diff --git a/Gores/SupremeCalamitas/SepulcherHead_Gore1.png b/Gores/SupremeCalamitas/SepulcherHead_Gore1.png new file mode 100644 index 0000000000..955bb07c3e Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherHead_Gore1.png differ diff --git a/Gores/SupremeCalamitas/SepulcherHead_Gore2.png b/Gores/SupremeCalamitas/SepulcherHead_Gore2.png new file mode 100644 index 0000000000..9615453c81 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherHead_Gore2.png differ diff --git a/Gores/SupremeCalamitas/SepulcherHead_Gore3.png b/Gores/SupremeCalamitas/SepulcherHead_Gore3.png new file mode 100644 index 0000000000..52ada3c123 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherHead_Gore3.png differ diff --git a/Gores/SupremeCalamitas/SepulcherHead_Gore4.png b/Gores/SupremeCalamitas/SepulcherHead_Gore4.png new file mode 100644 index 0000000000..7b37e0a607 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherHead_Gore4.png differ diff --git a/Gores/SupremeCalamitas/SepulcherHead_Gore5.png b/Gores/SupremeCalamitas/SepulcherHead_Gore5.png new file mode 100644 index 0000000000..d8f20446d2 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherHead_Gore5.png differ diff --git a/Gores/SupremeCalamitas/SepulcherTail_Gore1.png b/Gores/SupremeCalamitas/SepulcherTail_Gore1.png new file mode 100644 index 0000000000..40ca1472d8 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherTail_Gore1.png differ diff --git a/Gores/SupremeCalamitas/SepulcherTail_Gore2.png b/Gores/SupremeCalamitas/SepulcherTail_Gore2.png new file mode 100644 index 0000000000..81a900a180 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherTail_Gore2.png differ diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 9f841afa66..34d75aec1c 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -3204,7 +3204,7 @@ namespace CalamityMod.NPCs 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() && + npc.type != NPCType() && npc.type != NPCType() && npc.type != NPCType()) { npc.active = false; @@ -3789,7 +3789,7 @@ namespace CalamityMod.NPCs else if (projectile.type == ProjectileType() || projectile.type == ProjectileType()) damage = (int)(damage * 0.75); } - else if (npc.type == NPCType()) + else if (npc.type == NPCType()) { // 30% resist to Surge Driver's alt click comets. if (projectile.type == ProjectileType()) diff --git a/NPCs/SupremeCalamitas/SCalWormHeart.cs b/NPCs/SupremeCalamitas/BrimstoneHeart.cs similarity index 82% rename from NPCs/SupremeCalamitas/SCalWormHeart.cs rename to NPCs/SupremeCalamitas/BrimstoneHeart.cs index 43ea6157ca..ed6df8c4bc 100644 --- a/NPCs/SupremeCalamitas/SCalWormHeart.cs +++ b/NPCs/SupremeCalamitas/BrimstoneHeart.cs @@ -10,7 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.SupremeCalamitas { - public class SCalWormHeart : ModNPC + public class BrimstoneHeart : ModNPC { public PrimitiveTrail ChainDrawer = null; public int ChainHeartIndex => (int)npc.ai[0]; @@ -18,6 +18,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas public override void SetStaticDefaults() { DisplayName.SetDefault("Brimstone Heart"); + Main.npcFrameCount[npc.type] = 6; } public override void SetDefaults() @@ -49,7 +50,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas public override void ReceiveExtraAI(BinaryReader reader) { ChainEndpoints.Clear(); - for (int i = 0; i < reader.ReadInt32(); i++) + int endpointCount = reader.ReadInt32(); + for (int i = 0; i < endpointCount; i++) ChainEndpoints.Add(reader.ReadVector2()); } @@ -72,7 +74,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas float widthInterpolant = Utils.InverseLerp(0f, 0.16f, completionRatio, true) * Utils.InverseLerp(1f, 0.84f, completionRatio, true); widthInterpolant = (float)Math.Pow(widthInterpolant, 8D); float baseWidth = MathHelper.Lerp(4f, 1f, widthInterpolant); - float pulseWidth = MathHelper.Lerp(0f, 3.2f, (float)Math.Pow(Math.Sin(Main.GlobalTime * 4.4f + npc.whoAmI * 1.3f + completionRatio), 16D)); + float pulseWidth = MathHelper.Lerp(0f, 3.2f, (float)Math.Pow(Math.Sin(Main.GlobalTime * 2.6f + npc.whoAmI * 1.3f + completionRatio), 16D)); return baseWidth + pulseWidth; } @@ -82,6 +84,14 @@ namespace CalamityMod.NPCs.SupremeCalamitas return Color.Lerp(Color.DarkRed * 0.7f, Color.Red, colorInterpolant) * 0.425f; } + public override void FindFrame(int frameHeight) + { + int frame = (int)Math.Round((float)Math.Pow(Math.Sin(Main.GlobalTime * 2.6f + npc.whoAmI * 1.3f), 6D) * Main.npcFrameCount[npc.type]); + if (frame >= Main.npcFrameCount[npc.type]) + frame = Main.npcFrameCount[npc.type] - 1; + npc.frame.Y = frame * frameHeight; + } + public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) { if (ChainDrawer is null) @@ -114,6 +124,11 @@ namespace CalamityMod.NPCs.SupremeCalamitas { if (npc.life <= 0) { + for (int i = 1; i <= 2; i++) + { + Vector2 heartGoreVelocity = new Vector2((i == 1).ToDirectionInt() * 3f, Main.rand.NextFloat(-2f, 0f)); + Gore.NewGorePerfect(npc.Center, heartGoreVelocity, mod.GetGoreSlot($"Gores/SupremeCalamitas/BrimstoneHeart_Gore{i}"), npc.scale); + } for (int i = 0; i < ChainEndpoints.Count; i++) TendrilDestructionEffects(i); } diff --git a/NPCs/SupremeCalamitas/BrimstoneHeart.png b/NPCs/SupremeCalamitas/BrimstoneHeart.png new file mode 100644 index 0000000000..c597cfe505 Binary files /dev/null and b/NPCs/SupremeCalamitas/BrimstoneHeart.png differ diff --git a/NPCs/SupremeCalamitas/SCalSky.cs b/NPCs/SupremeCalamitas/SCalSky.cs deleted file mode 100644 index bf4233d713..0000000000 --- a/NPCs/SupremeCalamitas/SCalSky.cs +++ /dev/null @@ -1,107 +0,0 @@ -using CalamityMod.Projectiles.Boss; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Graphics.Effects; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.SupremeCalamitas -{ - public class SCalSky : CustomSky - { - private bool isActive = false; - private float intensity = 0f; - private int SCalIndex = -1; - public static float OverridingIntensity = 0f; - - public override void Update(GameTime gameTime) - { - if (isActive && intensity < 1f) - { - intensity += 0.01f; - } - else if (!isActive && intensity > 0f) - { - intensity -= 0.01f; - } - } - - private float GetIntensity() - { - if (CalamityUtils.CountProjectiles(ModContent.ProjectileType()) > 0) - return OverridingIntensity; - - OverridingIntensity = 0f; - if (this.UpdateSCalIndex()) - { - float x = 0f; - if (this.SCalIndex != -1) - { - x = Vector2.Distance(Main.player[Main.myPlayer].Center, Main.npc[this.SCalIndex].Center); - } - return 1f - Utils.SmoothStep(3000f, 6000f, x); - } - return 0f; - } - - public override Color OnTileColor(Color inColor) - { - float intensity = this.GetIntensity(); - return new Color(Vector4.Lerp(new Vector4(0.5f, 0.8f, 1f, 1f), inColor.ToVector4(), 1f - intensity)); - } - - private bool UpdateSCalIndex() - { - int SCalType = ModContent.NPCType(); - if (SCalIndex >= 0 && Main.npc[SCalIndex].active && Main.npc[SCalIndex].type == SCalType) - { - return true; - } - SCalIndex = -1; - for (int i = 0; i < Main.npc.Length; i++) - { - if (Main.npc[i].active && Main.npc[i].type == SCalType) - { - SCalIndex = i; - break; - } - } - //this.DoGIndex = DoGIndex; - return SCalIndex != -1; - } - - public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth) - { - if (maxDepth >= 0 && minDepth < 0) - { - float intensity = this.GetIntensity(); - spriteBatch.Draw(Main.blackTileTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.Black * intensity); - } - } - - public override float GetCloudAlpha() - { - return 0f; - } - - public override void Activate(Vector2 position, params object[] args) - { - isActive = true; - } - - public override void Deactivate(params object[] args) - { - isActive = false; - } - - public override void Reset() - { - isActive = false; - } - - public override bool IsActive() - { - return isActive || intensity > 0f; - } - } -} diff --git a/NPCs/SupremeCalamitas/SCalWormArm.cs b/NPCs/SupremeCalamitas/SCalWormArm.cs new file mode 100644 index 0000000000..126860646d --- /dev/null +++ b/NPCs/SupremeCalamitas/SCalWormArm.cs @@ -0,0 +1,217 @@ +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.SupremeCalamitas +{ + public class SCalWormArm : ModNPC + { + public class SepulcherArmLimb + { + public Vector2 Center; + public float Rotation; + + public SepulcherArmLimb(Vector2 center, float rotation) + { + Center = center; + Rotation = rotation; + } + + public void SendData(BinaryWriter writer) + { + writer.WritePackedVector2(Center); + writer.Write(Rotation); + } + + public void ReceiveData(BinaryReader reader) + { + Center = reader.ReadPackedVector2(); + Rotation = reader.ReadSingle(); + } + } + + public NPC SegmentToAttachTo => Main.npc[(int)npc.ai[0]]; + public bool CurrentlyMoving + { + get => npc.ai[1] == 1f; + set => npc.ai[1] = value.ToInt(); + } + public Vector2 MoveDestination + { + get => new Vector2(npc.ai[2], npc.ai[3]); + set + { + npc.ai[2] = value.X; + npc.ai[3] = value.Y; + } + } + public ref float Time => ref npc.localAI[0]; + public bool ReelingBack + { + get => npc.localAI[1] == 0f; + set => npc.localAI[1] = 1f - value.ToInt(); + } + public Player Target => Main.player[npc.target]; + public SepulcherArmLimb[] Limbs = new SepulcherArmLimb[4]; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Sepulcher"); + } + + public override void SetDefaults() + { + npc.damage = 0; + npc.npcSlots = 5f; + npc.width = 34; + npc.height = 48; + npc.defense = 0; + CalamityGlobalNPC global = npc.Calamity(); + global.DR = 0.999999f; + global.unbreakableDR = true; + npc.lifeMax = CalamityWorld.revenge ? 345000 : 300000; + npc.aiStyle = aiType = -1; + npc.knockBackResist = 0f; + npc.scale = Main.expertMode ? 1.35f : 1.2f; + npc.dontTakeDamage = true; + npc.alpha = 255; + npc.chaseable = false; + npc.behindTiles = true; + npc.noGravity = true; + npc.noTileCollide = true; + npc.canGhostHeal = false; + npc.netAlways = true; + npc.dontCountMe = true; + + for (int i = 0; i < Limbs.Length; i++) + Limbs[i] = new SepulcherArmLimb(npc.Center, 0f); + } + + public override void SendExtraAI(BinaryWriter writer) + { + for (int i = 0; i < Limbs.Length; i++) + Limbs[i].SendData(writer); + writer.Write(npc.rotation); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + for (int i = 0; i < Limbs.Length; i++) + Limbs[i].ReceiveData(reader); + npc.rotation = reader.ReadSingle(); + } + + public override void AI() + { + // Die if the segment is not present. + if (!Main.npc.IndexInRange((int)npc.ai[0]) || !Main.npc[(int)npc.ai[0]].active) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + return; + } + + npc.Opacity = SegmentToAttachTo.Opacity; + npc.TargetClosest(false); + + Vector2 idealMovePosition = SegmentToAttachTo.Center; + float sideFactor = MathHelper.Lerp(200f, 18f, Utils.InverseLerp(-0.51f, -0.06f, npc.rotation, true)); + float aheadFactor = MathHelper.Lerp(284f, 680f, Utils.InverseLerp(-0.51f, -0.06f, npc.rotation, true)); + idealMovePosition += (SegmentToAttachTo.rotation + npc.rotation * npc.direction - MathHelper.PiOver2).ToRotationVector2() * npc.scale * aheadFactor; + idealMovePosition += (SegmentToAttachTo.rotation + npc.rotation * npc.direction - MathHelper.PiOver2 + MathHelper.PiOver2 * npc.direction).ToRotationVector2() * npc.scale * sideFactor; + npc.Center = idealMovePosition; + UpdateLimbs(); + + if (ReelingBack) + { + npc.rotation -= 0.066f; + if (npc.rotation < -0.55f) + ReelingBack = false; + } + else + { + npc.rotation += 0.029f; + if (npc.rotation > 0.77f) + ReelingBack = true; + } + + Time++; + } + + public void MoveToDestination() + { + npc.Center = Vector2.Lerp(npc.Center, MoveDestination, 0.05f); + npc.Center = npc.Center.MoveTowards(MoveDestination, 10f); + + // Stop moving if sufficiently close to the desired destination. + if (npc.WithinRange(MoveDestination, 15f)) + { + npc.Center = MoveDestination; + MoveDestination = Vector2.Zero; + CurrentlyMoving = false; + npc.netUpdate = true; + } + } + + public void UpdateLimbs() + { + Vector2 offsetFromSegment = Vector2.Zero; + + offsetFromSegment += new Vector2(npc.direction * 60f, 55f).RotatedBy(SegmentToAttachTo.rotation - (MathHelper.PiOver2 - npc.rotation * 1.7f - 0.77f) * npc.direction).SafeNormalize(Vector2.UnitY) * 92f; + Limbs[0].Center = SegmentToAttachTo.Center + offsetFromSegment; + Limbs[0].Rotation = offsetFromSegment.ToRotation(); + + Limbs[1].Rotation = npc.AngleFrom(Limbs[0].Center); + Limbs[1].Center = Limbs[0].Center + offsetFromSegment * 0.5f + (npc.Center - Limbs[0].Center).SafeNormalize(Vector2.UnitY) * 84f; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D armTexture = Main.npcTexture[npc.type]; + Texture2D foreArmTexture = ModContent.GetTexture("CalamityMod/NPCs/SupremeCalamitas/SCalWormForeArm"); + Texture2D handTexture = ModContent.GetTexture("CalamityMod/NPCs/SupremeCalamitas/SCalWormHand"); + + Vector2 forearmDrawPosition = Limbs[0].Center - Main.screenPosition; + Color drawColor = Lighting.GetColor((int)(Limbs[0].Center.X / 16), (int)(Limbs[0].Center.Y / 16)); + spriteBatch.Draw(foreArmTexture, forearmDrawPosition, null, drawColor, Limbs[0].Rotation + MathHelper.PiOver2, foreArmTexture.Size() * 0.5f, npc.scale, SpriteEffects.None, 0f); + + Vector2 armDrawPosition = Limbs[1].Center - Main.screenPosition; + drawColor = Lighting.GetColor((int)(Limbs[1].Center.X / 16), (int)(Limbs[1].Center.Y / 16)); + spriteBatch.Draw(armTexture, armDrawPosition, null, drawColor, Limbs[1].Rotation + MathHelper.PiOver2, armTexture.Size() * new Vector2(0.5f, 0f), npc.scale, SpriteEffects.FlipVertically, 0f); + + Vector2 handDrawPosition = armDrawPosition; + SpriteEffects handDirection = npc.direction == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + spriteBatch.Draw(handTexture, handDrawPosition, null, drawColor, Limbs[1].Rotation - MathHelper.PiOver2, handTexture.Size() * new Vector2(0.5f, 0f), npc.scale, handDirection, 0f); + + return false; + } + + public override void HitEffect(int hitDirection, double damage) + { + if (npc.life <= 0) + { + Vector2 forearmGoreSpawnPosition = Limbs[0].Center + Main.rand.NextVector2Circular(6f, 6f); + Vector2 armGoreSpawnPosition = Limbs[1].Center + Main.rand.NextVector2Circular(6f, 6f); + Vector2 handGoreSpawnPosition = armGoreSpawnPosition + Main.rand.NextVector2Circular(6f, 6f); + + Gore.NewGorePerfect(armGoreSpawnPosition, Main.rand.NextVector2Circular(3f, 3f), mod.GetGoreSlot($"Gores/SupremeCalamitas/SepulcherArm_Gore"), npc.scale); + for (int i = 1; i <= 2; i++) + Gore.NewGorePerfect(forearmGoreSpawnPosition, Main.rand.NextVector2Circular(3f, 3f), mod.GetGoreSlot($"Gores/SupremeCalamitas/SepulcherForearm_Gore{i}"), npc.scale); + for (int i = 1; i <= 2; i++) + Gore.NewGorePerfect(handGoreSpawnPosition, Main.rand.NextVector2Circular(3f, 3f), mod.GetGoreSlot($"Gores/SupremeCalamitas/SepulcherHand_Gore{i}"), npc.scale); + } + } + + public override bool CheckActive() => false; + + public override bool PreNPCLoot() => false; + + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => false; + } +} diff --git a/NPCs/SupremeCalamitas/SCalWormArm.png b/NPCs/SupremeCalamitas/SCalWormArm.png new file mode 100644 index 0000000000..b45111f206 Binary files /dev/null and b/NPCs/SupremeCalamitas/SCalWormArm.png differ diff --git a/NPCs/SupremeCalamitas/SCalWormBody.cs b/NPCs/SupremeCalamitas/SCalWormBody.cs index a6265bf8d7..59835db0ec 100644 --- a/NPCs/SupremeCalamitas/SCalWormBody.cs +++ b/NPCs/SupremeCalamitas/SCalWormBody.cs @@ -12,8 +12,10 @@ namespace CalamityMod.NPCs.SupremeCalamitas public class SCalWormBody : ModNPC { private bool setAlpha = false; + public NPC AheadSegment => Main.npc[(int)npc.ai[1]]; + public NPC HeadSegment => Main.npc[(int)npc.ai[2]]; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("Sepulcher"); } @@ -22,8 +24,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas { npc.damage = 0; //70 npc.npcSlots = 5f; - npc.width = 20; //28 - npc.height = 20; //28 + npc.width = npc.height = 48; npc.defense = 0; CalamityGlobalNPC global = npc.Calamity(); global.DR = 0.999999f; @@ -43,8 +44,6 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.noGravity = true; npc.noTileCollide = true; npc.canGhostHeal = false; - npc.HitSound = SoundID.NPCHit4; - npc.DeathSound = SoundID.NPCDeath14; npc.netAlways = true; npc.dontCountMe = true; } @@ -73,85 +72,49 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.realLife = (int)npc.ai[2]; } - bool flag = false; - if (npc.ai[1] <= 0f) - { - flag = true; - } - else if (Main.npc[(int)npc.ai[1]].life <= 0 || npc.life <= 0) - { - flag = true; - } - if (flag) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - } + bool shouldDie = false; + if (npc.ai[1] <= 0f) + shouldDie = true; + else if (AheadSegment.life <= 0 || !AheadSegment.active || npc.life <= 0) + shouldDie = true; - if (Main.npc[(int)npc.ai[1]].alpha < 128 && !setAlpha) - { - if (npc.alpha != 0) - { - for (int num934 = 0; num934 < 2; num934++) - { - int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 182, 0f, 0f, 100, default, 2f); - Main.dust[num935].noGravity = true; - Main.dust[num935].noLight = true; - } - } - npc.alpha -= 42; - if (npc.alpha <= 0) - { - setAlpha = true; - npc.alpha = 0; - } - } - else - { - npc.alpha = Main.npc[(int)npc.ai[2]].alpha; - } + if (shouldDie) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + } - Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); - float num192 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2); - num191 = (int)(num191 / 16f) * 16; - num192 = (int)(num192 / 16f) * 16; - vector18.X = (int)(vector18.X / 16f) * 16; - vector18.Y = (int)(vector18.Y / 16f) * 16; - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); - if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) - { - try - { - vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - num191 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; - } - catch - { - } - npc.rotation = (float)System.Math.Atan2(num192, num191) + 1.57f; - num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); - int num194 = npc.width; - num193 = (num193 - num194) / num193; - num191 *= num193; - num192 *= num193; - npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + num191; - npc.position.Y = npc.position.Y + num192; - if (num191 < 0f) - { - npc.spriteDirection = -1; - } - else if (num191 > 0f) - { - npc.spriteDirection = 1; - } - } - } + if (AheadSegment.alpha < 128 && !setAlpha) + { + if (npc.alpha != 0) + { + for (int i = 0; i < 2; i++) + { + Dust fire = Dust.NewDustDirect(npc.position, npc.width, npc.height, 182, 0f, 0f, 100, default, 2f); + fire.noGravity = true; + fire.noLight = true; + } + } + npc.alpha -= 42; + if (npc.alpha <= 0) + { + setAlpha = true; + npc.alpha = 0; + } + } + else + npc.alpha = HeadSegment.alpha; + + if (Main.npc.IndexInRange((int)npc.ai[1])) + { + Vector2 offsetToAheadSegment = AheadSegment.Center - npc.Center; + npc.rotation = offsetToAheadSegment.ToRotation() + MathHelper.PiOver2; + npc.velocity = Vector2.Zero; + npc.Center = AheadSegment.Center - offsetToAheadSegment.SafeNormalize(Vector2.UnitY) * 52f; + npc.spriteDirection = (offsetToAheadSegment.X > 0f).ToDirectionInt(); + } + } public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) { @@ -174,7 +137,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (npc.spriteDirection == 1) spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = npc.localAI[3] == 1f ? ModContent.GetTexture("CalamityMod/NPCs/SupremeCalamitas/SCalWormBodyAlt") : Main.npcTexture[npc.type]; + Texture2D texture2D15 = npc.localAI[3] / 2f % 2f == 0f ? ModContent.GetTexture("CalamityMod/NPCs/SupremeCalamitas/SCalWormBodyAlt") : Main.npcTexture[npc.type]; Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / 2)); Vector2 vector43 = npc.Center - Main.screenPosition; @@ -182,14 +145,6 @@ namespace CalamityMod.NPCs.SupremeCalamitas vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - if (npc.localAI[3] == 1f) - { - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/SupremeCalamitas/SCalWormBodyAltGlow"); - Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); - - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - return false; } @@ -207,29 +162,28 @@ namespace CalamityMod.NPCs.SupremeCalamitas { if (npc.life <= 0) { - npc.position.X = npc.position.X + (float)(npc.width / 2); - npc.position.Y = npc.position.Y + (float)(npc.height / 2); - npc.width = 50; - npc.height = 50; - npc.position.X = npc.position.X - (float)(npc.width / 2); - npc.position.Y = npc.position.Y - (float)(npc.height / 2); - for (int num621 = 0; num621 < 5; num621++) + int variant = (int)(npc.localAI[3] / 2f % 2f); + if (variant == 0) { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) + for (int i = 1; i <= 9; i++) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + if (!Main.rand.NextBool(3)) + continue; + + Vector2 goreSpawnPosition = npc.Center; + Gore.NewGorePerfect(goreSpawnPosition, Main.rand.NextVector2Circular(2f, 2f), mod.GetGoreSlot($"Gores/SupremeCalamitas/SepulcherBody1_Gore{i}"), npc.scale); } } - for (int num623 = 0; num623 < 10; num623++) + else { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + for (int i = 1; i <= 7; i++) + { + if (!Main.rand.NextBool(3)) + continue; + + Vector2 goreSpawnPosition = npc.Center; + Gore.NewGorePerfect(goreSpawnPosition, Main.rand.NextVector2Circular(2f, 2f), mod.GetGoreSlot($"Gores/SupremeCalamitas/SepulcherBody2_Gore{i}"), npc.scale); + } } } } diff --git a/NPCs/SupremeCalamitas/SCalWormBody.png b/NPCs/SupremeCalamitas/SCalWormBody.png index 5a37855ad8..5e8b75333e 100644 Binary files a/NPCs/SupremeCalamitas/SCalWormBody.png and b/NPCs/SupremeCalamitas/SCalWormBody.png differ diff --git a/NPCs/SupremeCalamitas/SCalWormBodyAlt.png b/NPCs/SupremeCalamitas/SCalWormBodyAlt.png index 35971e8491..7bddb6f35e 100644 Binary files a/NPCs/SupremeCalamitas/SCalWormBodyAlt.png and b/NPCs/SupremeCalamitas/SCalWormBodyAlt.png differ diff --git a/NPCs/SupremeCalamitas/SCalWormBodyAltGlow.png b/NPCs/SupremeCalamitas/SCalWormBodyAltGlow.png deleted file mode 100644 index 5e4e89bd98..0000000000 Binary files a/NPCs/SupremeCalamitas/SCalWormBodyAltGlow.png and /dev/null differ diff --git a/NPCs/SupremeCalamitas/SCalWormBodyWeak.cs b/NPCs/SupremeCalamitas/SCalWormBodyWeak.cs index 33fa11dda4..913ddad300 100644 --- a/NPCs/SupremeCalamitas/SCalWormBodyWeak.cs +++ b/NPCs/SupremeCalamitas/SCalWormBodyWeak.cs @@ -1,4 +1,5 @@ using CalamityMod.Projectiles.Boss; +using CalamityMod.Projectiles.Typeless; using CalamityMod.World; using Microsoft.Xna.Framework; using System.IO; @@ -11,10 +12,14 @@ namespace CalamityMod.NPCs.SupremeCalamitas public class SCalWormBodyWeak : ModNPC { private bool setAlpha = false; + public NPC AheadSegment => Main.npc[(int)npc.ai[1]]; + public NPC HeadSegment => Main.npc[(int)npc.ai[2]]; + public ref float AttackTimer => ref npc.localAI[0]; public override void SetStaticDefaults() { DisplayName.SetDefault("Brimstone Heart"); + Main.npcFrameCount[npc.type] = 5; } public override void SetDefaults() @@ -27,70 +32,60 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.aiStyle = -1; aiType = -1; npc.knockBackResist = 0f; - CalamityGlobalNPC global = npc.Calamity(); - global.DR = 0.999999f; - global.unbreakableDR = true; - npc.scale = 1.2f; - if (Main.expertMode) - { - npc.scale = 1.35f; - } + npc.scale = Main.expertMode ? 1.35f : 1.2f; npc.alpha = 255; npc.chaseable = false; npc.behindTiles = true; npc.noGravity = true; npc.noTileCollide = true; npc.canGhostHeal = false; - npc.HitSound = SoundID.NPCHit13; - npc.DeathSound = SoundID.NPCDeath13; npc.netAlways = true; npc.dontCountMe = true; - } + + CalamityGlobalNPC global = npc.Calamity(); + global.DR = 0.999999f; + global.unbreakableDR = true; + } public override void SendExtraAI(BinaryWriter writer) { - writer.Write(npc.localAI[0]); + writer.Write(AttackTimer); writer.Write(setAlpha); } public override void ReceiveExtraAI(BinaryReader reader) { - npc.localAI[0] = reader.ReadSingle(); + AttackTimer = reader.ReadSingle(); setAlpha = reader.ReadBoolean(); } public override void AI() { if (npc.ai[2] > 0f) - { npc.realLife = (int)npc.ai[2]; - } - bool flag = false; + bool shouldDie = false; if (npc.ai[1] <= 0f) - { - flag = true; - } - else if (Main.npc[(int)npc.ai[1]].life <= 0 || npc.life <= 0) - { - flag = true; - } - if (flag) + shouldDie = true; + else if (AheadSegment.life <= 0 || !AheadSegment.active || npc.life <= 0) + shouldDie = true; + + if (shouldDie) { npc.life = 0; npc.HitEffect(0, 10.0); npc.checkDead(); } - if (Main.npc[(int)npc.ai[1]].alpha < 128 && !setAlpha) + if (AheadSegment.alpha < 128 && !setAlpha) { if (npc.alpha != 0) { - for (int num934 = 0; num934 < 2; num934++) + for (int i = 0; i < 2; i++) { - int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 182, 0f, 0f, 100, default, 2f); - Main.dust[num935].noGravity = true; - Main.dust[num935].noLight = true; + Dust fire = Dust.NewDustDirect(npc.position, npc.width, npc.height, 182, 0f, 0f, 100, default, 2f); + fire.noGravity = true; + fire.noLight = true; } } npc.alpha -= 42; @@ -101,16 +96,14 @@ namespace CalamityMod.NPCs.SupremeCalamitas } } else - { - npc.alpha = Main.npc[(int)npc.ai[2]].alpha; - } + npc.alpha = HeadSegment.alpha; - if (Main.netMode != NetmodeID.MultiplayerClient) + AttackTimer += CalamityWorld.malice ? 1.5f : 1f; + if (AttackTimer >= 900f) { - npc.localAI[0] += CalamityWorld.malice ? 1.5f : 1f; - if (npc.localAI[0] >= 900f) + AttackTimer = 0f; + if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.localAI[0] = 0f; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); int totalProjectiles = 4; @@ -121,48 +114,18 @@ namespace CalamityMod.NPCs.SupremeCalamitas Vector2 velocity = spinningPoint.RotatedBy(radians * k); Projectile.NewProjectile(npc.Center, velocity, type, damage, 0f, Main.myPlayer); } - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneShoot"), npc.Center); + npc.netUpdate = true; } + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneShoot"), npc.Center); } - Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); - float num192 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2); - num191 = (int)(num191 / 16f) * 16; - num192 = (int)(num192 / 16f) * 16; - vector18.X = (int)(vector18.X / 16f) * 16; - vector18.Y = (int)(vector18.Y / 16f) * 16; - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); - if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) + if (Main.npc.IndexInRange((int)npc.ai[1])) { - try - { - vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - num191 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; - } - catch - { - } - npc.rotation = (float)System.Math.Atan2(num192, num191) + 1.57f; - num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); - int num194 = npc.width; - num193 = (num193 - num194) / num193; - num191 *= num193; - num192 *= num193; + Vector2 offsetToAheadSegment = AheadSegment.Center - npc.Center; + npc.rotation = offsetToAheadSegment.ToRotation() + MathHelper.PiOver2; npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + num191; - npc.position.Y = npc.position.Y + num192; - if (num191 < 0f) - { - npc.spriteDirection = -1; - } - else if (num191 > 0f) - { - npc.spriteDirection = 1; - } + npc.Center = AheadSegment.Center - offsetToAheadSegment.SafeNormalize(Vector2.UnitY) * 34f; + npc.spriteDirection = (offsetToAheadSegment.X > 0f).ToDirectionInt(); } } @@ -181,6 +144,27 @@ namespace CalamityMod.NPCs.SupremeCalamitas } } + public override void FindFrame(int frameHeight) + { + npc.frameCounter++; + npc.frame.Y = ((int)(npc.frameCounter / 5) + npc.whoAmI) % Main.npcFrameCount[npc.type] * frameHeight; + } + + public override void HitEffect(int hitDirection, double damage) + { + if (Main.netMode != NetmodeID.MultiplayerClient && npc.life <= 0) + { + for (int i = 0; i < Main.rand.Next(1, 3 + 1); i++) + { + if (!Main.rand.NextBool(3)) + continue; + + Vector2 soulVelocity = -Vector2.UnitY.RotatedByRandom(0.53f) * Main.rand.NextFloat(2.5f, 4f); + Projectile.NewProjectile(npc.Center, soulVelocity, ModContent.ProjectileType(), 0, 0f); + } + } + } + public override bool CheckActive() { return false; diff --git a/NPCs/SupremeCalamitas/SCalWormBodyWeak.png b/NPCs/SupremeCalamitas/SCalWormBodyWeak.png index 8bc8635d1b..3ab290bdf1 100644 Binary files a/NPCs/SupremeCalamitas/SCalWormBodyWeak.png and b/NPCs/SupremeCalamitas/SCalWormBodyWeak.png differ diff --git a/NPCs/SupremeCalamitas/SCalWormForeArm.png b/NPCs/SupremeCalamitas/SCalWormForeArm.png new file mode 100644 index 0000000000..da24ee8a4f Binary files /dev/null and b/NPCs/SupremeCalamitas/SCalWormForeArm.png differ diff --git a/NPCs/SupremeCalamitas/SCalWormHand.png b/NPCs/SupremeCalamitas/SCalWormHand.png new file mode 100644 index 0000000000..c28935e9f2 Binary files /dev/null and b/NPCs/SupremeCalamitas/SCalWormHand.png differ diff --git a/NPCs/SupremeCalamitas/SCalWormHead.cs b/NPCs/SupremeCalamitas/SCalWormHead.cs index bf98c7ff11..97fa659099 100644 --- a/NPCs/SupremeCalamitas/SCalWormHead.cs +++ b/NPCs/SupremeCalamitas/SCalWormHead.cs @@ -27,7 +27,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.damage = 0; //150 npc.npcSlots = 5f; npc.width = 62; //324 - npc.height = 78; //216 + npc.height = 64; //216 npc.defense = 0; CalamityGlobalNPC global = npc.Calamity(); global.DR = 0.999999f; @@ -36,20 +36,16 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.aiStyle = -1; //new aiType = -1; //new npc.knockBackResist = 0f; - npc.scale = 1.2f; - if (Main.expertMode) - { - npc.scale = 1.35f; - } - npc.alpha = 255; + npc.scale = Main.expertMode ? 1.35f : 1.2f; + npc.scale *= 1.25f; + + npc.alpha = 255; npc.chaseable = false; npc.behindTiles = true; npc.noGravity = true; npc.noTileCollide = true; npc.canGhostHeal = false; - npc.HitSound = SoundID.NPCHit4; - npc.DeathSound = SoundID.NPCDeath14; - npc.netAlways = true; + npc.netAlways = true; } public override void SendExtraAI(BinaryWriter writer) @@ -81,44 +77,58 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) npc.TargetClosest(); - Player player = Main.player[npc.target]; - if (npc.ai[2] > 0f) - { npc.realLife = (int)npc.ai[2]; - } if (Main.netMode != NetmodeID.MultiplayerClient) { if (!TailSpawned && npc.ai[0] == 0f) { + float rotationalOffset = 0f; int Previous = npc.whoAmI; - for (int num36 = 0; num36 < maxLength; num36++) + for (int i = 0; i < maxLength; i++) { int lol; - if (num36 >= 0 && num36 < minLength && num36 % 2 == 0) + if (i >= 0 && i < minLength && i % 2 == 1) { lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); Main.npc[lol].localAI[0] += passedVar; passedVar += 36f; } - else if (num36 >= 0 && num36 < minLength) + else if (i >= 0 && i < minLength) { lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - if (npc.localAI[0] % 2 == 0) - { - Main.npc[lol].localAI[3] = 1f; - npc.localAI[0] = 1f; - } - else - { - npc.localAI[0] = 2f; - } - } + Main.npc[lol].localAI[3] = i; + } else - { lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - } + + // Create arms. + if (i >= 3 && i % 4 == 0) + { + NPC segment = Main.npc[lol]; + int arm = NPC.NewNPC((int)segment.Center.X, (int)segment.Center.Y, ModContent.NPCType(), lol); + if (Main.npc.IndexInRange(arm)) + { + Main.npc[arm].ai[0] = lol; + Main.npc[arm].direction = 1; + Main.npc[arm].rotation = rotationalOffset; + } + + rotationalOffset += MathHelper.Pi / 6f; + + arm = NPC.NewNPC((int)segment.Center.X, (int)segment.Center.Y, ModContent.NPCType(), lol); + if (Main.npc.IndexInRange(arm)) + { + Main.npc[arm].ai[0] = lol; + Main.npc[arm].direction = -1; + Main.npc[arm].rotation = rotationalOffset + MathHelper.Pi; + } + + rotationalOffset += MathHelper.Pi / 6f; + rotationalOffset = MathHelper.WrapAngle(rotationalOffset); + } + Main.npc[lol].realLife = npc.whoAmI; Main.npc[lol].ai[2] = npc.whoAmI; Main.npc[lol].ai[1] = Previous; @@ -133,30 +143,17 @@ namespace CalamityMod.NPCs.SupremeCalamitas } } - if (Main.player[npc.target].dead || !NPC.AnyNPCs(ModContent.NPCType()) || CalamityGlobalNPC.SCal < 0 || !Main.npc[CalamityGlobalNPC.SCal].active) - { - npc.TargetClosest(false); - npc.alpha += 5; - if (npc.alpha >= 255) - { - npc.alpha = 255; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].type == npc.type || Main.npc[i].type == ModContent.NPCType() || Main.npc[i].type == ModContent.NPCType() || Main.npc[i].type == ModContent.NPCType()) - { - Main.npc[i].active = false; - } - } - } - } - else - { - npc.alpha -= 42; - if (npc.alpha < 0) - { - npc.alpha = 0; - } - } + if (Main.player[npc.target].dead || !NPC.AnyNPCs(ModContent.NPCType()) || CalamityGlobalNPC.SCal < 0 || !Main.npc[CalamityGlobalNPC.SCal].active) + { + npc.TargetClosest(false); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/SepulcherDeath"), Main.player[npc.target].Center); + npc.life = 0; + npc.HitEffect(); + npc.active = false; + npc.netUpdate = true; + } + else + npc.Opacity = MathHelper.Clamp(npc.Opacity + 0.165f, 0f, 1f); Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); @@ -304,11 +301,6 @@ namespace CalamityMod.NPCs.SupremeCalamitas vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/SupremeCalamitas/SCalWormHeadGlow"); - Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); - - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; } @@ -334,33 +326,20 @@ namespace CalamityMod.NPCs.SupremeCalamitas public override void HitEffect(int hitDirection, double damage) { - if (npc.life <= 0) - { - npc.position.X = npc.position.X + (float)(npc.width / 2); - npc.position.Y = npc.position.Y + (float)(npc.height / 2); - npc.width = 50; - npc.height = 50; - npc.position.X = npc.position.X - (float)(npc.width / 2); - npc.position.Y = npc.position.Y - (float)(npc.height / 2); - for (int num621 = 0; num621 < 5; num621++) + if (npc.life <= 0) + { + for (int i = 1; i <= 3; i++) { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } + Vector2 goreSpawnPosition = npc.Center; + + // Spawn at a slight offset when spawning mandibles. + if (i == 2) + goreSpawnPosition += npc.velocity.SafeNormalize(Vector2.Zero).RotatedBy(MathHelper.PiOver4) * 16f; + if (i == 3) + goreSpawnPosition += npc.velocity.SafeNormalize(Vector2.Zero).RotatedBy(-MathHelper.PiOver4) * 16f; + Gore.NewGorePerfect(goreSpawnPosition, npc.velocity, mod.GetGoreSlot($"Gores/SupremeCalamitas/SepulcherHead_Gore{i}"), npc.scale); } - for (int num623 = 0; num623 < 10; num623++) - { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } + } } } } diff --git a/NPCs/SupremeCalamitas/SCalWormHead.png b/NPCs/SupremeCalamitas/SCalWormHead.png index 8bd5ba6d26..ce918150f1 100644 Binary files a/NPCs/SupremeCalamitas/SCalWormHead.png and b/NPCs/SupremeCalamitas/SCalWormHead.png differ diff --git a/NPCs/SupremeCalamitas/SCalWormHeadGlow.png b/NPCs/SupremeCalamitas/SCalWormHeadGlow.png deleted file mode 100644 index 6b5306839a..0000000000 Binary files a/NPCs/SupremeCalamitas/SCalWormHeadGlow.png and /dev/null differ diff --git a/NPCs/SupremeCalamitas/SCalWormHeart.png b/NPCs/SupremeCalamitas/SCalWormHeart.png deleted file mode 100644 index 8bc8635d1b..0000000000 Binary files a/NPCs/SupremeCalamitas/SCalWormHeart.png and /dev/null differ diff --git a/NPCs/SupremeCalamitas/SCalWormTail.cs b/NPCs/SupremeCalamitas/SCalWormTail.cs index 3fb861c106..d0200712e0 100644 --- a/NPCs/SupremeCalamitas/SCalWormTail.cs +++ b/NPCs/SupremeCalamitas/SCalWormTail.cs @@ -42,8 +42,6 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.noGravity = true; npc.noTileCollide = true; npc.canGhostHeal = false; - npc.HitSound = SoundID.NPCHit4; - npc.DeathSound = SoundID.NPCDeath14; npc.netAlways = true; npc.dontCountMe = true; } @@ -164,11 +162,6 @@ namespace CalamityMod.NPCs.SupremeCalamitas vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/SupremeCalamitas/SCalWormTailGlow"); - Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); - - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; } @@ -190,32 +183,15 @@ namespace CalamityMod.NPCs.SupremeCalamitas public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) - { - npc.position.X = npc.position.X + (float)(npc.width / 2); - npc.position.Y = npc.position.Y + (float)(npc.height / 2); - npc.width = 50; - npc.height = 50; - npc.position.X = npc.position.X - (float)(npc.width / 2); - npc.position.Y = npc.position.Y - (float)(npc.height / 2); - for (int num621 = 0; num621 < 5; num621++) - { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 173, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int num623 = 0; num623 < 10; num623++) - { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 173, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 173, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } + { + for (int i = 1; i <= 2; i++) + { + Vector2 goreSpawnPosition = npc.Center; + if (i == 2) + goreSpawnPosition -= (npc.rotation - MathHelper.PiOver2).ToRotationVector2() * 20f; + Gore.NewGorePerfect(goreSpawnPosition, Main.rand.NextVector2Circular(3f, 3f), mod.GetGoreSlot($"Gores/SupremeCalamitas/SepulcherTail_Gore{i}"), npc.scale); + } + } } public override bool CheckActive() diff --git a/NPCs/SupremeCalamitas/SCalWormTail.png b/NPCs/SupremeCalamitas/SCalWormTail.png index a8e1ab41e1..283e094283 100644 Binary files a/NPCs/SupremeCalamitas/SCalWormTail.png and b/NPCs/SupremeCalamitas/SCalWormTail.png differ diff --git a/NPCs/SupremeCalamitas/SCalWormTailGlow.png b/NPCs/SupremeCalamitas/SCalWormTailGlow.png deleted file mode 100644 index 2d4265fd16..0000000000 Binary files a/NPCs/SupremeCalamitas/SCalWormTailGlow.png and /dev/null differ diff --git a/NPCs/SupremeCalamitas/SoulSeekerSupreme.cs b/NPCs/SupremeCalamitas/SoulSeekerSupreme.cs index 894bb0b395..9d706a6e3e 100644 --- a/NPCs/SupremeCalamitas/SoulSeekerSupreme.cs +++ b/NPCs/SupremeCalamitas/SoulSeekerSupreme.cs @@ -16,11 +16,15 @@ namespace CalamityMod.NPCs.SupremeCalamitas { private int timer = 0; private bool start = true; + public NPC SCal => Main.npc[CalamityGlobalNPC.SCal]; + public Player Target => Main.player[npc.target]; + public Vector2 EyePosition => npc.Center + new Vector2(npc.spriteDirection == -1 ? 40f : -36f, 16f); + public ref float RotationalDegreeOffset => ref npc.ai[1]; public override void SetStaticDefaults() { DisplayName.SetDefault("Soul Seeker"); - Main.npcFrameCount[npc.type] = 8; + Main.npcFrameCount[npc.type] = 6; NPCID.Sets.TrailingMode[npc.type] = 1; } @@ -37,8 +41,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.defense = 60; npc.DR_NERD(0.25f); npc.LifeMaxNERB(Main.expertMode ? 24000 : 15000, 28000); - npc.HitSound = SoundID.NPCHit4; - npc.DeathSound = SoundID.NPCDeath14; + npc.DeathSound = SoundID.DD2_SkeletonDeath; } public override void SendExtraAI(BinaryWriter writer) @@ -62,33 +65,35 @@ namespace CalamityMod.NPCs.SupremeCalamitas public override bool PreAI() { - NPC parent = Main.npc[CalamityGlobalNPC.SCal]; - bool expertMode = Main.expertMode; + // Die if SCal is no longer present. + if (CalamityGlobalNPC.SCal < 0 || !SCal.active) + { + npc.active = false; + npc.netUpdate = true; + return false; + } + if (start) { - for (int num621 = 0; num621 < 10; num621++) - { - int num622 = Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - } - npc.ai[1] = npc.ai[0]; + for (int i = 0; i < 10; i++) + Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); + RotationalDegreeOffset = npc.ai[0]; start = false; } // 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 || Target.dead || !Target.active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + // Target another player if the current player target is too far away + if (!npc.WithinRange(Target.Center, CalamityGlobalNPC.CatchUpDistance200Tiles)) npc.TargetClosest(); - Vector2 direction = Main.player[npc.target].Center - npc.Center; - direction.Normalize(); - direction *= 9f; - npc.rotation = direction.ToRotation(); + npc.spriteDirection = (Target.Center.X < npc.Center.X).ToDirectionInt(); + timer++; - int timerLimit = CalamityWorld.malice ? 120 : 180; - if (timer > timerLimit) + int shootRate = CalamityWorld.malice ? 120 : 180; + if (timer > shootRate) { for (int i = 0; i < Main.maxNPCs; i++) { @@ -96,7 +101,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (seeker.type == npc.type) { if (seeker == npc) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneShoot"), parent.Center); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneShoot"), SCal.Center); break; } } @@ -104,24 +109,15 @@ namespace CalamityMod.NPCs.SupremeCalamitas { int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(npc.Center, direction, type, damage, 1f, Main.myPlayer); + Vector2 shootVelocity = (Target.Center - EyePosition).SafeNormalize(Vector2.UnitY) * 9f; + Projectile.NewProjectile(EyePosition, shootVelocity, type, damage, 1f, Main.myPlayer); } timer = 0; npc.netUpdate = true; } - if (CalamityGlobalNPC.SCal < 0 || !parent.active) - { - npc.active = false; - npc.netUpdate = true; - return false; - } - Player player = Main.player[npc.target]; - double deg = npc.ai[1]; - double rad = deg * (Math.PI / 180); - double dist = 300; - npc.position.X = parent.Center.X - (int)(Math.Cos(rad) * dist) - npc.width / 2; - npc.position.Y = parent.Center.Y - (int)(Math.Sin(rad) * dist) - npc.height / 2; - npc.ai[1] += 0.5f; //2 + + npc.position = SCal.Center - MathHelper.ToRadians(RotationalDegreeOffset).ToRotationVector2() * 300f - npc.Size * 0.5f; + RotationalDegreeOffset += 0.5f; return false; } @@ -159,16 +155,13 @@ namespace CalamityMod.NPCs.SupremeCalamitas num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SoulSeekerSupremeGores/SupremeSoulSeeker"), npc.scale); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SoulSeekerSupremeGores/SupremeSoulSeeker2"), npc.scale); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SoulSeekerSupremeGores/SupremeSoulSeeker3"), npc.scale); + + for (int i = 1; i <= 5; i++) + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot($"Gores/SoulSeekerSupremeGores/SupremeSoulSeeker_Gore{i}"), npc.scale); } } - public override bool CheckActive() - { - return false; - } + public override bool CheckActive() => false; public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { @@ -180,7 +173,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); Color color36 = Color.White; float amount9 = 0.5f; - int num153 = 5; + int num153 = 2; if (CalamityConfig.Instance.Afterimages) { diff --git a/NPCs/SupremeCalamitas/SoulSeekerSupreme.png b/NPCs/SupremeCalamitas/SoulSeekerSupreme.png index d0ae0b4980..cea992e2a7 100644 Binary files a/NPCs/SupremeCalamitas/SoulSeekerSupreme.png and b/NPCs/SupremeCalamitas/SoulSeekerSupreme.png differ diff --git a/NPCs/SupremeCalamitas/SoulSeekerSupremeGlow.png b/NPCs/SupremeCalamitas/SoulSeekerSupremeGlow.png index 27c809cbac..5c481d1bf2 100644 Binary files a/NPCs/SupremeCalamitas/SoulSeekerSupremeGlow.png and b/NPCs/SupremeCalamitas/SoulSeekerSupremeGlow.png differ diff --git a/NPCs/SupremeCalamitas/SupremeCalamitas.cs b/NPCs/SupremeCalamitas/SupremeCalamitas.cs index 701c0a6ef0..d2f24dcac9 100644 --- a/NPCs/SupremeCalamitas/SupremeCalamitas.cs +++ b/NPCs/SupremeCalamitas/SupremeCalamitas.cs @@ -86,8 +86,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas private int spawnY = 0; private int spawnYReset = 0; private int spawnYAdd = 0; - private int bulletHellCounter = 0; - private int bulletHellCounter2 = 0; + public int bulletHellCounter = 0; + public int bulletHellCounter2 = 0; private int attackCastDelay = 0; private int hitTimer = 0; @@ -415,7 +415,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas } // Summon a shield if the next attack will be a charge. - else if (!npc.dontTakeDamage && ((willCharge && AttackCloseToBeingOver) || npc.ai[1] == 2f)) + else if (((willCharge && AttackCloseToBeingOver) || npc.ai[1] == 2f) && bulletHellCounter2 % 900 == 0) { if (npc.ai[1] != 2f) { @@ -2543,20 +2543,18 @@ namespace CalamityMod.NPCs.SupremeCalamitas } // And play a fire-like sound effect. - Main.PlaySound(SoundID.DD2_BetsyWindAttack, target.Center); hasSummonedSepulcher1 = true; hasSummonedSepulcher2 = npc.life <= npc.lifeMax * 0.08; - // TODO: Resprite brimstone hearts a bit. if (Main.netMode != NetmodeID.MultiplayerClient) { List hearts = new List(); for (int x = 0; x < 5; x++) { - hearts.Add(NPC.NewNPC(spawnX + 50, tempSpawnY, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255)); + hearts.Add(NPC.NewNPC(spawnX + 50, tempSpawnY, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255)); spawnX += spawnXAdd; - hearts.Add(NPC.NewNPC(spawnX2 - 50, tempSpawnY, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255)); + hearts.Add(NPC.NewNPC(spawnX2 - 50, tempSpawnY, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255)); spawnX2 -= spawnXAdd; tempSpawnY += spawnYAdd; } @@ -2569,6 +2567,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas NPC.SpawnOnPlayer(npc.FindClosestPlayer(), ModContent.NPCType()); npc.netUpdate = true; } + + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/SepulcherSpawn"), target.Center); } } @@ -2662,7 +2662,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas public void ConnectAllBrimstoneHearts(List heartIndices) { - int heartType = ModContent.NPCType(); + int heartType = ModContent.NPCType(); // Ensure that the hearts go in order based on the arena. IEnumerable hearts = heartIndices.Select(i => Main.npc[i]); @@ -2695,14 +2695,14 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (tries >= 100) endpoint.X = MathHelper.Clamp(endpoint.X, safeBox.Left, safeBox.Right); - heart.ModNPC().ChainEndpoints.Add(endpoint); + heart.ModNPC().ChainEndpoints.Add(endpoint); } if (Main.rand.NextBool(2)) { endpoint.X = heart.Center.X + Main.rand.NextBool(2).ToDirectionInt() * Main.rand.NextFloat(45f, 360f); endpoint.X = MathHelper.Clamp(endpoint.X, safeBox.Left, safeBox.Right); - heart.ModNPC().ChainEndpoints.Add(endpoint); + heart.ModNPC().ChainEndpoints.Add(endpoint); } heart.netUpdate = true; @@ -2945,7 +2945,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (lifeRatio < 0.05f) flickerPower += 0.1f; float opacity = forcefieldOpacity; - opacity *= MathHelper.Lerp(1f, 1f - flickerPower, (float)Math.Pow(Math.Cos(Main.GlobalTime * MathHelper.Lerp(3f, 9f, flickerPower)), 24D)); + opacity *= MathHelper.Lerp(1f, MathHelper.Max(1f - flickerPower, 0.56f), (float)Math.Pow(Math.Cos(Main.GlobalTime * MathHelper.Lerp(3f, 5f, flickerPower)), 24D)); // During/prior to a charge the forcefield is always darker than usual and thus its intensity is also higher. if (!npc.dontTakeDamage && (willCharge || npc.ai[1] == 2f)) diff --git a/NPCs/SupremeCalamitas/unknown.png b/NPCs/SupremeCalamitas/unknown.png deleted file mode 100644 index 8aec7550d7..0000000000 Binary files a/NPCs/SupremeCalamitas/unknown.png and /dev/null differ diff --git a/Projectiles/Boss/SCalRitualDrama.cs b/Projectiles/Boss/SCalRitualDrama.cs index 4854623359..eb6ca69f86 100644 --- a/Projectiles/Boss/SCalRitualDrama.cs +++ b/Projectiles/Boss/SCalRitualDrama.cs @@ -1,5 +1,6 @@ using CalamityMod.Dusts; using CalamityMod.NPCs.SupremeCalamitas; +using CalamityMod.Skies; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; diff --git a/Projectiles/Typeless/SepulcherSoul.cs b/Projectiles/Typeless/SepulcherSoul.cs new file mode 100644 index 0000000000..38e6ccace4 --- /dev/null +++ b/Projectiles/Typeless/SepulcherSoul.cs @@ -0,0 +1,42 @@ +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class SepulcherSoul : ModProjectile + { + public ref float Time => ref projectile.ai[0]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Tormented Soul"); + Main.projFrames[projectile.type] = 3; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 16; + projectile.Opacity = 0f; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.timeLeft = 120; + } + + public override void AI() + { + if (projectile.localAI[0] == 0f) + { + projectile.frame = Main.rand.Next(Main.projFrames[projectile.type]); + projectile.localAI[0] = 1f; + } + Vector2 idealVelocity = Vector2.Zero; + idealVelocity.X = (float)(Math.Sin(Time / 27f + projectile.identity * 1.1f) + (float)Math.Cos(Math.E * (Time / 27f + projectile.identity * 1.1f))) * 4f; + idealVelocity.Y = MathHelper.SmoothStep(-3f, -9f, (float)Math.Sin(Time / 23f + projectile.identity * 1.1f) * 0.5f + 0.5f); + projectile.velocity = Vector2.Lerp(projectile.velocity, idealVelocity, 0.075f); + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + projectile.Opacity = Utils.InverseLerp(0f, 15f, Time, true) * Utils.InverseLerp(0f, 25f, projectile.timeLeft, true); + Time++; + } + } +} diff --git a/Projectiles/Typeless/SepulcherSoul.png b/Projectiles/Typeless/SepulcherSoul.png new file mode 100644 index 0000000000..a59212a6b7 Binary files /dev/null and b/Projectiles/Typeless/SepulcherSoul.png differ diff --git a/NPCs/SupremeCalamitas/SCalScreenShaderData.cs b/Skies/SCalScreenShaderData.cs similarity index 94% rename from NPCs/SupremeCalamitas/SCalScreenShaderData.cs rename to Skies/SCalScreenShaderData.cs index 7f0b3dca34..af7e823da1 100644 --- a/NPCs/SupremeCalamitas/SCalScreenShaderData.cs +++ b/Skies/SCalScreenShaderData.cs @@ -1,8 +1,9 @@ +using CalamityMod.NPCs.SupremeCalamitas; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ModLoader; -namespace CalamityMod.NPCs.SupremeCalamitas +namespace CalamityMod.Skies { public class SCalScreenShaderData : ScreenShaderData { diff --git a/Skies/SCalSky.cs b/Skies/SCalSky.cs new file mode 100644 index 0000000000..d0e2978fe8 --- /dev/null +++ b/Skies/SCalSky.cs @@ -0,0 +1,246 @@ +using CalamityMod.NPCs; +using CalamityMod.NPCs.SupremeCalamitas; +using CalamityMod.Projectiles.Boss; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using Terraria; +using Terraria.Graphics.Effects; +using Terraria.ModLoader; + +namespace CalamityMod.Skies +{ + public class SCalSky : CustomSky + { + public class Cinder + { + public int Time; + public int Lifetime; + public int IdentityIndex; + public float Scale; + public float Depth; + public Color DrawColor; + public Vector2 Velocity; + public Vector2 Center; + public Cinder(int lifetime, int identity, float depth, Color color, Vector2 startingPosition, Vector2 startingVelocity) + { + Lifetime = lifetime; + IdentityIndex = identity; + Depth = depth; + DrawColor = color; + Center = startingPosition; + Velocity = startingVelocity; + } + } + + private bool isActive = false; + private float intensity = 0f; + private int SCalIndex = -1; + public List Cinders = new List(); + public static int CinderReleaseChance + { + get + { + if (!Main.npc.IndexInRange(CalamityGlobalNPC.SCal) || Main.npc[CalamityGlobalNPC.SCal].type != ModContent.NPCType()) + return int.MaxValue; + + NPC scal = Main.npc[CalamityGlobalNPC.SCal]; + float lifeRatio = scal.life / (float)scal.lifeMax; + + // Release a good amount of cinders during bullet hells. If this is too distracting this can be + // inverted so that less appear than usual instead. + if (scal.ModNPC().bulletHellCounter2 % 900 != 0) + return lifeRatio <= 0.1f ? 8 : 11; + + // Release more and more cinders at the end of the battle until the acceptance phase, where it all slows down dramatically, with just a few ashes. + if (lifeRatio < 0.1f) + { + if (lifeRatio <= 0.01f) + return 32; + + return (int)Math.Round(MathHelper.Lerp(2f, 11f, Utils.InverseLerp(0.03f, 0.1f, lifeRatio, true))); + } + + // Release a good amount of cinders while brothers or Sepulcher-1 are alive. Sepulcher-2 falls into an above case and does not execute this return. + if (NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType())) + return 10; + + // Release a moderate amount of cinders normally. + return 18; + } + } + public static float CinderSpeed + { + get + { + if (!Main.npc.IndexInRange(CalamityGlobalNPC.SCal) || Main.npc[CalamityGlobalNPC.SCal].type != ModContent.NPCType()) + return 0f; + + NPC scal = Main.npc[CalamityGlobalNPC.SCal]; + float lifeRatio = scal.life / (float)scal.lifeMax; + + // Move more and more quickly at the end of the battle until the acceptance phase, where it all slows down dramatically. + if (lifeRatio < 0.1f) + { + if (lifeRatio <= 0.01f) + return 4.5f; + + return MathHelper.Lerp(10.75f, 6.7f, Utils.InverseLerp(0.03f, 0.1f, lifeRatio, true)); + } + + // Move a little quickly while brothers or Sepulcher-1 are alive. Sepulcher-2 falls into an above case and does not execute this return. + if (NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType())) + return 7.4f; + + // Move moderately quickly usually. + return 5.6f; + } + } + public static float OverridingIntensity = 0f; + + public override void Update(GameTime gameTime) + { + if (isActive && intensity < 1f) + { + intensity += 0.01f; + } + else if (!isActive && intensity > 0f) + { + intensity -= 0.01f; + } + + Color selectCinderColor() + { + if (!Main.npc.IndexInRange(CalamityGlobalNPC.SCal) || Main.npc[CalamityGlobalNPC.SCal].type != ModContent.NPCType()) + return Color.Transparent; + + NPC scal = Main.npc[CalamityGlobalNPC.SCal]; + float lifeRatio = scal.life / (float)scal.lifeMax; + if (lifeRatio > 0.5f) + return Color.Lerp(Color.Red, Color.Orange, Main.rand.NextFloat(0.8f)); + else if (lifeRatio > 0.3f) + return Color.Lerp(Color.DarkRed, Color.Lerp(Color.Blue, Color.DarkBlue, Main.rand.NextFloat() * 0.65f), 0.45f); + else if (lifeRatio > 0.01f) + return Color.Lerp(Color.Red, Color.Yellow, Main.rand.NextFloat(0.2f, 0.9f)); + else + return Color.Gray; + } + + // Randomly add cinders. + if (intensity >= 1f && Main.rand.NextBool(CinderReleaseChance)) + { + int lifetime = Main.rand.Next(285, 445); + float depth = Main.rand.NextFloat(1.8f, 5f); + Vector2 startingPosition = Main.screenPosition + new Vector2(Main.screenWidth * Main.rand.NextFloat(-0.1f, 1.1f), Main.screenHeight * 1.05f); + Vector2 startingVelocity = -Vector2.UnitY.RotatedByRandom(0.91f); + Cinders.Add(new Cinder(lifetime, Cinders.Count, depth, selectCinderColor(), startingPosition, startingVelocity)); + } + + // Update all cinders. + for (int i = 0; i < Cinders.Count; i++) + { + Cinders[i].Scale = Utils.InverseLerp(Cinders[i].Lifetime, Cinders[i].Lifetime / 3, Cinders[i].Time, true); + Cinders[i].Scale *= MathHelper.Lerp(0.6f, 0.9f, Cinders[i].IdentityIndex % 6f / 6f); + + Vector2 idealVelocity = -Vector2.UnitY.RotatedBy(MathHelper.Lerp(-0.94f, 0.94f, (float)Math.Sin(Cinders[i].Time / 36f + Cinders[i].IdentityIndex) * 0.5f + 0.5f)) * CinderSpeed; + float movementInterpolant = MathHelper.Lerp(0.01f, 0.08f, Utils.InverseLerp(45f, 145f, Cinders[i].Time, true)); + Cinders[i].Velocity = Vector2.Lerp(Cinders[i].Velocity, idealVelocity, movementInterpolant); + Cinders[i].Velocity = Cinders[i].Velocity.SafeNormalize(-Vector2.UnitY) * CinderSpeed; + Cinders[i].Time++; + + Cinders[i].Center += Cinders[i].Velocity; + } + + // Clear away all dead cinders. + Cinders.RemoveAll(c => c.Time >= c.Lifetime); + } + + private float GetIntensity() + { + if (CalamityUtils.CountProjectiles(ModContent.ProjectileType()) > 0) + return OverridingIntensity; + + OverridingIntensity = 0f; + if (UpdateSCalIndex()) + { + float x = 0f; + if (SCalIndex != -1) + x = Vector2.Distance(Main.player[Main.myPlayer].Center, Main.npc[this.SCalIndex].Center); + + return 1f - Utils.SmoothStep(3000f, 6000f, x); + } + return 0f; + } + + public override Color OnTileColor(Color inColor) => new Color(Vector4.Lerp(new Vector4(0.5f, 0.8f, 1f, 1f), inColor.ToVector4(), 1f - GetIntensity())); + + private bool UpdateSCalIndex() + { + int SCalType = ModContent.NPCType(); + if (SCalIndex >= 0 && Main.npc[SCalIndex].active && Main.npc[SCalIndex].type == SCalType) + { + return true; + } + SCalIndex = -1; + for (int i = 0; i < Main.npc.Length; i++) + { + if (Main.npc[i].active && Main.npc[i].type == SCalType) + { + SCalIndex = i; + break; + } + } + return SCalIndex != -1; + } + + public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth) + { + if (maxDepth >= 0 && minDepth < 0) + { + float intensity = GetIntensity(); + spriteBatch.Draw(Main.blackTileTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.Black * intensity); + } + + // Draw cinders. + Texture2D cinderTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/CalamitasCinder"); + for (int i = 0; i < Cinders.Count; i++) + { + Vector2 drawPosition = Cinders[i].Center - Main.screenPosition; + for (int j = 0; j < 3; j++) + { + Vector2 offsetDrawPosition = drawPosition + (MathHelper.TwoPi * j / 3f).ToRotationVector2() * 1.4f; + Color offsetDrawColor = Color.Red * 0.56f; + offsetDrawColor.A = 0; + spriteBatch.Draw(cinderTexture, offsetDrawPosition, null, offsetDrawColor, 0f, cinderTexture.Size() * 0.5f, Cinders[i].Scale * 1.5f, SpriteEffects.None, 0f); + } + spriteBatch.Draw(cinderTexture, drawPosition, null, Cinders[i].DrawColor, 0f, cinderTexture.Size() * 0.5f, Cinders[i].Scale, SpriteEffects.None, 0f); + } + } + + public override float GetCloudAlpha() + { + return 0f; + } + + public override void Activate(Vector2 position, params object[] args) + { + isActive = true; + } + + public override void Deactivate(params object[] args) + { + isActive = false; + } + + public override void Reset() + { + isActive = false; + } + + public override bool IsActive() + { + return isActive || intensity > 0f; + } + } +} diff --git a/Sounds/Custom/SCalSounds/SepulcherSpawn.cs b/Sounds/Custom/SCalSounds/SepulcherSpawn.cs new file mode 100644 index 0000000000..45ffb992dd --- /dev/null +++ b/Sounds/Custom/SCalSounds/SepulcherSpawn.cs @@ -0,0 +1,18 @@ +using Microsoft.Xna.Framework.Audio; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Sounds.Custom.SCalSounds +{ + public class SepulcherSpawn : ModSound + { + public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) + { + soundInstance = sound.CreateInstance(); + soundInstance.Volume = volume; + soundInstance.Pan = pan; + Main.PlaySoundInstance(soundInstance); + return soundInstance; + } + } +} diff --git a/Sounds/Custom/SCalSounds/SepulcherSpawn.ogg b/Sounds/Custom/SCalSounds/SepulcherSpawn.ogg new file mode 100644 index 0000000000..b0b6e2ccf8 Binary files /dev/null and b/Sounds/Custom/SCalSounds/SepulcherSpawn.ogg differ diff --git a/Sounds/NPCKilled/SepulcherDeath.cs b/Sounds/NPCKilled/SepulcherDeath.cs new file mode 100644 index 0000000000..d4e74ea577 --- /dev/null +++ b/Sounds/NPCKilled/SepulcherDeath.cs @@ -0,0 +1,18 @@ +using Microsoft.Xna.Framework.Audio; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Sounds.NPCKilled +{ + public class SepulcherDeath : ModSound + { + public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) + { + soundInstance = sound.CreateInstance(); + soundInstance.Volume = volume; + soundInstance.Pan = pan; + Main.PlaySoundInstance(soundInstance); + return soundInstance; + } + } +} diff --git a/Sounds/NPCKilled/SepulcherDeath.ogg b/Sounds/NPCKilled/SepulcherDeath.ogg new file mode 100644 index 0000000000..8da5bc6466 Binary files /dev/null and b/Sounds/NPCKilled/SepulcherDeath.ogg differ diff --git a/Utilities/NPCDebuffs.cs b/Utilities/NPCDebuffs.cs index 794f7ce459..8c214aa6bc 100644 --- a/Utilities/NPCDebuffs.cs +++ b/Utilities/NPCDebuffs.cs @@ -190,7 +190,7 @@ namespace CalamityMod { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, { ModContent.NPCType(), new Tuple(true, new int[] { }) }, { ModContent.NPCType(), new Tuple(true, new int[] { }) }, { ModContent.NPCType(), new Tuple(true, new int[] { }) },