diff --git a/Gores/Draedon/Chair1.png b/Gores/Draedon/Chair1.png new file mode 100644 index 0000000000..e514084ae2 Binary files /dev/null and b/Gores/Draedon/Chair1.png differ diff --git a/Gores/Draedon/Chair2.png b/Gores/Draedon/Chair2.png new file mode 100644 index 0000000000..99377710bc Binary files /dev/null and b/Gores/Draedon/Chair2.png differ diff --git a/Gores/Draedon/Chair3.png b/Gores/Draedon/Chair3.png new file mode 100644 index 0000000000..3d1a32e2bc Binary files /dev/null and b/Gores/Draedon/Chair3.png differ diff --git a/Gores/Draedon/Chair4.png b/Gores/Draedon/Chair4.png new file mode 100644 index 0000000000..767c9e1f02 Binary files /dev/null and b/Gores/Draedon/Chair4.png differ diff --git a/Gores/Draedon/Draedon1.png b/Gores/Draedon/Draedon1.png new file mode 100644 index 0000000000..88bd633548 Binary files /dev/null and b/Gores/Draedon/Draedon1.png differ diff --git a/Gores/Draedon/Draedon2.png b/Gores/Draedon/Draedon2.png new file mode 100644 index 0000000000..9fd23773a0 Binary files /dev/null and b/Gores/Draedon/Draedon2.png differ diff --git a/Gores/Draedon/Draedon3.png b/Gores/Draedon/Draedon3.png new file mode 100644 index 0000000000..ca30e2e8b9 Binary files /dev/null and b/Gores/Draedon/Draedon3.png differ diff --git a/Gores/Draedon/Draedon4.png b/Gores/Draedon/Draedon4.png new file mode 100644 index 0000000000..7343b8d0ec Binary files /dev/null and b/Gores/Draedon/Draedon4.png differ diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index e681fae2c4..44be8f7587 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -146,6 +146,7 @@ namespace CalamityMod.NPCs // Stuff used by the Boss Health UI public bool SplittingWorm = false; + public bool CanHaveBossHealthBar = false; // Timer for how long an NPC is immune to certain debuffs public const int slowingDebuffResistanceMin = 1800; @@ -749,6 +750,7 @@ namespace CalamityMod.NPCs // Reset the enraged state every frame. The expectation is that bosses will continuously set it back to true if necessary. CurrentlyEnraged = false; + CanHaveBossHealthBar = false; } #endregion diff --git a/NPCs/ExoMechs/Draedon.cs b/NPCs/ExoMechs/Draedon.cs index 4dae958568..c0aebc5cef 100644 --- a/NPCs/ExoMechs/Draedon.cs +++ b/NPCs/ExoMechs/Draedon.cs @@ -4,6 +4,7 @@ using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; +using System.IO; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; @@ -16,22 +17,24 @@ namespace CalamityMod.NPCs.ExoMechs { public class Draedon : ModNPC { + public float DefeatTimer; + public bool ShouldStartStandingUp; public Vector2 HoverDestinationOffset - { + { get => new Vector2(npc.ai[1], npc.ai[2]); - set - { + set + { npc.ai[1] = value.X; npc.ai[2] = value.Y; - } - } + } + } public Player PlayerToFollow => Main.player[npc.target]; public ref float TalkTimer => ref npc.ai[0]; public ref float GeneralTimer => ref npc.ai[3]; public bool ExoMechIsPresent - { - get - { + { + get + { if (NPC.AnyNPCs(ModContent.NPCType())) return true; @@ -43,26 +46,27 @@ namespace CalamityMod.NPCs.ExoMechs return false; } - } + } public static readonly Color TextColor = new Color(155, 255, 255); public static readonly Color TextColorEdgy = new Color(213, 4, 11); public const int TeleportFadeinTime = 45; - public const int TalkDelay = 80; + public const int TalkDelay = 150; public const int DelayPerDialogLine = 130; public const int ExoMechChooseDelay = TalkDelay + DelayPerDialogLine * 4 + 10; public const int ExoMechShakeTime = 100; + public const int DelayBeforeDefeatStandup = 30; public override void SetStaticDefaults() { DisplayName.SetDefault("Draedon"); - Main.npcFrameCount[npc.type] = 12; + Main.npcFrameCount[npc.type] = 15; } public override void SetDefaults() { npc.damage = 0; npc.width = npc.height = 34; - npc.defense = 9999; - npc.lifeMax = 50; + npc.defense = 100; + npc.lifeMax = 16000; npc.noGravity = true; npc.noTileCollide = true; npc.dontTakeDamage = true; @@ -70,6 +74,18 @@ namespace CalamityMod.NPCs.ExoMechs npc.knockBackResist = 0f; } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(DefeatTimer); + writer.Write(ShouldStartStandingUp); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + DefeatTimer = reader.ReadSingle(); + ShouldStartStandingUp = reader.ReadBoolean(); + } + public override void AI() { // Set the whoAmI variable. @@ -89,7 +105,7 @@ namespace CalamityMod.NPCs.ExoMechs // Fuck off if no living target exists. if (PlayerToFollow.dead || !PlayerToFollow.active) - { + { npc.life = 0; npc.checkDead(); npc.active = false; @@ -98,10 +114,15 @@ namespace CalamityMod.NPCs.ExoMechs } // Stay within the world. - npc.position.Y = MathHelper.Clamp(npc.position.Y, 150f, Main.maxTilesY * 16f - 150f); + npc.position.Y = MathHelper.Clamp(npc.position.Y, 150f, Main.maxTilesY * 16f - 150f); npc.Opacity = Utils.InverseLerp(0f, 8f, TalkTimer, true); npc.spriteDirection = (PlayerToFollow.Center.X < npc.Center.X).ToDirectionInt(); + + // Play the stand up animation after teleportation. + if (TalkTimer == TeleportFadeinTime + 5f) + ShouldStartStandingUp = true; + if (Main.netMode != NetmodeID.MultiplayerClient && TalkTimer == TalkDelay) { CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.DraedonIntroductionText1", TextColor); @@ -135,13 +156,13 @@ namespace CalamityMod.NPCs.ExoMechs // Wait for the player to select an exo mech. if (TalkTimer >= ExoMechChooseDelay && TalkTimer < ExoMechChooseDelay + 8f && CalamityWorld.DraedonMechToSummon == ExoMech.None) - { + { PlayerToFollow.Calamity().AbleToSelectExoMech = true; TalkTimer = ExoMechChooseDelay; - } + } // Fly around once the exo mechs have been spawned. - if (ExoMechIsPresent) + if (ExoMechIsPresent || DefeatTimer > 0f) { FlyAroundInGamerChair(); GeneralTimer++; @@ -163,22 +184,30 @@ namespace CalamityMod.NPCs.ExoMechs if (Main.netMode != NetmodeID.Server) { var sound = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/FlareSound"), PlayerToFollow.Center); - sound.Volume = MathHelper.Clamp(sound.Volume * 1.55f, 0f, 1f); + + if (sound != null) + sound.Volume = MathHelper.Clamp(sound.Volume * 1.55f, 0f, 1f); } } + if (TalkTimer > ExoMechChooseDelay + 10f && !ExoMechIsPresent) + { + HandleDefeatStuff(); + DefeatTimer++; + } + TalkTimer++; } // TODO - Make this work in conjunction with exo mech transitions. This requires that the exo mech AIs be finished. public void FlyAroundInGamerChair() - { + { // Define a hover destination offset if one hasn't been decided yet. if (Main.netMode != NetmodeID.MultiplayerClient && HoverDestinationOffset == Vector2.Zero) - { + { HoverDestinationOffset = -Vector2.UnitY * 700f; npc.netUpdate = true; - } + } // Switch hover destinations from time to time. if (Main.netMode != NetmodeID.MultiplayerClient && GeneralTimer % 480f == 479f) @@ -197,6 +226,10 @@ namespace CalamityMod.NPCs.ExoMechs npc.netUpdate = true; } + // Always hover to the side of the target when defeated. + if (DefeatTimer > 5f) + HoverDestinationOffset = Vector2.UnitX * (PlayerToFollow.Center.X < npc.Center.X).ToDirectionInt() * 325f; + Vector2 hoverDestination = PlayerToFollow.Center + HoverDestinationOffset; // Decide sprite direction based on movement if not close enough to the desination. @@ -210,10 +243,12 @@ namespace CalamityMod.NPCs.ExoMechs } else { - npc.spriteDirection = (npc.velocity.X < 0f).ToDirectionInt(); + if (DefeatTimer < DelayBeforeDefeatStandup) + npc.spriteDirection = (npc.velocity.X < 0f).ToDirectionInt(); - Vector2 idealVelocity = npc.SafeDirectionTo(hoverDestination) * 32f; - npc.SimpleFlyMovement(idealVelocity, 0.8f); + float flySpeed = DefeatTimer > 5f ? 14f : 32f; + Vector2 idealVelocity = npc.SafeDirectionTo(hoverDestination) * flySpeed; + npc.SimpleFlyMovement(idealVelocity, flySpeed / 400f); npc.velocity = Vector2.Lerp(npc.velocity, idealVelocity, 0.045f); } } @@ -246,55 +281,133 @@ namespace CalamityMod.NPCs.ExoMechs } } + public void HandleDefeatStuff() + { + // Become vulnerable after being defeated after a certain point. + npc.dontTakeDamage = DefeatTimer < 250f; + npc.Calamity().CanHaveBossHealthBar = !npc.dontTakeDamage; + + // Stand up in awe after a small amount of time has passed. + if (DefeatTimer > DelayBeforeDefeatStandup) + ShouldStartStandingUp = true; + + // TODO - This needs to be changed. + if (DefeatTimer == DelayBeforeDefeatStandup + 10f) + Main.NewText("Wait, what? How?", TextColor); + + if (DefeatTimer == DelayBeforeDefeatStandup + 80f) + Main.NewText("No", TextColor); + } + // Draedon should not manually despawn. public override bool CheckActive() => false; - public override Color? GetAlpha(Color drawColor) - { + public override Color? GetAlpha(Color drawColor) + { float teleportFade = Utils.InverseLerp(0f, TeleportFadeinTime, TalkTimer, true); Color color = Color.Lerp(drawColor, Color.Cyan, 1f - (float)Math.Pow(teleportFade, 3D)); color.A = (byte)(int)(teleportFade * 255f); return color * npc.Opacity; - } + } - public override void FindFrame(int frameHeight) + public override void FindFrame(int frameHeight) { - npc.frame.Width = 106; + npc.frame.Width = 102; + int xFrame = npc.frame.X / npc.frame.Width; + int yFrame = npc.frame.Y / npc.frame.Height; + int frame = xFrame * Main.npcFrameCount[npc.type] + yFrame; + + // Prepare to stand up if called for and not already doing so. + if (ShouldStartStandingUp && frame < 23) + frame = 23; + + int frameChangeDelay = 7; + bool shouldNotSitDown = DefeatTimer > DelayBeforeDefeatStandup; npc.frameCounter++; - if (npc.frameCounter >= 6f) - { - npc.frame.Y = npc.frame.Y + frameHeight; - if (npc.frame.Y >= Main.npcFrameCount[npc.type] * frameHeight) - { - npc.frame.X = (npc.frame.X + 106) % 212; - npc.frame.Y = 0; - } - npc.frameCounter = 0; - } - } + if (npc.frameCounter >= frameChangeDelay) + { + frame++; - public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) - { + if (!ShouldStartStandingUp && frame >= 23) + frame = 0; + + // Do the sit animation infinitely if Draedon should not sit down again. + if (shouldNotSitDown && frame >= 47) + frame = 36; + + if (frame >= 59) + { + frame = 0; + ShouldStartStandingUp = false; + } + + npc.frameCounter = 0; + } + + npc.frame.X = frame / Main.npcFrameCount[npc.type] * npc.frame.Width; + npc.frame.Y = frame % Main.npcFrameCount[npc.type] * npc.frame.Height; + } + + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + { + npc.lifeMax = 16000; + } + + public override void HitEffect(int hitDirection, double damage) + { + if (npc.life > 0) + return; + + for (int i = 1; i <= 4; i++) + { + Vector2 goreSpawnOffset = Main.rand.NextVector2Circular(12f, 12f); + Vector2 draedonPieceVelocity = Main.rand.NextVector2CircularEdge(7f, 7f) - Vector2.UnitY * 8f; + Vector2 chairPieceVelocity = Vector2.UnitY.RotatedByRandom(0.13f) * Main.rand.NextFloat(4.45f, 5.4f); + Gore.NewGoreDirect(npc.Center + goreSpawnOffset, draedonPieceVelocity, mod.GetGoreSlot($"Gores/Draedon/Draedon{i}")); + + goreSpawnOffset = Main.rand.NextVector2Circular(18f, 18f); + Gore.NewGoreDirect(npc.Center + goreSpawnOffset, chairPieceVelocity, mod.GetGoreSlot($"Gores/Draedon/Chair{i}")); + } + } + + // Always instantly kill Draedon when he's vulnerable + public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) + { + damage *= 56D; + if (damage < npc.lifeMax) + damage = npc.lifeMax + Main.rand.NextFloat(50f, 750f); + crit = true; + return true; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) + { spriteBatch.EnterShaderRegion(); Texture2D texture = Main.npcTexture[npc.type]; + Texture2D glowmask = Main.npcTexture[npc.type]; + Rectangle frame = npc.frame; + Vector2 drawPosition = npc.Center - Main.screenPosition - Vector2.UnitY * 38f; - Vector2 origin = npc.frame.Size() * 0.5f; + Vector2 origin = frame.Size() * 0.5f; Color color = npc.GetAlpha(drawColor); - SpriteEffects direction = npc.spriteDirection == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + SpriteEffects direction = npc.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; GameShaders.Misc["CalamityMod:TeleportDisplacement"].UseOpacity(MathHelper.Clamp(1f - TalkTimer / TeleportFadeinTime, 0f, 1f) * 0.38f); GameShaders.Misc["CalamityMod:TeleportDisplacement"].UseSecondaryColor(color); GameShaders.Misc["CalamityMod:TeleportDisplacement"].UseSaturation(color.A / 255f); GameShaders.Misc["CalamityMod:TeleportDisplacement"].Shader.Parameters["frameCount"].SetValue(new Vector2(2f, Main.npcFrameCount[npc.type])); GameShaders.Misc["CalamityMod:TeleportDisplacement"].Apply(); - spriteBatch.Draw(texture, drawPosition, npc.frame, Color.White * npc.Opacity, npc.rotation, origin, npc.scale, direction, 0f); + spriteBatch.Draw(texture, drawPosition, frame, drawColor * npc.Opacity, npc.rotation, origin, npc.scale, direction, 0f); spriteBatch.ExitShaderRegion(); + if (TalkTimer >= TeleportFadeinTime) + spriteBatch.Draw(glowmask, drawPosition, frame, Color.White * npc.Opacity, npc.rotation, origin, npc.scale, direction, 0f); + return false; - } - } + } + } } diff --git a/NPCs/ExoMechs/Draedon.png b/NPCs/ExoMechs/Draedon.png index 0db4c0553c..c0ec806a42 100644 Binary files a/NPCs/ExoMechs/Draedon.png and b/NPCs/ExoMechs/Draedon.png differ diff --git a/NPCs/ExoMechs/DraedonGlowmask.png b/NPCs/ExoMechs/DraedonGlowmask.png new file mode 100644 index 0000000000..ea7762e563 Binary files /dev/null and b/NPCs/ExoMechs/DraedonGlowmask.png differ diff --git a/UI/BossHealthBarManager.cs b/UI/BossHealthBarManager.cs index 565eabcaaf..516551a6cd 100644 --- a/UI/BossHealthBarManager.cs +++ b/UI/BossHealthBarManager.cs @@ -348,7 +348,7 @@ namespace CalamityMod.UI continue; bool isEoWSegment = Main.npc[i].type == NPCID.EaterofWorldsBody || Main.npc[i].type == NPCID.EaterofWorldsTail; - if ((Main.npc[i].IsABoss() && !isEoWSegment) || MinibossHPBarList.Contains(Main.npc[i].type)) + if ((Main.npc[i].IsABoss() && !isEoWSegment) || MinibossHPBarList.Contains(Main.npc[i].type) || Main.npc[i].Calamity().CanHaveBossHealthBar) AttemptToAddBar(i); }