diff --git a/Localization/en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson b/Localization/en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson index 8a48f4a9fc..35c60fa863 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson @@ -166,7 +166,7 @@ FathomSwarmerVisage: { {$CommonItemTooltip.IncreasesMaxMinionsBy} {$CommonItemTooltip.PercentIncreasedSummonDamage@1} Provides breathing and light underwater - Greatly enhances visibility in the abyss + Greatly enhances visibility in the abyss ''' SetBonus: ''' @@ -446,7 +446,7 @@ ReaverHeadExplore: { ''' Emits light and shows the location of treasure and ore {$Common.AggroReduction} and grants underwater breathing - Greatly enhances visibility in the abyss + Greatly enhances visibility in the abyss Increased block placement & tool range by {0} Increases pickup range for items ''' diff --git a/Localization/en-US/Mods.CalamityMod.Items.Fishing.hjson b/Localization/en-US/Mods.CalamityMod.Items.Fishing.hjson index 5e2a3dba02..01bff6009c 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Fishing.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Fishing.hjson @@ -175,7 +175,7 @@ RustedJingleBell: { ''' Summons a baby ghost bell to light the way for you Provides a moderate amount of light while underwater - {$Common.AbyssLightLevel} + {$Common.AbyssLightLevel} ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Pets.hjson b/Localization/en-US/Mods.CalamityMod.Items.Pets.hjson index fd9a313a46..12e02b0929 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Pets.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Pets.hjson @@ -163,7 +163,7 @@ StrangeOrb: { ''' Summons a miniature Ocean Spirit light pet Provides a large amount of light while underwater - {$Common.AbyssLightLevel} + {$Common.AbyssLightLevel} ''' } diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 0397a4b12b..32c967dc5f 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -76,6 +76,7 @@ using Terraria.GameContent; using Terraria.GameContent.Achievements; using Terraria.GameContent.Bestiary; using Terraria.GameContent.Events; +using Terraria.GameContent.UI.BigProgressBar; using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; @@ -1235,9 +1236,13 @@ namespace CalamityMod.NPCs VulnerabilitiesAndResistances(npc); - //Gives Brain of Cthulhu a unique boss bar in Rev+ where Creepers contribute to a Shield rather than additional Health + // Gives Brain of Cthulhu a unique boss bar in Rev+ where Creepers contribute to a Shield rather than additional Health if (npc.type == NPCID.BrainofCthulhu && CalamityWorld.revenge) npc.BossBar = GetInstance(); + // Replaces Moon Lord's boss bar in Rev+ to fix a health counting bug with the eyes after being killed + bool hasBar = Main.BigBossProgressBar.TryGetSpecialVanillaBossBar(npc.type, out IBigProgressBar bar); + if (hasBar && bar is MoonLordProgressBar && CalamityWorld.revenge) + npc.BossBar = GetInstance(); } public override bool? CanFallThroughPlatforms(NPC npc) diff --git a/UI/VanillaBossBars/RevMoonLordBossBar.cs b/UI/VanillaBossBars/RevMoonLordBossBar.cs new file mode 100644 index 0000000000..d90123097e --- /dev/null +++ b/UI/VanillaBossBars/RevMoonLordBossBar.cs @@ -0,0 +1,81 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using System.Collections.Generic; +using Terraria; +using Terraria.GameContent; +using Terraria.GameContent.UI.BigProgressBar; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.UI.VanillaBossBars +{ + internal class RevMoonLordBossBar : ModBossBar + { + private List MoonLordPartIDs = [NPCID.MoonLordCore, NPCID.MoonLordHead, NPCID.MoonLordHand]; + private NPC _dummy; + + public override void SetStaticDefaults() + { + _dummy = new NPC(); + } + public override Asset GetIconTexture(ref Rectangle? iconFrame) => TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[NPCID.MoonLordHead]]; + + public override bool? ModifyInfo(ref BigProgressBarInfo info, ref float life, ref float lifeMax, ref float shield, ref float shieldMax) + { + NPC target = Main.npc[info.npcIndexToAimAt]; + if ((!target.active || InBadAI(target)) && !TryFindingAnotherMoonLordPiece(ref info)) + return false; + + life = 0f; + lifeMax = 0f; + shield = 0f; + shieldMax = 0f; + + NPCSpawnParams dummy = default; + dummy.strengthMultiplierOverride = target.strengthMultiplier; + dummy.playerCountForMultiplayerDifficultyOverride = target.statsAreScaledForThisManyPlayers; + _dummy.SetDefaults(NPCID.MoonLordCore, dummy); + lifeMax += _dummy.lifeMax; + _dummy.SetDefaults(NPCID.MoonLordHead, dummy); + lifeMax += _dummy.lifeMax; + _dummy.SetDefaults(NPCID.MoonLordHand, dummy); + lifeMax += _dummy.lifeMax * 2; + + // Find all the Moon Lord parts, and add their totals. Do not add them if in a "bad AI" state. + foreach (NPC n in Main.ActiveNPCs) + { + if (MoonLordPartIDs.Contains(n.type) && !InBadAI(n)) + { + life += n.life; + } + } + + return true; + } + + private static bool InBadAI(NPC n) + { + // If in death animation, or in initial startup state + if (n.type == NPCID.MoonLordCore && (n.ai[0] == 2f || n.ai[0] == -1f || n.localAI[3] == 0f)) + return true; + // If in death animation, or this eye has been "killed" + if (n.ai[0] == -2f || n.ai[0] == -3f || n.Calamity().newAI[0] == 1f) + return true; + return false; + } + + private bool TryFindingAnotherMoonLordPiece(ref BigProgressBarInfo info) + { + foreach (NPC n in Main.ActiveNPCs) + { + if (MoonLordPartIDs.Contains(n.type) && !InBadAI(n)) + { + info.npcIndexToAimAt = n.whoAmI; + return true; + } + } + return false; + } + } +}