diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index dc157b221e..20227acaa0 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -222,6 +222,7 @@ namespace CalamityMod.CalPlayer public int auralisAuroraCounter = 0; public int auralisAuroraCooldown = 0; public int auralisAurora = 0; + public int necroReviveCounter = -1; public int hideOfDeusTimer = 0; public int spiritOriginBullseyeShootCountdown = 0; public int spiritOriginConvertedCrit = 0; @@ -611,6 +612,8 @@ namespace CalamityMod.CalPlayer public int tornadoCooldown = 0; public bool eskimoSet = false; //vanilla armor public bool meteorSet = false; //vanilla armor, for space gun nerf + public bool necroSet = false; //vanilla armor + public bool frostSet = false; //vanilla armor public bool victideSet = false; public bool victideSummoner = false; public bool sulfurSet = false; @@ -1704,6 +1707,8 @@ namespace CalamityMod.CalPlayer eskimoSet = false; //vanilla armor meteorSet = false; //vanilla armor, for Space Gun nerf + necroSet = false; //vanilla armor + frostSet = false; //vanilla armor victideSet = false; victideSummoner = false; @@ -2116,6 +2121,7 @@ namespace CalamityMod.CalPlayer auralisAuroraCounter = 0; auralisAuroraCooldown = 0; auralisAurora = 0; + necroReviveCounter = -1; hideOfDeusTimer = 0; RustyMedallionCooldown = 0; SulphWaterPoisoningLevel = 0f; @@ -2387,6 +2393,8 @@ namespace CalamityMod.CalPlayer tornadoCooldown = 0; eskimoSet = false; //vanilla armor meteorSet = false; //vanilla armor, for Space Gun nerf + necroSet = false; //vanilla armor + frostSet = false; //vanilla armor victideSet = false; aeroSet = false; sulfurSet = false; @@ -3827,6 +3835,18 @@ namespace CalamityMod.CalPlayer return false; } + if (necroSet && necroReviveCounter == -1) + { + SoundEngine.PlaySound(SoundID.DD2_SkeletonDeath, Player.Center); + + necroReviveCounter = 0; // Start ticking the timer of death + Player.statLife = Player.statLifeMax2; + + if (Player.statLife < 1) + Player.statLife = 1; + return false; + } + if (permafrostsConcoction && !Player.HasCooldown(PermafrostConcoction.ID)) { Player.AddCooldown(PermafrostConcoction.ID, CalamityUtils.SecondsToFrames(180)); @@ -4269,6 +4289,21 @@ namespace CalamityMod.CalPlayer int defenseAdd = (int)(target.defense * 0.5); damage += defenseAdd; } + if (frostSet) + { + float DistanceInterpolant = Utils.GetLerpValue(FrostArmorSetChange.MinDistance, FrostArmorSetChange.MaxDistance, target.Distance(Main.player[Main.myPlayer].Center), true); + if (item.CountsAsClass()) + { + float MeleeDamageFactor = MathHelper.Lerp(1f, FrostArmorSetChange.ProximityBoost, 1 - DistanceInterpolant); + damage = (int)Math.Ceiling(damage * MeleeDamageFactor); + } + // Works with bayonets too... for the few that exists + else if (item.CountsAsClass()) + { + float RangedDamageFactor = MathHelper.Lerp(1f, FrostArmorSetChange.ProximityBoost, DistanceInterpolant); + damage = (int)Math.Ceiling(damage * RangedDamageFactor); + } + } #endregion } @@ -4353,6 +4388,20 @@ namespace CalamityMod.CalPlayer } } } + if (frostSet) + { + float DistanceInterpolant = Utils.GetLerpValue(FrostArmorSetChange.MinDistance, FrostArmorSetChange.MaxDistance, target.Distance(Main.player[proj.owner].Center), true); + if (proj.CountsAsClass()) + { + float MeleeDamageFactor = MathHelper.Lerp(1f, FrostArmorSetChange.ProximityBoost, 1 - DistanceInterpolant); + damage = (int)Math.Ceiling(damage * MeleeDamageFactor); + } + else if (proj.CountsAsClass()) + { + float RangedDamageFactor = MathHelper.Lerp(1f, FrostArmorSetChange.ProximityBoost, DistanceInterpolant); + damage = (int)Math.Ceiling(damage * RangedDamageFactor); + } + } #endregion #region MultiplicativeReductions diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 99a1cad7f8..56dd614209 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -1287,6 +1287,22 @@ namespace CalamityMod.CalPlayer } } + // Necro armor post-mortem effects. Activates regardless of having the armor equipped because it is a "delayed death" + if (necroReviveCounter >= 0) + { + necroReviveCounter++; + float ratioUntilDead = necroReviveCounter / (NecroArmorSetChange.PostMortemDuration * 60f); + int upperHealthLimit = (int)MathHelper.Lerp(Player.statLifeMax2, 1, ratioUntilDead); + + if (Player.statLife > upperHealthLimit) + Player.statLife = upperHealthLimit; + + if (necroReviveCounter >= NecroArmorSetChange.PostMortemDuration * 60) + Player.KillMe(PlayerDeathReason.ByCustomReason($"{Player.name} fell to the inevitable."), 1000, -1); + else if (necroReviveCounter % 60 == 59) + SoundEngine.PlaySound(SoundID.Item17, Player.Center); + } + // Silva invincibility effects if (silvaCountdown > 0 && hasSilvaEffect && silvaSet) { diff --git a/Items/Placeables/Furniture/CraftingStations/AltarOfTheAccursedItem.cs b/Items/Placeables/Furniture/CraftingStations/AltarOfTheAccursedItem.cs index a7c1a0ce0e..d5d6f7c45f 100644 --- a/Items/Placeables/Furniture/CraftingStations/AltarOfTheAccursedItem.cs +++ b/Items/Placeables/Furniture/CraftingStations/AltarOfTheAccursedItem.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Placeables.Furniture.CraftingStations public override void SetDefaults() { - Item.createTile = ModContent.TileType(); + Item.createTile = ModContent.TileType(); Item.useTurn = true; Item.useAnimation = 15; Item.useTime = 10; diff --git a/Items/VanillaArmorChanges/FrostArmorSetChange.cs b/Items/VanillaArmorChanges/FrostArmorSetChange.cs new file mode 100644 index 0000000000..507695e736 --- /dev/null +++ b/Items/VanillaArmorChanges/FrostArmorSetChange.cs @@ -0,0 +1,39 @@ +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.VanillaArmorChanges +{ + public class FrostArmorSetChange : VanillaArmorChange + { + public override int? HeadPieceID => ItemID.FrostHelmet; + + public override int? BodyPieceID => ItemID.FrostBreastplate; + + public override int? LegPieceID => ItemID.FrostLeggings; + + public override string ArmorSetName => "Frost"; + + public const float ProximityBoost = 1.15f; + public const float MinDistance = 160f; + public const float MaxDistance = 800f; + + public override void UpdateSetBonusText(ref string setBonusText) + { + int PercentBoost = (int)Math.Round(ProximityBoost * 100) - 100; + setBonusText = "Melee and ranged attacks inflict Frostbite\n" + + $"{PercentBoost}% increased damage which scales based on how far the target is from you\n" + + "Closer range grants melee damage, while farther range grants ranged damage"; + } + + public override void ApplyArmorSetBonus(Player player) + { + player.Calamity().frostSet = true; + + // Cancel out the old bonuses + player.GetDamage() -= 0.1f; + player.GetDamage() -= 0.1f; + } + } +} diff --git a/Items/VanillaArmorChanges/NecroArmorSetChange.cs b/Items/VanillaArmorChanges/NecroArmorSetChange.cs new file mode 100644 index 0000000000..e117cdff2a --- /dev/null +++ b/Items/VanillaArmorChanges/NecroArmorSetChange.cs @@ -0,0 +1,30 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.VanillaArmorChanges +{ + public class NecroArmorSetChange : VanillaArmorChange + { + public override int? HeadPieceID => ItemID.NecroHelmet; + + public override int? BodyPieceID => ItemID.NecroBreastplate; + + public override int? LegPieceID => ItemID.NecroGreaves; + + public override int[] AlternativeHeadPieceIDs => new int[] { ItemID.AncientNecroHelmet }; + + public override string ArmorSetName => "Necro"; + + public const int PostMortemDuration = 7; + + public override void UpdateSetBonusText(ref string setBonusText) + { + string extraLines = "\nAllows you to temporarily survive fatal damage\n" + + $"Grants up to {PostMortemDuration} seconds of life before imminent death"; + setBonusText += extraLines; + } + + public override void ApplyArmorSetBonus(Player player) => player.Calamity().necroSet = true; + } +} diff --git a/NPCs/AstrumDeus/AstrumDeusHead.cs b/NPCs/AstrumDeus/AstrumDeusHead.cs index c00405f93e..ace603f448 100644 --- a/NPCs/AstrumDeus/AstrumDeusHead.cs +++ b/NPCs/AstrumDeus/AstrumDeusHead.cs @@ -16,6 +16,7 @@ using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; +using CalamityMod.UI.VanillaBossBars; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -79,6 +80,7 @@ namespace CalamityMod.NPCs.AstrumDeus NPC.scale *= 1.2f; NPC.boss = true; + NPC.BossBar = ModContent.GetInstance(); NPC.value = Item.buyPrice(1, 0, 0, 0); NPC.alpha = 255; NPC.behindTiles = true; diff --git a/NPCs/CalClone/Cataclysm.cs b/NPCs/CalClone/Cataclysm.cs index af14001c08..68ef20fd45 100644 --- a/NPCs/CalClone/Cataclysm.cs +++ b/NPCs/CalClone/Cataclysm.cs @@ -35,6 +35,7 @@ namespace CalamityMod.NPCs.CalClone public override void SetDefaults() { + NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.Calamity().canBreakPlayerDefense = true; NPC.GetNPCDamage(); NPC.npcSlots = 5f; diff --git a/NPCs/CalClone/Catastrophe.cs b/NPCs/CalClone/Catastrophe.cs index 68e5076599..c7cc639cf9 100644 --- a/NPCs/CalClone/Catastrophe.cs +++ b/NPCs/CalClone/Catastrophe.cs @@ -35,6 +35,7 @@ namespace CalamityMod.NPCs.CalClone public override void SetDefaults() { + NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.Calamity().canBreakPlayerDefense = true; NPC.GetNPCDamage(); NPC.npcSlots = 5f; diff --git a/NPCs/CeaselessVoid/CeaselessVoid.cs b/NPCs/CeaselessVoid/CeaselessVoid.cs index b34f9d20ca..c0b4431c8f 100644 --- a/NPCs/CeaselessVoid/CeaselessVoid.cs +++ b/NPCs/CeaselessVoid/CeaselessVoid.cs @@ -10,6 +10,7 @@ using CalamityMod.Items.Potions; using CalamityMod.Items.TreasureBags; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Summon; +using CalamityMod.UI.VanillaBossBars; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -67,6 +68,7 @@ namespace CalamityMod.NPCs.CeaselessVoid NPC.noGravity = true; NPC.noTileCollide = true; NPC.boss = true; + NPC.BossBar = ModContent.GetInstance(); NPC.DeathSound = DeathSound; NPC.Calamity().VulnerableToSickness = false; } diff --git a/NPCs/Crags/CalamityEye.cs b/NPCs/Crags/CalamityEye.cs index 0de082a0ff..4f06f9f8bf 100644 --- a/NPCs/Crags/CalamityEye.cs +++ b/NPCs/Crags/CalamityEye.cs @@ -105,7 +105,7 @@ namespace CalamityMod.NPCs.Crags npcLoot.Add(ItemID.Lens, 2); LeadingConditionRule hardmode = npcLoot.DefineConditionalDropSet(DropHelper.Hardmode()); LeadingConditionRule postProv = npcLoot.DefineConditionalDropSet(DropHelper.PostProv()); - hardmode.Add(ModContent.ItemType(), 3); + hardmode.Add(ModContent.ItemType(), 2); postProv.Add(ModContent.ItemType(), 4); } } diff --git a/NPCs/Crags/CharredSlime.cs b/NPCs/Crags/CharredSlime.cs index 95d2c0e153..9af8a406e2 100644 --- a/NPCs/Crags/CharredSlime.cs +++ b/NPCs/Crags/CharredSlime.cs @@ -93,7 +93,7 @@ namespace CalamityMod.NPCs.Crags public override void ModifyNPCLoot(NPCLoot npcLoot) { npcLoot.Add(ModContent.ItemType(), 1, 10, 26); - npcLoot.Add(ModContent.ItemType(), 3); + npcLoot.Add(ModContent.ItemType(), 2); LeadingConditionRule postProv = npcLoot.DefineConditionalDropSet(DropHelper.PostProv()); postProv.Add(ModContent.ItemType(), 4); } diff --git a/NPCs/Crags/CultistAssassin.cs b/NPCs/Crags/CultistAssassin.cs index d629072267..934f0977c4 100644 --- a/NPCs/Crags/CultistAssassin.cs +++ b/NPCs/Crags/CultistAssassin.cs @@ -96,7 +96,7 @@ namespace CalamityMod.NPCs.Crags public override void ModifyNPCLoot(NPCLoot npcLoot) { - npcLoot.Add(ModContent.ItemType(), 3); + npcLoot.Add(ModContent.ItemType(), 2); LeadingConditionRule postProv = npcLoot.DefineConditionalDropSet(DropHelper.PostProv()); postProv.Add(ModContent.ItemType(), 4); } diff --git a/NPCs/Crags/DespairStone.cs b/NPCs/Crags/DespairStone.cs index 654b6c9ce2..2f7df4bd17 100644 --- a/NPCs/Crags/DespairStone.cs +++ b/NPCs/Crags/DespairStone.cs @@ -165,7 +165,7 @@ namespace CalamityMod.NPCs.Crags npcLoot.Add(ModContent.ItemType(), 5, 10, 30); LeadingConditionRule hardmode = npcLoot.DefineConditionalDropSet(DropHelper.Hardmode()); LeadingConditionRule postProv = npcLoot.DefineConditionalDropSet(DropHelper.PostProv()); - hardmode.Add(ModContent.ItemType(), 3); + hardmode.Add(ModContent.ItemType(), 2); postProv.Add(ModContent.ItemType(), 4); } diff --git a/NPCs/Crags/HeatSpirit.cs b/NPCs/Crags/HeatSpirit.cs index cf29e2cc44..651a07114f 100644 --- a/NPCs/Crags/HeatSpirit.cs +++ b/NPCs/Crags/HeatSpirit.cs @@ -118,7 +118,7 @@ namespace CalamityMod.NPCs.Crags public override void ModifyNPCLoot(NPCLoot npcLoot) { LeadingConditionRule hardmode = npcLoot.DefineConditionalDropSet(DropHelper.Hardmode()); - hardmode.Add(ModContent.ItemType(), 3); + hardmode.Add(ModContent.ItemType(), 2); } } } diff --git a/NPCs/Crags/Scryllar.cs b/NPCs/Crags/Scryllar.cs index 0adc6789c6..ac86af97b1 100644 --- a/NPCs/Crags/Scryllar.cs +++ b/NPCs/Crags/Scryllar.cs @@ -269,7 +269,7 @@ namespace CalamityMod.NPCs.Crags { LeadingConditionRule hardmode = npcLoot.DefineConditionalDropSet(DropHelper.Hardmode()); LeadingConditionRule postProv = npcLoot.DefineConditionalDropSet(DropHelper.PostProv()); - hardmode.Add(ModContent.ItemType(), 3); + hardmode.Add(ModContent.ItemType(), 2); postProv.Add(ModContent.ItemType(), 4); postProv.Add(ModContent.ItemType(), 20); } diff --git a/NPCs/Crags/SoulSlurper.cs b/NPCs/Crags/SoulSlurper.cs index 9a08e4f0fb..582f9292ff 100644 --- a/NPCs/Crags/SoulSlurper.cs +++ b/NPCs/Crags/SoulSlurper.cs @@ -297,7 +297,7 @@ namespace CalamityMod.NPCs.Crags LeadingConditionRule hardmode = npcLoot.DefineConditionalDropSet(DropHelper.Hardmode()); LeadingConditionRule postProv = npcLoot.DefineConditionalDropSet(DropHelper.PostProv()); - hardmode.Add(ModContent.ItemType(), 3); + hardmode.Add(ModContent.ItemType(), 2); postProv.Add(ModContent.ItemType(), 4); } diff --git a/NPCs/Cryogen/Cryogen.cs b/NPCs/Cryogen/Cryogen.cs index 0aa1c90ae3..5d2c00e449 100644 --- a/NPCs/Cryogen/Cryogen.cs +++ b/NPCs/Cryogen/Cryogen.cs @@ -20,6 +20,7 @@ using CalamityMod.Particles; using CalamityMod.Projectiles.Boss; using CalamityMod.Tiles.AstralSnow; using CalamityMod.Tiles.Ores; +using CalamityMod.UI.VanillaBossBars; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -93,6 +94,7 @@ namespace CalamityMod.NPCs.Cryogen NPC.knockBackResist = 0f; NPC.value = Item.buyPrice(0, 40, 0, 0); NPC.boss = true; + NPC.BossBar = ModContent.GetInstance(); NPC.noGravity = true; NPC.noTileCollide = true; NPC.coldDamage = true; diff --git a/NPCs/DesertScourge/DesertNuisanceHead.cs b/NPCs/DesertScourge/DesertNuisanceHead.cs index 59eadfcb72..39672c490e 100644 --- a/NPCs/DesertScourge/DesertNuisanceHead.cs +++ b/NPCs/DesertScourge/DesertNuisanceHead.cs @@ -39,6 +39,7 @@ namespace CalamityMod.NPCs.DesertScourge public override void SetDefaults() { + NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.Calamity().canBreakPlayerDefense = true; NPC.GetNPCDamage(); diff --git a/NPCs/ExoMechs/Apollo/Apollo.cs b/NPCs/ExoMechs/Apollo/Apollo.cs index 81a99ece0f..a6ebc685e9 100644 --- a/NPCs/ExoMechs/Apollo/Apollo.cs +++ b/NPCs/ExoMechs/Apollo/Apollo.cs @@ -166,6 +166,7 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo NPC.DeathSound = SoundID.NPCDeath14; NPC.netAlways = true; NPC.boss = true; + NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; } diff --git a/NPCs/ExoMechs/Ares/AresBody.cs b/NPCs/ExoMechs/Ares/AresBody.cs index 320d13384c..8afaa0fb43 100644 --- a/NPCs/ExoMechs/Ares/AresBody.cs +++ b/NPCs/ExoMechs/Ares/AresBody.cs @@ -17,6 +17,7 @@ using CalamityMod.NPCs.ExoMechs.Thanatos; using CalamityMod.Particles; using CalamityMod.Projectiles.Boss; using CalamityMod.Skies; +using CalamityMod.UI.VanillaBossBars; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -188,6 +189,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares NPC.DeathSound = SoundID.NPCDeath14; NPC.netAlways = true; NPC.boss = true; + NPC.BossBar = ModContent.GetInstance(); NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; } diff --git a/NPCs/ExoMechs/Artemis/Artemis.cs b/NPCs/ExoMechs/Artemis/Artemis.cs index 3187ec4cbd..320a259ea7 100644 --- a/NPCs/ExoMechs/Artemis/Artemis.cs +++ b/NPCs/ExoMechs/Artemis/Artemis.cs @@ -3,6 +3,7 @@ using CalamityMod.NPCs.ExoMechs.Ares; using CalamityMod.NPCs.ExoMechs.Thanatos; using CalamityMod.Projectiles.Boss; using CalamityMod.Skies; +using CalamityMod.UI.VanillaBossBars; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -197,6 +198,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis NPC.DeathSound = SoundID.NPCDeath14; NPC.netAlways = true; NPC.boss = true; + NPC.BossBar = ModContent.GetInstance(); NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; } diff --git a/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs b/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs index 64128e45e9..29d5401566 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs @@ -80,6 +80,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos NPC.dontCountMe = true; NPC.chaseable = false; NPC.boss = true; + NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; } diff --git a/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs b/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs index 4d0ec2bb13..b741f1ef05 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs @@ -80,6 +80,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos NPC.dontCountMe = true; NPC.chaseable = false; NPC.boss = true; + NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; } diff --git a/NPCs/ExoMechs/Thanatos/ThanatosHead.cs b/NPCs/ExoMechs/Thanatos/ThanatosHead.cs index c86a65bec2..474b64c369 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosHead.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosHead.cs @@ -3,6 +3,7 @@ using CalamityMod.Items.Potions; using CalamityMod.NPCs.ExoMechs.Ares; using CalamityMod.Particles; using CalamityMod.Projectiles.Boss; +using CalamityMod.UI.VanillaBossBars; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -165,6 +166,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos NPC.DeathSound = SoundID.NPCDeath14; NPC.netAlways = true; NPC.boss = true; + NPC.BossBar = ModContent.GetInstance(); NPC.chaseable = false; NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; diff --git a/NPCs/ExoMechs/Thanatos/ThanatosTail.cs b/NPCs/ExoMechs/Thanatos/ThanatosTail.cs index c62205fa1e..06d9168cb9 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosTail.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosTail.cs @@ -80,6 +80,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos NPC.dontCountMe = true; NPC.chaseable = false; NPC.boss = true; + NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; } diff --git a/NPCs/Leviathan/Anahita.cs b/NPCs/Leviathan/Anahita.cs index 7c33f13cc6..5b7aa5d78f 100644 --- a/NPCs/Leviathan/Anahita.cs +++ b/NPCs/Leviathan/Anahita.cs @@ -1,6 +1,7 @@ using CalamityMod.Events; using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Projectiles.Boss; +using CalamityMod.UI.VanillaBossBars; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -63,6 +64,7 @@ namespace CalamityMod.NPCs.Leviathan NPC.aiStyle = -1; AIType = -1; NPC.boss = true; + NPC.BossBar = ModContent.GetInstance(); NPC.value = Item.buyPrice(0, 60, 0, 0); NPC.noGravity = true; NPC.noTileCollide = true; diff --git a/NPCs/Leviathan/Leviathan.cs b/NPCs/Leviathan/Leviathan.cs index 22cadde2ab..9653752fb1 100644 --- a/NPCs/Leviathan/Leviathan.cs +++ b/NPCs/Leviathan/Leviathan.cs @@ -14,6 +14,7 @@ using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; using CalamityMod.Projectiles.Boss; +using CalamityMod.UI.VanillaBossBars; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -76,6 +77,7 @@ namespace CalamityMod.NPCs.Leviathan NPC.noTileCollide = true; NPC.noGravity = true; NPC.boss = true; + NPC.BossBar = ModContent.GetInstance(); NPC.netAlways = true; NPC.Calamity().VulnerableToHeat = false; NPC.Calamity().VulnerableToSickness = true; diff --git a/NPCs/Perforator/PerforatorHeadLarge.cs b/NPCs/Perforator/PerforatorHeadLarge.cs index 2b9d869f14..65d801b37f 100644 --- a/NPCs/Perforator/PerforatorHeadLarge.cs +++ b/NPCs/Perforator/PerforatorHeadLarge.cs @@ -40,6 +40,7 @@ namespace CalamityMod.NPCs.Perforator public override void SetDefaults() { + NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.Calamity().canBreakPlayerDefense = true; NPC.GetNPCDamage(); NPC.npcSlots = 5f; diff --git a/NPCs/Perforator/PerforatorHeadMedium.cs b/NPCs/Perforator/PerforatorHeadMedium.cs index 4679cf2016..f0d96c51c6 100644 --- a/NPCs/Perforator/PerforatorHeadMedium.cs +++ b/NPCs/Perforator/PerforatorHeadMedium.cs @@ -36,6 +36,7 @@ namespace CalamityMod.NPCs.Perforator public override void SetDefaults() { + NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.Calamity().canBreakPlayerDefense = true; NPC.GetNPCDamage(); NPC.npcSlots = 5f; diff --git a/NPCs/Perforator/PerforatorHeadSmall.cs b/NPCs/Perforator/PerforatorHeadSmall.cs index f27818ddef..5ba09f8a80 100644 --- a/NPCs/Perforator/PerforatorHeadSmall.cs +++ b/NPCs/Perforator/PerforatorHeadSmall.cs @@ -40,6 +40,7 @@ namespace CalamityMod.NPCs.Perforator public override void SetDefaults() { + NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.Calamity().canBreakPlayerDefense = true; NPC.GetNPCDamage(); NPC.npcSlots = 5f; diff --git a/NPCs/Polterghast/PolterPhantom.cs b/NPCs/Polterghast/PolterPhantom.cs index 517c39e17f..64570305b7 100644 --- a/NPCs/Polterghast/PolterPhantom.cs +++ b/NPCs/Polterghast/PolterPhantom.cs @@ -30,6 +30,7 @@ namespace CalamityMod.NPCs.Polterghast public override void SetDefaults() { + NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.Calamity().canBreakPlayerDefense = true; NPC.GetNPCDamage(); NPC.width = 90; diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianDefender.cs b/NPCs/ProfanedGuardians/ProfanedGuardianDefender.cs index 2ef7313209..e857fcd836 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianDefender.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianDefender.cs @@ -46,6 +46,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians public override void SetDefaults() { + NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.Calamity().canBreakPlayerDefense = true; NPC.npcSlots = 3f; NPC.aiStyle = -1; diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianHealer.cs b/NPCs/ProfanedGuardians/ProfanedGuardianHealer.cs index 51d843806d..0fecc720d0 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianHealer.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianHealer.cs @@ -59,6 +59,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians public override void SetDefaults() { + NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.Calamity().canBreakPlayerDefense = true; NPC.npcSlots = 3f; NPC.aiStyle = -1; diff --git a/NPCs/Providence/ProvSpawnDefense.cs b/NPCs/Providence/ProvSpawnDefense.cs index bbf528aaac..3c8062a3f1 100644 --- a/NPCs/Providence/ProvSpawnDefense.cs +++ b/NPCs/Providence/ProvSpawnDefense.cs @@ -27,6 +27,7 @@ namespace CalamityMod.NPCs.Providence public override void SetDefaults() { + NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.Calamity().canBreakPlayerDefense = true; NPC.npcSlots = 1f; NPC.aiStyle = -1; diff --git a/NPCs/Providence/ProvSpawnHealer.cs b/NPCs/Providence/ProvSpawnHealer.cs index c294bf0d35..bf083cee58 100644 --- a/NPCs/Providence/ProvSpawnHealer.cs +++ b/NPCs/Providence/ProvSpawnHealer.cs @@ -27,6 +27,7 @@ namespace CalamityMod.NPCs.Providence public override void SetDefaults() { + NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.npcSlots = 1f; NPC.aiStyle = -1; NPC.damage = 20; diff --git a/NPCs/Providence/ProvSpawnOffense.cs b/NPCs/Providence/ProvSpawnOffense.cs index 840a9c3fc4..f82004e85b 100644 --- a/NPCs/Providence/ProvSpawnOffense.cs +++ b/NPCs/Providence/ProvSpawnOffense.cs @@ -27,6 +27,7 @@ namespace CalamityMod.NPCs.Providence public override void SetDefaults() { + NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.Calamity().canBreakPlayerDefense = true; NPC.npcSlots = 1f; NPC.aiStyle = -1; diff --git a/NPCs/SlimeGod/CrimulanSlimeGod.cs b/NPCs/SlimeGod/CrimulanSlimeGod.cs index 3da4c135bb..5f2b8a46bc 100644 --- a/NPCs/SlimeGod/CrimulanSlimeGod.cs +++ b/NPCs/SlimeGod/CrimulanSlimeGod.cs @@ -35,6 +35,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.LifeMaxNERB(7500, 9000, 160000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; NPC.lifeMax += (int)(NPC.lifeMax * HPBoost); + NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.knockBackResist = 0f; AnimationType = NPCID.KingSlime; NPC.value = 0f; diff --git a/NPCs/SlimeGod/EbonianSlimeGod.cs b/NPCs/SlimeGod/EbonianSlimeGod.cs index 2aab009cde..08dbb444e4 100644 --- a/NPCs/SlimeGod/EbonianSlimeGod.cs +++ b/NPCs/SlimeGod/EbonianSlimeGod.cs @@ -35,6 +35,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.LifeMaxNERB(8000, 9600, 220000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; NPC.lifeMax += (int)(NPC.lifeMax * HPBoost); + NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; diff --git a/NPCs/SlimeGod/SlimeGodCore.cs b/NPCs/SlimeGod/SlimeGodCore.cs index 6c3d1f187d..0ca86ea7af 100644 --- a/NPCs/SlimeGod/SlimeGodCore.cs +++ b/NPCs/SlimeGod/SlimeGodCore.cs @@ -14,6 +14,7 @@ using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Summon; using CalamityMod.NPCs.TownNPCs; using CalamityMod.Projectiles.Boss; +using CalamityMod.UI.VanillaBossBars; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -68,6 +69,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.value = Item.buyPrice(0, 25, 0, 0); NPC.Opacity = 0.8f; NPC.boss = true; + NPC.BossBar = ModContent.GetInstance(); NPC.noGravity = true; NPC.noTileCollide = true; NPC.dontTakeDamage = true; diff --git a/NPCs/SlimeGod/SplitCrimulanSlimeGod.cs b/NPCs/SlimeGod/SplitCrimulanSlimeGod.cs index c2b120d2ac..a2fdc09278 100644 --- a/NPCs/SlimeGod/SplitCrimulanSlimeGod.cs +++ b/NPCs/SlimeGod/SplitCrimulanSlimeGod.cs @@ -39,6 +39,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.LifeMaxNERB(1875, 2250, 80000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; NPC.lifeMax += (int)(NPC.lifeMax * HPBoost); + NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.GetNPCDamage(); NPC.width = 150; NPC.height = 92; diff --git a/NPCs/SlimeGod/SplitEbonianSlimeGod.cs b/NPCs/SlimeGod/SplitEbonianSlimeGod.cs index a60ba8dd54..8a5e4942c3 100644 --- a/NPCs/SlimeGod/SplitEbonianSlimeGod.cs +++ b/NPCs/SlimeGod/SplitEbonianSlimeGod.cs @@ -39,6 +39,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.LifeMaxNERB(2000, 2400, 110000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; NPC.lifeMax += (int)(NPC.lifeMax * HPBoost); + NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.GetNPCDamage(); NPC.width = 150; NPC.height = 92; diff --git a/NPCs/SupremeCalamitas/SupremeCataclysm.cs b/NPCs/SupremeCalamitas/SupremeCataclysm.cs index 44938a6aa0..bec75d3832 100644 --- a/NPCs/SupremeCalamitas/SupremeCataclysm.cs +++ b/NPCs/SupremeCalamitas/SupremeCataclysm.cs @@ -56,6 +56,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas public override void SetDefaults() { + NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.damage = 0; NPC.npcSlots = 5f; NPC.width = 120; diff --git a/NPCs/SupremeCalamitas/SupremeCatastrophe.cs b/NPCs/SupremeCalamitas/SupremeCatastrophe.cs index 58679d1848..1b00361bfe 100644 --- a/NPCs/SupremeCalamitas/SupremeCatastrophe.cs +++ b/NPCs/SupremeCalamitas/SupremeCatastrophe.cs @@ -48,6 +48,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas public override void SetDefaults() { + NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.damage = 0; NPC.npcSlots = 5f; NPC.width = 120; diff --git a/Tiles/Furniture/CraftingStations/SCalAltar.cs b/Tiles/Furniture/CraftingStations/SCalAltar.cs index 7f875c2668..1d21c37f36 100644 --- a/Tiles/Furniture/CraftingStations/SCalAltar.cs +++ b/Tiles/Furniture/CraftingStations/SCalAltar.cs @@ -62,7 +62,22 @@ namespace CalamityMod.Tiles.Furniture.CraftingStations Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, Width * 16, Height * 16, ModContent.ItemType()); } - public override bool RightClick(int i, int j) + public override bool RightClick(int i, int j) => AttemptToSummonSCal(i, j); + public override void MouseOver(int i, int j) => HoverItemIcon(); + public override void MouseOverFar(int i, int j) => HoverItemIcon(); + + public static void HoverItemIcon() + { + if (Main.LocalPlayer.HasItem(ModContent.ItemType())) + Main.LocalPlayer.cursorItemIconID = ModContent.ItemType(); + else + Main.LocalPlayer.cursorItemIconID = ModContent.ItemType(); + + Main.LocalPlayer.noThrow = 2; + Main.LocalPlayer.cursorItemIconEnabled = true; + } + + public static bool AttemptToSummonSCal(int i, int j) { Tile tile = Main.tile[i, j]; @@ -91,30 +106,57 @@ namespace CalamityMod.Tiles.Furniture.CraftingStations if (!usingSpecialItem) Main.LocalPlayer.ConsumeItem(ModContent.ItemType(), true); + return true; + } + } + public class SCalAltarLarge : ModTile + { + public const int Width = 5; + public const int Height = 3; + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoAttach[Type] = true; + Main.tileLavaDeath[Type] = false; + + // Various data sets to protect this tile from unintentional death + TileID.Sets.PreventsTileRemovalIfOnTopOfIt[Type] = true; + //TileID.Sets.PreventsTileReplaceIfOnTopOfIt[Type] = true; Since this is a furniture item this may be unnecessary? + TileID.Sets.PreventsSandfall[Type] = true; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.Width = 5; + TileObjectData.newTile.Height = 3; + TileObjectData.newTile.Origin = new Point16(1, 2); + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16 }; + TileObjectData.newTile.DrawYOffset = 2; + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.LavaDeath = false; + TileObjectData.addTile(Type); + ModTranslation name = CreateMapEntryName(); + name.SetDefault("Altar"); + AddMapEntry(new Color(43, 19, 42), name); + TileID.Sets.DisableSmartCursor[Type] = true; + } + + public override bool CanExplode(int i, int j) => false; + + public override bool CreateDust(int i, int j, ref int type) + { + // Red torch dust. + type = 60; return true; } - public override void MouseOver(int i, int j) + public override void KillMultiTile(int i, int j, int frameX, int frameY) { - if (Main.LocalPlayer.HasItem(ModContent.ItemType())) - Main.LocalPlayer.cursorItemIconID = ModContent.ItemType(); - else - Main.LocalPlayer.cursorItemIconID = ModContent.ItemType(); - - Main.LocalPlayer.noThrow = 2; - Main.LocalPlayer.cursorItemIconEnabled = true; + Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, Width * 16, Height * 16, ModContent.ItemType()); } - public override void MouseOverFar(int i, int j) - { - if (Main.LocalPlayer.HasItem(ModContent.ItemType())) - Main.LocalPlayer.cursorItemIconID = ModContent.ItemType(); - else - Main.LocalPlayer.cursorItemIconID = ModContent.ItemType(); - - Main.LocalPlayer.noThrow = 2; - Main.LocalPlayer.cursorItemIconEnabled = true; - } + public override bool RightClick(int i, int j) => SCalAltar.AttemptToSummonSCal(i, j); + public override void MouseOver(int i, int j) => SCalAltar.HoverItemIcon(); + public override void MouseOverFar(int i, int j) => SCalAltar.HoverItemIcon(); } } diff --git a/Tiles/Furniture/CraftingStations/SCalAltarLarge.png b/Tiles/Furniture/CraftingStations/SCalAltarLarge.png new file mode 100644 index 0000000000..5663969f59 Binary files /dev/null and b/Tiles/Furniture/CraftingStations/SCalAltarLarge.png differ diff --git a/UI/VanillaBossBars/AstrumDeusBossBar.cs b/UI/VanillaBossBars/AstrumDeusBossBar.cs new file mode 100644 index 0000000000..218d462908 --- /dev/null +++ b/UI/VanillaBossBars/AstrumDeusBossBar.cs @@ -0,0 +1,72 @@ +using CalamityMod.NPCs.AstrumDeus; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using System; +using System.Collections.Generic; +using Terraria; +using Terraria.GameContent; +using Terraria.GameContent.UI.BigProgressBar; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.UI.VanillaBossBars +{ + public class AstrumDeusBossBar : ModBossBar + { + public override Asset GetIconTexture(ref Rectangle? iconFrame) => TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[NPCType()]]; + + public override bool? ModifyInfo(ref BigProgressBarInfo info, ref float lifePercent, ref float shieldPercent) + { + NPC target = Main.npc[info.npcIndexToAimAt]; + if (!target.active && !FindMoreWorms(ref info)) + return false; + + int life = 0; + int lifeMax = 0; + + // Determine the real health by finding more of itself + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC worm = Main.npc[i]; + if (worm.active && worm.type == target.type) + { + // In Death Mode, every worm must be killed + if (CalamityWorld.death) + { + life += worm.life; + lifeMax += worm.lifeMax; + } + // Otherwise, find the minimum + else + { + if (life <= 0) + life = worm.life; + else + life = Math.Min(life, worm.life); + + lifeMax = worm.lifeMax; + } + } + } + lifePercent = Utils.Clamp(life / (float)lifeMax, 0f, 1f); + return true; + } + + public bool FindMoreWorms(ref BigProgressBarInfo info) + { + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC target = Main.npc[i]; + if (target.active && target.type == NPCType()) + { + info.npcIndexToAimAt = i; + return true; + } + } + return false; + } + } +} \ No newline at end of file diff --git a/UI/VanillaBossBars/CeaselessVoidBossBar.cs b/UI/VanillaBossBars/CeaselessVoidBossBar.cs new file mode 100644 index 0000000000..d8f4d8b705 --- /dev/null +++ b/UI/VanillaBossBars/CeaselessVoidBossBar.cs @@ -0,0 +1,59 @@ +using CalamityMod.NPCs.CeaselessVoid; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using System; +using System.Collections.Generic; +using Terraria; +using Terraria.GameContent; +using Terraria.GameContent.UI.BigProgressBar; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.UI.VanillaBossBars +{ + public class CeaselessVoidBossBar : ModBossBar + { + // Used to determine the max health of a multi-segmented boss + public NPC FalseNPCSegment; + + public override Asset GetIconTexture(ref Rectangle? iconFrame) => TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[NPCType()]]; + + public override bool? ModifyInfo(ref BigProgressBarInfo info, ref float lifePercent, ref float shieldPercent) + { + NPC target = Main.npc[info.npcIndexToAimAt]; + if (!target.active) + return false; + + // Normal boss health + lifePercent = Utils.Clamp(target.life / (float)target.lifeMax, 0f, 1f); + + // Determine the shield health + int shield = 0; + int shieldMax = 0; + // Amount of Dark Energies expected from each phase/difficulty + int ExpectedBallsCounter = ((lifePercent <= 0.1f ? 3 : lifePercent <= 0.4f ? 2 : lifePercent <= 0.7f ? 1 : 0) + (CalamityWorld.death ? 6 : CalamityWorld.revenge ? 5 : Main.expertMode ? 4 : 3)) * (Main.getGoodWorld ? 6 : 3) + 2; + // The Dark Energies will instantly all die at a certain point of their total max health + float RatioToCombust = 0.2f; + if (NPC.AnyNPCs(NPCType())) + { + // Add max shield by feeding the data of false NPCs + FalseNPCSegment = new NPC(); + FalseNPCSegment.SetDefaults(NPCType(), target.GetMatchingSpawnParams()); + shieldMax = (int)(FalseNPCSegment.lifeMax * ExpectedBallsCounter * (1 - RatioToCombust)); + shield -= (int)(FalseNPCSegment.lifeMax * ExpectedBallsCounter * RatioToCombust); + + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC part = Main.npc[i]; + if (part.active && part.type == NPCType()) + shield += part.life; + } + } + shieldPercent = Utils.Clamp(shield / (float)shieldMax, 0f, 1f); + return true; + } + } +} \ No newline at end of file diff --git a/UI/VanillaBossBars/CryogenBossBar.cs b/UI/VanillaBossBars/CryogenBossBar.cs new file mode 100644 index 0000000000..215a36bb1c --- /dev/null +++ b/UI/VanillaBossBars/CryogenBossBar.cs @@ -0,0 +1,52 @@ +using CalamityMod.NPCs.Cryogen; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using System; +using System.Collections.Generic; +using Terraria; +using Terraria.GameContent; +using Terraria.GameContent.UI.BigProgressBar; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.UI.VanillaBossBars +{ + public class CryogenBossBar : ModBossBar + { + public override Asset GetIconTexture(ref Rectangle? iconFrame) + { + // Pyrogen moment + if (CalamityWorld.getFixedBoi) + return ModContent.Request("CalamityMod/NPCs/Cryogen/Pyrogen_Head_Boss"); + return ModContent.Request("CalamityMod/NPCs/Cryogen/Cryogen_Phase1_Head_Boss"); + } + + public override bool? ModifyInfo(ref BigProgressBarInfo info, ref float lifePercent, ref float shieldPercent) + { + NPC target = Main.npc[info.npcIndexToAimAt]; + if (!target.active) + return false; + + // Normal boss health + lifePercent = Utils.Clamp(target.life / (float)target.lifeMax, 0f, 1f); + + // Determine the shield health + int shield = 0; + int shieldMax = 0; + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC part = Main.npc[i]; + if (part.active && part.type == NPCType()) + { + shield += part.life; + shieldMax += part.lifeMax; + } + } + shieldPercent = Utils.Clamp(shield / (float)shieldMax, 0f, 1f); + return true; + } + } +} \ No newline at end of file diff --git a/UI/VanillaBossBars/ExoMechsBossBar.cs b/UI/VanillaBossBars/ExoMechsBossBar.cs new file mode 100644 index 0000000000..64d0dc01d1 --- /dev/null +++ b/UI/VanillaBossBars/ExoMechsBossBar.cs @@ -0,0 +1,152 @@ +using CalamityMod.NPCs.ExoMechs.Ares; +using CalamityMod.NPCs.ExoMechs.Artemis; +using CalamityMod.NPCs.ExoMechs.Thanatos; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using System; +using System.Collections.Generic; +using Terraria; +using Terraria.GameContent; +using Terraria.GameContent.UI.BigProgressBar; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.UI.VanillaBossBars +{ + public class ExoMechsBossBar : ModBossBar + { + // Artemis will always be used to check twins, Apollo is there in spirit + // For showing the correct boss icon when bosses go into solo + public bool HideAres = false; + public bool HideArtemis = false; + public bool HideThanatos = false; + + // For properly showing the first phase health + public bool AllBossesSpawned = false; + + // Used to determine the max health of a multi-segmented boss + public NPC FalseNPCSegment; + + public override Asset GetIconTexture(ref Rectangle? iconFrame) + { + // Prioritize based on which boss(es) are hidden + if (HideArtemis && HideThanatos && !HideAres) + return TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[NPCType()]]; + if (HideAres && HideThanatos && !HideArtemis) + return ModContent.Request("CalamityMod/NPCs/ExoMechs/Artemis/ArtemisHead"); + if (HideAres && HideArtemis && !HideThanatos) + return ModContent.Request("CalamityMod/NPCs/ExoMechs/Thanatos/ThanatosNormalHead"); + // Otherwise, just run through alphabet sorting: Ares, Artemis, Thanatos + if (!HideAres) + return TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[NPCType()]]; + if (!HideArtemis) + return ModContent.Request("CalamityMod/NPCs/ExoMechs/Artemis/ArtemisHead"); + return ModContent.Request("CalamityMod/NPCs/ExoMechs/Thanatos/ThanatosNormalHead"); + } + + public override bool? ModifyInfo(ref BigProgressBarInfo info, ref float lifePercent, ref float shieldPercent) + { + ValidateAllMechs(ref info); + NPC target = Main.npc[info.npcIndexToAimAt]; + + if (!target.active && !FindMechsAgain(ref info)) + return false; + + // Immediately grab the boss's health, whichever one it is. We will check later. + int life = target.life; + int lifeMax = target.lifeMax; + + // Checking for all bosses + if (NPC.AnyNPCs(NPCType()) && NPC.AnyNPCs(NPCType()) && NPC.AnyNPCs(NPCType())) + AllBossesSpawned = true; + + // Only run this after the first phase, where every boss has spawned + if (AllBossesSpawned) + { + // Override max health by feeding the data of false NPCs + FalseNPCSegment = new NPC(); + FalseNPCSegment.SetDefaults(NPCType(), target.GetMatchingSpawnParams()); + lifeMax = FalseNPCSegment.lifeMax; + FalseNPCSegment.SetDefaults(NPCType(), target.GetMatchingSpawnParams()); + lifeMax += FalseNPCSegment.lifeMax; + FalseNPCSegment.SetDefaults(NPCType(), target.GetMatchingSpawnParams()); + lifeMax += FalseNPCSegment.lifeMax; + + // Find the others + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC ecco = Main.npc[i]; + if (ecco.active && ecco.type == NPCType() && target.type != NPCType()) + life += ecco.life; + + if (ecco.active && ecco.type == NPCType() && target.type != NPCType()) + life += ecco.life; + + if (ecco.active && ecco.type == NPCType() && target.type != NPCType()) + life += ecco.life; + } + } + lifePercent = Utils.Clamp(life / (float)lifeMax, 0f, 1f); + return true; + } + + public void ValidateAllMechs(ref BigProgressBarInfo info) + { + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC target = Main.npc[i]; + // Find out first whether or not each of the mechs are in hiding + if (target.type == NPCType()) + HideAres = target.Opacity < 0.5f; + if (target.type == NPCType()) + HideArtemis = target.Opacity < 0.5f; + if (target.type == NPCType()) + HideThanatos = target.Opacity < 0.5f; + } + + // Manually re-hide bosses once they commit die + if (!NPC.AnyNPCs(NPCType())) + HideAres = true; + if (!NPC.AnyNPCs(NPCType())) + HideArtemis = true; + if (!NPC.AnyNPCs(NPCType())) + HideThanatos = true; + } + + public bool FindMechsAgain(ref BigProgressBarInfo info) + { + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC target = Main.npc[i]; + if (target.active) + { + // Get the index of the mech that's not hiding + if (target.type == NPCType() && !HideAres) + { + info.npcIndexToAimAt = i; + return true; + } + else if (target.type == NPCType() && !HideArtemis) + { + info.npcIndexToAimAt = i; + return true; + } + else if (target.type == NPCType() && !HideThanatos) + { + info.npcIndexToAimAt = i; + return true; + } + // Failsafe + else if (target.type == NPCType() || target.type == NPCType() || target.type == NPCType()) + { + info.npcIndexToAimAt = i; + return true; + } + } + } + return false; + } + } +} \ No newline at end of file diff --git a/UI/VanillaBossBars/LeviathanAnahitaBossBar.cs b/UI/VanillaBossBars/LeviathanAnahitaBossBar.cs new file mode 100644 index 0000000000..e6ed6a8a80 --- /dev/null +++ b/UI/VanillaBossBars/LeviathanAnahitaBossBar.cs @@ -0,0 +1,88 @@ +using CalamityMod.NPCs.Leviathan; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using System; +using System.Collections.Generic; +using Terraria; +using Terraria.GameContent; +using Terraria.GameContent.UI.BigProgressBar; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.UI.VanillaBossBars +{ + public class LeviathanAnahitaBossBar : ModBossBar + { + public override Asset GetIconTexture(ref Rectangle? iconFrame) + { + // Prevent icon seizures by prioritizing Leviathan first + if (NPC.AnyNPCs(NPCType())) + return TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[NPCType()]]; + return TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[NPCType()]]; + } + + public override bool? ModifyInfo(ref BigProgressBarInfo info, ref float lifePercent, ref float shieldPercent) + { + NPC target = Main.npc[info.npcIndexToAimAt]; + + if (!target.active && !FindTheRightFish(ref info)) + return false; + + // Immediately grab the boss's health, whichever one it is. We will check later. + int life = target.life; + int lifeMax = target.lifeMax; + + // Find the partner in question + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC wife = Main.npc[i]; + int targetCouple = target.type == NPCType() ? NPCType() : NPCType(); + if (wife.active && wife.type == targetCouple) + { + life += wife.life; + lifeMax += wife.lifeMax; + } + } + lifePercent = Utils.Clamp(life / (float)lifeMax, 0f, 1f); + + // Determine Anahita's shield health only if she's solo (she can't just block Leviathan out of existence) + int shield = 0; + int shieldMax = 0; + if (target.type == NPCType() && !NPC.AnyNPCs(NPCType())) + { + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC part = Main.npc[i]; + if (part.active && part.type == NPCType()) + { + shield += part.life; + shieldMax += part.lifeMax; + } + } + } + shieldPercent = Utils.Clamp(shield / (float)shieldMax, 0f, 1f); + return true; + } + + public bool FindTheRightFish(ref BigProgressBarInfo info) + { + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC target = Main.npc[i]; + if (target.active && target.type == NPCType()) + { + info.npcIndexToAimAt = i; + return true; + } + else if (target.active && target.type == NPCType()) + { + info.npcIndexToAimAt = i; + return true; + } + } + return false; + } + } +} \ No newline at end of file diff --git a/UI/VanillaBossBars/RavagerBossBar.cs b/UI/VanillaBossBars/RavagerBossBar.cs index d58c3bf189..1401fcf55c 100644 --- a/UI/VanillaBossBars/RavagerBossBar.cs +++ b/UI/VanillaBossBars/RavagerBossBar.cs @@ -15,8 +15,6 @@ namespace CalamityMod.UI.VanillaBossBars { public class RavagerBossBar : ModBossBar { - public override Asset GetIconTexture(ref Rectangle? iconFrame) => TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[NPCType()]]; - // Used to determine the max health of a multi-segmented boss public NPC FalseNPCSegment; public List RavagerParts = new List @@ -28,6 +26,8 @@ namespace CalamityMod.UI.VanillaBossBars NPCType() }; + public override Asset GetIconTexture(ref Rectangle? iconFrame) => TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[NPCType()]]; + public override bool? ModifyInfo(ref BigProgressBarInfo info, ref float lifePercent, ref float shieldPercent) { NPC target = Main.npc[info.npcIndexToAimAt]; diff --git a/UI/VanillaBossBars/SlimeGodBossBar.cs b/UI/VanillaBossBars/SlimeGodBossBar.cs new file mode 100644 index 0000000000..d630f20483 --- /dev/null +++ b/UI/VanillaBossBars/SlimeGodBossBar.cs @@ -0,0 +1,59 @@ +using CalamityMod.NPCs.SlimeGod; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using System; +using System.Collections.Generic; +using Terraria; +using Terraria.GameContent; +using Terraria.GameContent.UI.BigProgressBar; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.UI.VanillaBossBars +{ + public class SlimeGodBossBar : ModBossBar + { + // Used to determine the max health of a multi-segmented boss + public NPC FalseNPCSegment; + public List SlimeGodSlimes = new List + { + NPCType(), + NPCType(), + NPCType(), + NPCType() + }; + + public override Asset GetIconTexture(ref Rectangle? iconFrame) => TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[NPCType()]]; + + public override bool? ModifyInfo(ref BigProgressBarInfo info, ref float lifePercent, ref float shieldPercent) + { + NPC target = Main.npc[info.npcIndexToAimAt]; + if (!target.active) + return false; + + int life = 0; + int lifeMax = 0; + FalseNPCSegment = new NPC(); + + // Add max health by feeding the data of false NPCs + FalseNPCSegment.SetDefaults(NPCType(), target.GetMatchingSpawnParams()); + lifeMax += FalseNPCSegment.lifeMax; + FalseNPCSegment.SetDefaults(NPCType(), target.GetMatchingSpawnParams()); + lifeMax += FalseNPCSegment.lifeMax; + + // Determine the current health of each slime + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC part = Main.npc[i]; + if (part.active && SlimeGodSlimes.Contains(part.type)) + { + life += part.life; + } + } + lifePercent = Utils.Clamp(life / (float)lifeMax, 0f, 1f); + return true; + } + } +} \ No newline at end of file