From 489fca00fd73baa14b699cd234ae841af1c56cc8 Mon Sep 17 00:00:00 2001 From: DominicKarma <51094361+DominicKarma@users.noreply.github.com> Date: Tue, 1 Feb 2022 17:13:13 -0600 Subject: [PATCH] Armor set system streamlining and cobalt set rework --- CalPlayer/CalamityPlayer.cs | 13 +- CalPlayer/CalamityPlayerDrawEffects.cs | 1362 ++++---- CalPlayer/CalamityPlayerMiscEffects.cs | 5 + CalamityMod.cs | 29 +- Items/CalamityGlobalItem.cs | 2947 ++++++++--------- Items/CalamityGlobalItemTooltip.cs | 1996 ++++++----- Items/CalamityGlobalItemTweaks.cs | 5 + .../CobaltArmorSetChange.cs | 55 + .../CopperArmorSetChange.cs | 25 + .../EskimoArmorSetChange.cs | 43 + .../GladiatorArmorSetChange.cs | 56 + .../VanillaArmorChanges/GoldArmorSetChange.cs | 25 + .../VanillaArmorChanges/IronArmorSetChange.cs | 27 + .../VanillaArmorChanges/LeadArmorSetChange.cs | 25 + .../MeteorArmorSetChange.cs | 28 + .../MoltenArmorSetChange.cs | 34 + .../MonkT2ArmorSetChange.cs | 47 + .../ObsidianArmorSetChange.cs | 61 + .../PlatinumArmorSetChange.cs | 25 + .../SilverArmorSetChange.cs | 25 + .../StardustArmorSetChange.cs | 26 + .../VanillaArmorChanges/TinArmorSetChange.cs | 25 + .../TungstenArmorSetChange.cs | 25 + .../VanillaArmorChanges/VanillaArmorChange.cs | 61 + .../VanillaArmorChangeManager.cs | 77 + 25 files changed, 3808 insertions(+), 3239 deletions(-) create mode 100644 Items/VanillaArmorChanges/CobaltArmorSetChange.cs create mode 100644 Items/VanillaArmorChanges/CopperArmorSetChange.cs create mode 100644 Items/VanillaArmorChanges/EskimoArmorSetChange.cs create mode 100644 Items/VanillaArmorChanges/GladiatorArmorSetChange.cs create mode 100644 Items/VanillaArmorChanges/GoldArmorSetChange.cs create mode 100644 Items/VanillaArmorChanges/IronArmorSetChange.cs create mode 100644 Items/VanillaArmorChanges/LeadArmorSetChange.cs create mode 100644 Items/VanillaArmorChanges/MeteorArmorSetChange.cs create mode 100644 Items/VanillaArmorChanges/MoltenArmorSetChange.cs create mode 100644 Items/VanillaArmorChanges/MonkT2ArmorSetChange.cs create mode 100644 Items/VanillaArmorChanges/ObsidianArmorSetChange.cs create mode 100644 Items/VanillaArmorChanges/PlatinumArmorSetChange.cs create mode 100644 Items/VanillaArmorChanges/SilverArmorSetChange.cs create mode 100644 Items/VanillaArmorChanges/StardustArmorSetChange.cs create mode 100644 Items/VanillaArmorChanges/TinArmorSetChange.cs create mode 100644 Items/VanillaArmorChanges/TungstenArmorSetChange.cs create mode 100644 Items/VanillaArmorChanges/VanillaArmorChange.cs create mode 100644 Items/VanillaArmorChanges/VanillaArmorChangeManager.cs diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index f4f419856f..c237e5cc1a 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -18,6 +18,7 @@ using CalamityMod.Items.Mounts; using CalamityMod.Items.Mounts.Minecarts; using CalamityMod.Items.Tools; using CalamityMod.Items.TreasureBags; +using CalamityMod.Items.VanillaArmorChanges; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; @@ -104,7 +105,7 @@ namespace CalamityMod.CalPlayer public int waterLeechTarget = -1; public float KameiTrailXScale = 0.1f; public int KameiBladeUseDelay = 0; - public Vector2[] KameiOldPositions = new Vector2[4]; + public Vector2[] OldPositions = new Vector2[4]; public double trueMeleeDamage = 0D; public double contactDamageReduction = 0D; public double projectileDamageReduction = 0D; @@ -800,6 +801,7 @@ namespace CalamityMod.CalPlayer public bool chaosSpirit = false; public bool redDevil = false; public bool GemTechSet = false; + public bool CobaltSet = false; private GemTechArmorState gemTechState; public GemTechArmorState GemTechState { @@ -1601,6 +1603,8 @@ namespace CalamityMod.CalPlayer GemTechSet = false; + CobaltSet = false; + omegaBlueChestplate = false; omegaBlueSet = false; omegaBlueHentai = false; @@ -2443,6 +2447,7 @@ namespace CalamityMod.CalPlayer silvaCountdown = silvaReviveDuration; auricSet = false; GemTechSet = false; + CobaltSet = false; omegaBlueChestplate = false; omegaBlueSet = false; omegaBlueCooldown = 0; @@ -4076,7 +4081,8 @@ namespace CalamityMod.CalPlayer ((frostFlare && player.statLife < (int)(player.statLifeMax2 * 0.25)) ? 0.15f : 0f) + (dragonScales ? 0.1f : 0f) + (kamiBoost ? KamiBuff.RunAccelerationBoost : 0f) + - (silvaSet ? 0.05f : 0f) + + (CobaltSet ? CobaltArmorSetChange.SpeedBoostSetBonusPercentage * 0.01f : 0f) + + (silvaSet ? 0.05f : 0f) + (blueCandle ? 0.05f : 0f) + (planarSpeedBoost > 0 ? (0.01f * planarSpeedBoost) : 0f) + ((deepDiver && player.IsUnderwater()) ? 0.15f : 0f) + @@ -4090,7 +4096,8 @@ namespace CalamityMod.CalPlayer ((frostFlare && player.statLife < (int)(player.statLifeMax2 * 0.25)) ? 0.15f : 0f) + (dragonScales ? 0.1f : 0f) + (kamiBoost ? KamiBuff.RunSpeedBoost : 0f) + - (silvaSet ? 0.05f : 0f) + + (CobaltSet ? CobaltArmorSetChange.SpeedBoostSetBonusPercentage * 0.01f : 0f) + + (silvaSet ? 0.05f : 0f) + (planarSpeedBoost > 0 ? (0.01f * planarSpeedBoost) : 0f) + ((deepDiver && player.IsUnderwater()) ? 0.15f : 0f) + (rogueStealthMax > 0f ? (rogueStealth >= rogueStealthMax ? rogueStealth * 0.05f : rogueStealth * 0.025f) : 0f); diff --git a/CalPlayer/CalamityPlayerDrawEffects.cs b/CalPlayer/CalamityPlayerDrawEffects.cs index 66439d5931..3020c9db04 100644 --- a/CalPlayer/CalamityPlayerDrawEffects.cs +++ b/CalPlayer/CalamityPlayerDrawEffects.cs @@ -2,6 +2,7 @@ using CalamityMod.Dusts; using CalamityMod.Items.Armor; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.Dyes; +using CalamityMod.Items.VanillaArmorChanges; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; @@ -48,7 +49,7 @@ using Terraria.ModLoader; namespace CalamityMod.CalPlayer { - public partial class CalamityPlayer : ModPlayer + public partial class CalamityPlayer : ModPlayer { #region Profaned Moonlight Colors public static readonly List MoonlightDyeDayColors = new List() @@ -222,21 +223,22 @@ namespace CalamityMod.CalPlayer Player drawPlayer = drawInfo.drawPlayer; Item currentlyHeldItem = drawPlayer.ActiveItem(); + // Go through the old positions for the player. + for (int i = drawPlayer.Calamity().OldPositions.Length - 1; i > 0; i--) + { + if (drawPlayer.Calamity().OldPositions[i - 1] == Vector2.Zero) + drawPlayer.Calamity().OldPositions[i - 1] = drawPlayer.position; + drawPlayer.Calamity().OldPositions[i] = drawPlayer.Calamity().OldPositions[i - 1]; + } + drawPlayer.Calamity().OldPositions[0] = drawPlayer.position; + // Kamei trail/afterimage effect. if (drawPlayer.Calamity().kamiBoost) { - for (int i = drawPlayer.Calamity().KameiOldPositions.Length - 1; i > 0; i--) - { - if (drawPlayer.Calamity().KameiOldPositions[i - 1] == Vector2.Zero) - drawPlayer.Calamity().KameiOldPositions[i - 1] = drawPlayer.position; - drawPlayer.Calamity().KameiOldPositions[i] = drawPlayer.Calamity().KameiOldPositions[i - 1]; - } - drawPlayer.Calamity().KameiOldPositions[0] = drawPlayer.position; - List existingDrawData = Main.playerDrawData; - for (int i = 0; i < drawPlayer.Calamity().KameiOldPositions.Length; i++) + for (int i = 0; i < drawPlayer.Calamity().OldPositions.Length; i++) { - float completionRatio = i / (float)drawPlayer.Calamity().KameiOldPositions.Length; + float completionRatio = i / (float)drawPlayer.Calamity().OldPositions.Length; float scale = MathHelper.Lerp(1f, 0.5f, completionRatio); float opacity = MathHelper.Lerp(0.25f, 0.08f, completionRatio); List afterimages = new List(); @@ -254,6 +256,30 @@ namespace CalamityMod.CalPlayer } } + // Cobalt set trail/afterimage effect. + if (drawPlayer.Calamity().CobaltSet) + { + List existingDrawData = Main.playerDrawData; + for (int i = 0; i < drawPlayer.Calamity().OldPositions.Length; i++) + { + float completionRatio = i / (float)drawPlayer.Calamity().OldPositions.Length; + float scale = MathHelper.Lerp(1f, 0.5f, completionRatio); + float opacity = MathHelper.Lerp(0.23f, 0.07f, completionRatio) * CobaltArmorSetChange.CalculateMovementSpeedInterpolant(drawPlayer); + List afterimages = new List(); + for (int j = 0; j < existingDrawData.Count; j++) + { + var drawData = existingDrawData[j]; + drawData.position = existingDrawData[j].position - drawPlayer.position + drawPlayer.oldPosition; + drawData.color = Color.Cyan * opacity; + drawData.color.G = (byte)(drawData.color.G * 0.87); + drawData.color.B = (byte)(drawData.color.B * 1.24); + drawData.scale = new Vector2(scale); + afterimages.Add(drawData); + } + Main.playerDrawData.InsertRange(0, afterimages); + } + } + if (!drawPlayer.frozen && currentlyHeldItem.type > ItemID.None && !drawPlayer.dead && @@ -444,7 +470,7 @@ namespace CalamityMod.CalPlayer Rectangle frame = texture.Frame(1, 4, 0, modPlayer.tailFrame); if (modPlayer.fathomSwarmerTail) { - int dyeShader = drawPlayer.dye?[2].dye ?? 0; + int dyeShader = drawPlayer.dye?[2].dye ?? 0; int frameSizeY = texture.Height / 4; int centerX = (int)(drawInfo.position.X + drawPlayer.width / 2f); int centerY = (int)(drawInfo.position.Y + drawPlayer.height / 2f); @@ -880,723 +906,723 @@ namespace CalamityMod.CalPlayer list.Add(GemTechGems); } - public override void DrawEffects(PlayerDrawInfo drawInfo, ref float r, ref float g, ref float b, ref float a, ref bool fullBright) - { - CalamityPlayer calamityPlayer = player.Calamity(); - if (Main.myPlayer == player.whoAmI && !Main.gameMenu && CalamityConfig.Instance.SpeedrunTimer) - { - string formatStr = @"hh\:mm\:ss\.ff"; - string formatStrDays = @"d\:hh\:mm\:ss\.ff"; - TimeSpan totalTime = CalamityMod.SpeedrunTimer.Elapsed.Add(calamityPlayer.previousSessionTotal); - string text = totalTime.ToString(totalTime.Days > 0 ? formatStrDays : formatStr); - float scale = 2f; - float xOffset = CalamityConfig.Instance.SpeedrunTimerPosX; - float yOffset = CalamityConfig.Instance.SpeedrunTimerPosY; + public override void DrawEffects(PlayerDrawInfo drawInfo, ref float r, ref float g, ref float b, ref float a, ref bool fullBright) + { + CalamityPlayer calamityPlayer = player.Calamity(); + if (Main.myPlayer == player.whoAmI && !Main.gameMenu && CalamityConfig.Instance.SpeedrunTimer) + { + string formatStr = @"hh\:mm\:ss\.ff"; + string formatStrDays = @"d\:hh\:mm\:ss\.ff"; + TimeSpan totalTime = CalamityMod.SpeedrunTimer.Elapsed.Add(calamityPlayer.previousSessionTotal); + string text = totalTime.ToString(totalTime.Days > 0 ? formatStrDays : formatStr); + float scale = 2f; + float xOffset = CalamityConfig.Instance.SpeedrunTimerPosX; + float yOffset = CalamityConfig.Instance.SpeedrunTimerPosY; - Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontMouseText, text, Main.screenWidth / 2f - xOffset, yOffset, Color.White, Color.Black, default, scale); + Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontMouseText, text, Main.screenWidth / 2f - xOffset, yOffset, Color.White, Color.Black, default, scale); - if (calamityPlayer.lastSplitType > -1) - { - TimeSpan split = calamityPlayer.lastSplit; - text = split.ToString(split.Days > 0 ? formatStrDays : formatStr); - scale = 1f; - yOffset += 44f; + if (calamityPlayer.lastSplitType > -1) + { + TimeSpan split = calamityPlayer.lastSplit; + text = split.ToString(split.Days > 0 ? formatStrDays : formatStr); + scale = 1f; + yOffset += 44f; - Texture2D texture = null; - switch (calamityPlayer.lastSplitType) - { - // King Slime - case 1: - texture = Main.npcHeadBossTexture[7]; - break; + Texture2D texture = null; + switch (calamityPlayer.lastSplitType) + { + // King Slime + case 1: + texture = Main.npcHeadBossTexture[7]; + break; - case 2: - texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; - break; + case 2: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; - // Eye of Cthulhu - case 3: - texture = Main.npcHeadBossTexture[1]; - break; + // Eye of Cthulhu + case 3: + texture = Main.npcHeadBossTexture[1]; + break; - case 4: - texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; - break; + case 4: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; - // Eater of Worlds - case 5: - texture = Main.npcHeadBossTexture[2]; - break; + // Eater of Worlds + case 5: + texture = Main.npcHeadBossTexture[2]; + break; - // Brain of Cthulhu - case 6: - texture = Main.npcHeadBossTexture[23]; - break; + // Brain of Cthulhu + case 6: + texture = Main.npcHeadBossTexture[23]; + break; - case 7: - texture = ModContent.GetTexture("CalamityMod/NPCs/HiveMind/HiveMindP2_Head_Boss"); - break; + case 7: + texture = ModContent.GetTexture("CalamityMod/NPCs/HiveMind/HiveMindP2_Head_Boss"); + break; - case 8: - texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; - break; + case 8: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; - // Queen Bee - case 9: - texture = Main.npcHeadBossTexture[14]; - break; + // Queen Bee + case 9: + texture = Main.npcHeadBossTexture[14]; + break; - // Skeletron - case 10: - texture = Main.npcHeadBossTexture[19]; - break; + // Skeletron + case 10: + texture = Main.npcHeadBossTexture[19]; + break; - case 11: - texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; - break; + case 11: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; - // Wall of Flesh - case 12: - texture = Main.npcHeadBossTexture[22]; - break; + // Wall of Flesh + case 12: + texture = Main.npcHeadBossTexture[22]; + break; - case 13: - texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; - break; + case 13: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; - // The Twins - case 14: - texture = Main.npcHeadBossTexture[21]; - break; + // The Twins + case 14: + texture = Main.npcHeadBossTexture[21]; + break; - case 15: - texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; - break; + case 15: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; - // The Destroyer - case 16: - texture = Main.npcHeadBossTexture[25]; - break; + // The Destroyer + case 16: + texture = Main.npcHeadBossTexture[25]; + break; - case 17: - texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; - break; + case 17: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; - // Skeletron Prime - case 18: - texture = Main.npcHeadBossTexture[18]; - break; + // Skeletron Prime + case 18: + texture = Main.npcHeadBossTexture[18]; + break; - case 19: - texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; - break; + case 19: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; - // Plantera - case 20: - texture = Main.npcHeadBossTexture[12]; - break; + // Plantera + case 20: + texture = Main.npcHeadBossTexture[12]; + break; - case 21: - texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; - break; + case 21: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; - case 22: - texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; - break; + case 22: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; - // Golem - case 23: - texture = Main.npcHeadBossTexture[5]; - break; + // Golem + case 23: + texture = Main.npcHeadBossTexture[5]; + break; - case 24: - texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; - break; + case 24: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; - // Duke Fishron - case 25: - texture = Main.npcHeadBossTexture[4]; - break; + // Duke Fishron + case 25: + texture = Main.npcHeadBossTexture[4]; + break; - case 26: - texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; - break; + case 26: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; - // Lunatic Cultist - case 27: - texture = Main.npcHeadBossTexture[31]; - break; + // Lunatic Cultist + case 27: + texture = Main.npcHeadBossTexture[31]; + break; - case 28: - texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; - break; + case 28: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; - // Moon Lord - case 29: - texture = Main.npcHeadBossTexture[8]; - break; + // Moon Lord + case 29: + texture = Main.npcHeadBossTexture[8]; + break; - case 30: - texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; - break; + case 30: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; - case 31: - texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; - break; + case 31: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; - case 32: - texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; - break; + case 32: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; - case 33: - texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; - break; + case 33: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; - case 34: - texture = ModContent.GetTexture("CalamityMod/NPCs/StormWeaver/StormWeaverHeadNaked_Head_Boss"); - break; + case 34: + texture = ModContent.GetTexture("CalamityMod/NPCs/StormWeaver/StormWeaverHeadNaked_Head_Boss"); + break; - case 35: - texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; - break; + case 35: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; - case 36: - texture = ModContent.GetTexture("CalamityMod/NPCs/Polterghast/Necroplasm_Head_Boss"); - break; + case 36: + texture = ModContent.GetTexture("CalamityMod/NPCs/Polterghast/Necroplasm_Head_Boss"); + break; - case 37: - texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; - break; + case 37: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; - case 38: - texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; - break; + case 38: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; - case 39: - texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; - break; + case 39: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; - case 40: - texture = ModContent.GetTexture("CalamityMod/NPCs/SupremeCalamitas/HoodlessHeadIcon"); - break; + case 40: + texture = ModContent.GetTexture("CalamityMod/NPCs/SupremeCalamitas/HoodlessHeadIcon"); + break; - case 41: - texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; - break; + case 41: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; - case 42: - texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; - break; + case 42: + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + break; - default: - break; - } + default: + break; + } - xOffset -= 58f; + xOffset -= 58f; - if (texture != null) - Main.spriteBatch.Draw(texture, new Vector2(Main.screenWidth / 2f - xOffset - texture.Width - 4f, yOffset), null, Color.White, 0f, default, 1f, SpriteEffects.None, 0f); + if (texture != null) + Main.spriteBatch.Draw(texture, new Vector2(Main.screenWidth / 2f - xOffset - texture.Width - 4f, yOffset), null, Color.White, 0f, default, 1f, SpriteEffects.None, 0f); - Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontMouseText, text, Main.screenWidth / 2f - xOffset, yOffset, Color.White, Color.Black, default, scale); - } - } + Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontMouseText, text, Main.screenWidth / 2f - xOffset, yOffset, Color.White, Color.Black, default, scale); + } + } - // Dust modifications while high. - if (calamityPlayer.trippy) - { - if (Main.myPlayer == player.whoAmI) - { - Rectangle screenArea = new Rectangle((int)Main.screenPosition.X - 500, (int)Main.screenPosition.Y - 50, Main.screenWidth + 1000, Main.screenHeight + 100); - int dustDrawn = 0; - float maxShroomDust = Main.maxDustToDraw / 2; - for (int i = 0; i < Main.maxDustToDraw; i++) - { - Dust dust = Main.dust[i]; - if (dust.active) - { - // Only draw dust near the screen, for performance reasons. - if (new Rectangle((int)dust.position.X, (int)dust.position.Y, 4, 4).Intersects(screenArea)) - { - dust.color = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, 0); - for (int j = 0; j < 4; j++) - { - Vector2 dustDrawPosition = dust.position; - Vector2 dustCenter = dustDrawPosition + new Vector2(4f); + // Dust modifications while high. + if (calamityPlayer.trippy) + { + if (Main.myPlayer == player.whoAmI) + { + Rectangle screenArea = new Rectangle((int)Main.screenPosition.X - 500, (int)Main.screenPosition.Y - 50, Main.screenWidth + 1000, Main.screenHeight + 100); + int dustDrawn = 0; + float maxShroomDust = Main.maxDustToDraw / 2; + for (int i = 0; i < Main.maxDustToDraw; i++) + { + Dust dust = Main.dust[i]; + if (dust.active) + { + // Only draw dust near the screen, for performance reasons. + if (new Rectangle((int)dust.position.X, (int)dust.position.Y, 4, 4).Intersects(screenArea)) + { + dust.color = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, 0); + for (int j = 0; j < 4; j++) + { + Vector2 dustDrawPosition = dust.position; + Vector2 dustCenter = dustDrawPosition + new Vector2(4f); - float distanceX = Math.Abs(dustCenter.X - player.Center.X); - float distanceY = Math.Abs(dustCenter.Y - player.Center.Y); - if (j == 0 || j == 2) - dustDrawPosition.X = player.Center.X + distanceX; - else dustDrawPosition.X = player.Center.X - distanceX; + float distanceX = Math.Abs(dustCenter.X - player.Center.X); + float distanceY = Math.Abs(dustCenter.Y - player.Center.Y); + if (j == 0 || j == 2) + dustDrawPosition.X = player.Center.X + distanceX; + else dustDrawPosition.X = player.Center.X - distanceX; - dustDrawPosition.X -= 4f; + dustDrawPosition.X -= 4f; - if (j == 0 || j == 1) - dustDrawPosition.Y = player.Center.Y + distanceY; + if (j == 0 || j == 1) + dustDrawPosition.Y = player.Center.Y + distanceY; - else dustDrawPosition.Y = player.Center.Y - distanceY; + else dustDrawPosition.Y = player.Center.Y - distanceY; - dustDrawPosition.Y -= 4f; - Main.spriteBatch.Draw(Main.dustTexture, dustDrawPosition - Main.screenPosition, dust.frame, dust.color, dust.rotation, new Vector2(4f), dust.scale, SpriteEffects.None, 0f); - dustDrawn++; - } + dustDrawPosition.Y -= 4f; + Main.spriteBatch.Draw(Main.dustTexture, dustDrawPosition - Main.screenPosition, dust.frame, dust.color, dust.rotation, new Vector2(4f), dust.scale, SpriteEffects.None, 0f); + dustDrawn++; + } - // Break if too many dust clones have been drawn - if (dustDrawn > maxShroomDust) - break; - } - } - } - } - } + // Break if too many dust clones have been drawn + if (dustDrawn > maxShroomDust) + break; + } + } + } + } + } - bool noRogueStealth = calamityPlayer.rogueStealth == 0f || player.townNPCs > 2f || !CalamityConfig.Instance.StealthInvisbility; - if (calamityPlayer.rogueStealth > 0f && calamityPlayer.rogueStealthMax > 0f && player.townNPCs < 3f && CalamityConfig.Instance.StealthInvisbility) - { - // A translucent orchid color, the rogue class color - float colorValue = calamityPlayer.rogueStealth / calamityPlayer.rogueStealthMax * 0.9f; //0 to 0.9 - r *= 1f - (colorValue * 0.89f); //255 to 50 - g *= 1f - colorValue; //255 to 25 - b *= 1f - (colorValue * 0.89f); //255 to 50 - a *= 1f - colorValue; //255 to 25 - player.armorEffectDrawOutlines = false; - player.armorEffectDrawShadow = false; - player.armorEffectDrawShadowSubtle = false; - } + bool noRogueStealth = calamityPlayer.rogueStealth == 0f || player.townNPCs > 2f || !CalamityConfig.Instance.StealthInvisbility; + if (calamityPlayer.rogueStealth > 0f && calamityPlayer.rogueStealthMax > 0f && player.townNPCs < 3f && CalamityConfig.Instance.StealthInvisbility) + { + // A translucent orchid color, the rogue class color + float colorValue = calamityPlayer.rogueStealth / calamityPlayer.rogueStealthMax * 0.9f; //0 to 0.9 + r *= 1f - (colorValue * 0.89f); //255 to 50 + g *= 1f - colorValue; //255 to 25 + b *= 1f - (colorValue * 0.89f); //255 to 50 + a *= 1f - colorValue; //255 to 25 + player.armorEffectDrawOutlines = false; + player.armorEffectDrawShadow = false; + player.armorEffectDrawShadowSubtle = false; + } - Texture2D heart3 = ModContent.GetTexture("CalamityMod/ExtraTextures/Heart3"); - Texture2D heart4 = ModContent.GetTexture("CalamityMod/ExtraTextures/Heart4"); - Texture2D heart5 = ModContent.GetTexture("CalamityMod/ExtraTextures/Heart5"); - Texture2D heart6 = ModContent.GetTexture("CalamityMod/ExtraTextures/Heart6"); - Texture2D heartOriginal = ModContent.GetTexture("CalamityMod/ExtraTextures/HeartOriginal"); // Life fruit - Texture2D heartOriginal2 = ModContent.GetTexture("CalamityMod/ExtraTextures/HeartOriginal2"); // Life crystal + Texture2D heart3 = ModContent.GetTexture("CalamityMod/ExtraTextures/Heart3"); + Texture2D heart4 = ModContent.GetTexture("CalamityMod/ExtraTextures/Heart4"); + Texture2D heart5 = ModContent.GetTexture("CalamityMod/ExtraTextures/Heart5"); + Texture2D heart6 = ModContent.GetTexture("CalamityMod/ExtraTextures/Heart6"); + Texture2D heartOriginal = ModContent.GetTexture("CalamityMod/ExtraTextures/HeartOriginal"); // Life fruit + Texture2D heartOriginal2 = ModContent.GetTexture("CalamityMod/ExtraTextures/HeartOriginal2"); // Life crystal - int totalFruit = - (calamityPlayer.mFruit ? 1 : 0) + - (calamityPlayer.bOrange ? 1 : 0) + - (calamityPlayer.eBerry ? 1 : 0) + - (calamityPlayer.dFruit ? 1 : 0); + int totalFruit = + (calamityPlayer.mFruit ? 1 : 0) + + (calamityPlayer.bOrange ? 1 : 0) + + (calamityPlayer.eBerry ? 1 : 0) + + (calamityPlayer.dFruit ? 1 : 0); - switch (totalFruit) - { - default: - Main.heart2Texture = heartOriginal; - break; - case 4: - Main.heart2Texture = heart6; - break; - case 3: - Main.heart2Texture = heart5; - break; - case 2: - Main.heart2Texture = heart4; - break; - case 1: - Main.heart2Texture = heart3; - break; - } + switch (totalFruit) + { + default: + Main.heart2Texture = heartOriginal; + break; + case 4: + Main.heart2Texture = heart6; + break; + case 3: + Main.heart2Texture = heart5; + break; + case 2: + Main.heart2Texture = heart4; + break; + case 1: + Main.heart2Texture = heart3; + break; + } - Main.heartTexture = heartOriginal2; - if (calamityPlayer.revivify) - { - if (Main.rand.NextBool(2) && drawInfo.shadow == 0f) - { - int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, 91, player.velocity.X * 0.2f, player.velocity.Y * 0.2f, 100, default, 1f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity.Y -= 0.5f; - Main.playerDrawDust.Add(dust); - } - } - if (calamityPlayer.tRegen) - { - if (Main.rand.NextBool(10) && drawInfo.shadow == 0f) - { - int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, 107, player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 1f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 0.75f; - Main.dust[dust].velocity.Y -= 0.35f; - Main.playerDrawDust.Add(dust); - } - if (noRogueStealth) - { - r *= 0.025f; - g *= 0.15f; - b *= 0.035f; - fullBright = true; - } - } - if (calamityPlayer.IBoots) - { - if (!player.StandingStill() && !player.mount.Active) - { - if (Main.rand.NextBool(2) && drawInfo.shadow == 0f) - { - int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, 229, player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 1f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 0.5f; - Main.playerDrawDust.Add(dust); - } - if (noRogueStealth) - { - r *= 0.05f; - g *= 0.05f; - b *= 0.05f; - fullBright = true; - } - } - } - if (calamityPlayer.elysianFire) - { - if (!player.StandingStill() && !player.mount.Active) - { - if (Main.rand.NextBool(2) && drawInfo.shadow == 0f) - { - int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, 246, player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 1f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 0.5f; - Main.playerDrawDust.Add(dust); - } - if (noRogueStealth) - { - r *= 0.75f; - g *= 0.55f; - b *= 0f; - fullBright = true; - } - } - } - if (calamityPlayer.dsSetBonus) - { - if (!player.StandingStill() && !player.mount.Active) - { - if (Main.rand.NextBool(2) && drawInfo.shadow == 0f) - { - int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, 27, player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 1.5f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 0.5f; - Main.playerDrawDust.Add(dust); - } - if (noRogueStealth) - { - r *= 0.15f; - g *= 0.025f; - b *= 0.1f; - fullBright = true; - } - } - } - if (calamityPlayer.auricSet) - { - if (!player.StandingStill() && !player.mount.Active) - { - if (drawInfo.shadow == 0f) - { - int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, Main.rand.NextBool(2) ? 57 : 244, player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 1.5f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 0.5f; - Main.playerDrawDust.Add(dust); - } - if (noRogueStealth) - { - r *= 0.15f; - g *= 0.025f; - b *= 0.1f; - fullBright = true; - } - } - } - if (calamityPlayer.bFlames || calamityPlayer.aFlames || calamityPlayer.rageModeActive) - { - if (Main.rand.NextBool(4) && drawInfo.shadow == 0f) - { - int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, ModContent.DustType(), player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 3f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 1.8f; - Main.dust[dust].velocity.Y -= 0.5f; - Main.playerDrawDust.Add(dust); - } - if (noRogueStealth) - { - r *= 0.25f; - g *= 0.01f; - b *= 0.01f; - fullBright = true; - } - } - if (calamityPlayer.shadowflame) - { - if (Main.rand.Next(5) < 4 && drawInfo.shadow == 0f) - { - int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, 27, player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 1.95f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 0.75f; - Main.dust[dust].velocity.X = Main.dust[dust].velocity.X * 0.75f; - Main.dust[dust].velocity.Y = Main.dust[dust].velocity.Y - 1f; - if (Main.rand.NextBool(4)) - { - Main.dust[dust].noGravity = false; - Main.dust[dust].scale *= 0.5f; - } - } - } - if (calamityPlayer.sulphurPoison) - { - if (Main.rand.Next(5) < 4 && drawInfo.shadow == 0f) - { - int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, 46, player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 1.95f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 0.75f; - Main.dust[dust].velocity.X = Main.dust[dust].velocity.X * 0.75f; - Main.dust[dust].velocity.Y = Main.dust[dust].velocity.Y - 1f; - if (Main.rand.NextBool(4)) - { - Main.dust[dust].noGravity = false; - Main.dust[dust].scale *= 0.5f; - } - } - if (noRogueStealth) - { - r *= 0.65f; - b *= 0.75f; - fullBright = true; - } - } - if (calamityPlayer.adrenalineModeActive) - { - if (Main.rand.NextBool(4) && drawInfo.shadow == 0f) - { - int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, 206, player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 3f); - Main.dust[dust].velocity *= 1.8f; - Main.dust[dust].velocity.Y -= 0.5f; - Main.playerDrawDust.Add(dust); - } - if (noRogueStealth) - { - r *= 0.01f; - g *= 0.15f; - b *= 0.1f; - fullBright = true; - } - } - if (calamityPlayer.gsInferno) - { - if (Main.rand.NextBool(4) && drawInfo.shadow == 0f) - { - int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, 173, player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 3f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 1.8f; - Main.dust[dust].velocity.Y -= 0.5f; - Main.playerDrawDust.Add(dust); - } - if (noRogueStealth) - { - r *= 0.25f; - g *= 0.01f; - b *= 0.01f; - fullBright = true; - } - } - if (calamityPlayer.astralInfection) - { - if (Main.rand.NextBool(4) && drawInfo.shadow == 0f) - { - int dustType = Main.rand.NextBool(2) ? ModContent.DustType() : ModContent.DustType(); - int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, dustType, player.velocity.X * 0.2f, player.velocity.Y * 0.2f, 100, default, 0.7f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 1.2f; - Main.dust[dust].velocity.Y -= 0.5f; - Main.dust[dust].color = new Color(255, 255, 255, 0); - Main.playerDrawDust.Add(dust); - } - } - if (calamityPlayer.hFlames || calamityPlayer.hInferno || calamityPlayer.banishingFire) - { - if (Main.rand.NextBool(4) && drawInfo.shadow == 0f) - { - int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, ModContent.DustType(), player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 3f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 1.8f; - Main.dust[dust].velocity.Y -= 0.5f; - Main.playerDrawDust.Add(dust); - } - if (noRogueStealth) - { - r *= 0.25f; - g *= 0.25f; - b *= 0.1f; - fullBright = true; - } - } - else if (calamityPlayer.eGravity) - { - if (Main.rand.NextBool(12) && drawInfo.shadow == 0f) - { - int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, (int)CalamityDusts.ProfanedFire, player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 3f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 1.8f; - Main.dust[dust].velocity.Y -= 0.5f; - Main.playerDrawDust.Add(dust); - } - } - if (calamityPlayer.pFlames) - { - if (Main.rand.NextBool(4) && drawInfo.shadow == 0f) - { - int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, 89, player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 3f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 1.2f; - Main.dust[dust].velocity.Y -= 0.15f; - Main.playerDrawDust.Add(dust); - } - if (noRogueStealth) - { - r *= 0.07f; - g *= 0.15f; - b *= 0.01f; - fullBright = true; - } - } - if (calamityPlayer.nightwither) - { - if (Main.rand.NextBool(4) && drawInfo.shadow == 0f) - { - int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, 176, player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 3f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 1.8f; - Main.dust[dust].velocity.Y -= 0.5f; - Main.playerDrawDust.Add(dust); - } - if (noRogueStealth) - { - r *= 0.25f; - g *= 0.25f; - b *= 0.1f; - fullBright = true; - } - } - if (calamityPlayer.vaporfied) - { - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - 246, - 242, - 229, - 226, - 247, - 187, - 234 - }); - if (Main.rand.NextBool(4) && drawInfo.shadow == 0f) - { - int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, dustType, player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 3f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 1.8f; - Main.dust[dust].velocity.Y -= 0.5f; - if (Main.rand.NextBool(4)) - { - Main.dust[dust].noGravity = false; - Main.dust[dust].scale *= 0.5f; - } - Main.playerDrawDust.Add(dust); - } - if (noRogueStealth) - { - r *= 0.25f; - g *= 0.25f; - b *= 0.1f; - fullBright = true; - } - } - if (calamityPlayer.eFreeze || calamityPlayer.gState || calamityPlayer.cDepth || calamityPlayer.eutrophication) - { - if (noRogueStealth) - { - r *= 0f; - g *= 0.05f; - b *= 0.3f; - fullBright = true; - } - } - if (calamityPlayer.draedonsHeart && !calamityPlayer.shadeRegen && !calamityPlayer.cFreeze && player.StandingStill() && player.itemAnimation == 0) - { - if (noRogueStealth) - { - r *= 0f; - g *= 0.5f; - b *= 0f; - fullBright = true; - } - } - if (calamityPlayer.bBlood) - { - if (Main.rand.NextBool(6) && drawInfo.shadow == 0f) - { - int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, 5, player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 3f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 1.8f; - Main.dust[dust].velocity.Y -= 0.5f; - Main.playerDrawDust.Add(dust); - } - if (noRogueStealth) - { - r *= 0.15f; - g *= 0.01f; - b *= 0.01f; - fullBright = true; - } - } - if (calamityPlayer.mushy) - { - if (Main.rand.NextBool(6) && drawInfo.shadow == 0f) - { - int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, 56, player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 2f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 0.5f; - Main.dust[dust].velocity.Y -= 0.1f; - Main.playerDrawDust.Add(dust); - } - if (noRogueStealth) - { - r *= 0.15f; - g *= 0.01f; - b *= 0.01f; - fullBright = true; - } - } - if (calamityPlayer.bloodfinBoost) - { - if (Main.rand.NextBool(6) && drawInfo.shadow == 0f) - { - int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, 5, player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 3f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 1.8f; - Main.dust[dust].velocity.Y -= 0.5f; - Main.playerDrawDust.Add(dust); - } - if (noRogueStealth) - { - r *= 0.5f; - g *= 0f; - b *= 0f; - fullBright = true; - } - } - if ((calamityPlayer.cadence || calamityPlayer.ladHearts > 0) && !player.loveStruck) - { - if (Main.rand.NextBool(5) && drawInfo.shadow == 0f) - { - Vector2 velocity = Main.rand.NextVector2Unit(); - velocity.X *= 0.66f; - velocity *= Main.rand.NextFloat(1f, 2f); + Main.heartTexture = heartOriginal2; + if (calamityPlayer.revivify) + { + if (Main.rand.NextBool(2) && drawInfo.shadow == 0f) + { + int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, 91, player.velocity.X * 0.2f, player.velocity.Y * 0.2f, 100, default, 1f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity.Y -= 0.5f; + Main.playerDrawDust.Add(dust); + } + } + if (calamityPlayer.tRegen) + { + if (Main.rand.NextBool(10) && drawInfo.shadow == 0f) + { + int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, 107, player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 1f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 0.75f; + Main.dust[dust].velocity.Y -= 0.35f; + Main.playerDrawDust.Add(dust); + } + if (noRogueStealth) + { + r *= 0.025f; + g *= 0.15f; + b *= 0.035f; + fullBright = true; + } + } + if (calamityPlayer.IBoots) + { + if (!player.StandingStill() && !player.mount.Active) + { + if (Main.rand.NextBool(2) && drawInfo.shadow == 0f) + { + int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, 229, player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 1f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 0.5f; + Main.playerDrawDust.Add(dust); + } + if (noRogueStealth) + { + r *= 0.05f; + g *= 0.05f; + b *= 0.05f; + fullBright = true; + } + } + } + if (calamityPlayer.elysianFire) + { + if (!player.StandingStill() && !player.mount.Active) + { + if (Main.rand.NextBool(2) && drawInfo.shadow == 0f) + { + int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, 246, player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 1f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 0.5f; + Main.playerDrawDust.Add(dust); + } + if (noRogueStealth) + { + r *= 0.75f; + g *= 0.55f; + b *= 0f; + fullBright = true; + } + } + } + if (calamityPlayer.dsSetBonus) + { + if (!player.StandingStill() && !player.mount.Active) + { + if (Main.rand.NextBool(2) && drawInfo.shadow == 0f) + { + int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, 27, player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 1.5f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 0.5f; + Main.playerDrawDust.Add(dust); + } + if (noRogueStealth) + { + r *= 0.15f; + g *= 0.025f; + b *= 0.1f; + fullBright = true; + } + } + } + if (calamityPlayer.auricSet) + { + if (!player.StandingStill() && !player.mount.Active) + { + if (drawInfo.shadow == 0f) + { + int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, Main.rand.NextBool(2) ? 57 : 244, player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 1.5f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 0.5f; + Main.playerDrawDust.Add(dust); + } + if (noRogueStealth) + { + r *= 0.15f; + g *= 0.025f; + b *= 0.1f; + fullBright = true; + } + } + } + if (calamityPlayer.bFlames || calamityPlayer.aFlames || calamityPlayer.rageModeActive) + { + if (Main.rand.NextBool(4) && drawInfo.shadow == 0f) + { + int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, ModContent.DustType(), player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 3f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 1.8f; + Main.dust[dust].velocity.Y -= 0.5f; + Main.playerDrawDust.Add(dust); + } + if (noRogueStealth) + { + r *= 0.25f; + g *= 0.01f; + b *= 0.01f; + fullBright = true; + } + } + if (calamityPlayer.shadowflame) + { + if (Main.rand.Next(5) < 4 && drawInfo.shadow == 0f) + { + int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, 27, player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 1.95f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 0.75f; + Main.dust[dust].velocity.X = Main.dust[dust].velocity.X * 0.75f; + Main.dust[dust].velocity.Y = Main.dust[dust].velocity.Y - 1f; + if (Main.rand.NextBool(4)) + { + Main.dust[dust].noGravity = false; + Main.dust[dust].scale *= 0.5f; + } + } + } + if (calamityPlayer.sulphurPoison) + { + if (Main.rand.Next(5) < 4 && drawInfo.shadow == 0f) + { + int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, 46, player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 1.95f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 0.75f; + Main.dust[dust].velocity.X = Main.dust[dust].velocity.X * 0.75f; + Main.dust[dust].velocity.Y = Main.dust[dust].velocity.Y - 1f; + if (Main.rand.NextBool(4)) + { + Main.dust[dust].noGravity = false; + Main.dust[dust].scale *= 0.5f; + } + } + if (noRogueStealth) + { + r *= 0.65f; + b *= 0.75f; + fullBright = true; + } + } + if (calamityPlayer.adrenalineModeActive) + { + if (Main.rand.NextBool(4) && drawInfo.shadow == 0f) + { + int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, 206, player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 3f); + Main.dust[dust].velocity *= 1.8f; + Main.dust[dust].velocity.Y -= 0.5f; + Main.playerDrawDust.Add(dust); + } + if (noRogueStealth) + { + r *= 0.01f; + g *= 0.15f; + b *= 0.1f; + fullBright = true; + } + } + if (calamityPlayer.gsInferno) + { + if (Main.rand.NextBool(4) && drawInfo.shadow == 0f) + { + int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, 173, player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 3f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 1.8f; + Main.dust[dust].velocity.Y -= 0.5f; + Main.playerDrawDust.Add(dust); + } + if (noRogueStealth) + { + r *= 0.25f; + g *= 0.01f; + b *= 0.01f; + fullBright = true; + } + } + if (calamityPlayer.astralInfection) + { + if (Main.rand.NextBool(4) && drawInfo.shadow == 0f) + { + int dustType = Main.rand.NextBool(2) ? ModContent.DustType() : ModContent.DustType(); + int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, dustType, player.velocity.X * 0.2f, player.velocity.Y * 0.2f, 100, default, 0.7f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 1.2f; + Main.dust[dust].velocity.Y -= 0.5f; + Main.dust[dust].color = new Color(255, 255, 255, 0); + Main.playerDrawDust.Add(dust); + } + } + if (calamityPlayer.hFlames || calamityPlayer.hInferno || calamityPlayer.banishingFire) + { + if (Main.rand.NextBool(4) && drawInfo.shadow == 0f) + { + int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, ModContent.DustType(), player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 3f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 1.8f; + Main.dust[dust].velocity.Y -= 0.5f; + Main.playerDrawDust.Add(dust); + } + if (noRogueStealth) + { + r *= 0.25f; + g *= 0.25f; + b *= 0.1f; + fullBright = true; + } + } + else if (calamityPlayer.eGravity) + { + if (Main.rand.NextBool(12) && drawInfo.shadow == 0f) + { + int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, (int)CalamityDusts.ProfanedFire, player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 3f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 1.8f; + Main.dust[dust].velocity.Y -= 0.5f; + Main.playerDrawDust.Add(dust); + } + } + if (calamityPlayer.pFlames) + { + if (Main.rand.NextBool(4) && drawInfo.shadow == 0f) + { + int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, 89, player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 3f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 1.2f; + Main.dust[dust].velocity.Y -= 0.15f; + Main.playerDrawDust.Add(dust); + } + if (noRogueStealth) + { + r *= 0.07f; + g *= 0.15f; + b *= 0.01f; + fullBright = true; + } + } + if (calamityPlayer.nightwither) + { + if (Main.rand.NextBool(4) && drawInfo.shadow == 0f) + { + int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, 176, player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 3f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 1.8f; + Main.dust[dust].velocity.Y -= 0.5f; + Main.playerDrawDust.Add(dust); + } + if (noRogueStealth) + { + r *= 0.25f; + g *= 0.25f; + b *= 0.1f; + fullBright = true; + } + } + if (calamityPlayer.vaporfied) + { + int dustType = Utils.SelectRandom(Main.rand, new int[] + { + 246, + 242, + 229, + 226, + 247, + 187, + 234 + }); + if (Main.rand.NextBool(4) && drawInfo.shadow == 0f) + { + int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, dustType, player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 3f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 1.8f; + Main.dust[dust].velocity.Y -= 0.5f; + if (Main.rand.NextBool(4)) + { + Main.dust[dust].noGravity = false; + Main.dust[dust].scale *= 0.5f; + } + Main.playerDrawDust.Add(dust); + } + if (noRogueStealth) + { + r *= 0.25f; + g *= 0.25f; + b *= 0.1f; + fullBright = true; + } + } + if (calamityPlayer.eFreeze || calamityPlayer.gState || calamityPlayer.cDepth || calamityPlayer.eutrophication) + { + if (noRogueStealth) + { + r *= 0f; + g *= 0.05f; + b *= 0.3f; + fullBright = true; + } + } + if (calamityPlayer.draedonsHeart && !calamityPlayer.shadeRegen && !calamityPlayer.cFreeze && player.StandingStill() && player.itemAnimation == 0) + { + if (noRogueStealth) + { + r *= 0f; + g *= 0.5f; + b *= 0f; + fullBright = true; + } + } + if (calamityPlayer.bBlood) + { + if (Main.rand.NextBool(6) && drawInfo.shadow == 0f) + { + int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, 5, player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 3f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 1.8f; + Main.dust[dust].velocity.Y -= 0.5f; + Main.playerDrawDust.Add(dust); + } + if (noRogueStealth) + { + r *= 0.15f; + g *= 0.01f; + b *= 0.01f; + fullBright = true; + } + } + if (calamityPlayer.mushy) + { + if (Main.rand.NextBool(6) && drawInfo.shadow == 0f) + { + int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, 56, player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 2f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 0.5f; + Main.dust[dust].velocity.Y -= 0.1f; + Main.playerDrawDust.Add(dust); + } + if (noRogueStealth) + { + r *= 0.15f; + g *= 0.01f; + b *= 0.01f; + fullBright = true; + } + } + if (calamityPlayer.bloodfinBoost) + { + if (Main.rand.NextBool(6) && drawInfo.shadow == 0f) + { + int dust = Dust.NewDust(drawInfo.position - new Vector2(2f), player.width + 4, player.height + 4, 5, player.velocity.X * 0.4f, player.velocity.Y * 0.4f, 100, default, 3f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 1.8f; + Main.dust[dust].velocity.Y -= 0.5f; + Main.playerDrawDust.Add(dust); + } + if (noRogueStealth) + { + r *= 0.5f; + g *= 0f; + b *= 0f; + fullBright = true; + } + } + if ((calamityPlayer.cadence || calamityPlayer.ladHearts > 0) && !player.loveStruck) + { + if (Main.rand.NextBool(5) && drawInfo.shadow == 0f) + { + Vector2 velocity = Main.rand.NextVector2Unit(); + velocity.X *= 0.66f; + velocity *= Main.rand.NextFloat(1f, 2f); - int heart = Gore.NewGore(drawInfo.position + new Vector2(Main.rand.Next(player.width + 1), Main.rand.Next(player.height + 1)), velocity, 331, Main.rand.NextFloat(0.4f, 1.2f)); - Main.gore[heart].sticky = false; - Main.gore[heart].velocity *= 0.4f; - Main.gore[heart].velocity.Y -= 0.6f; - Main.playerDrawGore.Add(heart); - } - } - } + int heart = Gore.NewGore(drawInfo.position + new Vector2(Main.rand.Next(player.width + 1), Main.rand.Next(player.height + 1)), velocity, 331, Main.rand.NextFloat(0.4f, 1.2f)); + Main.gore[heart].sticky = false; + Main.gore[heart].velocity *= 0.4f; + Main.gore[heart].velocity.Y -= 0.6f; + Main.playerDrawGore.Add(heart); + } + } + } #endregion #region Tanks/Backpacks diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 1178dd67cc..128f9b4e77 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -20,6 +20,7 @@ using CalamityMod.Items.Fishing.FishingRods; using CalamityMod.Items.Mounts.Minecarts; using CalamityMod.Items.Potions; using CalamityMod.Items.Potions.Alcohol; +using CalamityMod.Items.VanillaArmorChanges; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; @@ -2514,6 +2515,10 @@ namespace CalamityMod.CalPlayer } } + // Cobalt armor set effects. + if (CobaltSet) + CobaltArmorSetChange.ApplyMovementSpeedBonuses(player); + if (astralInjection) { if (player.statMana < player.statManaMax2) diff --git a/CalamityMod.cs b/CalamityMod.cs index c2e5bb9045..f3f066e902 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -10,6 +10,7 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Accessories.Vanity; using CalamityMod.Items.Armor; using CalamityMod.Items.Dyes.HairDye; +using CalamityMod.Items.VanillaArmorChanges; using CalamityMod.Localization; using CalamityMod.NPCs; using CalamityMod.NPCs.Abyss; @@ -218,6 +219,7 @@ namespace CalamityMod BossHealthBarManager.Load(this); DraedonStructures.Load(); EnchantmentManager.LoadAllEnchantments(); + VanillaArmorChangeManager.Load(); SetupVanillaDR(); SetupBossKillTimes(); SetupBossVelocityScalingValues(); @@ -262,7 +264,7 @@ namespace CalamityMod AddEquipTexture(new FeatherCrownHair(), null, EquipType.Head, "FeatherCrownHead", "CalamityMod/Items/Accessories/FeatherCrown_Face"); AddEquipTexture(new MoonstoneCrownHair(), null, EquipType.Head, "MoonstoneCrownHead", "CalamityMod/Items/Accessories/MoonstoneCrown_Face"); - AddEquipTexture(null, EquipType.Legs, "CirrusDress_Legs", "CalamityMod/Items/Armor/CirrusDress_Legs"); + AddEquipTexture(null, EquipType.Legs, "CirrusDress_Legs", "CalamityMod/Items/Armor/CirrusDress_Legs"); AstralCactusTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/Tiles/AstralCactus"); AstralCactusGlowTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/Tiles/AstralCactusGlow"); @@ -378,6 +380,7 @@ namespace CalamityMod Attunement.Unload(); EnchantmentManager.UnloadAllEnchantments(); + VanillaArmorChangeManager.Unload(); CalamityLists.UnloadLists(); NPCStats.Unload(); CalamityGlobalItem.UnloadTweaks(); @@ -745,9 +748,9 @@ namespace CalamityMod { ModContent.NPCType(), velocityScaleMin }, { ModContent.NPCType(), velocityScaleMin }, { ModContent.NPCType(), velocityScaleMin }, - { ModContent.NPCType(), bitingEnemeyVelocityScale }, - { ModContent.NPCType(), bitingEnemeyVelocityScale }, - { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), bitingEnemeyVelocityScale }, + { ModContent.NPCType(), bitingEnemeyVelocityScale }, + { ModContent.NPCType(), velocityScaleMin }, { ModContent.NPCType(), bitingEnemeyVelocityScale }, { ModContent.NPCType(), velocityScaleMin }, { ModContent.NPCType(), velocityScaleMin }, @@ -881,22 +884,22 @@ namespace CalamityMod music = GetMusicFromMusicMod("SulphurousSea") ?? MusicID.Desert; } } - if (CalamityWorld.DoGSecondStageCountdown <= 530 && CalamityWorld.DoGSecondStageCountdown > 50) // 8 seconds before DoG returns - { - music = GetMusicFromMusicMod("DevourerOfGodsP2") ?? MusicID.LunarBoss; - priority = MusicPriority.BossMedium; - } + if (CalamityWorld.DoGSecondStageCountdown <= 530 && CalamityWorld.DoGSecondStageCountdown > 50) // 8 seconds before DoG returns + { + music = GetMusicFromMusicMod("DevourerOfGodsP2") ?? MusicID.LunarBoss; + priority = MusicPriority.BossMedium; + } - // This section handles boss rush music. However, at the time of PR-ing the boss rush visuals branch not all - // of the boss rush themes have been completed. As such, the custom music is intentionally omitted for the time being. - /* + // This section handles boss rush music. However, at the time of PR-ing the boss rush visuals branch not all + // of the boss rush themes have been completed. As such, the custom music is intentionally omitted for the time being. + /* if (BossRushEvent.BossRushActive && BossRushEvent.StartTimer >= BossRushEvent.StartEffectTotalTime) { music = BossRushEvent.MusicToPlay; priority = MusicPriority.BossHigh; } */ - } + } } } #endregion diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index da66668749..b4e0ea0499 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -5,6 +5,7 @@ using CalamityMod.CalPlayer; using CalamityMod.Events; using CalamityMod.Items.Accessories; using CalamityMod.Items.Potions; +using CalamityMod.Items.VanillaArmorChanges; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Summon; using CalamityMod.NPCs.Other; @@ -31,13 +32,13 @@ using Terraria.ModLoader.IO; namespace CalamityMod.Items { - public partial class CalamityGlobalItem : GlobalItem + public partial class CalamityGlobalItem : GlobalItem { - public override bool InstancePerEntity => true; - public override bool CloneNewInstances => true; + public override bool InstancePerEntity => true; + public override bool CloneNewInstances => true; - public bool rogue = false; - public float StealthGenBonus; + public bool rogue = false; + public float StealthGenBonus; #region Chargeable Item Variables public bool UsesCharge = false; @@ -48,65 +49,65 @@ namespace CalamityMod.Items // If you want a different amount of charge used for alt fire, then set a different value here. public float ChargePerAltUse = -1f; public float ChargeRatio - { + { get - { + { float ratio = Charge / MaxCharge; - return float.IsNaN(ratio) || float.IsInfinity(ratio) ? 0f : MathHelper.Clamp(ratio, 0f, 1f); - } - } - #endregion + return float.IsNaN(ratio) || float.IsInfinity(ratio) ? 0f : MathHelper.Clamp(ratio, 0f, 1f); + } + } + #endregion - #region Enchantment Variables - public bool CannotBeEnchanted = false; - public Enchantment? AppliedEnchantment = null; - public float DischargeEnchantExhaustion = 0; - public float DischargeExhaustionRatio - { - get - { - float ratio = DischargeEnchantExhaustion / DischargeEnchantExhaustionCap; - return float.IsNaN(ratio) || float.IsInfinity(ratio) ? 0f : MathHelper.Clamp(ratio, 0f, 1f); - } - } - public const float DischargeEnchantExhaustionCap = 1600f; - public const float DischargeEnchantMinDamageFactor = 0.77f; - public const float DischargeEnchantMaxDamageFactor = 1.26f; - #endregion + #region Enchantment Variables + public bool CannotBeEnchanted = false; + public Enchantment? AppliedEnchantment = null; + public float DischargeEnchantExhaustion = 0; + public float DischargeExhaustionRatio + { + get + { + float ratio = DischargeEnchantExhaustion / DischargeEnchantExhaustionCap; + return float.IsNaN(ratio) || float.IsInfinity(ratio) ? 0f : MathHelper.Clamp(ratio, 0f, 1f); + } + } + public const float DischargeEnchantExhaustionCap = 1600f; + public const float DischargeEnchantMinDamageFactor = 0.77f; + public const float DischargeEnchantMaxDamageFactor = 1.26f; + #endregion - // Miscellaneous stuff - public CalamityRarity customRarity = CalamityRarity.NoEffect; + // Miscellaneous stuff + public CalamityRarity customRarity = CalamityRarity.NoEffect; public int timesUsed = 0; public int reforgeTier = 0; public bool donorItem = false; public bool devItem = false; - public bool canFirePointBlankShots = false; - public bool trueMelee = false; + public bool canFirePointBlankShots = false; + public bool trueMelee = false; - public static readonly Color ExhumedTooltipColor = new Color(198, 27, 64); + public static readonly Color ExhumedTooltipColor = new Color(198, 27, 64); // See RogueWeapon.cs for rogue modifier shit #region Modifiers public CalamityGlobalItem() - { - StealthGenBonus = 1f; - } + { + StealthGenBonus = 1f; + } - public override GlobalItem Clone(Item item, Item itemClone) - { - CalamityGlobalItem myClone = (CalamityGlobalItem)base.Clone(item, itemClone); - myClone.StealthGenBonus = StealthGenBonus; - myClone.DischargeEnchantExhaustion = DischargeEnchantExhaustion; - myClone.Charge = Charge; - return myClone; - } + public override GlobalItem Clone(Item item, Item itemClone) + { + CalamityGlobalItem myClone = (CalamityGlobalItem)base.Clone(item, itemClone); + myClone.StealthGenBonus = StealthGenBonus; + myClone.DischargeEnchantExhaustion = DischargeEnchantExhaustion; + myClone.Charge = Charge; + return myClone; + } - public override bool NewPreReforge(Item item) - { - StealthGenBonus = 1f; - return true; - } - #endregion + public override bool NewPreReforge(Item item) + { + StealthGenBonus = 1f; + return true; + } + #endregion #region SetDefaults public override void SetDefaults(Item item) @@ -117,78 +118,78 @@ namespace CalamityMod.Items item.rare = ItemRarityID.Purple; // All items that stack to 30, 50, 75, 99 , or 999 now stack to 9999 instead. - if (item.maxStack == 30 || item.maxStack == 50 || item.maxStack == 75 || item.maxStack == 99 || item.maxStack == 999) + if (item.maxStack == 30 || item.maxStack == 50 || item.maxStack == 75 || item.maxStack == 99 || item.maxStack == 999) item.maxStack = 9999; - // Shield of Cthulhu cannot be enchanted (it is an accessory with a damage value). - // TODO -- there are better ways to do this. Just stop letting accessories be enchanted, even if they do have a damage value. - if (item.type == ItemID.EoCShield) - CannotBeEnchanted = true; + // Shield of Cthulhu cannot be enchanted (it is an accessory with a damage value). + // TODO -- there are better ways to do this. Just stop letting accessories be enchanted, even if they do have a damage value. + if (item.type == ItemID.EoCShield) + CannotBeEnchanted = true; - // Star Cannon no longer makes noise. - if (item.type == ItemID.StarCannon) - item.UseSound = null; + // Star Cannon no longer makes noise. + if (item.type == ItemID.StarCannon) + item.UseSound = null; - // Fix Bones being attracted to the player when you have open ammo slots - if (item.type == ItemID.Bone) - item.notAmmo = true; + // Fix Bones being attracted to the player when you have open ammo slots + if (item.type == ItemID.Bone) + item.notAmmo = true; - // Modified Pearlwood items are now Light Red - if (item.type == ItemID.PearlwoodBow || item.type == ItemID.PearlwoodHammer || item.type == ItemID.PearlwoodSword) - item.rare = ItemRarityID.LightRed; + // Modified Pearlwood items are now Light Red + if (item.type == ItemID.PearlwoodBow || item.type == ItemID.PearlwoodHammer || item.type == ItemID.PearlwoodSword) + item.rare = ItemRarityID.LightRed; - // Make most expert items no longer expert because they drop in all modes now. - switch (item.type) - { - case ItemID.RoyalGel: - case ItemID.EoCShield: - case ItemID.WormScarf: - case ItemID.BrainOfConfusion: - case ItemID.HiveBackpack: - case ItemID.BoneGlove: - case ItemID.MechanicalBatteryPiece: - case ItemID.MechanicalWagonPiece: - case ItemID.MechanicalWheelPiece: - case ItemID.SporeSac: - case ItemID.ShinyStone: - case ItemID.ShrimpyTruffle: - case ItemID.GravityGlobe: - case ItemID.SuspiciousLookingTentacle: - item.expert = false; - break; - } + // Make most expert items no longer expert because they drop in all modes now. + switch (item.type) + { + case ItemID.RoyalGel: + case ItemID.EoCShield: + case ItemID.WormScarf: + case ItemID.BrainOfConfusion: + case ItemID.HiveBackpack: + case ItemID.BoneGlove: + case ItemID.MechanicalBatteryPiece: + case ItemID.MechanicalWagonPiece: + case ItemID.MechanicalWheelPiece: + case ItemID.SporeSac: + case ItemID.ShinyStone: + case ItemID.ShrimpyTruffle: + case ItemID.GravityGlobe: + case ItemID.SuspiciousLookingTentacle: + item.expert = false; + break; + } - SetDefaults_ApplyTweaks(item); + SetDefaults_ApplyTweaks(item); - // TODO -- these properties should be some sort of dictionary. - // Perhaps the solution here is to just apply all changes of all kinds using the "Balance" system - if (CalamityLists.noGravityList.Contains(item.type)) - ItemID.Sets.ItemNoGravity[item.type] = true; + // TODO -- these properties should be some sort of dictionary. + // Perhaps the solution here is to just apply all changes of all kinds using the "Balance" system + if (CalamityLists.noGravityList.Contains(item.type)) + ItemID.Sets.ItemNoGravity[item.type] = true; - if (CalamityLists.lavaFishList.Contains(item.type)) - ItemID.Sets.CanFishInLava[item.type] = true; + if (CalamityLists.lavaFishList.Contains(item.type)) + ItemID.Sets.CanFishInLava[item.type] = true; } #endregion #region Shoot public override bool Shoot(Item item, Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - CalamityPlayer modPlayer = player.Calamity(); - if (Main.myPlayer == player.whoAmI && player.Calamity().cursedSummonsEnchant && NPC.CountNPCS(ModContent.NPCType()) < 2) - { - CalamityNetcode.NewNPC_ClientSide(Main.MouseWorld, ModContent.NPCType(), player); - Main.PlaySound(SoundID.DD2_DarkMageSummonSkeleton, Main.MouseWorld); - } + CalamityPlayer modPlayer = player.Calamity(); + if (Main.myPlayer == player.whoAmI && player.Calamity().cursedSummonsEnchant && NPC.CountNPCS(ModContent.NPCType()) < 2) + { + CalamityNetcode.NewNPC_ClientSide(Main.MouseWorld, ModContent.NPCType(), player); + Main.PlaySound(SoundID.DD2_DarkMageSummonSkeleton, Main.MouseWorld); + } - bool belowHalfMana = player.statMana < player.statManaMax2 * 0.5f; - if (Main.myPlayer == player.whoAmI && player.Calamity().manaMonsterEnchant && Main.rand.NextBool(12) && player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0 && belowHalfMana) - { - int monsterDamage = (int)(165000 * player.MagicDamage()); - Vector2 shootVelocity = player.SafeDirectionTo(Main.MouseWorld, -Vector2.UnitY).RotatedByRandom(0.07f) * Main.rand.NextFloat(4f, 5f); - Projectile.NewProjectile(player.Center + shootVelocity, shootVelocity, ModContent.ProjectileType(), monsterDamage, 0f, player.whoAmI); - } + bool belowHalfMana = player.statMana < player.statManaMax2 * 0.5f; + if (Main.myPlayer == player.whoAmI && player.Calamity().manaMonsterEnchant && Main.rand.NextBool(12) && player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0 && belowHalfMana) + { + int monsterDamage = (int)(165000 * player.MagicDamage()); + Vector2 shootVelocity = player.SafeDirectionTo(Main.MouseWorld, -Vector2.UnitY).RotatedByRandom(0.07f) * Main.rand.NextFloat(4f, 5f); + Projectile.NewProjectile(player.Center + shootVelocity, shootVelocity, ModContent.ProjectileType(), monsterDamage, 0f, player.whoAmI); + } - if (rogue) + if (rogue) { speedX *= modPlayer.throwingVelocity; speedY *= modPlayer.throwingVelocity; @@ -205,7 +206,7 @@ namespace CalamityMod.Items speedX *= 1.25f; speedY *= 1.25f; } - Vector2 velocity = new Vector2(speedX, speedY); + Vector2 velocity = new Vector2(speedX, speedY); if (modPlayer.luxorsGift) { // useTime 9 = 0.9 useTime 2 = 0.2 @@ -217,48 +218,48 @@ namespace CalamityMod.Items if (player.whoAmI == Main.myPlayer) { - if (item.melee) - { - int projectile = Projectile.NewProjectile(position, velocity * 0.5f, ModContent.ProjectileType(), (int)(newDamage * 0.25), 0f, player.whoAmI); - if (projectile.WithinBounds(Main.maxProjectiles)) - Main.projectile[projectile].Calamity().forceTypeless = true; - } - else if (rogue) - { - int projectile = Projectile.NewProjectile(position, velocity, ModContent.ProjectileType(), (int)(newDamage * 0.2), 0f, player.whoAmI); - if (projectile.WithinBounds(Main.maxProjectiles)) - Main.projectile[projectile].Calamity().forceTypeless = true; - } - else if (item.ranged) - { - int projectile = Projectile.NewProjectile(position, velocity * 1.5f, ModContent.ProjectileType(), (int)(newDamage * 0.15), 0f, player.whoAmI); - if (projectile.WithinBounds(Main.maxProjectiles)) - Main.projectile[projectile].Calamity().forceTypeless = true; - } - else if (item.magic) - { - int projectile = Projectile.NewProjectile(position, velocity, ModContent.ProjectileType(), (int)(newDamage * 0.3), 0f, player.whoAmI); - if (projectile.WithinBounds(Main.maxProjectiles)) - Main.projectile[projectile].Calamity().forceTypeless = true; - } - else if (item.summon && player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) - { - int projectile = Projectile.NewProjectile(position, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, player.whoAmI); - if (projectile.WithinBounds(Main.maxProjectiles)) - Main.projectile[projectile].Calamity().forceTypeless = true; - } + if (item.melee) + { + int projectile = Projectile.NewProjectile(position, velocity * 0.5f, ModContent.ProjectileType(), (int)(newDamage * 0.25), 0f, player.whoAmI); + if (projectile.WithinBounds(Main.maxProjectiles)) + Main.projectile[projectile].Calamity().forceTypeless = true; + } + else if (rogue) + { + int projectile = Projectile.NewProjectile(position, velocity, ModContent.ProjectileType(), (int)(newDamage * 0.2), 0f, player.whoAmI); + if (projectile.WithinBounds(Main.maxProjectiles)) + Main.projectile[projectile].Calamity().forceTypeless = true; + } + else if (item.ranged) + { + int projectile = Projectile.NewProjectile(position, velocity * 1.5f, ModContent.ProjectileType(), (int)(newDamage * 0.15), 0f, player.whoAmI); + if (projectile.WithinBounds(Main.maxProjectiles)) + Main.projectile[projectile].Calamity().forceTypeless = true; + } + else if (item.magic) + { + int projectile = Projectile.NewProjectile(position, velocity, ModContent.ProjectileType(), (int)(newDamage * 0.3), 0f, player.whoAmI); + if (projectile.WithinBounds(Main.maxProjectiles)) + Main.projectile[projectile].Calamity().forceTypeless = true; + } + else if (item.summon && player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) + { + int projectile = Projectile.NewProjectile(position, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, player.whoAmI); + if (projectile.WithinBounds(Main.maxProjectiles)) + Main.projectile[projectile].Calamity().forceTypeless = true; + } } } if (modPlayer.bloodflareMage && modPlayer.canFireBloodflareMageProjectile) { if (item.magic) { - modPlayer.canFireBloodflareMageProjectile = false; - if (player.whoAmI == Main.myPlayer) + modPlayer.canFireBloodflareMageProjectile = false; + if (player.whoAmI == Main.myPlayer) { - // Bloodflare Mage Bolt: 130%, soft cap starts at 2000 base damage - int bloodflareBoltDamage = CalamityUtils.DamageSoftCap(damage * 1.3, 2600); - Projectile.NewProjectile(position, velocity, ModContent.ProjectileType(), bloodflareBoltDamage, 1f, player.whoAmI); + // Bloodflare Mage Bolt: 130%, soft cap starts at 2000 base damage + int bloodflareBoltDamage = CalamityUtils.DamageSoftCap(damage * 1.3, 2600); + Projectile.NewProjectile(position, velocity, ModContent.ProjectileType(), bloodflareBoltDamage, 1f, player.whoAmI); } } } @@ -266,13 +267,13 @@ namespace CalamityMod.Items { if (item.ranged) { - modPlayer.canFireBloodflareRangedProjectile = false; - if (player.whoAmI == Main.myPlayer) + modPlayer.canFireBloodflareRangedProjectile = false; + if (player.whoAmI == Main.myPlayer) { - // Bloodflare Ranged Bloodsplosion: 80%, soft cap starts at 150 base damage - // This is intentionally extremely low because this effect can be grossly overpowered with sniper rifles and the like. - int bloodsplosionDamage = CalamityUtils.DamageSoftCap(damage * 0.8, 120); - Projectile.NewProjectile(position, velocity, ModContent.ProjectileType(), bloodsplosionDamage, 2f, player.whoAmI); + // Bloodflare Ranged Bloodsplosion: 80%, soft cap starts at 150 base damage + // This is intentionally extremely low because this effect can be grossly overpowered with sniper rifles and the like. + int bloodsplosionDamage = CalamityUtils.DamageSoftCap(damage * 0.8, 120); + Projectile.NewProjectile(position, velocity, ModContent.ProjectileType(), bloodsplosionDamage, 2f, player.whoAmI); } } } @@ -281,11 +282,11 @@ namespace CalamityMod.Items if (modPlayer.tarraCrits >= 5 && player.whoAmI == Main.myPlayer) { modPlayer.tarraCrits = 0; - // Tarragon Mage Leaves: (8-10) x 20%, soft cap starts at 200 base damage - int leafAmt = 8 + Main.rand.Next(3); // 8, 9, or 10 - int leafDamage = (int)(damage * 0.2); + // Tarragon Mage Leaves: (8-10) x 20%, soft cap starts at 200 base damage + int leafAmt = 8 + Main.rand.Next(3); // 8, 9, or 10 + int leafDamage = (int)(damage * 0.2); - for (int l = 0; l < leafAmt; l++) + for (int l = 0; l < leafAmt; l++) { float spreadMult = 0.025f * l; float xDiff = speedX + Main.rand.Next(-25, 26) * spreadMult; @@ -294,21 +295,21 @@ namespace CalamityMod.Items speed = item.shootSpeed / speed; xDiff *= speed; yDiff *= speed; - int projectile = Projectile.NewProjectile(position, new Vector2(xDiff, yDiff), ProjectileID.Leaf, leafDamage, knockBack, player.whoAmI); - if (projectile.WithinBounds(Main.maxProjectiles)) - Main.projectile[projectile].Calamity().forceTypeless = true; - } + int projectile = Projectile.NewProjectile(position, new Vector2(xDiff, yDiff), ProjectileID.Leaf, leafDamage, knockBack, player.whoAmI); + if (projectile.WithinBounds(Main.maxProjectiles)) + Main.projectile[projectile].Calamity().forceTypeless = true; + } } } if (modPlayer.ataxiaBolt && modPlayer.canFireAtaxiaRangedProjectile) { if (item.ranged) { - modPlayer.canFireAtaxiaRangedProjectile = false; + modPlayer.canFireAtaxiaRangedProjectile = false; if (player.whoAmI == Main.myPlayer) { - int ataxiaFlareDamage = (int)(damage * 0.25); - Projectile.NewProjectile(position, velocity * 1.25f, ModContent.ProjectileType(), ataxiaFlareDamage, 2f, player.whoAmI); + int ataxiaFlareDamage = (int)(damage * 0.25); + Projectile.NewProjectile(position, velocity * 1.25f, ModContent.ProjectileType(), ataxiaFlareDamage, 2f, player.whoAmI); } } } @@ -316,12 +317,12 @@ namespace CalamityMod.Items { if (item.ranged) { - modPlayer.canFireGodSlayerRangedProjectile = false; - if (player.whoAmI == Main.myPlayer) + modPlayer.canFireGodSlayerRangedProjectile = false; + if (player.whoAmI == Main.myPlayer) { - // God Slayer Ranged Shrapnel: 100%, soft cap starts at 800 base damage - int shrapnelRoundDamage = CalamityUtils.DamageSoftCap(damage, 800); - Projectile.NewProjectile(position, velocity * 1.25f, ModContent.ProjectileType(), shrapnelRoundDamage, 2f, player.whoAmI); + // God Slayer Ranged Shrapnel: 100%, soft cap starts at 800 base damage + int shrapnelRoundDamage = CalamityUtils.DamageSoftCap(damage, 800); + Projectile.NewProjectile(position, velocity * 1.25f, ModContent.ProjectileType(), shrapnelRoundDamage, 2f, player.whoAmI); } } } @@ -329,12 +330,12 @@ namespace CalamityMod.Items { if (rogue) { - modPlayer.canFireAtaxiaRogueProjectile = false; - int flareID = ModContent.ProjectileType(); + modPlayer.canFireAtaxiaRogueProjectile = false; + int flareID = ModContent.ProjectileType(); - // Ataxia Rogue Flares: 8 x 50%, soft cap starts at 200 base damage - int flareDamage = CalamityUtils.DamageSoftCap(damage * 0.5, 100); - if (player.whoAmI == Main.myPlayer) + // Ataxia Rogue Flares: 8 x 50%, soft cap starts at 200 base damage + int flareDamage = CalamityUtils.DamageSoftCap(damage * 0.5, 100); + if (player.whoAmI == Main.myPlayer) { Main.PlaySound(SoundID.Item20, player.Center); float spread = 45f * 0.0174f; @@ -356,9 +357,9 @@ namespace CalamityMod.Items { if (player.whoAmI == Main.myPlayer) { - // Victide All-class Seashells: 200%, soft cap starts at 23 base damage - int seashellDamage = CalamityUtils.DamageSoftCap(damage * 2, 46); - Projectile.NewProjectile(position, velocity * 1.25f, ModContent.ProjectileType(), seashellDamage, 1f, player.whoAmI); + // Victide All-class Seashells: 200%, soft cap starts at 23 base damage + int seashellDamage = CalamityUtils.DamageSoftCap(damage * 2, 46); + Projectile.NewProjectile(position, velocity * 1.25f, ModContent.ProjectileType(), seashellDamage, 1f, player.whoAmI); } } } @@ -366,18 +367,18 @@ namespace CalamityMod.Items { if (item.ranged && Main.rand.NextBool(20)) { - double damageMult = item.useTime / 30D; - if (damageMult < 0.35) - damageMult = 0.35; + double damageMult = item.useTime / 30D; + if (damageMult < 0.35) + damageMult = 0.35; - int newDamage = (int)(damage * 2 * damageMult); + int newDamage = (int)(damage * 2 * damageMult); if (player.whoAmI == Main.myPlayer) { int projectile = Projectile.NewProjectile(position, velocity * 1.25f, ModContent.ProjectileType(), newDamage, 2f, player.whoAmI); - if (projectile.WithinBounds(Main.maxProjectiles)) - Main.projectile[projectile].Calamity().forceTypeless = true; - } + if (projectile.WithinBounds(Main.maxProjectiles)) + Main.projectile[projectile].Calamity().forceTypeless = true; + } } } if (modPlayer.prismaticRegalia) @@ -386,50 +387,50 @@ namespace CalamityMod.Items { if (player.whoAmI == Main.myPlayer) { - for (int i = -5; i <= 5; i += 5) - { - if (i != 0) - { - Vector2 perturbedSpeed = velocity.RotatedBy(MathHelper.ToRadians(i)); - int rocket = Projectile.NewProjectile(position, perturbedSpeed, ModContent.ProjectileType(), (int)(damage * 0.25), 2f, player.whoAmI); - if (rocket.WithinBounds(Main.maxProjectiles)) - Main.projectile[rocket].Calamity().forceTypeless = true; - } - } + for (int i = -5; i <= 5; i += 5) + { + if (i != 0) + { + Vector2 perturbedSpeed = velocity.RotatedBy(MathHelper.ToRadians(i)); + int rocket = Projectile.NewProjectile(position, perturbedSpeed, ModContent.ProjectileType(), (int)(damage * 0.25), 2f, player.whoAmI); + if (rocket.WithinBounds(Main.maxProjectiles)) + Main.projectile[rocket].Calamity().forceTypeless = true; + } + } } } } if (modPlayer.harpyWingBoost && modPlayer.harpyRing) { - if (Main.rand.NextBool(5)) - { + if (Main.rand.NextBool(5)) + { if (player.whoAmI == Main.myPlayer) { - float spreadX = speedX + Main.rand.NextFloat(-0.75f, 0.75f); - float spreadY = speedY + Main.rand.NextFloat(-0.75f, 0.75f); + float spreadX = speedX + Main.rand.NextFloat(-0.75f, 0.75f); + float spreadY = speedY + Main.rand.NextFloat(-0.75f, 0.75f); int feather = Projectile.NewProjectile(position, new Vector2(spreadX, spreadY) * 1.25f, ModContent.ProjectileType(), (int)(damage * 0.3), 2f, player.whoAmI); - if (feather.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[feather].usesLocalNPCImmunity = true; - Main.projectile[feather].localNPCHitCooldown = 10; - Main.projectile[feather].Calamity().forceTypeless = true; - } + if (feather.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[feather].usesLocalNPCImmunity = true; + Main.projectile[feather].localNPCHitCooldown = 10; + Main.projectile[feather].Calamity().forceTypeless = true; + } } } } - if (item.type == ItemID.StarCannon) - { - Vector2 muzzleOffset = Vector2.Normalize(new Vector2(speedX, speedY)) * 5f; - if (Collision.CanHit(position, 0, 0, position + muzzleOffset, 0, 0)) - { - position += muzzleOffset; - } - Projectile.NewProjectile(position, velocity, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - Main.PlaySound(SoundID.Item11.WithPitchVariance(0.05f), position); - return false; - } - if (item.type == ItemID.PearlwoodBow) - { + if (item.type == ItemID.StarCannon) + { + Vector2 muzzleOffset = Vector2.Normalize(new Vector2(speedX, speedY)) * 5f; + if (Collision.CanHit(position, 0, 0, position + muzzleOffset, 0, 0)) + { + position += muzzleOffset; + } + Projectile.NewProjectile(position, velocity, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + Main.PlaySound(SoundID.Item11.WithPitchVariance(0.05f), position); + return false; + } + if (item.type == ItemID.PearlwoodBow) + { for (int i = 0; i < Main.maxProjectiles; i++) { if (Main.projectile[i].active && (Main.projectile[i].type == ModContent.ProjectileType() || Main.projectile[i].type == ModContent.ProjectileType()) && Main.projectile[i].owner == player.whoAmI) @@ -437,18 +438,18 @@ namespace CalamityMod.Items Main.projectile[i].Kill(); } } - for (int i = -8; i <= 8; i += 8) - { - Vector2 perturbedSpeed = velocity.RotatedBy(MathHelper.ToRadians(i)); - Projectile.NewProjectile(position, perturbedSpeed, ModContent.ProjectileType(), damage, 0f, player.whoAmI); - } - } + for (int i = -8; i <= 8; i += 8) + { + Vector2 perturbedSpeed = velocity.RotatedBy(MathHelper.ToRadians(i)); + Projectile.NewProjectile(position, perturbedSpeed, ModContent.ProjectileType(), damage, 0f, player.whoAmI); + } + } return true; } - #endregion + #endregion - #region Saving And Loading - public override bool NeedsSaving(Item item) + #region Saving And Loading + public override bool NeedsSaving(Item item) { return rogue || canFirePointBlankShots || trueMelee || timesUsed != 0 || customRarity != 0 || Charge != 0 || reforgeTier != 0 || AppliedEnchantment.HasValue || DischargeEnchantExhaustion != 0; } @@ -461,20 +462,20 @@ namespace CalamityMod.Items ["timesUsed"] = timesUsed, ["rarity"] = (int)customRarity, ["charge"] = Charge, - ["reforgeTier"] = reforgeTier, - ["enchantmentID"] = AppliedEnchantment.HasValue ? AppliedEnchantment.Value.ID : 0, - ["DischargeEnchantExhaustion"] = DischargeEnchantExhaustion, - ["canFirePointBlankShots"] = canFirePointBlankShots, - ["trueMelee"] = trueMelee - }; + ["reforgeTier"] = reforgeTier, + ["enchantmentID"] = AppliedEnchantment.HasValue ? AppliedEnchantment.Value.ID : 0, + ["DischargeEnchantExhaustion"] = DischargeEnchantExhaustion, + ["canFirePointBlankShots"] = canFirePointBlankShots, + ["trueMelee"] = trueMelee + }; } public override void Load(Item item, TagCompound tag) { rogue = tag.GetBool("rogue"); - canFirePointBlankShots = tag.GetBool("canFirePointBlankShots"); - trueMelee = tag.GetBool("trueMelee"); - timesUsed = tag.GetInt("timesUsed"); + canFirePointBlankShots = tag.GetBool("canFirePointBlankShots"); + trueMelee = tag.GetBool("trueMelee"); + timesUsed = tag.GetInt("timesUsed"); customRarity = (CalamityRarity)tag.GetInt("rarity"); // Changed charge from int to float. If an old charge int is present, load that instead. @@ -483,16 +484,16 @@ namespace CalamityMod.Items else Charge = tag.GetFloat("charge"); - DischargeEnchantExhaustion = tag.GetFloat("DischargeEnchantExhaustion"); - reforgeTier = tag.GetInt("reforgeTimer"); - Enchantment? savedEnchantment = EnchantmentManager.FindByID(tag.GetInt("enchantmentID")); - if (savedEnchantment.HasValue) - { - AppliedEnchantment = savedEnchantment.Value; - bool hasCreationEffect = AppliedEnchantment.Value.CreationEffect != null; - item.Calamity().AppliedEnchantment.Value.CreationEffect?.Invoke(item); - } - } + DischargeEnchantExhaustion = tag.GetFloat("DischargeEnchantExhaustion"); + reforgeTier = tag.GetInt("reforgeTimer"); + Enchantment? savedEnchantment = EnchantmentManager.FindByID(tag.GetInt("enchantmentID")); + if (savedEnchantment.HasValue) + { + AppliedEnchantment = savedEnchantment.Value; + bool hasCreationEffect = AppliedEnchantment.Value.CreationEffect != null; + item.Calamity().AppliedEnchantment.Value.CreationEffect?.Invoke(item); + } + } public override void LoadLegacy(Item item, BinaryReader reader) { @@ -500,15 +501,15 @@ namespace CalamityMod.Items customRarity = (CalamityRarity)reader.ReadInt32(); timesUsed = reader.ReadInt32(); Charge = reader.ReadSingle(); - reforgeTier = reader.ReadInt32(); + reforgeTier = reader.ReadInt32(); if (loadVersion == 0) { BitsByte flags = reader.ReadByte(); rogue = flags[0]; - canFirePointBlankShots = flags[1]; - trueMelee = flags[2]; - } + canFirePointBlankShots = flags[1]; + trueMelee = flags[2]; + } else { ModContent.GetInstance().Logger.Error("Unknown loadVersion: " + loadVersion); @@ -519,40 +520,40 @@ namespace CalamityMod.Items { BitsByte flags = new BitsByte(); flags[0] = rogue; - flags[1] = canFirePointBlankShots; - flags[2] = trueMelee; + flags[1] = canFirePointBlankShots; + flags[2] = trueMelee; - writer.Write(flags); + writer.Write(flags); writer.Write((int)customRarity); writer.Write(timesUsed); writer.Write(Charge); - writer.Write(reforgeTier); - writer.Write(AppliedEnchantment.HasValue ? AppliedEnchantment.Value.ID : 0); - writer.Write(DischargeEnchantExhaustion); - } + writer.Write(reforgeTier); + writer.Write(AppliedEnchantment.HasValue ? AppliedEnchantment.Value.ID : 0); + writer.Write(DischargeEnchantExhaustion); + } public override void NetReceive(Item item, BinaryReader reader) { BitsByte flags = reader.ReadByte(); rogue = flags[0]; - canFirePointBlankShots = flags[1]; - trueMelee = flags[2]; + canFirePointBlankShots = flags[1]; + trueMelee = flags[2]; - customRarity = (CalamityRarity)reader.ReadInt32(); + customRarity = (CalamityRarity)reader.ReadInt32(); timesUsed = reader.ReadInt32(); Charge = reader.ReadSingle(); - reforgeTier = reader.ReadInt32(); + reforgeTier = reader.ReadInt32(); - Enchantment? savedEnchantment = EnchantmentManager.FindByID(reader.ReadInt32()); - if (savedEnchantment.HasValue) - { - AppliedEnchantment = savedEnchantment.Value; - bool hasCreationEffect = AppliedEnchantment.Value.CreationEffect != null; - if (hasCreationEffect) - item.Calamity().AppliedEnchantment.Value.CreationEffect(item); - } - DischargeEnchantExhaustion = reader.ReadSingle(); - } + Enchantment? savedEnchantment = EnchantmentManager.FindByID(reader.ReadInt32()); + if (savedEnchantment.HasValue) + { + AppliedEnchantment = savedEnchantment.Value; + bool hasCreationEffect = AppliedEnchantment.Value.CreationEffect != null; + if (hasCreationEffect) + item.Calamity().AppliedEnchantment.Value.CreationEffect(item); + } + DischargeEnchantExhaustion = reader.ReadSingle(); + } #endregion #region Pickup Item Changes @@ -581,33 +582,33 @@ namespace CalamityMod.Items #region Use Item Changes public override bool UseItem(Item item, Player player) { - if (player.Calamity().evilSmasherBoost > 0) - { - if (item.type != ModContent.ItemType()) - player.Calamity().evilSmasherBoost = 0; - } + if (player.Calamity().evilSmasherBoost > 0) + { + if (item.type != ModContent.ItemType()) + player.Calamity().evilSmasherBoost = 0; + } - if (player.HasBuff(BuffID.ParryDamageBuff)) - { - if (item.type != ItemID.DD2SquireDemonSword) - { - player.parryDamageBuff = false; - player.ClearBuff(BuffID.ParryDamageBuff); - } - } + if (player.HasBuff(BuffID.ParryDamageBuff)) + { + if (item.type != ItemID.DD2SquireDemonSword) + { + player.parryDamageBuff = false; + player.ClearBuff(BuffID.ParryDamageBuff); + } + } - // Give 2 minutes of Honey buff when drinking Bottled Honey. + // Give 2 minutes of Honey buff when drinking Bottled Honey. if (item.type == ItemID.BottledHoney) - player.AddBuff(BuffID.Honey, 7200); + player.AddBuff(BuffID.Honey, 7200); - // Moon Lord instantly spawns when Celestial Sigil is used. - if (item.type == ItemID.CelestialSigil) - { - NPC.MoonLordCountdown = 1; - NetMessage.SendData(MessageID.MoonlordCountdown, -1, -1, null, NPC.MoonLordCountdown); - } + // Moon Lord instantly spawns when Celestial Sigil is used. + if (item.type == ItemID.CelestialSigil) + { + NPC.MoonLordCountdown = 1; + NetMessage.SendData(MessageID.MoonlordCountdown, -1, -1, null, NPC.MoonLordCountdown); + } - return base.UseItem(item, player); + return base.UseItem(item, player); } public override bool AltFunctionUse(Item item, Player player) @@ -765,7 +766,7 @@ namespace CalamityMod.Items if (PopupGUIManager.AnyGUIsActive) return false; - if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0 && + if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0 && (item.damage > 0 || item.ammo != AmmoID.None)) { return false; // Don't use weapons if you're charging with a spear @@ -774,34 +775,34 @@ namespace CalamityMod.Items // Conversion for Andromeda if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) { - if (item.type == ItemID.WireKite) - return false; + if (item.type == ItemID.WireKite) + return false; if (item.pick > 0 || item.axe > 0 || item.hammer > 0 || item.fishingPole > 0) return false; // compiler optimization: && short-circuits, so if altFunctionUse != 0, Andromeda code is never called. if (item.Calamity().rogue || item.magic || item.ranged || item.melee) - return player.altFunctionUse == 0 && PrototypeAndromechaRing.TransformItemUsage(item, player); + return player.altFunctionUse == 0 && PrototypeAndromechaRing.TransformItemUsage(item, player); } // Conversion for Profaned Soul Crystal if (modPlayer.profanedCrystalBuffs && item.pick == 0 && item.axe == 0 && item.hammer == 0 && item.autoReuse && (modItem.rogue || item.magic || item.ranged || item.melee)) - return player.altFunctionUse == 0 ? ProfanedSoulCrystal.TransformItemUsage(item, player) : AltFunctionUse(item, player); + return player.altFunctionUse == 0 ? ProfanedSoulCrystal.TransformItemUsage(item, player) : AltFunctionUse(item, player); - if (!item.IsAir) - { - // Exhaust the weapon if it has the necessary enchant. - if (modPlayer.dischargingItemEnchant) - { - float exhaustionCost = item.useTime * 2.25f; - if (exhaustionCost < 10f) - exhaustionCost = 10f; - DischargeEnchantExhaustion = MathHelper.Clamp(DischargeEnchantExhaustion - exhaustionCost, 0.001f, DischargeEnchantExhaustionCap); - } + if (!item.IsAir) + { + // Exhaust the weapon if it has the necessary enchant. + if (modPlayer.dischargingItemEnchant) + { + float exhaustionCost = item.useTime * 2.25f; + if (exhaustionCost < 10f) + exhaustionCost = 10f; + DischargeEnchantExhaustion = MathHelper.Clamp(DischargeEnchantExhaustion - exhaustionCost, 0.001f, DischargeEnchantExhaustionCap); + } - // Otherwise, if it doesn't, clear exhaustion. - else - DischargeEnchantExhaustion = 0; - } + // Otherwise, if it doesn't, clear exhaustion. + else + DischargeEnchantExhaustion = 0; + } // Check for sufficient charge if this item uses charge. if (item.type >= ItemID.Count && modItem.UsesCharge) @@ -811,7 +812,7 @@ namespace CalamityMod.Items // If the amount of charge needed is zero or less, ignore the charge requirement entirely (e.g. summon staff right click). if (chargeNeeded > 0f) - { + { if (modItem.Charge < chargeNeeded) return false; @@ -822,10 +823,10 @@ namespace CalamityMod.Items } } - // Handle general use-item effects for the Gem Tech Armor. - player.Calamity().GemTechState.OnItemUseEffects(item); + // Handle general use-item effects for the Gem Tech Armor. + player.Calamity().GemTechState.OnItemUseEffects(item); - if (item.type == ItemID.MonkStaffT1 || CalamityLists.spearAutoreuseList.Contains(item.type)) + if (item.type == ItemID.MonkStaffT1 || CalamityLists.spearAutoreuseList.Contains(item.type)) { return player.ownedProjectileCounts[item.shoot] <= 0; } @@ -859,38 +860,38 @@ namespace CalamityMod.Items } if (item.type == ItemID.RodofDiscord) { - if (player.chaosState) - return false; + if (player.chaosState) + return false; - Vector2 teleportLocation; - teleportLocation.X = (float)Main.mouseX + Main.screenPosition.X; - if (player.gravDir == 1f) - { - teleportLocation.Y = (float)Main.mouseY + Main.screenPosition.Y - (float)player.height; - } - else - { - teleportLocation.Y = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY; - } - teleportLocation.X -= (float)(player.width / 2); - if (teleportLocation.X > 50f && teleportLocation.X < (float)(Main.maxTilesX * 16 - 50) && teleportLocation.Y > 50f && teleportLocation.Y < (float)(Main.maxTilesY * 16 - 50)) - { - int x = (int)teleportLocation.X / 16; - int y = (int)teleportLocation.Y / 16; - bool templeCheck = Main.tile[x, y].wall != WallID.LihzahrdBrickUnsafe || y <= Main.worldSurface || NPC.downedPlantBoss; - if (templeCheck && !Collision.SolidCollision(teleportLocation, player.width, player.height)) - { - int duration = CalamityPlayer.chaosStateDuration; - if (CalamityPlayer.areThereAnyDamnBosses || CalamityPlayer.areThereAnyDamnEvents) - duration = CalamityPlayer.chaosStateDurationBoss; - if (modPlayer.eScarfCooldown) - duration = (int)(duration * 1.5); - else if (modPlayer.scarfCooldown) - duration *= 2; - player.AddBuff(BuffID.ChaosState, duration, true); - } - } - } + Vector2 teleportLocation; + teleportLocation.X = (float)Main.mouseX + Main.screenPosition.X; + if (player.gravDir == 1f) + { + teleportLocation.Y = (float)Main.mouseY + Main.screenPosition.Y - (float)player.height; + } + else + { + teleportLocation.Y = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY; + } + teleportLocation.X -= (float)(player.width / 2); + if (teleportLocation.X > 50f && teleportLocation.X < (float)(Main.maxTilesX * 16 - 50) && teleportLocation.Y > 50f && teleportLocation.Y < (float)(Main.maxTilesY * 16 - 50)) + { + int x = (int)teleportLocation.X / 16; + int y = (int)teleportLocation.Y / 16; + bool templeCheck = Main.tile[x, y].wall != WallID.LihzahrdBrickUnsafe || y <= Main.worldSurface || NPC.downedPlantBoss; + if (templeCheck && !Collision.SolidCollision(teleportLocation, player.width, player.height)) + { + int duration = CalamityPlayer.chaosStateDuration; + if (CalamityPlayer.areThereAnyDamnBosses || CalamityPlayer.areThereAnyDamnEvents) + duration = CalamityPlayer.chaosStateDurationBoss; + if (modPlayer.eScarfCooldown) + duration = (int)(duration * 1.5); + else if (modPlayer.scarfCooldown) + duration *= 2; + player.AddBuff(BuffID.ChaosState, duration, true); + } + } + } if (item.type == ItemID.SuspiciousLookingEye || item.type == ItemID.WormFood || item.type == ItemID.BloodySpine || item.type == ItemID.SlimeCrown || item.type == ItemID.Abeemination || item.type == ItemID.MechanicalEye || item.type == ItemID.MechanicalWorm || item.type == ItemID.MechanicalSkull || item.type == ItemID.CelestialSigil) { return !BossRushEvent.BossRushActive; @@ -902,24 +903,24 @@ namespace CalamityMod.Items #region Modify Weapon Damage public override void ModifyWeaponDamage(Item item, Player player, ref float add, ref float mult, ref float flat) { - // Nerf yoyo glove and bag because it's bad and stupid and dumb and bad. - if (player.yoyoGlove && ItemID.Sets.Yoyo[item.type]) - mult *= 0.66f; + // Nerf yoyo glove and bag because it's bad and stupid and dumb and bad. + if (player.yoyoGlove && ItemID.Sets.Yoyo[item.type]) + mult *= 0.66f; - // Nerf archery potion damage buff from 1.2x to 1.05x. - if (item.useAmmo == AmmoID.Arrow && player.archery) - mult *= 0.875f; + // Nerf archery potion damage buff from 1.2x to 1.05x. + if (item.useAmmo == AmmoID.Arrow && player.archery) + mult *= 0.875f; - if (item.type < ItemID.Count) + if (item.type < ItemID.Count) return; // Summon weapons specifically do not have their damage affected by charge. They still require charge to function however. CalamityGlobalItem modItem = item.Calamity(); - if (!item.summon && modItem.DischargeEnchantExhaustion > 0f) - mult *= DischargeEnchantmentDamageFormula(); + if (!item.summon && modItem.DischargeEnchantExhaustion > 0f) + mult *= DischargeEnchantmentDamageFormula(); - if (!item.summon && (modItem?.UsesCharge ?? false)) + if (!item.summon && (modItem?.UsesCharge ?? false)) { // At exactly zero charge, do not perform any multiplication. // This makes charge-using weapons show up at full damage when previewed in crafting, Recipe Browser, etc. @@ -929,20 +930,20 @@ namespace CalamityMod.Items } } - internal float DischargeEnchantmentDamageFormula() - { - // This exponential has the properties of beginning at 0 and ending at 1, yet also has their signature rising curve. - // It is therefore perfect for a potential interpolant. - float interpolant = (float)Math.Pow(2D, DischargeExhaustionRatio) - 1f; + internal float DischargeEnchantmentDamageFormula() + { + // This exponential has the properties of beginning at 0 and ending at 1, yet also has their signature rising curve. + // It is therefore perfect for a potential interpolant. + float interpolant = (float)Math.Pow(2D, DischargeExhaustionRatio) - 1f; - // No further smoothening is required in the form of a Smoothstep remap. - // A linear interpolation works fine; the exponential already has the desired curve shape. - return MathHelper.Lerp(DischargeEnchantMinDamageFactor, DischargeEnchantMaxDamageFactor, interpolant); - } + // No further smoothening is required in the form of a Smoothstep remap. + // A linear interpolation works fine; the exponential already has the desired curve shape. + return MathHelper.Lerp(DischargeEnchantMinDamageFactor, DischargeEnchantMaxDamageFactor, interpolant); + } - // This formula gives a slightly higher value than 1.0 above 85% charge, and a slightly lower value than 0.0 at 0% charge. - // Specifically, it gives 0.0 or less at 0.36% charge or lower. This is fine because the result is immediately clamped. - internal float ChargeDamageFormula() + // This formula gives a slightly higher value than 1.0 above 85% charge, and a slightly lower value than 0.0 at 0% charge. + // Specifically, it gives 0.0 or less at 0.36% charge or lower. This is fine because the result is immediately clamped. + internal float ChargeDamageFormula() { float x = MathHelper.Clamp(ChargeRatio, 0f, 1f); float y = 1.087f - 0.08f / (x + 0.07f); @@ -953,294 +954,162 @@ namespace CalamityMod.Items #region Armor Set Changes public override string IsArmorSet(Item head, Item body, Item legs) { - if (head.type == ItemID.CopperHelmet && body.type == ItemID.CopperChainmail && legs.type == ItemID.CopperGreaves) - return "Copper"; - if (head.type == ItemID.TinHelmet && body.type == ItemID.TinChainmail && legs.type == ItemID.TinGreaves) - return "Tin"; - if ((head.type == ItemID.IronHelmet || head.type == ItemID.AncientIronHelmet) && body.type == ItemID.IronChainmail && legs.type == ItemID.IronGreaves) - return "Iron"; - if (head.type == ItemID.LeadHelmet && body.type == ItemID.LeadChainmail && legs.type == ItemID.LeadGreaves) - return "Lead"; - if (head.type == ItemID.SilverHelmet && body.type == ItemID.SilverChainmail && legs.type == ItemID.SilverGreaves) - return "Silver"; - if (head.type == ItemID.TungstenHelmet && body.type == ItemID.TungstenChainmail && legs.type == ItemID.TungstenGreaves) - return "Tungsten"; - if ((head.type == ItemID.GoldHelmet || head.type == ItemID.AncientGoldHelmet) && body.type == ItemID.GoldChainmail && legs.type == ItemID.GoldGreaves) - return "Gold"; - if (head.type == ItemID.PlatinumHelmet && body.type == ItemID.PlatinumChainmail && legs.type == ItemID.PlatinumGreaves) - return "Platinum"; - if (head.type == ItemID.GladiatorHelmet && body.type == ItemID.GladiatorBreastplate && legs.type == ItemID.GladiatorLeggings) - return "Gladiator"; - if (head.type == ItemID.ObsidianHelm && body.type == ItemID.ObsidianShirt && legs.type == ItemID.ObsidianPants) - return "Obsidian"; - if (head.type == ItemID.MoltenHelmet && body.type == ItemID.MoltenBreastplate && legs.type == ItemID.MoltenGreaves) - return "Molten"; - // Normal and Pink Eskimo set can be mixed and matched - if ((head.type == ItemID.EskimoHood || head.type == ItemID.PinkEskimoHood) && (body.type == ItemID.EskimoCoat || body.type == ItemID.PinkEskimoCoat) && (legs.type == ItemID.EskimoPants || legs.type == ItemID.PinkEskimoPants)) - return "Eskimo"; - if (head.type == ItemID.MeteorHelmet && body.type == ItemID.MeteorSuit && legs.type == ItemID.MeteorLeggings) - return "Meteor"; - if (head.type == ItemID.PearlwoodHelmet && body.type == ItemID.PearlwoodBreastplate && legs.type == ItemID.PearlwoodGreaves) - return "Pearlwood"; - if (head.type == ItemID.MonkBrows && body.type == ItemID.MonkShirt && legs.type == ItemID.MonkPants) - return "MonkTier2"; - if (head.type == ItemID.SquireGreatHelm && body.type == ItemID.SquirePlating && legs.type == ItemID.SquireGreaves) - return "SquireTier2"; - if (head.type == ItemID.HuntressWig && body.type == ItemID.HuntressJerkin && legs.type == ItemID.HuntressPants) - return "HuntressTier2"; - if (head.type == ItemID.ApprenticeHat && body.type == ItemID.ApprenticeRobe && legs.type == ItemID.ApprenticeTrousers) - return "ApprenticeTier2"; - if (head.type == ItemID.MonkAltHead && body.type == ItemID.MonkAltShirt && legs.type == ItemID.MonkAltPants) - return "MonkTier3"; - if (head.type == ItemID.SquireAltHead && body.type == ItemID.SquireAltShirt && legs.type == ItemID.SquireAltPants) - return "SquireTier3"; - if (head.type == ItemID.HuntressAltHead && body.type == ItemID.HuntressAltShirt && legs.type == ItemID.HuntressAltPants) - return "HuntressTier3"; - if (head.type == ItemID.ApprenticeAltHead && body.type == ItemID.ApprenticeAltShirt && legs.type == ItemID.ApprenticeAltPants) - return "ApprenticeTier3"; - if (head.type == ItemID.SolarFlareHelmet && body.type == ItemID.SolarFlareBreastplate && legs.type == ItemID.SolarFlareLeggings) - return "SolarFlare"; + return VanillaArmorChangeManager.GetSetBonusName(Main.player[head.owner]); + + if (head.type == ItemID.SquireGreatHelm && body.type == ItemID.SquirePlating && legs.type == ItemID.SquireGreaves) + return "SquireTier2"; + if (head.type == ItemID.HuntressWig && body.type == ItemID.HuntressJerkin && legs.type == ItemID.HuntressPants) + return "HuntressTier2"; + if (head.type == ItemID.ApprenticeHat && body.type == ItemID.ApprenticeRobe && legs.type == ItemID.ApprenticeTrousers) + return "ApprenticeTier2"; + if (head.type == ItemID.MonkAltHead && body.type == ItemID.MonkAltShirt && legs.type == ItemID.MonkAltPants) + return "MonkTier3"; + if (head.type == ItemID.SquireAltHead && body.type == ItemID.SquireAltShirt && legs.type == ItemID.SquireAltPants) + return "SquireTier3"; + if (head.type == ItemID.HuntressAltHead && body.type == ItemID.HuntressAltShirt && legs.type == ItemID.HuntressAltPants) + return "HuntressTier3"; + if (head.type == ItemID.ApprenticeAltHead && body.type == ItemID.ApprenticeAltShirt && legs.type == ItemID.ApprenticeAltPants) + return "ApprenticeTier3"; + if (head.type == ItemID.SolarFlareHelmet && body.type == ItemID.SolarFlareBreastplate && legs.type == ItemID.SolarFlareLeggings) + return "SolarFlare"; return ""; } public override void UpdateArmorSet(Player player, string set) { CalamityPlayer modPlayer = player.Calamity(); - if (set == "Copper") - player.pickSpeed -= 0.15f; - else if (set == "Tin") - player.pickSpeed -= 0.1f; - else if (set == "Iron") - player.pickSpeed -= 0.25f; - else if (set == "Lead") - player.pickSpeed -= 0.2f; - else if (set == "Silver") - player.pickSpeed -= 0.35f; - else if (set == "Tungsten") - player.pickSpeed -= 0.3f; - else if (set == "Gold") - player.pickSpeed -= 0.45f; - else if (set == "Platinum") - player.pickSpeed -= 0.4f; - else if (set == "Gladiator") + VanillaArmorChangeManager.CreateTooltipManuallyAsNecessary(player); + + if (set == "SquireTier2") { - modPlayer.rogueStealthMax += 0.7f; - modPlayer.wearingRogueArmor = true; - modPlayer.throwingDamage += 0.05f; - modPlayer.throwingVelocity += 0.1f; - player.statDefense += 3; - player.setBonus = "+3 defense\n" + - "5% increased rogue damage and 10% increased velocity\n" + - "Rogue stealth builds while not attacking and not moving, up to a max of 70\n" + - "Once you have built max stealth, you will be able to perform a Stealth Strike\n" + - "Rogue stealth only reduces when you attack, it does not reduce while moving\n" + - "The higher your rogue stealth the higher your rogue damage, crit, and movement speed"; + player.lifeRegen += 3; + player.minionDamage += 0.15f; + player.meleeCrit += 15; + player.setBonus += "\nIncreases your life regeneration\n" + + "15% increased minion damage and melee critical strike chance"; } - else if (set == "Obsidian") + else if (set == "HuntressTier2") { - modPlayer.rogueStealthMax += 0.8f; - modPlayer.wearingRogueArmor = true; - modPlayer.throwingDamage += 0.05f; - modPlayer.throwingCrit += 5; - player.statDefense += 2; - player.fireWalk = true; - player.lavaMax += 180; - string heatImmunity = CalamityWorld.death ? "\nProvides heat protection in Death Mode" : ""; - player.setBonus = "+2 defense\n" + - "5% increased rogue damage and critical strike chance\n" + - "Grants immunity to fire blocks and temporary immunity to lava\n" + - "Rogue stealth builds while not attacking and not moving, up to a max of 80\n" + - "Once you have built max stealth, you will be able to perform a Stealth Strike\n" + - "Rogue stealth only reduces when you attack, it does not reduce while moving\n" + - "The higher your rogue stealth the higher your rogue damage, crit, and movement speed" + heatImmunity; + player.minionDamage += 0.1f; + player.rangedDamage += 0.1f; + player.setBonus += "\n10% increased minion and ranged damage"; } - else if (set == "Molten") + else if (set == "ApprenticeTier2") { - player.fireWalk = true; - player.lavaMax += 300; + player.minionDamage += 0.05f; + player.magicCrit += 15; + player.setBonus += "\n5% increased minion damage and 15% increased magic critical strike chance"; } - else if (set == "Eskimo") + else if (set == "MonkTier3") { - modPlayer.eskimoSet = true; - player.buffImmune[BuffID.Frostburn] = true; - player.buffImmune[ModContent.BuffType()] = true; - string coldImmunity = CalamityWorld.death ? "\nProvides cold protection in Death Mode" : ""; - player.setBonus = "All ice-themed damage over time debuffs receive a 50% damage bonus\n" + - "Cold enemies will deal reduced contact damage to the player\n" + - "Provides immunity to the Frostburn and Glacial State debuffs" + coldImmunity; + player.minionDamage += 0.3f; + player.meleeSpeed += 0.1f; + player.meleeDamage += 0.1f; + player.meleeCrit += 10; + player.setBonus += "\n10% increased melee damage, melee critical strike chance and melee speed\n" + + "30% increased minion damage"; } - else if (set == "Meteor") + else if (set == "SquireTier3") { - player.spaceGun = false; - modPlayer.meteorSet = true; + player.lifeRegen += 6; + player.minionDamage += 0.1f; + player.meleeCrit += 10; + player.setBonus += "\nMassively increased life regeneration\n" + + "10% increased minion damage and melee critical strike chance"; + } + else if (set == "HuntressTier3") + { + player.minionDamage += 0.1f; + player.rangedDamage += 0.1f; + player.setBonus += "\n10% increased minion and ranged damage"; + } + else if (set == "ApprenticeTier3") + { + player.minionDamage += 0.1f; + player.magicCrit += 15; + player.setBonus += "\n10% increased minion damage and 15% increased magic critical strike chance"; + } + else if (set == "SolarFlare") + { + modPlayer.dashMod = 0; } - else if (set == "MonkTier2") - { - player.minionDamage += 0.15f; - player.meleeDamage += 0.1f; - player.meleeSpeed += 0.1f; - player.meleeCrit += 10; - player.setBonus += "\n10% increased melee speed, crit, and damage\n" + - "15% increased minion damage"; - } - else if (set == "SquireTier2") - { - player.lifeRegen += 3; - player.minionDamage += 0.15f; - player.meleeCrit += 15; - player.setBonus += "\nIncreases your life regeneration\n" + - "15% increased minion damage and melee critical strike chance"; - } - else if (set == "HuntressTier2") - { - player.minionDamage += 0.1f; - player.rangedDamage += 0.1f; - player.setBonus += "\n10% increased minion and ranged damage"; - } - else if (set == "ApprenticeTier2") - { - player.minionDamage += 0.05f; - player.magicCrit += 15; - player.setBonus += "\n5% increased minion damage and 15% increased magic critical strike chance"; - } - else if (set == "MonkTier3") - { - player.minionDamage += 0.3f; - player.meleeSpeed += 0.1f; - player.meleeDamage += 0.1f; - player.meleeCrit += 10; - player.setBonus += "\n10% increased melee damage, melee critical strike chance and melee speed\n" + - "30% increased minion damage"; - } - else if (set == "SquireTier3") - { - player.lifeRegen += 6; - player.minionDamage += 0.1f; - player.meleeCrit += 10; - player.setBonus += "\nMassively increased life regeneration\n" + - "10% increased minion damage and melee critical strike chance"; - } - else if (set == "HuntressTier3") - { - player.minionDamage += 0.1f; - player.rangedDamage += 0.1f; - player.setBonus += "\n10% increased minion and ranged damage"; - } - else if (set == "ApprenticeTier3") - { - player.minionDamage += 0.1f; - player.magicCrit += 15; - player.setBonus += "\n10% increased minion damage and 15% increased magic critical strike chance"; - } - else if (set == "SolarFlare") - { - modPlayer.dashMod = 0; - } } #endregion #region Equip Changes public override void UpdateEquip(Item item, Player player) { - switch (item.type) - { - case ItemID.MagicHat: - player.magicDamage -= 0.02f; - player.magicCrit -= 2; - break; + VanillaArmorChangeManager.ApplyPotentialEffectsTo(player); - case ItemID.WizardHat: - player.magicDamage -= 0.1f; - break; + switch (item.type) + { + case ItemID.MagicHat: + player.magicDamage -= 0.02f; + player.magicCrit -= 2; + break; - case ItemID.GladiatorHelmet: - case ItemID.ObsidianHelm: - player.Calamity().throwingDamage += 0.03f; - break; - case ItemID.GladiatorBreastplate: - case ItemID.ObsidianShirt: - player.Calamity().throwingCrit += 3; - break; - case ItemID.GladiatorLeggings: - case ItemID.ObsidianPants: - player.Calamity().throwingVelocity += 0.03f; - break; + case ItemID.WizardHat: + player.magicDamage -= 0.1f; + break; - case ItemID.SpectreHood: - player.magicDamage += 0.2f; - break; + case ItemID.SpectreHood: + player.magicDamage += 0.2f; + break; - case ItemID.SquireGreatHelm: - player.lifeRegen -= 7; - break; - case ItemID.SquirePlating: - player.minionDamage -= 0.05f; - player.meleeDamage -= 0.05f; - break; - case ItemID.SquireGreaves: - player.minionDamage -= 0.1f; - player.meleeCrit -= 10; - break; + case ItemID.SquireGreatHelm: + player.lifeRegen -= 7; + break; + case ItemID.SquirePlating: + player.minionDamage -= 0.05f; + player.meleeDamage -= 0.05f; + break; + case ItemID.SquireGreaves: + player.minionDamage -= 0.1f; + player.meleeCrit -= 10; + break; - case ItemID.MonkBrows: - player.meleeSpeed -= 0.1f; - break; - case ItemID.MonkShirt: - player.minionDamage -= 0.1f; - player.meleeDamage -= 0.1f; - break; - case ItemID.MonkPants: - player.minionDamage -= 0.05f; - player.meleeCrit -= 10; - break; + case ItemID.HuntressJerkin: + player.minionDamage -= 0.1f; + player.rangedDamage -= 0.1f; + break; - case ItemID.HuntressJerkin: - player.minionDamage -= 0.1f; - player.rangedDamage -= 0.1f; - break; + case ItemID.ApprenticeTrousers: + player.minionDamage -= 0.05f; + player.magicCrit -= 15; + break; - case ItemID.ApprenticeTrousers: - player.minionDamage -= 0.05f; - player.magicCrit -= 15; - break; + case ItemID.SquireAltShirt: + player.lifeRegen -= 14; + break; + case ItemID.SquireAltPants: + player.minionDamage -= 0.1f; + player.meleeCrit -= 10; + break; - case ItemID.SquireAltShirt: - player.lifeRegen -= 14; - break; - case ItemID.SquireAltPants: - player.minionDamage -= 0.1f; - player.meleeCrit -= 10; - break; + case ItemID.MonkAltHead: + player.minionDamage -= 0.1f; + player.meleeDamage -= 0.1f; + break; + case ItemID.MonkAltShirt: + player.minionDamage -= 0.1f; + player.meleeSpeed -= 0.1f; + break; + case ItemID.MonkAltPants: + player.minionDamage -= 0.1f; + player.meleeCrit -= 10; + break; - case ItemID.MonkAltHead: - player.minionDamage -= 0.1f; - player.meleeDamage -= 0.1f; - break; - case ItemID.MonkAltShirt: - player.minionDamage -= 0.1f; - player.meleeSpeed -= 0.1f; - break; - case ItemID.MonkAltPants: - player.minionDamage -= 0.1f; - player.meleeCrit -= 10; - break; + case ItemID.HuntressAltShirt: + player.minionDamage -= 0.1f; + player.rangedDamage -= 0.1f; + break; - case ItemID.HuntressAltShirt: - player.minionDamage -= 0.1f; - player.rangedDamage -= 0.1f; - break; - - case ItemID.ApprenticeAltPants: - player.minionDamage -= 0.1f; - player.magicCrit -= 15; - break; - - case ItemID.StardustBreastplate: - case ItemID.StardustLeggings: - player.maxMinions--; - break; - } - } + case ItemID.ApprenticeAltPants: + player.minionDamage -= 0.1f; + player.magicCrit -= 15; + break; + } + } #endregion #region Accessory Changes @@ -1248,21 +1117,21 @@ namespace CalamityMod.Items { CalamityPlayer modPlayer = player.Calamity(); - if (item.prefix > 0) - { - float stealthGenBoost = item.Calamity().StealthGenBonus - 1f; - if (stealthGenBoost > 0) - { - modPlayer.accStealthGenBoost += stealthGenBoost; - } - } + if (item.prefix > 0) + { + float stealthGenBoost = item.Calamity().StealthGenBonus - 1f; + if (stealthGenBoost > 0) + { + modPlayer.accStealthGenBoost += stealthGenBoost; + } + } // Obsidian Skull and its upgrades make you immune to On Fire! if (item.type == ItemID.ObsidianSkull || item.type == ItemID.ObsidianHorseshoe || item.type == ItemID.ObsidianShield || item.type == ItemID.AnkhShield || item.type == ItemID.ObsidianWaterWalkingBoots || item.type == ItemID.LavaWaders) player.buffImmune[BuffID.OnFire] = true; if (item.type == ItemID.FrogLeg) - player.jumpSpeedBoost -= 1.2f; + player.jumpSpeedBoost -= 1.2f; if (item.type == ItemID.FireGauntlet) { @@ -1319,7 +1188,7 @@ namespace CalamityMod.Items player.noFallDmg = true; if (!Main.dayTime || Main.eclipse) { - player.jumpSpeedBoost += 0.5f; + player.jumpSpeedBoost += 0.5f; player.allDamage += 0.07f; modPlayer.AllCritBoost(3); player.moveSpeed += 0.1f; @@ -1327,7 +1196,7 @@ namespace CalamityMod.Items } else if (item.type == ItemID.HarpyWings) { - modPlayer.harpyWingBoost = true; + modPlayer.harpyWingBoost = true; player.moveSpeed += 0.2f; player.noFallDmg = true; } @@ -1419,10 +1288,10 @@ namespace CalamityMod.Items { player.rocketDamage += 0.05f; } - else if (player.Calamity().flamethrowerBoost) //flamethrowers - { - player.Calamity().hoverboardBoost = true; - } + else if (player.Calamity().flamethrowerBoost) //flamethrowers + { + player.Calamity().hoverboardBoost = true; + } } } else if (item.type == ItemID.LeafWings) // Bonus to defensive stats while wearing tiki armor @@ -1430,28 +1299,28 @@ namespace CalamityMod.Items player.noFallDmg = true; if (player.head == ArmorIDs.Head.TikiMask && player.body == ArmorIDs.Body.TikiShirt && player.legs == ArmorIDs.Legs.TikiPants) { - player.statDefense += 5; + player.statDefense += 5; player.endurance += 0.05f; - player.AddBuff(BuffID.DryadsWard, 5, true); // Dryad's Blessing + player.AddBuff(BuffID.DryadsWard, 5, true); // Dryad's Blessing } } else if (item.type == ItemID.FestiveWings) // Drop powerful homing christmas tree bulbs while in flight { player.noFallDmg = true; player.statLifeMax2 += 40; - if (modPlayer.icicleCooldown <= 0) - { - if (player.controlJump && !player.jumpAgainCloud && player.jump == 0 && player.velocity.Y != 0f && !player.mount.Active && !player.mount.Cart) - { - int p = Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 2f, ProjectileID.OrnamentFriendly, (int)(100 * player.AverageDamage()), 5f, player.whoAmI); - if (p.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[p].Calamity().forceTypeless = true; - Main.projectile[p].Calamity().lineColor = 1; - modPlayer.icicleCooldown = 10; - } - } - } + if (modPlayer.icicleCooldown <= 0) + { + if (player.controlJump && !player.jumpAgainCloud && player.jump == 0 && player.velocity.Y != 0f && !player.mount.Active && !player.mount.Cart) + { + int p = Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 2f, ProjectileID.OrnamentFriendly, (int)(100 * player.AverageDamage()), 5f, player.whoAmI); + if (p.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[p].Calamity().forceTypeless = true; + Main.projectile[p].Calamity().lineColor = 1; + modPlayer.icicleCooldown = 10; + } + } + } } else if (item.type == ItemID.SpookyWings) // Bonus to summon stats while wearing spooky armor { @@ -1515,10 +1384,10 @@ namespace CalamityMod.Items } } else if (item.type == ItemID.FishronWings || item.type == ItemID.BetsyWings || item.type == ItemID.Yoraiz0rWings || - item.type == ItemID.JimsWings || item.type == ItemID.SkiphsWings || item.type == ItemID.LokisWings || - item.type == ItemID.ArkhalisWings || item.type == ItemID.LeinforsWings || item.type == ItemID.BejeweledValkyrieWing || - item.type == ItemID.RedsWings || item.type == ItemID.DTownsWings || item.type == ItemID.WillsWings || - item.type == ItemID.CrownosWings || item.type == ItemID.CenxsWings) + item.type == ItemID.JimsWings || item.type == ItemID.SkiphsWings || item.type == ItemID.LokisWings || + item.type == ItemID.ArkhalisWings || item.type == ItemID.LeinforsWings || item.type == ItemID.BejeweledValkyrieWing || + item.type == ItemID.RedsWings || item.type == ItemID.DTownsWings || item.type == ItemID.WillsWings || + item.type == ItemID.CrownosWings || item.type == ItemID.CenxsWings) { player.noFallDmg = true; } @@ -1526,8 +1395,8 @@ namespace CalamityMod.Items if (item.type == ItemID.JellyfishNecklace || item.type == ItemID.JellyfishDivingGear || item.type == ItemID.ArcticDivingGear) modPlayer.jellyfishNecklace = true; - if (item.type == ItemID.FleshKnuckles) - modPlayer.fleshKnuckles = true; + if (item.type == ItemID.FleshKnuckles) + modPlayer.fleshKnuckles = true; if (item.type == ItemID.WormScarf) player.endurance -= 0.07f; @@ -1541,149 +1410,149 @@ namespace CalamityMod.Items if (item.type == ItemID.EoCShield || item.type == ItemID.Tabi || item.type == ItemID.MasterNinjaGear) modPlayer.dashMod = 0; - // Hard / Guarding / Armored / Warding give 0.25% / 0.5% / 0.75% / 1% DR - if (item.prefix == PrefixID.Hard) - { - /* Prehardmode = 1 - * Hardmode = 2 - * Post-Golem = 2 - * Post-Moon Lord = 2 - * Post-Provi = 2 - * Post-Polter = 3 - * Post-DoG = 3 - * Post-Yharon = 4 - */ - - if (CalamityWorld.downedYharon) - player.statDefense += 3; - else if (CalamityWorld.downedPolterghast || CalamityWorld.downedDoG) - player.statDefense += 2; - else if (Main.hardMode || NPC.downedGolemBoss || NPC.downedMoonlord || CalamityWorld.downedProvidence) - player.statDefense += 1; + // Hard / Guarding / Armored / Warding give 0.25% / 0.5% / 0.75% / 1% DR + if (item.prefix == PrefixID.Hard) + { + /* Prehardmode = 1 + * Hardmode = 2 + * Post-Golem = 2 + * Post-Moon Lord = 2 + * Post-Provi = 2 + * Post-Polter = 3 + * Post-DoG = 3 + * Post-Yharon = 4 + */ + + if (CalamityWorld.downedYharon) + player.statDefense += 3; + else if (CalamityWorld.downedPolterghast || CalamityWorld.downedDoG) + player.statDefense += 2; + else if (Main.hardMode || NPC.downedGolemBoss || NPC.downedMoonlord || CalamityWorld.downedProvidence) + player.statDefense += 1; - player.endurance += 0.0025f; - } - if (item.prefix == PrefixID.Guarding) - { - /* Prehardmode = 2 - * Hardmode = 3 - * Post-Golem = 4 - * Post-Moon Lord = 4 - * Post-Provi = 5 - * Post-Polter = 5 - * Post-DoG = 6 - * Post-Yharon = 8 - */ - - if (CalamityWorld.downedYharon) - player.statDefense += 6; - else if (CalamityWorld.downedDoG) - player.statDefense += 4; - else if (CalamityWorld.downedProvidence || CalamityWorld.downedPolterghast) - player.statDefense += 3; - else if (NPC.downedGolemBoss || NPC.downedMoonlord) - player.statDefense += 2; - else if (Main.hardMode) - player.statDefense += 1; + player.endurance += 0.0025f; + } + if (item.prefix == PrefixID.Guarding) + { + /* Prehardmode = 2 + * Hardmode = 3 + * Post-Golem = 4 + * Post-Moon Lord = 4 + * Post-Provi = 5 + * Post-Polter = 5 + * Post-DoG = 6 + * Post-Yharon = 8 + */ + + if (CalamityWorld.downedYharon) + player.statDefense += 6; + else if (CalamityWorld.downedDoG) + player.statDefense += 4; + else if (CalamityWorld.downedProvidence || CalamityWorld.downedPolterghast) + player.statDefense += 3; + else if (NPC.downedGolemBoss || NPC.downedMoonlord) + player.statDefense += 2; + else if (Main.hardMode) + player.statDefense += 1; - player.endurance += 0.005f; - } - if (item.prefix == PrefixID.Armored) - { - /* Prehardmode = 3 - * Hardmode = 5 - * Post-Golem = 5 - * Post-Moon Lord = 6 - * Post-Provi = 7 - * Post-Polter = 8 - * Post-DoG = 9 - * Post-Yharon = 11 - */ - - if (CalamityWorld.downedYharon) - player.statDefense += 8; - else if (CalamityWorld.downedDoG) - player.statDefense += 6; - else if (CalamityWorld.downedPolterghast) - player.statDefense += 5; - else if (CalamityWorld.downedProvidence) - player.statDefense += 4; - else if (NPC.downedMoonlord) - player.statDefense += 3; - else if (Main.hardMode || NPC.downedGolemBoss) - player.statDefense += 2; + player.endurance += 0.005f; + } + if (item.prefix == PrefixID.Armored) + { + /* Prehardmode = 3 + * Hardmode = 5 + * Post-Golem = 5 + * Post-Moon Lord = 6 + * Post-Provi = 7 + * Post-Polter = 8 + * Post-DoG = 9 + * Post-Yharon = 11 + */ + + if (CalamityWorld.downedYharon) + player.statDefense += 8; + else if (CalamityWorld.downedDoG) + player.statDefense += 6; + else if (CalamityWorld.downedPolterghast) + player.statDefense += 5; + else if (CalamityWorld.downedProvidence) + player.statDefense += 4; + else if (NPC.downedMoonlord) + player.statDefense += 3; + else if (Main.hardMode || NPC.downedGolemBoss) + player.statDefense += 2; - player.endurance += 0.0075f; - } - if (item.prefix == PrefixID.Warding) - { - /* Prehardmode = 4 - * Hardmode = 6 - * Post-Golem = 7 - * Post-Moon Lord = 8 - * Post-Provi = 9 - * Post-Polter = 10 - * Post-DoG = 12 - * Post-Yharon = 15 - */ - - if (CalamityWorld.downedYharon) - player.statDefense += 11; - else if (CalamityWorld.downedDoG) - player.statDefense += 8; - else if (CalamityWorld.downedPolterghast) - player.statDefense += 6; - else if (CalamityWorld.downedProvidence) - player.statDefense += 5; - else if (NPC.downedMoonlord) - player.statDefense += 4; - else if (NPC.downedGolemBoss) - player.statDefense += 3; - else if (Main.hardMode) - player.statDefense += 2; + player.endurance += 0.0075f; + } + if (item.prefix == PrefixID.Warding) + { + /* Prehardmode = 4 + * Hardmode = 6 + * Post-Golem = 7 + * Post-Moon Lord = 8 + * Post-Provi = 9 + * Post-Polter = 10 + * Post-DoG = 12 + * Post-Yharon = 15 + */ + + if (CalamityWorld.downedYharon) + player.statDefense += 11; + else if (CalamityWorld.downedDoG) + player.statDefense += 8; + else if (CalamityWorld.downedPolterghast) + player.statDefense += 6; + else if (CalamityWorld.downedProvidence) + player.statDefense += 5; + else if (NPC.downedMoonlord) + player.statDefense += 4; + else if (NPC.downedGolemBoss) + player.statDefense += 3; + else if (Main.hardMode) + player.statDefense += 2; - player.endurance += 0.01f; - } + player.endurance += 0.01f; + } // TODO -- make all prefixes relevant. Details in Ozz's todo. - /* - if (item.prefix == PrefixID.Precise || item.prefix == PrefixID.Lucky) - player.armorPenetration += 1; - */ + /* + if (item.prefix == PrefixID.Precise || item.prefix == PrefixID.Lucky) + player.armorPenetration += 1; + */ - if (item.prefix == PrefixID.Brisk) - player.moveSpeed += 0.005f; - if (item.prefix == PrefixID.Fleeting) - player.moveSpeed += 0.01f; - if (item.prefix == PrefixID.Hasty2) - player.moveSpeed += 0.015f; - if (item.prefix == PrefixID.Quick2) - player.moveSpeed += 0.02f; - } + if (item.prefix == PrefixID.Brisk) + player.moveSpeed += 0.005f; + if (item.prefix == PrefixID.Fleeting) + player.moveSpeed += 0.01f; + if (item.prefix == PrefixID.Hasty2) + player.moveSpeed += 0.015f; + if (item.prefix == PrefixID.Quick2) + player.moveSpeed += 0.02f; + } #endregion #region WingChanges public override void HorizontalWingSpeeds(Item item, Player player, ref float speed, ref float acceleration) { CalamityPlayer modPlayer = player.Calamity(); - float moveSpeedBoost = modPlayer.moveSpeedStat * 0.001f; + float moveSpeedBoost = modPlayer.moveSpeedStat * 0.001f; - float flightSpeedMult = 1f + + float flightSpeedMult = 1f + (modPlayer.soaring ? 0.1f : 0f) + (modPlayer.profanedRage ? 0.05f : 0f) + (modPlayer.draconicSurge ? 0.1f : 0f) + - (modPlayer.reaverSpeed ? 0.1f : 0f) + - moveSpeedBoost; + (modPlayer.reaverSpeed ? 0.1f : 0f) + + moveSpeedBoost; - float flightAccMult = 1f + - (modPlayer.draconicSurge ? 0.1f : 0f) + - moveSpeedBoost; + float flightAccMult = 1f + + (modPlayer.draconicSurge ? 0.1f : 0f) + + moveSpeedBoost; - flightSpeedMult = MathHelper.Clamp(flightSpeedMult, 0.5f, 1.5f); + flightSpeedMult = MathHelper.Clamp(flightSpeedMult, 0.5f, 1.5f); speed *= flightSpeedMult; - flightAccMult = MathHelper.Clamp(flightAccMult, 0.5f, 1.5f); - acceleration *= flightAccMult; + flightAccMult = MathHelper.Clamp(flightAccMult, 0.5f, 1.5f); + acceleration *= flightAccMult; } #endregion @@ -1692,16 +1561,16 @@ namespace CalamityMod.Items { CalamityPlayer modPlayer = player.Calamity(); int itemGrabRangeBoost = 0 + - (modPlayer.reaverExplore ? 20 : 0); + (modPlayer.reaverExplore ? 20 : 0); grabRange += itemGrabRangeBoost; } #endregion - #region Ammo - public override bool ConsumeAmmo(Item item, Player player) => Main.rand.NextFloat() <= player.Calamity().rangedAmmoCost; + #region Ammo + public override bool ConsumeAmmo(Item item, Player player) => Main.rand.NextFloat() <= player.Calamity().rangedAmmoCost; - public static bool HasEnoughAmmo(Player player, Item item, int ammoConsumed) + public static bool HasEnoughAmmo(Player player, Item item, int ammoConsumed) { bool flag = false; bool canShoot = false; @@ -1766,10 +1635,10 @@ namespace CalamityMod.Items dontConsumeAmmo = true; if (player.ammoCost75 && Main.rand.NextBool(4)) dontConsumeAmmo = true; - if (Main.rand.NextFloat() > player.Calamity().rangedAmmoCost) - dontConsumeAmmo = true; + if (Main.rand.NextFloat() > player.Calamity().rangedAmmoCost) + dontConsumeAmmo = true; - if (!dontConsumeAmmo && itemAmmo.consumable) + if (!dontConsumeAmmo && itemAmmo.consumable) { itemAmmo.stack -= ammoConsumed; if (itemAmmo.stack <= 0) @@ -1781,775 +1650,775 @@ namespace CalamityMod.Items } #endregion - #region PostUpdate - public override void PostUpdate(Item item) - { - if (CalamityLists.forceItemList?.Contains(item.type) ?? false) - CalamityUtils.ForceItemIntoWorld(item); - } - #endregion + #region PostUpdate + public override void PostUpdate(Item item) + { + if (CalamityLists.forceItemList?.Contains(item.type) ?? false) + CalamityUtils.ForceItemIntoWorld(item); + } + #endregion - #region Inventory Drawing - internal static ChargingEnergyParticleSet EnchantmentEnergyParticles = new ChargingEnergyParticleSet(-1, 2, Color.DarkViolet, Color.White, 0.04f, 24f); + #region Inventory Drawing + internal static ChargingEnergyParticleSet EnchantmentEnergyParticles = new ChargingEnergyParticleSet(-1, 2, Color.DarkViolet, Color.White, 0.04f, 24f); - internal static void UpdateAllParticleSets() - { - EnchantmentEnergyParticles.Update(); - } + internal static void UpdateAllParticleSets() + { + EnchantmentEnergyParticles.Update(); + } - public override bool PreDrawInInventory(Item item, SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) - { - // I want to strangle somebody. - Texture2D itemTexture = Main.itemTexture[item.type]; - Rectangle itemFrame = (Main.itemAnimations[item.type] == null) ? itemTexture.Frame() : Main.itemAnimations[item.type].GetFrame(itemTexture); + public override bool PreDrawInInventory(Item item, SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + // I want to strangle somebody. + Texture2D itemTexture = Main.itemTexture[item.type]; + Rectangle itemFrame = (Main.itemAnimations[item.type] == null) ? itemTexture.Frame() : Main.itemAnimations[item.type].GetFrame(itemTexture); - if (!EnchantmentManager.ItemUpgradeRelationship.ContainsKey(item.type) || !Main.LocalPlayer.InventoryHas(ModContent.ItemType())) - return true; + if (!EnchantmentManager.ItemUpgradeRelationship.ContainsKey(item.type) || !Main.LocalPlayer.InventoryHas(ModContent.ItemType())) + return true; - // Draw all particles. - float currentPower = 0f; - int calamitasNPCIndex = NPC.FindFirstNPC(ModContent.NPCType()); - if (calamitasNPCIndex != -1) - currentPower = Utils.InverseLerp(11750f, 1000f, Main.LocalPlayer.Distance(Main.npc[calamitasNPCIndex].Center), true); + // Draw all particles. + float currentPower = 0f; + int calamitasNPCIndex = NPC.FindFirstNPC(ModContent.NPCType()); + if (calamitasNPCIndex != -1) + currentPower = Utils.InverseLerp(11750f, 1000f, Main.LocalPlayer.Distance(Main.npc[calamitasNPCIndex].Center), true); - Vector2 particleDrawCenter = position + new Vector2(12f, 16f) * Main.inventoryScale; + Vector2 particleDrawCenter = position + new Vector2(12f, 16f) * Main.inventoryScale; - EnchantmentEnergyParticles.InterpolationSpeed = MathHelper.Lerp(0.035f, 0.1f, currentPower); - EnchantmentEnergyParticles.DrawSet(particleDrawCenter + Main.screenPosition); - spriteBatch.Draw(itemTexture, position, itemFrame, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); + EnchantmentEnergyParticles.InterpolationSpeed = MathHelper.Lerp(0.035f, 0.1f, currentPower); + EnchantmentEnergyParticles.DrawSet(particleDrawCenter + Main.screenPosition); + spriteBatch.Draw(itemTexture, position, itemFrame, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); - return false; - } - #endregion + return false; + } + #endregion - #region Reforging - private int NewPrefixType(Item item) - { - int prefix = -2; - if (item.accessory) - { - if (Main.player[Main.myPlayer].Calamity().finalTierAccessoryReforge) - { - // Warding = 18, Menacing = 19, Quick = 20, Violent = 21, Lucky = 22, Silent = 23 - prefix = Main.rand.Next(18, 24); - } - else - { - switch (reforgeTier) - { - case 0: - break; - case 1: - // Hard = 1, Jagged = 2, Brisk = 3, Wild = 4, Quiet = 5 - prefix = Main.rand.Next(1, 6); - break; - case 2: - // Guarding = 6, Spiked = 7, Fleeting = 8, Rash = 9, Cloaked = 10 - prefix = Main.rand.Next(6, 11); - break; - case 3: - // Precise = 11, Arcane = 12 - prefix = Main.rand.Next(11, 13); - break; - case 4: - // Armored = 13, Angry = 14, Hasty = 15, Intrepid = 16, Camouflaged = 17 - prefix = Main.rand.Next(13, 18); - break; - case 5: - case 6: - // Warding = 18, Menacing = 19, Quick = 20, Violent = 21, Lucky = 22, Silent = 23 - prefix = Main.rand.Next(18, 24); - break; - } - } - switch (prefix) - { - case -2: - break; - case 1: - prefix = PrefixID.Hard; - break; - case 2: - prefix = PrefixID.Jagged; - break; - case 3: - prefix = PrefixID.Brisk; - break; - case 4: - prefix = PrefixID.Wild; - break; - case 5: - prefix = mod.PrefixType("Quiet"); - break; - case 6: - prefix = PrefixID.Guarding; - break; - case 7: - prefix = PrefixID.Spiked; - break; - case 8: - prefix = PrefixID.Fleeting; - break; - case 9: - prefix = PrefixID.Rash; - break; - case 10: - prefix = mod.PrefixType("Cloaked"); - break; - case 11: - prefix = PrefixID.Precise; - break; - case 12: - prefix = PrefixID.Arcane; - break; - case 13: - prefix = PrefixID.Armored; - break; - case 14: - prefix = PrefixID.Angry; - break; - case 15: - prefix = PrefixID.Hasty2; - break; - case 16: - prefix = PrefixID.Intrepid; - break; - case 17: - prefix = mod.PrefixType("Camouflaged"); - break; - case 18: - prefix = PrefixID.Warding; - break; - case 19: - prefix = PrefixID.Menacing; - break; - case 20: - prefix = PrefixID.Quick2; - break; - case 21: - prefix = PrefixID.Violent; - break; - case 22: - prefix = PrefixID.Lucky; - break; - case 23: - prefix = mod.PrefixType("Silent"); - break; - } - } - else if (item.melee) - { - // Yoyos, Flails, Spears, etc. - if (item.channel || item.noMelee) - { - switch (reforgeTier) - { - case 0: - break; - case 1: - // Keen = 1, Ruthless = 2 - prefix = Main.rand.Next(1, 3); - break; - case 2: - // Hurtful = 3, Zealous = 4 - prefix = Main.rand.Next(3, 5); - break; - case 3: - // Forceful = 5, Strong = 6 - prefix = Main.rand.Next(5, 7); - break; - case 4: - // Demonic = 7 - prefix = 7; - break; - case 5: - // Superior = 8 - prefix = 8; - break; - case 6: - // Godly = 9 - prefix = 9; - break; - } - switch (prefix) - { - case -2: - break; - case 1: - prefix = PrefixID.Keen; - break; - case 2: - prefix = PrefixID.Ruthless; - break; - case 3: - prefix = PrefixID.Hurtful; - break; - case 4: - prefix = PrefixID.Zealous; - break; - case 5: - prefix = PrefixID.Forceful; - break; - case 6: - prefix = PrefixID.Strong; - break; - case 7: - prefix = PrefixID.Demonic; - break; - case 8: - prefix = PrefixID.Superior; - break; - case 9: - prefix = PrefixID.Godly; - break; - } - } - // All other melee weapons - else - { - switch (reforgeTier) - { - case 0: - break; - case 1: - // Keen = 1, Ruthless = 2, Nimble = 3, Nasty = 4, Heavy = 5, Light = 6 - prefix = Main.rand.Next(1, 7); - break; - case 2: - // Hurtful = 7, Zealous = 8, Quick = 9, Pointy = 10, Bulky = 11 - prefix = Main.rand.Next(7, 12); - break; - case 3: - // Forceful = 12, Strong = 13, Agile = 14, Large = 15, Dangerous = 16, Sharp = 17 - prefix = Main.rand.Next(12, 18); - break; - case 4: - // Murderous = 18, Massive = 19, Unpleasant = 20, Deadly2 = 21 - prefix = Main.rand.Next(18, 22); - break; - case 5: - // Superior = 22, Demonic = 23, Savage = 24 - prefix = Main.rand.Next(22, 25); - break; - case 6: - // Legendary = 25, Light = 6 ~We are tool friendly (= - if (item.pick > 0 || item.axe > 0 || item.hammer > 0) - prefix = Main.rand.NextBool() ? 25 : 6; - else - prefix = 25; - break; - } - switch (prefix) - { - case -2: - break; - case 1: - prefix = PrefixID.Keen; - break; - case 2: - prefix = PrefixID.Ruthless; - break; - case 3: - prefix = PrefixID.Nimble; - break; - case 4: - prefix = PrefixID.Nasty; - break; - case 5: - prefix = PrefixID.Heavy; - break; - case 6: - prefix = PrefixID.Light; - break; - case 7: - prefix = PrefixID.Hurtful; - break; - case 8: - prefix = PrefixID.Zealous; - break; - case 9: - prefix = PrefixID.Quick; - break; - case 10: - prefix = PrefixID.Pointy; - break; - case 11: - prefix = PrefixID.Bulky; - break; - case 12: - prefix = PrefixID.Forceful; - break; - case 13: - prefix = PrefixID.Strong; - break; - case 14: - prefix = PrefixID.Agile; - break; - case 15: - prefix = PrefixID.Large; - break; - case 16: - prefix = PrefixID.Dangerous; - break; - case 17: - prefix = PrefixID.Sharp; - break; - case 18: - prefix = PrefixID.Murderous; - break; - case 19: - prefix = PrefixID.Massive; - break; - case 20: - prefix = PrefixID.Unpleasant; - break; - case 21: - prefix = PrefixID.Deadly2; - break; - case 22: - prefix = PrefixID.Superior; - break; - case 23: - prefix = PrefixID.Demonic; - break; - case 24: - prefix = PrefixID.Savage; - break; - case 25: - prefix = PrefixID.Legendary; - break; - } - } - } - else if (item.ranged) - { - switch (reforgeTier) - { - case 0: - break; - case 1: - // Keen = 1, Ruthless = 2, Nimble = 3, Nasty = 4, Powerful = 5 - prefix = Main.rand.Next(1, 6); - break; - case 2: - // Hurtful = 6, Zealous = 7, Quick = 8 - prefix = Main.rand.Next(6, 9); - break; - case 3: - // Forceful = 9, Strong = 10, Agile = 11, Sighted = 12, Murderous = 13 - prefix = Main.rand.Next(9, 14); - break; - case 4: - // Superior = 14, Demonic = 15, Deadly2 = 16, Intimidating = 17, Unpleasant = 18 - prefix = Main.rand.Next(14, 19); - break; - case 5: - // Godly = 19, Rapid = 20, Hasty = 21, Deadly = 22, Staunch = 23 - prefix = Main.rand.Next(19, 24); - break; - case 6: - // Unreal = 24 - prefix = 24; - break; - } - switch (prefix) - { - case -2: - break; - case 1: - prefix = PrefixID.Keen; - break; - case 2: - prefix = PrefixID.Ruthless; - break; - case 3: - prefix = PrefixID.Nimble; - break; - case 4: - prefix = PrefixID.Nasty; - break; - case 5: - prefix = PrefixID.Powerful; - break; - case 6: - prefix = PrefixID.Hurtful; - break; - case 7: - prefix = PrefixID.Zealous; - break; - case 8: - prefix = PrefixID.Quick; - break; - case 9: - prefix = PrefixID.Forceful; - break; - case 10: - prefix = PrefixID.Strong; - break; - case 11: - prefix = PrefixID.Agile; - break; - case 12: - prefix = PrefixID.Sighted; - break; - case 13: - prefix = PrefixID.Murderous; - break; - case 14: - prefix = PrefixID.Superior; - break; - case 15: - prefix = PrefixID.Demonic; - break; - case 16: - prefix = PrefixID.Deadly2; - break; - case 17: - prefix = PrefixID.Intimidating; - break; - case 18: - prefix = PrefixID.Unpleasant; - break; - case 19: - prefix = PrefixID.Godly; - break; - case 20: - prefix = PrefixID.Rapid; - break; - case 21: - prefix = PrefixID.Hasty; - break; - case 22: - prefix = PrefixID.Deadly; - break; - case 23: - prefix = PrefixID.Staunch; - break; - case 24: - prefix = PrefixID.Unreal; - break; - } - } - else if (item.magic) - { - switch (reforgeTier) - { - case 0: - break; - case 1: - // Keen = 1, Ruthless = 2, Nimble = 3, Nasty = 4, Furious = 5 - prefix = Main.rand.Next(1, 6); - break; - case 2: - // Hurtful = 6, Zealous = 7, Quick = 8, Taboo = 9, Manic = 10 - prefix = Main.rand.Next(6, 11); - break; - case 3: - // Forceful = 11, Strong = 12, Agile = 13, Murderous = 14, Adept = 15, Celestial = 16 - prefix = Main.rand.Next(11, 17); - break; - case 4: - // Superior = 17, Demonic = 18, Deadly2 = 19, Mystic = 20 - prefix = Main.rand.Next(17, 21); - break; - case 5: - // Godly = 21, Masterful = 22 - prefix = Main.rand.Next(21, 23); - break; - case 6: - // Mythical = 23 - prefix = 23; - break; - } - switch (prefix) - { - case -2: - break; - case 1: - prefix = PrefixID.Keen; - break; - case 2: - prefix = PrefixID.Ruthless; - break; - case 3: - prefix = PrefixID.Nimble; - break; - case 4: - prefix = PrefixID.Nasty; - break; - case 5: - prefix = PrefixID.Furious; - break; - case 6: - prefix = PrefixID.Hurtful; - break; - case 7: - prefix = PrefixID.Zealous; - break; - case 8: - prefix = PrefixID.Quick; - break; - case 9: - prefix = PrefixID.Taboo; - break; - case 10: - prefix = PrefixID.Manic; - break; - case 11: - prefix = PrefixID.Forceful; - break; - case 12: - prefix = PrefixID.Strong; - break; - case 13: - prefix = PrefixID.Agile; - break; - case 14: - prefix = PrefixID.Murderous; - break; - case 15: - prefix = PrefixID.Adept; - break; - case 16: - prefix = PrefixID.Celestial; - break; - case 17: - prefix = PrefixID.Superior; - break; - case 18: - prefix = PrefixID.Demonic; - break; - case 19: - prefix = PrefixID.Deadly2; - break; - case 20: - prefix = PrefixID.Mystic; - break; - case 21: - prefix = PrefixID.Godly; - break; - case 22: - prefix = PrefixID.Masterful; - break; - case 23: - prefix = PrefixID.Mythical; - break; - } - } - else if (item.summon) - { - switch (reforgeTier) - { - case 0: - break; - case 1: - // Nimble = 1, Furious = 2 - prefix = Main.rand.Next(1, 3); - break; - case 2: - // Hurtful = 3, Quick = 4, Taboo = 5, Manic = 6 - prefix = Main.rand.Next(3, 7); - break; - case 3: - // Forceful = 7, Strong = 8, Adept = 9, Celestial = 10 - prefix = Main.rand.Next(7, 11); - break; - case 4: - // Deadly2 = 11, Mystic = 12, Superior = 13, Demonic = 14 - prefix = Main.rand.Next(11, 15); - break; - case 5: - // Masterful = 15, Mythical = 16, Godly = 17 - prefix = Main.rand.Next(15, 18); - break; - case 6: - // Ruthless = 18 - prefix = 18; - break; - } - switch (prefix) - { - case -2: - break; - case 1: - prefix = PrefixID.Nimble; - break; - case 2: - prefix = PrefixID.Furious; - break; - case 3: - prefix = PrefixID.Hurtful; - break; - case 4: - prefix = PrefixID.Quick; - break; - case 5: - prefix = PrefixID.Taboo; - break; - case 6: - prefix = PrefixID.Manic; - break; - case 7: - prefix = PrefixID.Forceful; - break; - case 8: - prefix = PrefixID.Strong; - break; - case 9: - prefix = PrefixID.Adept; - break; - case 10: - prefix = PrefixID.Celestial; - break; - case 11: - prefix = PrefixID.Deadly2; - break; - case 12: - prefix = PrefixID.Mystic; - break; - case 13: - prefix = PrefixID.Superior; - break; - case 14: - prefix = PrefixID.Demonic; - break; - case 15: - prefix = PrefixID.Masterful; - break; - case 16: - prefix = PrefixID.Mythical; - break; - case 17: - prefix = PrefixID.Godly; - break; - case 18: - prefix = PrefixID.Ruthless; - break; - } - } - else if (item.Calamity().rogue) - { - switch (reforgeTier) - { - case 0: - break; - case 1: - // Radical = 1, Pointy = 2 - prefix = Main.rand.Next(1, 3); - break; - case 2: - // Sharp = 3, Glorious = 4 - prefix = Main.rand.Next(3, 5); - break; - case 3: - // Feathered = 5, Sleek = 6, Hefty = 7 - prefix = Main.rand.Next(5, 8); - break; - case 4: - // Mighty = 8, Serrated = 9 - prefix = Main.rand.Next(8, 10); - break; - case 5: - // Vicious = 10, Lethal = 11 - prefix = Main.rand.Next(10, 12); - break; - case 6: - // Flawless = 12 - prefix = 12; - break; - } - switch (prefix) - { - case -2: - break; - case 1: - prefix = mod.PrefixType("Radical"); - break; - case 2: - prefix = mod.PrefixType("Pointy"); - break; - case 3: - prefix = mod.PrefixType("Sharp"); - break; - case 4: - prefix = mod.PrefixType("Glorious"); - break; - case 5: - prefix = mod.PrefixType("Feathered"); - break; - case 6: - prefix = mod.PrefixType("Sleek"); - break; - case 7: - prefix = mod.PrefixType("Hefty"); - break; - case 8: - prefix = mod.PrefixType("Mighty"); - break; - case 9: - prefix = mod.PrefixType("Serrated"); - break; - case 10: - prefix = mod.PrefixType("Vicious"); - break; - case 11: - prefix = mod.PrefixType("Lethal"); - break; - case 12: - prefix = mod.PrefixType("Flawless"); - break; - } - } - return prefix; - } + #region Reforging + private int NewPrefixType(Item item) + { + int prefix = -2; + if (item.accessory) + { + if (Main.player[Main.myPlayer].Calamity().finalTierAccessoryReforge) + { + // Warding = 18, Menacing = 19, Quick = 20, Violent = 21, Lucky = 22, Silent = 23 + prefix = Main.rand.Next(18, 24); + } + else + { + switch (reforgeTier) + { + case 0: + break; + case 1: + // Hard = 1, Jagged = 2, Brisk = 3, Wild = 4, Quiet = 5 + prefix = Main.rand.Next(1, 6); + break; + case 2: + // Guarding = 6, Spiked = 7, Fleeting = 8, Rash = 9, Cloaked = 10 + prefix = Main.rand.Next(6, 11); + break; + case 3: + // Precise = 11, Arcane = 12 + prefix = Main.rand.Next(11, 13); + break; + case 4: + // Armored = 13, Angry = 14, Hasty = 15, Intrepid = 16, Camouflaged = 17 + prefix = Main.rand.Next(13, 18); + break; + case 5: + case 6: + // Warding = 18, Menacing = 19, Quick = 20, Violent = 21, Lucky = 22, Silent = 23 + prefix = Main.rand.Next(18, 24); + break; + } + } + switch (prefix) + { + case -2: + break; + case 1: + prefix = PrefixID.Hard; + break; + case 2: + prefix = PrefixID.Jagged; + break; + case 3: + prefix = PrefixID.Brisk; + break; + case 4: + prefix = PrefixID.Wild; + break; + case 5: + prefix = mod.PrefixType("Quiet"); + break; + case 6: + prefix = PrefixID.Guarding; + break; + case 7: + prefix = PrefixID.Spiked; + break; + case 8: + prefix = PrefixID.Fleeting; + break; + case 9: + prefix = PrefixID.Rash; + break; + case 10: + prefix = mod.PrefixType("Cloaked"); + break; + case 11: + prefix = PrefixID.Precise; + break; + case 12: + prefix = PrefixID.Arcane; + break; + case 13: + prefix = PrefixID.Armored; + break; + case 14: + prefix = PrefixID.Angry; + break; + case 15: + prefix = PrefixID.Hasty2; + break; + case 16: + prefix = PrefixID.Intrepid; + break; + case 17: + prefix = mod.PrefixType("Camouflaged"); + break; + case 18: + prefix = PrefixID.Warding; + break; + case 19: + prefix = PrefixID.Menacing; + break; + case 20: + prefix = PrefixID.Quick2; + break; + case 21: + prefix = PrefixID.Violent; + break; + case 22: + prefix = PrefixID.Lucky; + break; + case 23: + prefix = mod.PrefixType("Silent"); + break; + } + } + else if (item.melee) + { + // Yoyos, Flails, Spears, etc. + if (item.channel || item.noMelee) + { + switch (reforgeTier) + { + case 0: + break; + case 1: + // Keen = 1, Ruthless = 2 + prefix = Main.rand.Next(1, 3); + break; + case 2: + // Hurtful = 3, Zealous = 4 + prefix = Main.rand.Next(3, 5); + break; + case 3: + // Forceful = 5, Strong = 6 + prefix = Main.rand.Next(5, 7); + break; + case 4: + // Demonic = 7 + prefix = 7; + break; + case 5: + // Superior = 8 + prefix = 8; + break; + case 6: + // Godly = 9 + prefix = 9; + break; + } + switch (prefix) + { + case -2: + break; + case 1: + prefix = PrefixID.Keen; + break; + case 2: + prefix = PrefixID.Ruthless; + break; + case 3: + prefix = PrefixID.Hurtful; + break; + case 4: + prefix = PrefixID.Zealous; + break; + case 5: + prefix = PrefixID.Forceful; + break; + case 6: + prefix = PrefixID.Strong; + break; + case 7: + prefix = PrefixID.Demonic; + break; + case 8: + prefix = PrefixID.Superior; + break; + case 9: + prefix = PrefixID.Godly; + break; + } + } + // All other melee weapons + else + { + switch (reforgeTier) + { + case 0: + break; + case 1: + // Keen = 1, Ruthless = 2, Nimble = 3, Nasty = 4, Heavy = 5, Light = 6 + prefix = Main.rand.Next(1, 7); + break; + case 2: + // Hurtful = 7, Zealous = 8, Quick = 9, Pointy = 10, Bulky = 11 + prefix = Main.rand.Next(7, 12); + break; + case 3: + // Forceful = 12, Strong = 13, Agile = 14, Large = 15, Dangerous = 16, Sharp = 17 + prefix = Main.rand.Next(12, 18); + break; + case 4: + // Murderous = 18, Massive = 19, Unpleasant = 20, Deadly2 = 21 + prefix = Main.rand.Next(18, 22); + break; + case 5: + // Superior = 22, Demonic = 23, Savage = 24 + prefix = Main.rand.Next(22, 25); + break; + case 6: + // Legendary = 25, Light = 6 ~We are tool friendly (= + if (item.pick > 0 || item.axe > 0 || item.hammer > 0) + prefix = Main.rand.NextBool() ? 25 : 6; + else + prefix = 25; + break; + } + switch (prefix) + { + case -2: + break; + case 1: + prefix = PrefixID.Keen; + break; + case 2: + prefix = PrefixID.Ruthless; + break; + case 3: + prefix = PrefixID.Nimble; + break; + case 4: + prefix = PrefixID.Nasty; + break; + case 5: + prefix = PrefixID.Heavy; + break; + case 6: + prefix = PrefixID.Light; + break; + case 7: + prefix = PrefixID.Hurtful; + break; + case 8: + prefix = PrefixID.Zealous; + break; + case 9: + prefix = PrefixID.Quick; + break; + case 10: + prefix = PrefixID.Pointy; + break; + case 11: + prefix = PrefixID.Bulky; + break; + case 12: + prefix = PrefixID.Forceful; + break; + case 13: + prefix = PrefixID.Strong; + break; + case 14: + prefix = PrefixID.Agile; + break; + case 15: + prefix = PrefixID.Large; + break; + case 16: + prefix = PrefixID.Dangerous; + break; + case 17: + prefix = PrefixID.Sharp; + break; + case 18: + prefix = PrefixID.Murderous; + break; + case 19: + prefix = PrefixID.Massive; + break; + case 20: + prefix = PrefixID.Unpleasant; + break; + case 21: + prefix = PrefixID.Deadly2; + break; + case 22: + prefix = PrefixID.Superior; + break; + case 23: + prefix = PrefixID.Demonic; + break; + case 24: + prefix = PrefixID.Savage; + break; + case 25: + prefix = PrefixID.Legendary; + break; + } + } + } + else if (item.ranged) + { + switch (reforgeTier) + { + case 0: + break; + case 1: + // Keen = 1, Ruthless = 2, Nimble = 3, Nasty = 4, Powerful = 5 + prefix = Main.rand.Next(1, 6); + break; + case 2: + // Hurtful = 6, Zealous = 7, Quick = 8 + prefix = Main.rand.Next(6, 9); + break; + case 3: + // Forceful = 9, Strong = 10, Agile = 11, Sighted = 12, Murderous = 13 + prefix = Main.rand.Next(9, 14); + break; + case 4: + // Superior = 14, Demonic = 15, Deadly2 = 16, Intimidating = 17, Unpleasant = 18 + prefix = Main.rand.Next(14, 19); + break; + case 5: + // Godly = 19, Rapid = 20, Hasty = 21, Deadly = 22, Staunch = 23 + prefix = Main.rand.Next(19, 24); + break; + case 6: + // Unreal = 24 + prefix = 24; + break; + } + switch (prefix) + { + case -2: + break; + case 1: + prefix = PrefixID.Keen; + break; + case 2: + prefix = PrefixID.Ruthless; + break; + case 3: + prefix = PrefixID.Nimble; + break; + case 4: + prefix = PrefixID.Nasty; + break; + case 5: + prefix = PrefixID.Powerful; + break; + case 6: + prefix = PrefixID.Hurtful; + break; + case 7: + prefix = PrefixID.Zealous; + break; + case 8: + prefix = PrefixID.Quick; + break; + case 9: + prefix = PrefixID.Forceful; + break; + case 10: + prefix = PrefixID.Strong; + break; + case 11: + prefix = PrefixID.Agile; + break; + case 12: + prefix = PrefixID.Sighted; + break; + case 13: + prefix = PrefixID.Murderous; + break; + case 14: + prefix = PrefixID.Superior; + break; + case 15: + prefix = PrefixID.Demonic; + break; + case 16: + prefix = PrefixID.Deadly2; + break; + case 17: + prefix = PrefixID.Intimidating; + break; + case 18: + prefix = PrefixID.Unpleasant; + break; + case 19: + prefix = PrefixID.Godly; + break; + case 20: + prefix = PrefixID.Rapid; + break; + case 21: + prefix = PrefixID.Hasty; + break; + case 22: + prefix = PrefixID.Deadly; + break; + case 23: + prefix = PrefixID.Staunch; + break; + case 24: + prefix = PrefixID.Unreal; + break; + } + } + else if (item.magic) + { + switch (reforgeTier) + { + case 0: + break; + case 1: + // Keen = 1, Ruthless = 2, Nimble = 3, Nasty = 4, Furious = 5 + prefix = Main.rand.Next(1, 6); + break; + case 2: + // Hurtful = 6, Zealous = 7, Quick = 8, Taboo = 9, Manic = 10 + prefix = Main.rand.Next(6, 11); + break; + case 3: + // Forceful = 11, Strong = 12, Agile = 13, Murderous = 14, Adept = 15, Celestial = 16 + prefix = Main.rand.Next(11, 17); + break; + case 4: + // Superior = 17, Demonic = 18, Deadly2 = 19, Mystic = 20 + prefix = Main.rand.Next(17, 21); + break; + case 5: + // Godly = 21, Masterful = 22 + prefix = Main.rand.Next(21, 23); + break; + case 6: + // Mythical = 23 + prefix = 23; + break; + } + switch (prefix) + { + case -2: + break; + case 1: + prefix = PrefixID.Keen; + break; + case 2: + prefix = PrefixID.Ruthless; + break; + case 3: + prefix = PrefixID.Nimble; + break; + case 4: + prefix = PrefixID.Nasty; + break; + case 5: + prefix = PrefixID.Furious; + break; + case 6: + prefix = PrefixID.Hurtful; + break; + case 7: + prefix = PrefixID.Zealous; + break; + case 8: + prefix = PrefixID.Quick; + break; + case 9: + prefix = PrefixID.Taboo; + break; + case 10: + prefix = PrefixID.Manic; + break; + case 11: + prefix = PrefixID.Forceful; + break; + case 12: + prefix = PrefixID.Strong; + break; + case 13: + prefix = PrefixID.Agile; + break; + case 14: + prefix = PrefixID.Murderous; + break; + case 15: + prefix = PrefixID.Adept; + break; + case 16: + prefix = PrefixID.Celestial; + break; + case 17: + prefix = PrefixID.Superior; + break; + case 18: + prefix = PrefixID.Demonic; + break; + case 19: + prefix = PrefixID.Deadly2; + break; + case 20: + prefix = PrefixID.Mystic; + break; + case 21: + prefix = PrefixID.Godly; + break; + case 22: + prefix = PrefixID.Masterful; + break; + case 23: + prefix = PrefixID.Mythical; + break; + } + } + else if (item.summon) + { + switch (reforgeTier) + { + case 0: + break; + case 1: + // Nimble = 1, Furious = 2 + prefix = Main.rand.Next(1, 3); + break; + case 2: + // Hurtful = 3, Quick = 4, Taboo = 5, Manic = 6 + prefix = Main.rand.Next(3, 7); + break; + case 3: + // Forceful = 7, Strong = 8, Adept = 9, Celestial = 10 + prefix = Main.rand.Next(7, 11); + break; + case 4: + // Deadly2 = 11, Mystic = 12, Superior = 13, Demonic = 14 + prefix = Main.rand.Next(11, 15); + break; + case 5: + // Masterful = 15, Mythical = 16, Godly = 17 + prefix = Main.rand.Next(15, 18); + break; + case 6: + // Ruthless = 18 + prefix = 18; + break; + } + switch (prefix) + { + case -2: + break; + case 1: + prefix = PrefixID.Nimble; + break; + case 2: + prefix = PrefixID.Furious; + break; + case 3: + prefix = PrefixID.Hurtful; + break; + case 4: + prefix = PrefixID.Quick; + break; + case 5: + prefix = PrefixID.Taboo; + break; + case 6: + prefix = PrefixID.Manic; + break; + case 7: + prefix = PrefixID.Forceful; + break; + case 8: + prefix = PrefixID.Strong; + break; + case 9: + prefix = PrefixID.Adept; + break; + case 10: + prefix = PrefixID.Celestial; + break; + case 11: + prefix = PrefixID.Deadly2; + break; + case 12: + prefix = PrefixID.Mystic; + break; + case 13: + prefix = PrefixID.Superior; + break; + case 14: + prefix = PrefixID.Demonic; + break; + case 15: + prefix = PrefixID.Masterful; + break; + case 16: + prefix = PrefixID.Mythical; + break; + case 17: + prefix = PrefixID.Godly; + break; + case 18: + prefix = PrefixID.Ruthless; + break; + } + } + else if (item.Calamity().rogue) + { + switch (reforgeTier) + { + case 0: + break; + case 1: + // Radical = 1, Pointy = 2 + prefix = Main.rand.Next(1, 3); + break; + case 2: + // Sharp = 3, Glorious = 4 + prefix = Main.rand.Next(3, 5); + break; + case 3: + // Feathered = 5, Sleek = 6, Hefty = 7 + prefix = Main.rand.Next(5, 8); + break; + case 4: + // Mighty = 8, Serrated = 9 + prefix = Main.rand.Next(8, 10); + break; + case 5: + // Vicious = 10, Lethal = 11 + prefix = Main.rand.Next(10, 12); + break; + case 6: + // Flawless = 12 + prefix = 12; + break; + } + switch (prefix) + { + case -2: + break; + case 1: + prefix = mod.PrefixType("Radical"); + break; + case 2: + prefix = mod.PrefixType("Pointy"); + break; + case 3: + prefix = mod.PrefixType("Sharp"); + break; + case 4: + prefix = mod.PrefixType("Glorious"); + break; + case 5: + prefix = mod.PrefixType("Feathered"); + break; + case 6: + prefix = mod.PrefixType("Sleek"); + break; + case 7: + prefix = mod.PrefixType("Hefty"); + break; + case 8: + prefix = mod.PrefixType("Mighty"); + break; + case 9: + prefix = mod.PrefixType("Serrated"); + break; + case 10: + prefix = mod.PrefixType("Vicious"); + break; + case 11: + prefix = mod.PrefixType("Lethal"); + break; + case 12: + prefix = mod.PrefixType("Flawless"); + break; + } + } + return prefix; + } - // Cut price in half because fuck the goblin - public override bool ReforgePrice(Item item, ref int reforgePrice, ref bool canApplyDiscount) - { - reforgePrice /= 2; - return true; - } + // Cut price in half because fuck the goblin + public override bool ReforgePrice(Item item, ref int reforgePrice, ref bool canApplyDiscount) + { + reforgePrice /= 2; + return true; + } - // Get cash from dickhead goblin fuck - public override void PostReforge(Item item) - { - CalamityPlayer modPlayer = Main.player[Main.myPlayer].Calamity(); - if (modPlayer.itemTypeLastReforged != item.type) - { - modPlayer.reforgeTierSafety = 0; - modPlayer.finalTierAccessoryReforge = false; - } + // Get cash from dickhead goblin fuck + public override void PostReforge(Item item) + { + CalamityPlayer modPlayer = Main.player[Main.myPlayer].Calamity(); + if (modPlayer.itemTypeLastReforged != item.type) + { + modPlayer.reforgeTierSafety = 0; + modPlayer.finalTierAccessoryReforge = false; + } - modPlayer.itemTypeLastReforged = item.type; + modPlayer.itemTypeLastReforged = item.type; - if (modPlayer.reforgeTierSafety > 6) - { - modPlayer.reforgeTierSafety = 0; - modPlayer.finalTierAccessoryReforge = true; - } + if (modPlayer.reforgeTierSafety > 6) + { + modPlayer.reforgeTierSafety = 0; + modPlayer.finalTierAccessoryReforge = true; + } - modPlayer.reforgeTierSafety++; - reforgeTier = modPlayer.reforgeTierSafety; + modPlayer.reforgeTierSafety++; + reforgeTier = modPlayer.reforgeTierSafety; - bool favorited = item.favorited; - item.netDefaults(item.netID); - item.Prefix(NewPrefixType(item)); + bool favorited = item.favorited; + item.netDefaults(item.netID); + item.Prefix(NewPrefixType(item)); - item.Center = Main.player[Main.myPlayer].Center; - item.favorited = favorited; + item.Center = Main.player[Main.myPlayer].Center; + item.favorited = favorited; - if (NPC.AnyNPCs(ModContent.NPCType())) - { - int value = item.value; - ItemLoader.ReforgePrice(item, ref value, ref Main.LocalPlayer.discount); - CalamityWorld.MoneyStolenByBandit += value / 5; - CalamityWorld.Reforges++; - } - } - #endregion + if (NPC.AnyNPCs(ModContent.NPCType())) + { + int value = item.value; + ItemLoader.ReforgePrice(item, ref value, ref Main.LocalPlayer.discount); + CalamityWorld.MoneyStolenByBandit += value / 5; + CalamityWorld.Reforges++; + } + } + #endregion - #region Money From Rarity - public static readonly int Rarity0BuyPrice = Item.buyPrice(0, 0, 50, 0); + #region Money From Rarity + public static readonly int Rarity0BuyPrice = Item.buyPrice(0, 0, 50, 0); public static readonly int Rarity1BuyPrice = Item.buyPrice(0, 1, 0, 0); public static readonly int Rarity2BuyPrice = Item.buyPrice(0, 2, 0, 0); public static readonly int Rarity3BuyPrice = Item.buyPrice(0, 4, 0, 0); @@ -2560,14 +2429,14 @@ namespace CalamityMod.Items public static readonly int Rarity8BuyPrice = Item.buyPrice(0, 80, 0, 0); public static readonly int Rarity9BuyPrice = Item.buyPrice(0, 95, 0, 0); public static readonly int Rarity10BuyPrice = Item.buyPrice(1, 0, 0, 0); - public static readonly int Rarity11BuyPrice = Item.buyPrice(1, 10, 0, 0); - public static readonly int RarityTurquoiseBuyPrice = Item.buyPrice(1, 20, 0, 0); + public static readonly int Rarity11BuyPrice = Item.buyPrice(1, 10, 0, 0); + public static readonly int RarityTurquoiseBuyPrice = Item.buyPrice(1, 20, 0, 0); public static readonly int RarityPureGreenBuyPrice = Item.buyPrice(1, 40, 0, 0); public static readonly int RarityDarkBlueBuyPrice = Item.buyPrice(1, 80, 0, 0); public static readonly int RarityVioletBuyPrice = Item.buyPrice(2, 50, 0, 0); public static readonly int RarityHotPinkBuyPrice = Item.buyPrice(5, 0, 0, 0); - //These duplicates are for my sanity... + //These duplicates are for my sanity... public static readonly int Rarity12BuyPrice = Item.buyPrice(1, 20, 0, 0); public static readonly int Rarity13BuyPrice = Item.buyPrice(1, 40, 0, 0); public static readonly int Rarity14BuyPrice = Item.buyPrice(1, 80, 0, 0); @@ -2600,8 +2469,8 @@ namespace CalamityMod.Items return Rarity9BuyPrice; case 10: return Rarity10BuyPrice; - case 11: - return Rarity11BuyPrice; + case 11: + return Rarity11BuyPrice; case (int)CalamityRarity.Turquoise: return RarityTurquoiseBuyPrice; case (int)CalamityRarity.PureGreen: @@ -2619,6 +2488,6 @@ namespace CalamityMod.Items { return GetBuyPrice(item.rare); } - #endregion + #endregion } } diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index 0b821942a1..dfe91704d5 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -3,6 +3,7 @@ using CalamityMod.CustomRecipes; using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor; using CalamityMod.Items.Tools; +using CalamityMod.Items.VanillaArmorChanges; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; @@ -22,26 +23,26 @@ using Terraria.UI.Chat; namespace CalamityMod.Items { - public partial class CalamityGlobalItem : GlobalItem - { - #region Main ModifyTooltips Function - public override void ModifyTooltips(Item item, List tooltips) - { - // Apply rarity coloration to the item's name. - TooltipLine nameLine = tooltips.FirstOrDefault(x => x.Name == "ItemName" && x.mod == "Terraria"); - if (nameLine != null) - ApplyRarityColor(item, nameLine); + public partial class CalamityGlobalItem : GlobalItem + { + #region Main ModifyTooltips Function + public override void ModifyTooltips(Item item, List tooltips) + { + // Apply rarity coloration to the item's name. + TooltipLine nameLine = tooltips.FirstOrDefault(x => x.Name == "ItemName" && x.mod == "Terraria"); + if (nameLine != null) + ApplyRarityColor(item, nameLine); - // If the item is true melee, add a true melee damage number adjacent to the standard damage number. - if (item.melee && (item.shoot == ProjectileID.None || trueMelee) && item.damage > 0 && Main.LocalPlayer.Calamity().trueMeleeDamage > 0D) - TrueMeleeDamageTooltip(item, tooltips); + // If the item is true melee, add a true melee damage number adjacent to the standard damage number. + if (item.melee && (item.shoot == ProjectileID.None || trueMelee) && item.damage > 0 && Main.LocalPlayer.Calamity().trueMeleeDamage > 0D) + TrueMeleeDamageTooltip(item, tooltips); - // Modify all vanilla tooltips before appending mod mechanics (if any). - ModifyVanillaTooltips(item, tooltips); + // Modify all vanilla tooltips before appending mod mechanics (if any). + ModifyVanillaTooltips(item, tooltips); - // If the item has a stealth generation prefix, show that on the tooltip. - // This is placed between vanilla tooltip edits and mod mechanics because it can apply to vanilla items. - StealthGenAccessoryTooltip(item, tooltips); + // If the item has a stealth generation prefix, show that on the tooltip. + // This is placed between vanilla tooltip edits and mod mechanics because it can apply to vanilla items. + StealthGenAccessoryTooltip(item, tooltips); // Adds "Does extra damage to enemies shot at point-blank range" to weapons capable of it. if (canFirePointBlankShots) @@ -50,534 +51,545 @@ namespace CalamityMod.Items tooltips.Add(line); } - // If an item has an enchantment, show its prefix in the first tooltip line and append its description to the - // tooltip list. - EnchantmentTooltips(item, tooltips); - - // Everything below this line can only apply to modded items. If the item is vanilla, stop here for efficiency. - if (item.type < ItemID.Count) - return; - - // Adds a Current Charge tooltip to all items which use charge. - CalamityGlobalItem modItem = item.Calamity(); - if (modItem?.UsesCharge ?? false) - { - // Convert current charge ratio into a percentage. - float displayedPercent = ChargeRatio * 100f; - TooltipLine line = new TooltipLine(mod, "CalamityCharge", $"Current Charge: {displayedPercent:N1}%"); - tooltips.Add(line); - } - - // Adds "Donor Item" and "Developer Item" to donor items and developer items respectively. - if (donorItem) - { - TooltipLine line = new TooltipLine(mod, "CalamityDonor", CalamityUtils.ColorMessage("- Donor Item -", CalamityUtils.DonatorItemColor)); - tooltips.Add(line); - } - if (devItem) - { - TooltipLine line = new TooltipLine(mod, "CalamityDev", CalamityUtils.ColorMessage("- Developer Item -", CalamityUtils.HotPinkRarityColor)); - tooltips.Add(line); - } - } - #endregion - - #region Rarity Coloration - private void ApplyRarityColor(Item item, TooltipLine nameLine) - { - // Apply standard post-ML rarities to the item's color first. - Color? standardRarityColor = CalamityUtils.GetRarityColor(customRarity); - if (!item.expert && standardRarityColor.HasValue) - nameLine.overrideColor = standardRarityColor.Value; - - #region Uniquely Colored Developer Items - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = new Color(Main.DiscoR, 100, 255); - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = new Color(0, 0, 255); - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = Judgement.GetSyncedLightColor(); - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = new Color(0.34f, 0.34f + 0.66f * Main.DiscoG / 255f, 0.34f + 0.5f * Main.DiscoG / 255f); - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = ShatteredCommunity.GetRarityColor(); - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(255, 166, 0), new Color(25, 250, 25), 4f); //alternates between emerald green and amber (BanditHueh) - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(210, 0, 255), new Color(255, 248, 24), 4f); - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(131, 239, 255), new Color(36, 55, 230), 4f); - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(255, 69, 0), new Color(139, 0, 0), 4f); - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(191, 45, 71), new Color(185, 187, 253), 4f); - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(204, 86, 80), new Color(237, 69, 141), 4f); - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = new Color(129, 29, 149); - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = new Color(220, 20, 60); - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = new Color(254, 253, 235); - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = new Color(207, 17, 117); - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = new Color(227, 226, 180); - if (item.type == ModContent.ItemType()) - nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(154, 255, 151), new Color(228, 151, 255), 4f); - if (item.type == ModContent.ItemType() || item.type == ModContent.ItemType() || item.type == ModContent.ItemType()) - nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(255, 132, 22), new Color(221, 85, 7), 4f); - if (item.type == ModContent.ItemType()) - { - nameLine.overrideColor = CalamityUtils.MulticolorLerp(Main.GlobalTime / 2f % 1f, new Color[] - { - new Color(255, 196, 55), - new Color(255, 231, 107), - new Color(255, 254, 243) - }); - } - - // TODO -- for cleanliness, ALL color math should either be a one-line color swap or inside the item's own file - // The items that currently violate this are all below: - // Eternity, Flamsteed Ring, Earth - if (item.type == ModContent.ItemType()) - { - List colorSet = new List() - { - new Color(188, 192, 193), // white - new Color(157, 100, 183), // purple - new Color(249, 166, 77), // honey-ish orange - new Color(255, 105, 234), // pink - new Color(67, 204, 219), // sky blue - new Color(249, 245, 99), // bright yellow - new Color(236, 168, 247), // purplish pink - }; - if (nameLine != null) - { - int colorIndex = (int)(Main.GlobalTime / 2 % colorSet.Count); - Color currentColor = colorSet[colorIndex]; - Color nextColor = colorSet[(colorIndex + 1) % colorSet.Count]; - nameLine.overrideColor = Color.Lerp(currentColor, nextColor, Main.GlobalTime % 2f > 1f ? 1f : Main.GlobalTime % 1f); - } - } - if (item.type == ModContent.ItemType()) - { - if (Main.GlobalTime % 1f < 0.6f) - { - nameLine.overrideColor = new Color(89, 229, 255); - } - else if (Main.GlobalTime % 1f < 0.8f) - { - nameLine.overrideColor = Color.Lerp(new Color(89, 229, 255), Color.White, (Main.GlobalTime % 1f - 0.6f) / 0.2f); - } - else - { - nameLine.overrideColor = Color.Lerp(Color.White, new Color(89, 229, 255), (Main.GlobalTime % 1f - 0.8f) / 0.2f); - } - } - if (item.type == ModContent.ItemType()) - { - List earthColors = new List() - { - new Color(255, 99, 146), - new Color(255, 228, 94), - new Color(127, 200, 248) - }; - if (nameLine != null) - { - int colorIndex = (int)(Main.GlobalTime / 2 % earthColors.Count); - Color currentColor = earthColors[colorIndex]; - Color nextColor = earthColors[(colorIndex + 1) % earthColors.Count]; - nameLine.overrideColor = Color.Lerp(currentColor, nextColor, Main.GlobalTime % 2f > 1f ? 1f : Main.GlobalTime % 1f); - } - } - #endregion - } - #endregion - - #region Enchantment Tooltips - private void EnchantmentTooltips(Item item, IList tooltips) - { - if (!item.IsAir && AppliedEnchantment.HasValue) - { - foreach (string line in AppliedEnchantment.Value.Description.Split('\n')) - { - TooltipLine descriptionLine = new TooltipLine(mod, "Enchantment", CalamityUtils.ColorMessage(line, Color.DarkRed)); - tooltips.Add(descriptionLine); - } - } - } - #endregion - - #region Vanilla Item Tooltip Modification - private void ModifyVanillaTooltips(Item item, IList tooltips) - { - #region Modular Tooltip Editing Code - // This is a modular tooltip editor which loops over all tooltip lines of an item, - // selects all those which match an arbitrary function you provide, - // then edits them using another arbitrary function you provide. - void ApplyTooltipEdits(IList lines, Func predicate, Action action) - { - foreach (TooltipLine line in lines) - if (predicate.Invoke(item, line)) - action.Invoke(line); - } - - // This function produces simple predicates to match a specific line of a tooltip, by number/index. - Func LineNum(int n) => (Item i, TooltipLine l) => l.mod == "Terraria" && l.Name == $"Tooltip{n}"; - // This function produces simple predicates to match a specific line of a tooltip, by name. - Func LineName(string s) => (Item i, TooltipLine l) => l.mod == "Terraria" && l.Name == s; - - // These functions are shorthand to invoke ApplyTooltipEdits using the above predicates. - void EditTooltipByNum(int lineNum, Action action) => ApplyTooltipEdits(tooltips, LineNum(lineNum), action); - void EditTooltipByName(string lineName, Action action) => ApplyTooltipEdits(tooltips, LineName(lineName), action); - #endregion - - // Numerous random tooltip edits which don't fit into another category - #region Various Tooltip Edits - - // Teleporters not working while a boss is alive. - if (item.type == ItemID.Teleporter) - EditTooltipByName("Placeable", (line) => line.text += "\nCannot be used while a boss is alive"); - - // Flesh Knuckles giving extra max life. - if (item.type == ItemID.FleshKnuckles) - EditTooltipByNum(0, (line) => line.text += "\nMax life increased by 45"); - - // Mirrors and Recall Potions cannot be used while a boss is alive. - if (item.type == ItemID.MagicMirror || item.type == ItemID.IceMirror || item.type == ItemID.CellPhone || item.type == ItemID.RecallPotion) - ApplyTooltipEdits(tooltips, - (i, l) => l.mod == "Terraria" && l.Name == (i.type == ItemID.CellPhone ? "Tooltip1" : "Tooltip0"), - (line) => line.text += "\nCannot be used while you have the Boss Effects buff"); - - // Rod of Discord cannot be used multiple times to hurt yourself - if (item.type == ItemID.RodofDiscord) - EditTooltipByNum(0, (line) => line.text += "\nTeleportation is disabled while Chaos State is active"); - - // Indicate that the Ankh Shield provides sandstorm wind push immunity - if (item.type == ItemID.AnkhShield) - EditTooltipByNum(1, (line) => line.text += ", including Mighty Wind"); - - // Water removing items cannot be used in the Abyss - string noAbyssLine = "\nCannot be used in the Abyss"; - if (item.type == ItemID.SuperAbsorbantSponge) - EditTooltipByNum(0, (line) => line.text += noAbyssLine); - if (item.type == ItemID.EmptyBucket) - EditTooltipByName("Defense", (line) => line.text += noAbyssLine); - - // If Early Hardmode Rework is enabled: Remind users that ores will NOT spawn when an altar is smashed. - if (CalamityConfig.Instance.EarlyHardmodeProgressionRework && (item.type == ItemID.Pwnhammer || item.type == ItemID.Hammush)) - EditTooltipByNum(0, (line) => line.text += "\nDemon Altars no longer spawn ores when destroyed"); - - // Bottled Honey gives the Honey buff - if (item.type == ItemID.BottledHoney) - EditTooltipByName("HealLife", (line) => line.text += "\nGrants the Honey buff for 2 minutes"); - - // Warmth Potion provides debuff immunities and Death Mode cold protection - if (item.type == ItemID.WarmthPotion) - { - string immunityLine = "\nMakes you immune to the Chilled, Frozen, and Glacial State debuffs"; - if (CalamityWorld.death) - immunityLine += "\nProvides cold protection in Death Mode"; - EditTooltipByNum(0, (line) => line.text += immunityLine); - } - - // Nerfed Archery Potion tooltip - if (item.type == ItemID.ArcheryPotion) - EditTooltipByNum(0, (line) => line.text = "20% increased arrow speed and 1.05x arrow damage"); - - // Nerfed Swiftness Potion tooltip - if (item.type == ItemID.SwiftnessPotion) - EditTooltipByNum(0, (line) => line.text = "15% increased movement speed"); - - // Nerfed Endurance Potion tooltip - if (item.type == ItemID.EndurancePotion) - EditTooltipByNum(0, (line) => line.text = "Reduces damage taken by 5%"); - - // Hand Warmer provides Death Mode cold protection and has a side bonus with Eskimo armor - if (item.type == ItemID.HandWarmer) - { - string extraLine = "\nProvides a regeneration boost while wearing the Eskimo armor"; - if (CalamityWorld.death) - extraLine += "\nProvides cold protection in Death Mode"; - EditTooltipByNum(0, (line) => line.text += extraLine); - } - - // Invisibility Potion provides various rogue boosts - if (item.type == ItemID.InvisibilityPotion) - EditTooltipByNum(0, (line) => line.text += "\nBoosts various rogue stats depending on held weapon"); - - // Golden Fishing Rod inherently contains High Test Fishing Line - if (item.type == ItemID.GoldenFishingRod) - EditTooltipByName("NeedsBait", (line) => line.text += "\nIts fishing line will never break"); - - // Eternity Crystal notifies the player that they can accelerate the invasion - if (item.type == ItemID.DD2ElderCrystal) - EditTooltipByNum(0, (line) => line.text += "\nOnce placed you can right click the crystal to skip waves or increase the spawn rate of the invaders"); - - // Fix a vanilla mistake in Magic Quiver's tooltip - // TODO -- in 1.4 this mistake is already corrected - if (item.type == ItemID.MagicQuiver) - EditTooltipByNum(0, (line) => line.text = line.text.Replace(" damage", " arrow damage")); - - // Aerial Bane is no longer the real bane of aerial enemies (50% dmg bonus removed) - if (item.type == ItemID.DD2BetsyBow) - EditTooltipByNum(0, (line) => line.text = "Shoots splitting arrows"); - #endregion - - // For boss summon item clarity - #region Boss Summon Tooltip Edits - - if (item.type == ItemID.Abeemination) - EditTooltipByNum(0, (line) => line.text += " when used in the jungle"); - - if (item.type == ItemID.BloodySpine) - EditTooltipByNum(0, (line) => line.text += " when used in the crimson"); - - if (item.type == ItemID.ClothierVoodooDoll) - EditTooltipByNum(0, (line) => line.text += "\nWhile equipped, summons Skeletron when the Clothier is killed during nighttime"); - - if (item.type == ItemID.GuideVoodooDoll) - EditTooltipByNum(0, (line) => line.text += "\nSummons the Wall of Flesh if thrown into lava in the underworld while the Guide is alive"); - - if (item.type == ItemID.LihzahrdPowerCell) - EditTooltipByNum(0, (line) => line.text += " to summon the Golem"); - - if (item.type == ItemID.MechanicalEye || item.type == ItemID.MechanicalSkull || item.type == ItemID.MechanicalWorm || item.type == ItemID.SuspiciousLookingEye) - EditTooltipByNum(0, (line) => line.text += " when used during nighttime"); - - if (item.type == ItemID.TruffleWorm) - EditTooltipByName("Consumable", (line) => line.text += "\nSummons Duke Fishron if used as bait in the ocean"); - - if (item.type == ItemID.WormFood) - EditTooltipByNum(0, (line) => line.text += " when used in the corruption"); - #endregion + // If an item has an enchantment, show its prefix in the first tooltip line and append its description to the + // tooltip list. + EnchantmentTooltips(item, tooltips); + + // Everything below this line can only apply to modded items. If the item is vanilla, stop here for efficiency. + if (item.type < ItemID.Count) + return; + + // Adds a Current Charge tooltip to all items which use charge. + CalamityGlobalItem modItem = item.Calamity(); + if (modItem?.UsesCharge ?? false) + { + // Convert current charge ratio into a percentage. + float displayedPercent = ChargeRatio * 100f; + TooltipLine line = new TooltipLine(mod, "CalamityCharge", $"Current Charge: {displayedPercent:N1}%"); + tooltips.Add(line); + } + + // Adds "Donor Item" and "Developer Item" to donor items and developer items respectively. + if (donorItem) + { + TooltipLine line = new TooltipLine(mod, "CalamityDonor", CalamityUtils.ColorMessage("- Donor Item -", CalamityUtils.DonatorItemColor)); + tooltips.Add(line); + } + if (devItem) + { + TooltipLine line = new TooltipLine(mod, "CalamityDev", CalamityUtils.ColorMessage("- Developer Item -", CalamityUtils.HotPinkRarityColor)); + tooltips.Add(line); + } + } + #endregion + + #region Rarity Coloration + private void ApplyRarityColor(Item item, TooltipLine nameLine) + { + // Apply standard post-ML rarities to the item's color first. + Color? standardRarityColor = CalamityUtils.GetRarityColor(customRarity); + if (!item.expert && standardRarityColor.HasValue) + nameLine.overrideColor = standardRarityColor.Value; + + #region Uniquely Colored Developer Items + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = new Color(Main.DiscoR, 100, 255); + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = new Color(0, 0, 255); + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = Judgement.GetSyncedLightColor(); + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = new Color(0.34f, 0.34f + 0.66f * Main.DiscoG / 255f, 0.34f + 0.5f * Main.DiscoG / 255f); + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = ShatteredCommunity.GetRarityColor(); + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(255, 166, 0), new Color(25, 250, 25), 4f); //alternates between emerald green and amber (BanditHueh) + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(210, 0, 255), new Color(255, 248, 24), 4f); + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(131, 239, 255), new Color(36, 55, 230), 4f); + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(255, 69, 0), new Color(139, 0, 0), 4f); + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(191, 45, 71), new Color(185, 187, 253), 4f); + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(204, 86, 80), new Color(237, 69, 141), 4f); + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = new Color(129, 29, 149); + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = new Color(220, 20, 60); + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = new Color(254, 253, 235); + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = new Color(207, 17, 117); + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = new Color(227, 226, 180); + if (item.type == ModContent.ItemType()) + nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(154, 255, 151), new Color(228, 151, 255), 4f); + if (item.type == ModContent.ItemType() || item.type == ModContent.ItemType() || item.type == ModContent.ItemType()) + nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(255, 132, 22), new Color(221, 85, 7), 4f); + if (item.type == ModContent.ItemType()) + { + nameLine.overrideColor = CalamityUtils.MulticolorLerp(Main.GlobalTime / 2f % 1f, new Color[] + { + new Color(255, 196, 55), + new Color(255, 231, 107), + new Color(255, 254, 243) + }); + } + + // TODO -- for cleanliness, ALL color math should either be a one-line color swap or inside the item's own file + // The items that currently violate this are all below: + // Eternity, Flamsteed Ring, Earth + if (item.type == ModContent.ItemType()) + { + List colorSet = new List() + { + new Color(188, 192, 193), // white + new Color(157, 100, 183), // purple + new Color(249, 166, 77), // honey-ish orange + new Color(255, 105, 234), // pink + new Color(67, 204, 219), // sky blue + new Color(249, 245, 99), // bright yellow + new Color(236, 168, 247), // purplish pink + }; + if (nameLine != null) + { + int colorIndex = (int)(Main.GlobalTime / 2 % colorSet.Count); + Color currentColor = colorSet[colorIndex]; + Color nextColor = colorSet[(colorIndex + 1) % colorSet.Count]; + nameLine.overrideColor = Color.Lerp(currentColor, nextColor, Main.GlobalTime % 2f > 1f ? 1f : Main.GlobalTime % 1f); + } + } + if (item.type == ModContent.ItemType()) + { + if (Main.GlobalTime % 1f < 0.6f) + { + nameLine.overrideColor = new Color(89, 229, 255); + } + else if (Main.GlobalTime % 1f < 0.8f) + { + nameLine.overrideColor = Color.Lerp(new Color(89, 229, 255), Color.White, (Main.GlobalTime % 1f - 0.6f) / 0.2f); + } + else + { + nameLine.overrideColor = Color.Lerp(Color.White, new Color(89, 229, 255), (Main.GlobalTime % 1f - 0.8f) / 0.2f); + } + } + if (item.type == ModContent.ItemType()) + { + List earthColors = new List() + { + new Color(255, 99, 146), + new Color(255, 228, 94), + new Color(127, 200, 248) + }; + if (nameLine != null) + { + int colorIndex = (int)(Main.GlobalTime / 2 % earthColors.Count); + Color currentColor = earthColors[colorIndex]; + Color nextColor = earthColors[(colorIndex + 1) % earthColors.Count]; + nameLine.overrideColor = Color.Lerp(currentColor, nextColor, Main.GlobalTime % 2f > 1f ? 1f : Main.GlobalTime % 1f); + } + } + #endregion + } + #endregion + + #region Enchantment Tooltips + private void EnchantmentTooltips(Item item, IList tooltips) + { + if (!item.IsAir && AppliedEnchantment.HasValue) + { + foreach (string line in AppliedEnchantment.Value.Description.Split('\n')) + { + TooltipLine descriptionLine = new TooltipLine(mod, "Enchantment", CalamityUtils.ColorMessage(line, Color.DarkRed)); + tooltips.Add(descriptionLine); + } + } + } + #endregion + + #region Vanilla Item Tooltip Modification + + // Turns a number into a string of increased mining speed. + public const string HeatProtectionLine = "\nProvides heat protection in Death Mode"; + public const string BothProtectionLine = "\nProvides heat and cold protection in Death Mode"; + + public static string MiningSpeedString(int percent) => $"\n{percent}% increased mining speed"; + + private void ModifyVanillaTooltips(Item item, IList tooltips) + { + #region Modular Tooltip Editing Code + // This is a modular tooltip editor which loops over all tooltip lines of an item, + // selects all those which match an arbitrary function you provide, + // then edits them using another arbitrary function you provide. + void ApplyTooltipEdits(IList lines, Func predicate, Action action) + { + foreach (TooltipLine line in lines) + if (predicate.Invoke(item, line)) + action.Invoke(line); + } + + // This function produces simple predicates to match a specific line of a tooltip, by number/index. + Func LineNum(int n) => (Item i, TooltipLine l) => l.mod == "Terraria" && l.Name == $"Tooltip{n}"; + // This function produces simple predicates to match a specific line of a tooltip, by name. + Func LineName(string s) => (Item i, TooltipLine l) => l.mod == "Terraria" && l.Name == s; + + // These functions are shorthand to invoke ApplyTooltipEdits using the above predicates. + void EditTooltipByNum(int lineNum, Action action) => ApplyTooltipEdits(tooltips, LineNum(lineNum), action); + void EditTooltipByName(string lineName, Action action) => ApplyTooltipEdits(tooltips, LineName(lineName), action); + #endregion + + // Numerous random tooltip edits which don't fit into another category + #region Various Tooltip Edits + + // Teleporters not working while a boss is alive. + if (item.type == ItemID.Teleporter) + EditTooltipByName("Placeable", (line) => line.text += "\nCannot be used while a boss is alive"); + + // Flesh Knuckles giving extra max life. + if (item.type == ItemID.FleshKnuckles) + EditTooltipByNum(0, (line) => line.text += "\nMax life increased by 45"); + + // Mirrors and Recall Potions cannot be used while a boss is alive. + if (item.type == ItemID.MagicMirror || item.type == ItemID.IceMirror || item.type == ItemID.CellPhone || item.type == ItemID.RecallPotion) + ApplyTooltipEdits(tooltips, + (i, l) => l.mod == "Terraria" && l.Name == (i.type == ItemID.CellPhone ? "Tooltip1" : "Tooltip0"), + (line) => line.text += "\nCannot be used while you have the Boss Effects buff"); + + // Rod of Discord cannot be used multiple times to hurt yourself + if (item.type == ItemID.RodofDiscord) + EditTooltipByNum(0, (line) => line.text += "\nTeleportation is disabled while Chaos State is active"); + + // Indicate that the Ankh Shield provides sandstorm wind push immunity + if (item.type == ItemID.AnkhShield) + EditTooltipByNum(1, (line) => line.text += ", including Mighty Wind"); + + // Water removing items cannot be used in the Abyss + string noAbyssLine = "\nCannot be used in the Abyss"; + if (item.type == ItemID.SuperAbsorbantSponge) + EditTooltipByNum(0, (line) => line.text += noAbyssLine); + if (item.type == ItemID.EmptyBucket) + EditTooltipByName("Defense", (line) => line.text += noAbyssLine); + + // If Early Hardmode Rework is enabled: Remind users that ores will NOT spawn when an altar is smashed. + if (CalamityConfig.Instance.EarlyHardmodeProgressionRework && (item.type == ItemID.Pwnhammer || item.type == ItemID.Hammush)) + EditTooltipByNum(0, (line) => line.text += "\nDemon Altars no longer spawn ores when destroyed"); + + // Bottled Honey gives the Honey buff + if (item.type == ItemID.BottledHoney) + EditTooltipByName("HealLife", (line) => line.text += "\nGrants the Honey buff for 2 minutes"); + + // Warmth Potion provides debuff immunities and Death Mode cold protection + if (item.type == ItemID.WarmthPotion) + { + string immunityLine = "\nMakes you immune to the Chilled, Frozen, and Glacial State debuffs"; + if (CalamityWorld.death) + immunityLine += "\nProvides cold protection in Death Mode"; + EditTooltipByNum(0, (line) => line.text += immunityLine); + } + + // Nerfed Archery Potion tooltip + if (item.type == ItemID.ArcheryPotion) + EditTooltipByNum(0, (line) => line.text = "20% increased arrow speed and 1.05x arrow damage"); + + // Nerfed Swiftness Potion tooltip + if (item.type == ItemID.SwiftnessPotion) + EditTooltipByNum(0, (line) => line.text = "15% increased movement speed"); + + // Nerfed Endurance Potion tooltip + if (item.type == ItemID.EndurancePotion) + EditTooltipByNum(0, (line) => line.text = "Reduces damage taken by 5%"); + + // Hand Warmer provides Death Mode cold protection and has a side bonus with Eskimo armor + if (item.type == ItemID.HandWarmer) + { + string extraLine = "\nProvides a regeneration boost while wearing the Eskimo armor"; + if (CalamityWorld.death) + extraLine += "\nProvides cold protection in Death Mode"; + EditTooltipByNum(0, (line) => line.text += extraLine); + } + + // Invisibility Potion provides various rogue boosts + if (item.type == ItemID.InvisibilityPotion) + EditTooltipByNum(0, (line) => line.text += "\nBoosts various rogue stats depending on held weapon"); + + // Golden Fishing Rod inherently contains High Test Fishing Line + if (item.type == ItemID.GoldenFishingRod) + EditTooltipByName("NeedsBait", (line) => line.text += "\nIts fishing line will never break"); + + // Eternity Crystal notifies the player that they can accelerate the invasion + if (item.type == ItemID.DD2ElderCrystal) + EditTooltipByNum(0, (line) => line.text += "\nOnce placed you can right click the crystal to skip waves or increase the spawn rate of the invaders"); + + // Fix a vanilla mistake in Magic Quiver's tooltip + // TODO -- in 1.4 this mistake is already corrected + if (item.type == ItemID.MagicQuiver) + EditTooltipByNum(0, (line) => line.text = line.text.Replace(" damage", " arrow damage")); + + // Aerial Bane is no longer the real bane of aerial enemies (50% dmg bonus removed) + if (item.type == ItemID.DD2BetsyBow) + EditTooltipByNum(0, (line) => line.text = "Shoots splitting arrows"); + #endregion + + // For boss summon item clarity + #region Boss Summon Tooltip Edits + + if (item.type == ItemID.Abeemination) + EditTooltipByNum(0, (line) => line.text += " when used in the jungle"); + + if (item.type == ItemID.BloodySpine) + EditTooltipByNum(0, (line) => line.text += " when used in the crimson"); + + if (item.type == ItemID.ClothierVoodooDoll) + EditTooltipByNum(0, (line) => line.text += "\nWhile equipped, summons Skeletron when the Clothier is killed during nighttime"); + + if (item.type == ItemID.GuideVoodooDoll) + EditTooltipByNum(0, (line) => line.text += "\nSummons the Wall of Flesh if thrown into lava in the underworld while the Guide is alive"); + + if (item.type == ItemID.LihzahrdPowerCell) + EditTooltipByNum(0, (line) => line.text += " to summon the Golem"); + + if (item.type == ItemID.MechanicalEye || item.type == ItemID.MechanicalSkull || item.type == ItemID.MechanicalWorm || item.type == ItemID.SuspiciousLookingEye) + EditTooltipByNum(0, (line) => line.text += " when used during nighttime"); + + if (item.type == ItemID.TruffleWorm) + EditTooltipByName("Consumable", (line) => line.text += "\nSummons Duke Fishron if used as bait in the ocean"); + + if (item.type == ItemID.WormFood) + EditTooltipByNum(0, (line) => line.text += " when used in the corruption"); + #endregion - // Black Belt and Master Ninja Gear have guaranteed dodges on a 90 second cooldown. - #region Dodging Belt Tooltips - string beltDodgeLine = "Grants the ability to dodge attacks\n" + - $"The dodge has a {CalamityPlayer.BeltDodgeCooldown / 60} second cooldown which is shared with all other dodges and reflects"; - if (item.type == ItemID.BlackBelt) - EditTooltipByNum(0, (line) => line.text = beltDodgeLine); - if (item.type == ItemID.MasterNinjaGear) - EditTooltipByNum(1, (line) => line.text = beltDodgeLine); - #endregion + // Black Belt and Master Ninja Gear have guaranteed dodges on a 90 second cooldown. + #region Dodging Belt Tooltips + string beltDodgeLine = "Grants the ability to dodge attacks\n" + + $"The dodge has a {CalamityPlayer.BeltDodgeCooldown / 60} second cooldown which is shared with all other dodges and reflects"; + if (item.type == ItemID.BlackBelt) + EditTooltipByNum(0, (line) => line.text = beltDodgeLine); + if (item.type == ItemID.MasterNinjaGear) + EditTooltipByNum(1, (line) => line.text = beltDodgeLine); + #endregion - // Early Hardmode ore melee weapons have new on-hit effects. - #region Early Hardmode Melee Tooltips + // Early Hardmode ore melee weapons have new on-hit effects. + #region Early Hardmode Melee Tooltips - // Cobalt - if (item.type == ItemID.CobaltSword || item.type == ItemID.CobaltNaginata) - EditTooltipByName("Knockback", (line) => line.text += "\nDecreases enemy defense by 25% on hit"); + // Cobalt + if (item.type == ItemID.CobaltSword || item.type == ItemID.CobaltNaginata) + EditTooltipByName("Knockback", (line) => line.text += "\nDecreases enemy defense by 25% on hit"); - // Palladium - if (item.type == ItemID.PalladiumSword || item.type == ItemID.PalladiumPike) - EditTooltipByName("Knockback", (line) => line.text += "\nIncreases life regen on hit"); - - // Mythril - if (item.type == ItemID.MythrilSword || item.type == ItemID.MythrilHalberd) - EditTooltipByName("Knockback", (line) => line.text += "\nDecreases enemy contact damage by 10% on hit"); - - // Orichalcum - if (item.type == ItemID.OrichalcumSword || item.type == ItemID.OrichalcumHalberd) - EditTooltipByName("Knockback", (line) => line.text += "\nIncreases how frequently the Orichalcum set bonus triggers on hit"); - - // Adamantite - if (item.type == ItemID.AdamantiteSword || item.type == ItemID.AdamantiteGlaive) - EditTooltipByName("Knockback", (line) => line.text += "\nSlows enemies on hit"); - - // Titanium - if (item.type == ItemID.TitaniumSword || item.type == ItemID.TitaniumTrident) - EditTooltipByName("Knockback", (line) => line.text += "\nDeals increased damage to enemies with high knockback resistance"); - - // Hallowed (and True Excalibur) - if (item.type == ItemID.Excalibur || item.type == ItemID.Gungnir || item.type == ItemID.TrueExcalibur) - EditTooltipByName("Knockback", (line) => line.text += "\nInflicts Holy Flames\nDeals double damage to enemies above 75% life"); - #endregion - - // Other melee weapon tooltips - #region Other Melee Tooltips - - if (item.type == ItemID.CandyCaneSword || item.type == ItemID.FruitcakeChakram) - EditTooltipByName("Knockback", (line) => line.text += "\nHeals you on hit"); - - // Stylish Scissors, all Phaseblades, and all Phasesabers - if (item.type == ItemID.StylistKilLaKillScissorsIWish || (item.type >= ItemID.BluePhaseblade && item.type <= ItemID.YellowPhaseblade) || (item.type >= ItemID.BluePhasesaber && item.type <= ItemID.YellowPhasesaber)) - EditTooltipByName("Knockback", (line) => line.text += "\nIgnores 100% of enemy defense"); - - if (item.type == ItemID.AntlionClaw || item.type == ItemID.BoneSword || item.type == ItemID.BreakerBlade) - EditTooltipByName("Knockback", (line) => line.text += "\nIgnores 50% of enemy defense"); - - if (item.type == ItemID.LightsBane || item.type == ItemID.NightsEdge || item.type == ItemID.TrueNightsEdge || item.type == ItemID.BallOHurt || item.type == ItemID.CorruptYoyo) - EditTooltipByName("Knockback", (line) => line.text += "\nInflicts Shadowflame on hit"); - - if (item.type == ItemID.BloodButcherer || item.type == ItemID.TheRottedFork || item.type == ItemID.TheMeatball || item.type == ItemID.CrimsonYoyo || item.type == ItemID.CrimsonRod) - EditTooltipByName("Knockback", (line) => line.text += "\nInflicts Burning Blood on hit"); - - if (item.type == ItemID.DeathSickle) - EditTooltipByNum(0, (line) => line.text += "\nInflicts Whispering Death on hit"); - #endregion - - // Light pets, accessories, and other items which boost the player's Abyss light stat - #region Abyss Light Tooltips - - // +1 to Abyss light level - string abyssSmallLightLine = "\nProvides a small amount of light in the abyss"; - - if (item.type == ItemID.CrimsonHeart || item.type == ItemID.ShadowOrb || item.type == ItemID.MagicLantern || item.type == ItemID.JellyfishNecklace || item.type == ItemID.MiningHelmet) - EditTooltipByNum(0, (line) => line.text += abyssSmallLightLine); - if (item.type == ItemID.JellyfishDivingGear) - EditTooltipByNum(1, (line) => line.text += abyssSmallLightLine); - - // +2 to Abyss light level - string abyssMediumLightLine = "\nProvides a moderate amount of light in the abyss"; - - if (item.type == ItemID.ShinePotion) - EditTooltipByName("BuffTime", (line) => line.text += abyssMediumLightLine); - - if (item.type == ItemID.FairyBell || item.type == ItemID.DD2PetGhost) - EditTooltipByNum(0, (line) => line.text += abyssMediumLightLine); - - // +3 to Abyss light level - string abyssLargeLightLine = "\nProvides a large amount of light in the abyss"; - - if (item.type == ItemID.WispinaBottle) - EditTooltipByNum(0, (line) => line.text += abyssLargeLightLine); - if (item.type == ItemID.SuspiciousLookingTentacle) - EditTooltipByNum(1, (line) => line.text += abyssLargeLightLine); - #endregion - - // Accessories and other items which boost the player's ability to breathe in the Abyss - #region Abyss Breath Tooltips - - // Moderate breath boost - string abyssModerateBreathLine = "\nModerately reduces breath loss in the abyss"; - - if (item.type == ItemID.DivingHelmet) - EditTooltipByNum(0, (line) => line.text += abyssModerateBreathLine); - if (item.type == ItemID.ArcticDivingGear) - EditTooltipByNum(1, (line) => line.text += abyssSmallLightLine + abyssModerateBreathLine); - - // Great breath boost - string abyssGreatBreathLine = "\nGreatly reduces breath loss in the abyss"; - - if (item.type == ItemID.GillsPotion) - EditTooltipByName("BuffTime", (line) => line.text += abyssGreatBreathLine); - - if (item.type == ItemID.NeptunesShell || item.type == ItemID.MoonShell) - EditTooltipByNum(0, (line) => line.text += abyssGreatBreathLine); - if (item.type == ItemID.CelestialShell) - EditTooltipByNum(1, (line) => line.text += abyssModerateBreathLine); - #endregion - - // Flasks apply to Rogue weapons - #region Rogue Flask Tooltips - if (item.type == ItemID.FlaskofCursedFlames) - EditTooltipByNum(0, (line) => line.text += "\nRogue attacks inflict enemies with cursed flames"); - if (item.type == ItemID.FlaskofFire) - EditTooltipByNum(0, (line) => line.text += "\nRogue attacks set enemies on fire"); - if (item.type == ItemID.FlaskofGold) - EditTooltipByNum(0, (line) => line.text += "\nRogue attacks make enemies drop more gold"); - if (item.type == ItemID.FlaskofIchor) - EditTooltipByNum(0, (line) => line.text += "\nRogue attacks decrease enemy defense"); - if (item.type == ItemID.FlaskofNanites) - EditTooltipByNum(0, (line) => line.text += "\nRogue attacks confuse enemies"); - // party flask is unique because it affects ALL projectiles in Calamity, not just "also rogue ones" - if (item.type == ItemID.FlaskofParty) - EditTooltipByNum(0, (line) => line.text = "All attacks cause confetti to appear"); - if (item.type == ItemID.FlaskofPoison) - EditTooltipByNum(0, (line) => line.text += "\nRogue attacks poison enemies"); - if (item.type == ItemID.FlaskofVenom) - EditTooltipByNum(0, (line) => line.text += "\nRogue attacks inflict Venom on enemies"); - #endregion - - // Rebalances to vanilla item stats - #region Vanilla Item Rebalance Tooltips - - // Magic Power Potion nerf - if (item.type == ItemID.MagicPowerPotion) - EditTooltipByNum(0, (line) => line.text = "10% increased magic damage"); - - // Magic and Wizard Hat nerfs - // Magic Hat - if (item.type == ItemID.MagicHat) - EditTooltipByNum(0, (line) => line.text = "5% increased magic damage and critical strike chance"); - - // Wizard Hat - if (item.type == ItemID.WizardHat) - EditTooltipByNum(0, (line) => line.text = "5% increased magic damage"); - - // Reduce DD2 armor piece bonuses because they're overpowered - // Squire armor - if (item.type == ItemID.SquirePlating) - EditTooltipByNum(0, (line) => line.text = "10% increased minion and melee damage"); - if (item.type == ItemID.SquireGreaves) - EditTooltipByNum(0, (line) => line.text = "5% increased minion damage and melee critical strike chance\n" + - "15% increased movement speed"); - - // Monk armor - if (item.type == ItemID.MonkBrows) - EditTooltipByNum(0, (line) => line.text = "Increases your max number of sentries by 1 and increases melee attack speed by 10%"); - if (item.type == ItemID.MonkShirt) - EditTooltipByNum(0, (line) => line.text = "10% increased minion and melee damage"); - if (item.type == ItemID.MonkPants) - { - EditTooltipByNum(0, (line) => line.text = "5% increased minion damage and melee critical strike chance"); - EditTooltipByNum(1, (line) => line.text = "20% increased movement speed"); - } - - // Huntress armor - if (item.type == ItemID.HuntressJerkin) - EditTooltipByNum(0, (line) => line.text = "10% increased minion and ranged damage\n" + - "10% chance to not consume ammo"); - - // Apprentice armor - if (item.type == ItemID.ApprenticeTrousers) - EditTooltipByNum(0, (line) => line.text = "5% increased minion damage and magic critical strike chance\n" + - "20% increased movement speed"); - - // Valhalla Knight armor - if (item.type == ItemID.SquireAltShirt) - EditTooltipByNum(0, (line) => line.text = "30% increased minion damage and increased life regeneration"); - if (item.type == ItemID.SquireAltPants) - EditTooltipByNum(0, (line) => line.text = "10% increased minion damage and melee critical strike chance\n" + - "20% increased movement speed"); - - // Shinobi Infiltrator armor - if (item.type == ItemID.MonkAltHead) - EditTooltipByNum(0, (line) => line.text = "Increases your max number of sentries by 2\n" + - "10% increased melee and minion damage"); - if (item.type == ItemID.MonkAltShirt) - EditTooltipByNum(0, (line) => line.text = "10% increased minion damage and melee speed\n" + - "5% increased melee critical strike chance"); - if (item.type == ItemID.MonkAltPants) - EditTooltipByNum(0, (line) => line.text = "10% increased minion damage and melee critical strike chance\n" + - "30% increased movement speed"); - - // Red Riding armor - if (item.type == ItemID.HuntressAltShirt) - EditTooltipByNum(0, (line) => line.text = "15% increased minion and ranged damage and 20% chance to not consume ammo"); - - // Dark Artist armor - if (item.type == ItemID.ApprenticeAltPants) - EditTooltipByNum(0, (line) => line.text = "10% increased minion damage and magic critical strike chance\n" + - "20% increased movement speed"); - - // Worm Scarf only gives 10% DR instead of 17% - if (item.type == ItemID.WormScarf) - EditTooltipByNum(0, (line) => line.text = line.text.Replace("17%", "10%")); - - if (item.type == ItemID.TitanGlove) - EditTooltipByNum(0, (line) => line.text += "\n10% increased true melee damage"); - if (item.type == ItemID.PowerGlove || item.type == ItemID.MechanicalGlove) - EditTooltipByNum(1, (line) => line.text += "\n10% increased true melee damage"); - if (item.type == ItemID.FireGauntlet) - { - string extraLine = "\n10% increased true melee damage"; - if (CalamityWorld.death) - extraLine += "\nProvides heat and cold protection in Death Mode"; - EditTooltipByNum(1, (line) => line.text = line.text.Replace("10%", "14%") + extraLine); - } + // Palladium + if (item.type == ItemID.PalladiumSword || item.type == ItemID.PalladiumPike) + EditTooltipByName("Knockback", (line) => line.text += "\nIncreases life regen on hit"); + + // Mythril + if (item.type == ItemID.MythrilSword || item.type == ItemID.MythrilHalberd) + EditTooltipByName("Knockback", (line) => line.text += "\nDecreases enemy contact damage by 10% on hit"); + + // Orichalcum + if (item.type == ItemID.OrichalcumSword || item.type == ItemID.OrichalcumHalberd) + EditTooltipByName("Knockback", (line) => line.text += "\nIncreases how frequently the Orichalcum set bonus triggers on hit"); + + // Adamantite + if (item.type == ItemID.AdamantiteSword || item.type == ItemID.AdamantiteGlaive) + EditTooltipByName("Knockback", (line) => line.text += "\nSlows enemies on hit"); + + // Titanium + if (item.type == ItemID.TitaniumSword || item.type == ItemID.TitaniumTrident) + EditTooltipByName("Knockback", (line) => line.text += "\nDeals increased damage to enemies with high knockback resistance"); + + // Hallowed (and True Excalibur) + if (item.type == ItemID.Excalibur || item.type == ItemID.Gungnir || item.type == ItemID.TrueExcalibur) + EditTooltipByName("Knockback", (line) => line.text += "\nInflicts Holy Flames\nDeals double damage to enemies above 75% life"); + #endregion + + // Other melee weapon tooltips + #region Other Melee Tooltips + + if (item.type == ItemID.CandyCaneSword || item.type == ItemID.FruitcakeChakram) + EditTooltipByName("Knockback", (line) => line.text += "\nHeals you on hit"); + + // Stylish Scissors, all Phaseblades, and all Phasesabers + if (item.type == ItemID.StylistKilLaKillScissorsIWish || (item.type >= ItemID.BluePhaseblade && item.type <= ItemID.YellowPhaseblade) || (item.type >= ItemID.BluePhasesaber && item.type <= ItemID.YellowPhasesaber)) + EditTooltipByName("Knockback", (line) => line.text += "\nIgnores 100% of enemy defense"); + + if (item.type == ItemID.AntlionClaw || item.type == ItemID.BoneSword || item.type == ItemID.BreakerBlade) + EditTooltipByName("Knockback", (line) => line.text += "\nIgnores 50% of enemy defense"); + + if (item.type == ItemID.LightsBane || item.type == ItemID.NightsEdge || item.type == ItemID.TrueNightsEdge || item.type == ItemID.BallOHurt || item.type == ItemID.CorruptYoyo) + EditTooltipByName("Knockback", (line) => line.text += "\nInflicts Shadowflame on hit"); + + if (item.type == ItemID.BloodButcherer || item.type == ItemID.TheRottedFork || item.type == ItemID.TheMeatball || item.type == ItemID.CrimsonYoyo || item.type == ItemID.CrimsonRod) + EditTooltipByName("Knockback", (line) => line.text += "\nInflicts Burning Blood on hit"); + + if (item.type == ItemID.DeathSickle) + EditTooltipByNum(0, (line) => line.text += "\nInflicts Whispering Death on hit"); + #endregion + + // Light pets, accessories, and other items which boost the player's Abyss light stat + #region Abyss Light Tooltips + + // +1 to Abyss light level + string abyssSmallLightLine = "\nProvides a small amount of light in the abyss"; + + if (item.type == ItemID.CrimsonHeart || item.type == ItemID.ShadowOrb || item.type == ItemID.MagicLantern || item.type == ItemID.JellyfishNecklace || item.type == ItemID.MiningHelmet) + EditTooltipByNum(0, (line) => line.text += abyssSmallLightLine); + if (item.type == ItemID.JellyfishDivingGear) + EditTooltipByNum(1, (line) => line.text += abyssSmallLightLine); + + // +2 to Abyss light level + string abyssMediumLightLine = "\nProvides a moderate amount of light in the abyss"; + + if (item.type == ItemID.ShinePotion) + EditTooltipByName("BuffTime", (line) => line.text += abyssMediumLightLine); + + if (item.type == ItemID.FairyBell || item.type == ItemID.DD2PetGhost) + EditTooltipByNum(0, (line) => line.text += abyssMediumLightLine); + + // +3 to Abyss light level + string abyssLargeLightLine = "\nProvides a large amount of light in the abyss"; + + if (item.type == ItemID.WispinaBottle) + EditTooltipByNum(0, (line) => line.text += abyssLargeLightLine); + if (item.type == ItemID.SuspiciousLookingTentacle) + EditTooltipByNum(1, (line) => line.text += abyssLargeLightLine); + #endregion + + // Accessories and other items which boost the player's ability to breathe in the Abyss + #region Abyss Breath Tooltips + + // Moderate breath boost + string abyssModerateBreathLine = "\nModerately reduces breath loss in the abyss"; + + if (item.type == ItemID.DivingHelmet) + EditTooltipByNum(0, (line) => line.text += abyssModerateBreathLine); + if (item.type == ItemID.ArcticDivingGear) + EditTooltipByNum(1, (line) => line.text += abyssSmallLightLine + abyssModerateBreathLine); + + // Great breath boost + string abyssGreatBreathLine = "\nGreatly reduces breath loss in the abyss"; + + if (item.type == ItemID.GillsPotion) + EditTooltipByName("BuffTime", (line) => line.text += abyssGreatBreathLine); + + if (item.type == ItemID.NeptunesShell || item.type == ItemID.MoonShell) + EditTooltipByNum(0, (line) => line.text += abyssGreatBreathLine); + if (item.type == ItemID.CelestialShell) + EditTooltipByNum(1, (line) => line.text += abyssModerateBreathLine); + #endregion + + // Flasks apply to Rogue weapons + #region Rogue Flask Tooltips + if (item.type == ItemID.FlaskofCursedFlames) + EditTooltipByNum(0, (line) => line.text += "\nRogue attacks inflict enemies with cursed flames"); + if (item.type == ItemID.FlaskofFire) + EditTooltipByNum(0, (line) => line.text += "\nRogue attacks set enemies on fire"); + if (item.type == ItemID.FlaskofGold) + EditTooltipByNum(0, (line) => line.text += "\nRogue attacks make enemies drop more gold"); + if (item.type == ItemID.FlaskofIchor) + EditTooltipByNum(0, (line) => line.text += "\nRogue attacks decrease enemy defense"); + if (item.type == ItemID.FlaskofNanites) + EditTooltipByNum(0, (line) => line.text += "\nRogue attacks confuse enemies"); + // party flask is unique because it affects ALL projectiles in Calamity, not just "also rogue ones" + if (item.type == ItemID.FlaskofParty) + EditTooltipByNum(0, (line) => line.text = "All attacks cause confetti to appear"); + if (item.type == ItemID.FlaskofPoison) + EditTooltipByNum(0, (line) => line.text += "\nRogue attacks poison enemies"); + if (item.type == ItemID.FlaskofVenom) + EditTooltipByNum(0, (line) => line.text += "\nRogue attacks inflict Venom on enemies"); + #endregion + + // Rebalances to vanilla item stats + #region Vanilla Item Rebalance Tooltips + + // Magic Power Potion nerf + if (item.type == ItemID.MagicPowerPotion) + EditTooltipByNum(0, (line) => line.text = "10% increased magic damage"); + + // Magic and Wizard Hat nerfs + // Magic Hat + if (item.type == ItemID.MagicHat) + EditTooltipByNum(0, (line) => line.text = "5% increased magic damage and critical strike chance"); + + // Wizard Hat + if (item.type == ItemID.WizardHat) + EditTooltipByNum(0, (line) => line.text = "5% increased magic damage"); + + // Edit individual tooltips for early hardmode armor sets. + if (item.type == ItemID.CobaltHat) + EditTooltipByNum(0, (line) => line.text = $"Increases maximum mana by {CobaltArmorSetChange.MaxManaBoost + 40}"); + + // Reduce DD2 armor piece bonuses because they're overpowered + // Squire armor + if (item.type == ItemID.SquirePlating) + EditTooltipByNum(0, (line) => line.text = "10% increased minion and melee damage"); + if (item.type == ItemID.SquireGreaves) + EditTooltipByNum(0, (line) => line.text = "5% increased minion damage and melee critical strike chance\n" + + "15% increased movement speed"); + + // Monk armor + if (item.type == ItemID.MonkBrows) + EditTooltipByNum(0, (line) => line.text = "Increases your max number of sentries by 1 and increases melee attack speed by 10%"); + if (item.type == ItemID.MonkShirt) + EditTooltipByNum(0, (line) => line.text = "10% increased minion and melee damage"); + if (item.type == ItemID.MonkPants) + { + EditTooltipByNum(0, (line) => line.text = "5% increased minion damage and melee critical strike chance"); + EditTooltipByNum(1, (line) => line.text = "20% increased movement speed"); + } + + // Huntress armor + if (item.type == ItemID.HuntressJerkin) + EditTooltipByNum(0, (line) => line.text = "10% increased minion and ranged damage\n" + + "10% chance to not consume ammo"); + + // Apprentice armor + if (item.type == ItemID.ApprenticeTrousers) + EditTooltipByNum(0, (line) => line.text = "5% increased minion damage and magic critical strike chance\n" + + "20% increased movement speed"); + + // Valhalla Knight armor + if (item.type == ItemID.SquireAltShirt) + EditTooltipByNum(0, (line) => line.text = "30% increased minion damage and increased life regeneration"); + if (item.type == ItemID.SquireAltPants) + EditTooltipByNum(0, (line) => line.text = "10% increased minion damage and melee critical strike chance\n" + + "20% increased movement speed"); + + // Shinobi Infiltrator armor + if (item.type == ItemID.MonkAltHead) + EditTooltipByNum(0, (line) => line.text = "Increases your max number of sentries by 2\n" + + "10% increased melee and minion damage"); + if (item.type == ItemID.MonkAltShirt) + EditTooltipByNum(0, (line) => line.text = "10% increased minion damage and melee speed\n" + + "5% increased melee critical strike chance"); + if (item.type == ItemID.MonkAltPants) + EditTooltipByNum(0, (line) => line.text = "10% increased minion damage and melee critical strike chance\n" + + "30% increased movement speed"); + + // Red Riding armor + if (item.type == ItemID.HuntressAltShirt) + EditTooltipByNum(0, (line) => line.text = "15% increased minion and ranged damage and 20% chance to not consume ammo"); + + // Dark Artist armor + if (item.type == ItemID.ApprenticeAltPants) + EditTooltipByNum(0, (line) => line.text = "10% increased minion damage and magic critical strike chance\n" + + "20% increased movement speed"); + + // Worm Scarf only gives 10% DR instead of 17% + if (item.type == ItemID.WormScarf) + EditTooltipByNum(0, (line) => line.text = line.text.Replace("17%", "10%")); + + if (item.type == ItemID.TitanGlove) + EditTooltipByNum(0, (line) => line.text += "\n10% increased true melee damage"); + if (item.type == ItemID.PowerGlove || item.type == ItemID.MechanicalGlove) + EditTooltipByNum(1, (line) => line.text += "\n10% increased true melee damage"); + if (item.type == ItemID.FireGauntlet) + { + string extraLine = "\n10% increased true melee damage"; + if (CalamityWorld.death) + extraLine += "\nProvides heat and cold protection in Death Mode"; + EditTooltipByNum(1, (line) => line.text = line.text.Replace("10%", "14%") + extraLine); + } // On Fire! debuff immunities if (item.type == ItemID.ObsidianSkull || item.type == ItemID.AnkhShield) @@ -588,491 +600,443 @@ namespace CalamityMod.Items // Spectre Hood's lifesteal is heavily nerfed, so it only reduces magic damage by 20% instead of 40% if (item.type == ItemID.SpectreHood) - EditTooltipByNum(0, (line) => line.text = line.text.Replace("40%", "20%")); + EditTooltipByNum(0, (line) => line.text = line.text.Replace("40%", "20%")); - // Yoyo Glove/Bag apply a 0.66x damage multiplier on yoyos - if (item.type == ItemID.YoyoBag || item.type == ItemID.YoYoGlove) - EditTooltipByNum(0, (line) => line.text += "\nYoyos will do 33% less damage"); - #endregion + // Yoyo Glove/Bag apply a 0.66x damage multiplier on yoyos + if (item.type == ItemID.YoyoBag || item.type == ItemID.YoYoGlove) + EditTooltipByNum(0, (line) => line.text += "\nYoyos will do 33% less damage"); + #endregion - // Non-consumable boss summon items - #region Vanilla Boss Summon Non-consumable Tooltips - if (item.type == ItemID.SlimeCrown || item.type == ItemID.SuspiciousLookingEye || item.type == ItemID.GoblinBattleStandard || + // Non-consumable boss summon items + #region Vanilla Boss Summon Non-consumable Tooltips + if (item.type == ItemID.SlimeCrown || item.type == ItemID.SuspiciousLookingEye || item.type == ItemID.GoblinBattleStandard || item.type == ItemID.WormFood || item.type == ItemID.BloodySpine || item.type == ItemID.Abeemination || item.type == ItemID.PirateMap || item.type == ItemID.SnowGlobe || item.type == ItemID.MechanicalEye || item.type == ItemID.MechanicalWorm || item.type == ItemID.MechanicalSkull || item.type == ItemID.NaughtyPresent ||item.type == ItemID.PumpkinMoonMedallion || item.type == ItemID.SolarTablet ||item.type == ItemID.SolarTablet || item.type == ItemID.CelestialSigil) - EditTooltipByNum(0, (line) => line.text += "\nNot consumable"); - #endregion - - // Items which provide immunity to either heat or cold in Death Mode, or interact with Lethal Lava - #region Lava and Death Mode Environmental Immunity Tooltips - string heatProtectionLine = "\nProvides heat protection in Death Mode"; - string bothProtectionLine = "\nProvides heat and cold protection in Death Mode"; - - if (item.type == ItemID.ObsidianSkinPotion) - { - // If Lethal Lava is enabled, Obsidian Skin Potions work very differently. - if (CalamityConfig.Instance.LethalLava) - { - string lethalLavaReplacement = "Provides immunity to direct damage from touching lava\n" - + "Provides temporary immunity to lava burn damage\n" - + "Greatly increases the speed at which lava immunity recharges\n" - + "Reduces lava burn damage"; - if (CalamityWorld.death) - lethalLavaReplacement += heatProtectionLine; - EditTooltipByNum(0, (line) => line.text = lethalLavaReplacement); - } - - // Otherwise, changes are only made on Death Mode, where heat immunity is mentioned. - else if (CalamityWorld.death) - EditTooltipByNum(0, (line) => line.text += heatProtectionLine); - } - - if (item.type == ItemID.ObsidianRose) - { - StringBuilder sb = new StringBuilder(128); - // If Lethal Lava is enabled, Obsidian Rose reduces the damage from the debuff. - if (CalamityConfig.Instance.LethalLava) - sb.Append("\nGreatly reduces lava burn damage"); - if (CalamityWorld.death) - sb.Append(heatProtectionLine); - EditTooltipByNum(0, (line) => line.text += sb.ToString()); - } - - if (CalamityWorld.death) - { - if (item.type == ItemID.MagmaStone) - EditTooltipByNum(0, (line) => line.text += bothProtectionLine); - if (item.type == ItemID.LavaCharm) - EditTooltipByNum(0, (line) => line.text += heatProtectionLine); - if (item.type == ItemID.LavaWaders) - EditTooltipByNum(1, (line) => line.text += heatProtectionLine); - if (item.type == ItemID.FrostHelmet || item.type == ItemID.FrostBreastplate || item.type == ItemID.FrostLeggings) - EditTooltipByName("SetBonus", (line) => line.text += bothProtectionLine); - } - #endregion - - // Add mentions of what Calamity ores vanilla pickaxes can mine - #region Pickaxe New Ore Tooltips - if (item.type == ItemID.Picksaw) - EditTooltipByNum(0, (line) => line.text += "\nCan mine Scoria Ore located in the Abyss"); - - if (item.type == ItemID.SolarFlarePickaxe || item.type == ItemID.VortexPickaxe || item.type == ItemID.NebulaPickaxe || item.type == ItemID.StardustPickaxe) - EditTooltipByName("Material", (line) => line.text += "\nCan mine Uelibloom Ore located in the Jungle"); - #endregion - - // Rebalances and information about vanilla set bonuses - #region Vanilla Set Bonus Tooltips - - // Turns a number into a string of increased mining speed. - string MiningSpeedString(int percent) => $"\n{percent}% increased mining speed"; - - // Copper - if (item.type == ItemID.CopperHelmet || item.type == ItemID.CopperChainmail || item.type == ItemID.CopperGreaves) - EditTooltipByName("SetBonus", (line) => line.text += MiningSpeedString(15)); - - // Tin - if (item.type == ItemID.TinHelmet || item.type == ItemID.TinChainmail || item.type == ItemID.TinGreaves) - EditTooltipByName("SetBonus", (line) => line.text += MiningSpeedString(10)); - - // Iron - if (item.type == ItemID.AncientIronHelmet || item.type == ItemID.IronHelmet || item.type == ItemID.IronChainmail || item.type == ItemID.IronGreaves) - EditTooltipByName("SetBonus", (line) => line.text += MiningSpeedString(25)); - - // Lead - if (item.type == ItemID.LeadHelmet || item.type == ItemID.LeadChainmail || item.type == ItemID.LeadGreaves) - EditTooltipByName("SetBonus", (line) => line.text += MiningSpeedString(20)); - - // Silver - if (item.type == ItemID.SilverHelmet || item.type == ItemID.SilverChainmail || item.type == ItemID.SilverGreaves) - EditTooltipByName("SetBonus", (line) => line.text += MiningSpeedString(35)); - - // Tungsten - if (item.type == ItemID.TungstenHelmet || item.type == ItemID.TungstenChainmail || item.type == ItemID.TungstenGreaves) - EditTooltipByName("SetBonus", (line) => line.text += MiningSpeedString(30)); - - // Gold - if (item.type == ItemID.AncientGoldHelmet || item.type == ItemID.GoldHelmet || item.type == ItemID.GoldChainmail || item.type == ItemID.GoldGreaves) - EditTooltipByName("SetBonus", (line) => line.text += MiningSpeedString(45)); - - // Platinum - if (item.type == ItemID.PlatinumHelmet || item.type == ItemID.PlatinumChainmail || item.type == ItemID.PlatinumGreaves) - EditTooltipByName("SetBonus", (line) => line.text += MiningSpeedString(40)); - - // Gladiator - if (item.type == ItemID.GladiatorHelmet) - EditTooltipByName("Defense", (line) => line.text += "\n3% increased rogue damage"); - if (item.type == ItemID.GladiatorBreastplate) - EditTooltipByName("Defense", (line) => line.text += "\n3% increased rogue critical strike chance"); - if (item.type == ItemID.GladiatorLeggings) - EditTooltipByName("Defense", (line) => line.text += "\n3% increased rogue velocity"); - - // Obsidian - if (item.type == ItemID.ObsidianHelm) - EditTooltipByName("Defense", (line) => line.text += "\n3% increased rogue damage"); - if (item.type == ItemID.ObsidianShirt) - EditTooltipByName("Defense", (line) => line.text += "\n3% increased rogue critical strike chance"); - if (item.type == ItemID.ObsidianPants) - EditTooltipByName("Defense", (line) => line.text += "\n3% increased rogue velocity"); - - // Meteor Armor only makes space gun cost 50% instead of zero mana - if (item.type == ItemID.MeteorHelmet || item.type == ItemID.MeteorSuit || item.type == ItemID.MeteorLeggings) - EditTooltipByName("SetBonus", (line) => line.text = line.text.Replace("0", "50%")); - - // Molten - if (item.type == ItemID.MoltenHelmet || item.type == ItemID.MoltenBreastplate || item.type == ItemID.MoltenGreaves) - { - string extraLine = "\n20% extra true melee damage\nGrants immunity to fire blocks and temporary immunity to lava"; - if (CalamityWorld.death) - extraLine += bothProtectionLine; - EditTooltipByName("SetBonus", (line) => line.text += extraLine); - } - - // Forbidden (UNLESS you are wearing the Circlet, which is Summon/Rogue and does not get this line) - if (item.type == ItemID.AncientBattleArmorHat || item.type == ItemID.AncientBattleArmorShirt || item.type == ItemID.AncientBattleArmorPants - && !Main.LocalPlayer.Calamity().forbiddenCirclet) - EditTooltipByName("SetBonus", (line) => line.text += "\nThe minion damage nerf is reduced while wielding magic weapons"); - - // Stardust - // 1) Chest and Legs only give 1 minion slot each instead of 2 each. - if (item.type == ItemID.StardustBreastplate || item.type == ItemID.StardustLeggings) - EditTooltipByNum(0, (line) => line.text = line.text.Replace('2', '1')); - #endregion - - // Provide the full stats of every vanilla set of wings - #region Wing Stat Tooltips - - // This function produces a "stat sheet" for a pair of wings from the raw stats. - // For "vertical speed", 0 = Average, 1 = Good, 2 = Great. - string[] vertSpeedStrings = new string[] { "Average vertical speed", "Good vertical speed", "Great vertical speed" }; - string WingStatsTooltip(float hSpeed, float accelMult, int vertSpeed, int flightTime, string extraTooltip = null) - { - StringBuilder sb = new StringBuilder(512); - sb.Append('\n'); - sb.Append($"Horizontal speed: {hSpeed:N2}\n"); - sb.Append($"Acceleration multiplier: {accelMult:N1}\n"); - sb.Append(vertSpeedStrings[vertSpeed]); - sb.Append('\n'); - sb.Append($"Flight time: {flightTime}"); - if (extraTooltip != null) - { - sb.Append('\n'); - sb.Append(extraTooltip); - } - return sb.ToString(); - } - - // This function is shorthand for appending a stat sheet to a pair of wings. - void AddWingStats(float h, float a, int v, int f, string s = null) => EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(h, a, v, f, s)); - void AddWingStats2(float h, float a, int v, int f, string s = null, string lineName = null) => EditTooltipByName(lineName, (line) => line.text += WingStatsTooltip(h, a, v, f, s)); - - if (item.type == ItemID.AngelWings) - AddWingStats(6.25f, 1f, 0, 100, "+20 max life, +10 defense and +2 life regen"); - - if (item.type == ItemID.DemonWings) - AddWingStats(6.25f, 1f, 0, 100, "5% increased damage and critical strike chance"); - - if (item.type == ItemID.Jetpack) - AddWingStats(6.5f, 1f, 0, 115); - - if (item.type == ItemID.ButterflyWings) - AddWingStats(6.75f, 1f, 0, 130, "+20 max mana, 5% decreased mana usage,\n" + - "5% increased magic damage and magic critical strike chance"); - - if (item.type == ItemID.FairyWings) - AddWingStats(6.75f, 1f, 0, 130, "+60 max life"); - - if (item.type == ItemID.BeeWings) - AddWingStats(6.75f, 1f, 0, 130, "Permanently gives the Honey buff"); - - if (item.type == ItemID.HarpyWings) - AddWingStats(7f, 1f, 0, 140, "20% increased movement speed\n" + - "With Harpy Ring or Angel Treads equipped, most attacks sometimes launch feathers"); - - if (item.type == ItemID.BoneWings) - AddWingStats(7f, 1f, 0, 140, "10% increased movement speed, ranged damage and critical strike chance\n" + - "and +30 defense while wearing the Necro Armor"); - - if (item.type == ItemID.FlameWings) - AddWingStats(7.5f, 1f, 0, 160, "5% increased melee damage and critical strike chance"); - - if (item.type == ItemID.FrozenWings) - AddWingStats(7.5f, 1f, 0, 160, "2% increased melee and ranged damage\n" + - "and 1% increased melee and ranged critical strike chance\n" + - "while wearing the Frost Armor"); - - if (item.type == ItemID.GhostWings) - AddWingStats(7.5f, 1f, 0, 160, "+10 defense and 5% increased damage reduction while wearing the Spectre Hood set\n" + - "5% increased magic damage and critical strike chance while wearing the Spectre Mask set"); - - if (item.type == ItemID.BeetleWings) - AddWingStats(7.5f, 1f, 0, 160, "+10 defense and 5% increased damage reduction while wearing the Beetle Shell set\n" + - "5% increased melee damage and critical strike chance while wearing the Beetle Scale Mail set"); - - if (item.type == ItemID.FinWings) - AddWingStats(0f, 0f, 0, 100, "Gills effect and you can move freely through liquids\n" + - "You fall faster while submerged in liquid\n" + - "15% increased movement speed and 18% increased jump speed"); - - if (item.type == ItemID.FishronWings) - AddWingStats(8f, 2f, 1, 180); - - if (item.type == ItemID.SteampunkWings) - AddWingStats(7.75f, 1f, 0, 180, "+8 defense, 10% increased movement speed,\n" + "4% increased damage, and 2% increased critical strike chance"); - - if (item.type == ItemID.LeafWings) - AddWingStats(6.75f, 1f, 0, 160, "+5 defense, 5% increased damage reduction,\n" + "and permanent Dryad's Blessing while wearing the Tiki Armor"); - - if (item.type == ItemID.BatWings) - AddWingStats(0f, 0f, 0, 140, "At night or during an eclipse, you will gain the following boosts:\n" + - "10% increased movement speed, 10% increased jump speed,\n" + - "7% increased damage and 3% increased critical strike chance"); - - // All developer wings have identical stats and no special effects - if (item.type == ItemID.Yoraiz0rWings || item.type == ItemID.JimsWings || item.type == ItemID.SkiphsWings || - item.type == ItemID.LokisWings || item.type == ItemID.ArkhalisWings || item.type == ItemID.LeinforsWings || - item.type == ItemID.BejeweledValkyrieWing || item.type == ItemID.RedsWings || item.type == ItemID.DTownsWings || - item.type == ItemID.WillsWings || item.type == ItemID.CrownosWings || item.type == ItemID.CenxsWings) - { - AddWingStats(7f, 1f, 0, 150); - } - - if (item.type == ItemID.TatteredFairyWings) - AddWingStats(7.5f, 1f, 0, 180, "5% increased damage and critical strike chance"); - - if (item.type == ItemID.SpookyWings) - AddWingStats(7.5f, 1f, 0, 180, "Increased minion knockback and 5% increased minion damage while wearing the Spooky Armor"); - - if (item.type == ItemID.Hoverboard) - AddWingStats(6.25f, 1f, 0, 170, "10% increased weapon-type damage while wearing the Shroomite Armor\n" + - "The weapon type boosted matches which Shroomite helmet is worn"); - - if (item.type == ItemID.FestiveWings) - AddWingStats(7.5f, 1f, 0, 170, "+40 max life\nOrnaments rain down as you fly"); - - if (item.type == ItemID.MothronWings) - AddWingStats(0f, 0f, 0, 160, "+5 defense, 5% increased damage,\n" + - "10% increased movement speed and 12% increased jump speed"); - - if (item.type == ItemID.WingsSolar) - AddWingStats(9f, 2.5f, 2, 180, "7% increased melee damage and 3% increased melee critical strike chance\n" + - "while wearing the Solar Flare Armor"); - - if (item.type == ItemID.WingsStardust) - AddWingStats(9f, 2.5f, 2, 180, "+1 max minion and 5% increased minion damage while wearing the Stardust Armor"); - - if (item.type == ItemID.WingsVortex) - AddWingStats(6.5f, 1.5f, 1, 160, "3% increased ranged damage and 7% increased ranged critical strike chance\n" + - "while wearing the Vortex Armor"); - - if (item.type == ItemID.WingsNebula) - AddWingStats(6.5f, 1.5f, 1, 160, "+20 max mana, 5% increased magic damage and critical strike chance,\n" + - "and 5% decreased mana usage while wearing the Nebula Armor"); - - // Betsy's Wings (and dev wings) are the only wings without "Allows flight and free fall" - if (item.type == ItemID.BetsyWings) - AddWingStats2(6f, 2.5f, 1, 150, null, "Equipable"); - #endregion - - // Provide the full stats of every vanilla grappling hook - #region Grappling Hook Stat Tooltips - - // This function produces a "stat sheet" for a grappling hook from the raw stats. - string HookStatsTooltip(float reach, float launch, float reel, float pull) - { - StringBuilder sb = new StringBuilder(128); - sb.Append('\n'); - sb.Append($"Reach: {reach:N3} tiles\n"); - sb.Append($"Launch Velocity: {launch:N2}\n"); - sb.Append($"Reelback Velocity: {reel:N2}\n"); - sb.Append($"Pull Velocity: {pull:N2}"); - return sb.ToString(); - } - - // This function is shorthand for appending a stat sheet to a grappling hook. - void AddGrappleStats(float r, float l, float e, float p) => EditTooltipByName("Equipable", (line) => line.text += HookStatsTooltip(r, l, e, p)); - - if (item.type == ItemID.GrapplingHook) - AddGrappleStats(18.75f, 11.5f, 11f, 11f); - if (item.type == ItemID.AmethystHook) - AddGrappleStats(18.75f, 10f, 11f, 11f); - if (item.type == ItemID.TopazHook) - AddGrappleStats(20.625f, 10.5f, 11.75f, 11f); - if (item.type == ItemID.SapphireHook) - AddGrappleStats(22.5f, 11f, 12.5f, 11f); - if (item.type == ItemID.EmeraldHook) - AddGrappleStats(24.375f, 11.5f, 13.25f, 11f); - if (item.type == ItemID.RubyHook) - AddGrappleStats(26.25f, 12f, 14f, 11f); - if (item.type == ItemID.DiamondHook) - AddGrappleStats(28.125f, 12.5f, 14.75f, 11f); - if (item.type == ItemID.WebSlinger) - AddGrappleStats(15.625f, 10f, 11f, 11f); - if (item.type == ItemID.SkeletronHand) - AddGrappleStats(21.875f, 15f, 11f, 11f); - if (item.type == ItemID.SlimeHook) - AddGrappleStats(18.75f, 13f, 11f, 11f); - if (item.type == ItemID.FishHook) - AddGrappleStats(25f, 13f, 11f, 11f); - if (item.type == ItemID.IvyWhip) - AddGrappleStats(25f, 13f, 15f, 11f); - if (item.type == ItemID.BatHook) // TODO -- This item should be dropped by Vampires in the Eclipse. It is very overpowered. - AddGrappleStats(31.25f, 15.5f, 20f, 16f); - if (item.type == ItemID.CandyCaneHook) - AddGrappleStats(25f, 11.5f, 11f, 11f); - if (item.type == ItemID.DualHook) - AddGrappleStats(27.5f, 14f, 17f, 11f); - // these four grapple hooks are all functionally identical - if (item.type == ItemID.ThornHook || item.type == ItemID.WormHook || item.type == ItemID.TendonHook || item.type == ItemID.IlluminantHook) - AddGrappleStats(30f, 15f, 18f, 11f); - if (item.type == ItemID.AntiGravityHook) - AddGrappleStats(31.25f, 14f, 20f, 11f); - if (item.type == ItemID.SpookyHook) - AddGrappleStats(34.375f, 15.5f, 22f, 11f); - if (item.type == ItemID.ChristmasHook) - AddGrappleStats(34.375f, 15.5f, 17f, 11f); - if (item.type == ItemID.LunarHook) - AddGrappleStats(34.375f, 16f, 24f, 13f); - if (item.type == ItemID.StaticHook) - AddGrappleStats(37.5f, 16f, 24f, 0f); - #endregion - - // Beyond this point all code only applies to accessories. Skip it all if the item is not an accessory. - if (!item.accessory) - return; - - // Display the stat changes to vanilla prefixes - #region Accessory Prefix Rebalance Tooltips - - // Turns a number into a string of increased DR. - string DRString(float percent) => $"\n+{percent:N2}% damage reduction"; - - switch (item.prefix) - { - case PrefixID.Brisk: - EditTooltipByName("PrefixAccMoveSpeed", (line) => line.text = line.text.Replace("1%", "1.5%")); - return; - case PrefixID.Fleeting: - EditTooltipByName("PrefixAccMoveSpeed", (line) => line.text = line.text.Replace("2%", "3%")); - return; - case PrefixID.Hasty2: // Hasty2 is the "Hasty" for accessories - EditTooltipByName("PrefixAccMoveSpeed", (line) => line.text = line.text.Replace("3%", "4.5%")); - return; - case PrefixID.Quick2: // Quick2 is the "Quick" for accessories - EditTooltipByName("PrefixAccMoveSpeed", (line) => line.text = line.text.Replace("4%", "6%")); - return; - case PrefixID.Hard: - EditTooltipByName("PrefixAccDefense", - (line) => line.text = line.text.Replace("1", CalamityUtils.GetScalingDefense(item.prefix).ToString()) + DRString(0.25f)); - return; - case PrefixID.Guarding: - EditTooltipByName("PrefixAccDefense", - (line) => line.text = line.text.Replace("2", CalamityUtils.GetScalingDefense(item.prefix).ToString()) + DRString(0.5f)); - return; - case PrefixID.Armored: - EditTooltipByName("PrefixAccDefense", - (line) => line.text = line.text.Replace("3", CalamityUtils.GetScalingDefense(item.prefix).ToString()) + DRString(0.75f)); - return; - case PrefixID.Warding: - EditTooltipByName("PrefixAccDefense", - (line) => line.text = line.text.Replace("4", CalamityUtils.GetScalingDefense(item.prefix).ToString()) + DRString(1f)); - return; - } - #endregion - } - #endregion - - #region True Melee Damage Tooltip - private void TrueMeleeDamageTooltip(Item item, IList tooltips) - { - TooltipLine line = tooltips.FirstOrDefault((l) => l.mod == "Terraria" && l.Name == "Damage"); - - // If there somehow isn't a damage tooltip line, do not try to perform any edits. - if (line is null) - return; - - // Start with the existing line of melee damage. - StringBuilder sb = new StringBuilder(64); - sb.Append(line.text).Append(" : "); - - Player p = Main.LocalPlayer; - float itemCurrentDamage = item.damage * p.MeleeDamage(); - double trueMeleeBoost = 1D + p.Calamity().trueMeleeDamage; - double imprecisionRoundingCorrection = 5E-06D; - int damageToDisplay = (int)(itemCurrentDamage * trueMeleeBoost + imprecisionRoundingCorrection); - sb.Append(damageToDisplay); - - // These two pieces are split apart for ease of translation - sb.Append(' '); - sb.Append("true melee damage"); - line.text = sb.ToString(); - } - #endregion - - #region Stealth Generation Prefix Accessory Tooltip - private void StealthGenAccessoryTooltip(Item item, IList tooltips) - { - if (!item.accessory || item.social || item.prefix <= 0) - return; - - float stealthGenBoost = item.Calamity().StealthGenBonus - 1f; - if (stealthGenBoost > 0) - { - TooltipLine StealthGen = new TooltipLine(mod, "PrefixStealthGenBoost", "+" + Math.Round(stealthGenBoost * 100f) + "% stealth generation") - { - isModifier = true - }; - tooltips.Add(StealthGen); - } - } - #endregion - - #region Enchanted Rarity Text Drawing - public override bool PreDrawTooltipLine(Item item, DrawableTooltipLine line, ref int yOffset) - { - // Special enchantment line color. - if (line.Name == "ItemName" && line.mod == "Terraria" && item.IsEnchanted()) - { - Color rarityColor = line.overrideColor ?? line.color; - Vector2 basePosition = new Vector2(line.X, line.Y); - - float backInterpolant = (float)Math.Pow(Main.GlobalTime * 0.81f % 1f, 1.5f); - Vector2 backScale = line.baseScale * MathHelper.Lerp(1f, 1.2f, backInterpolant); - Color backColor = Color.Lerp(rarityColor, Color.DarkRed, backInterpolant) * (float)Math.Pow(1f - backInterpolant, 0.46f); - Vector2 backPosition = basePosition - new Vector2(1f, 0.1f) * backInterpolant * 10f; - - Main.spriteBatch.End(); - Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive); - - // Draw the back text as an ominous pulse. - for (int i = 0; i < 2; i++) - ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, line.font, line.text, backPosition, backColor, line.rotation, line.origin, backScale, line.maxWidth, line.spread); - - Main.spriteBatch.End(); - Main.spriteBatch.Begin(); - - // Draw the front text as usual. - ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, line.font, line.text, basePosition, rarityColor, line.rotation, line.origin, line.baseScale, line.maxWidth, line.spread); - - return false; - } - return true; - } - #endregion + EditTooltipByNum(0, (line) => line.text += "\nNot consumable"); + #endregion + + // Items which provide immunity to either heat or cold in Death Mode, or interact with Lethal Lava + #region Lava and Death Mode Environmental Immunity Tooltips + + if (item.type == ItemID.ObsidianSkinPotion) + { + // If Lethal Lava is enabled, Obsidian Skin Potions work very differently. + if (CalamityConfig.Instance.LethalLava) + { + string lethalLavaReplacement = "Provides immunity to direct damage from touching lava\n" + + "Provides temporary immunity to lava burn damage\n" + + "Greatly increases the speed at which lava immunity recharges\n" + + "Reduces lava burn damage"; + if (CalamityWorld.death) + lethalLavaReplacement += HeatProtectionLine; + EditTooltipByNum(0, (line) => line.text = lethalLavaReplacement); + } + + // Otherwise, changes are only made on Death Mode, where heat immunity is mentioned. + else if (CalamityWorld.death) + EditTooltipByNum(0, (line) => line.text += HeatProtectionLine); + } + + if (item.type == ItemID.ObsidianRose) + { + StringBuilder sb = new StringBuilder(128); + // If Lethal Lava is enabled, Obsidian Rose reduces the damage from the debuff. + if (CalamityConfig.Instance.LethalLava) + sb.Append("\nGreatly reduces lava burn damage"); + if (CalamityWorld.death) + sb.Append(HeatProtectionLine); + EditTooltipByNum(0, (line) => line.text += sb.ToString()); + } + + if (CalamityWorld.death) + { + if (item.type == ItemID.MagmaStone) + EditTooltipByNum(0, (line) => line.text += BothProtectionLine); + if (item.type == ItemID.LavaCharm) + EditTooltipByNum(0, (line) => line.text += HeatProtectionLine); + if (item.type == ItemID.LavaWaders) + EditTooltipByNum(1, (line) => line.text += HeatProtectionLine); + if (item.type == ItemID.FrostHelmet || item.type == ItemID.FrostBreastplate || item.type == ItemID.FrostLeggings) + EditTooltipByName("SetBonus", (line) => line.text += BothProtectionLine); + } + #endregion + + // Add mentions of what Calamity ores vanilla pickaxes can mine + #region Pickaxe New Ore Tooltips + if (item.type == ItemID.Picksaw) + EditTooltipByNum(0, (line) => line.text += "\nCan mine Scoria Ore located in the Abyss"); + + if (item.type == ItemID.SolarFlarePickaxe || item.type == ItemID.VortexPickaxe || item.type == ItemID.NebulaPickaxe || item.type == ItemID.StardustPickaxe) + EditTooltipByName("Material", (line) => line.text += "\nCan mine Uelibloom Ore located in the Jungle"); + #endregion + + // Rebalances and information about vanilla set bonuses + #region Vanilla Set Bonus Tooltips + + EditTooltipByName("SetBonus", (line) => VanillaArmorChangeManager.ApplySetBonusTooltipChanges(item, ref line.text)); + + // Gladiator + if (item.type == ItemID.GladiatorHelmet) + EditTooltipByName("Defense", (line) => line.text += $"\n{GladiatorArmorSetChange.HelmetRogueDamageBoostPercent}% increased rogue damage"); + if (item.type == ItemID.GladiatorBreastplate) + EditTooltipByName("Defense", (line) => line.text += $"\n{GladiatorArmorSetChange.ChestplateRogueCritBoostPercent}% increased rogue critical strike chance"); + if (item.type == ItemID.GladiatorLeggings) + EditTooltipByName("Defense", (line) => line.text += $"\n{GladiatorArmorSetChange.LeggingRogueVelocityBoostPercent}% increased rogue velocity"); + + // Obsidian + if (item.type == ItemID.ObsidianHelm) + EditTooltipByName("Defense", (line) => line.text += $"\n{ObsidianArmorSetChange.HelmetRogueDamageBoostPercent}% increased rogue damage"); + if (item.type == ItemID.ObsidianShirt) + EditTooltipByName("Defense", (line) => line.text += $"\n{ObsidianArmorSetChange.ChestplateRogueCritBoostPercent}% increased rogue critical strike chance"); + if (item.type == ItemID.ObsidianPants) + EditTooltipByName("Defense", (line) => line.text += $"\n{ObsidianArmorSetChange.LeggingRogueVelocityBoostPercent}% increased rogue velocity"); + + // Forbidden (UNLESS you are wearing the Circlet, which is Summon/Rogue and does not get this line) + if (item.type == ItemID.AncientBattleArmorHat || item.type == ItemID.AncientBattleArmorShirt || item.type == ItemID.AncientBattleArmorPants + && !Main.LocalPlayer.Calamity().forbiddenCirclet) + EditTooltipByName("SetBonus", (line) => line.text += "\nThe minion damage nerf is reduced while wielding magic weapons"); + + // Stardust + // 1) Chest and Legs only give 1 minion slot each instead of 2 each. + if (item.type == ItemID.StardustBreastplate || item.type == ItemID.StardustLeggings) + EditTooltipByNum(0, (line) => line.text = line.text.Replace('2', '1')); + #endregion + + // Provide the full stats of every vanilla set of wings + #region Wing Stat Tooltips + + // This function produces a "stat sheet" for a pair of wings from the raw stats. + // For "vertical speed", 0 = Average, 1 = Good, 2 = Great. + string[] vertSpeedStrings = new string[] { "Average vertical speed", "Good vertical speed", "Great vertical speed" }; + string WingStatsTooltip(float hSpeed, float accelMult, int vertSpeed, int flightTime, string extraTooltip = null) + { + StringBuilder sb = new StringBuilder(512); + sb.Append('\n'); + sb.Append($"Horizontal speed: {hSpeed:N2}\n"); + sb.Append($"Acceleration multiplier: {accelMult:N1}\n"); + sb.Append(vertSpeedStrings[vertSpeed]); + sb.Append('\n'); + sb.Append($"Flight time: {flightTime}"); + if (extraTooltip != null) + { + sb.Append('\n'); + sb.Append(extraTooltip); + } + return sb.ToString(); + } + + // This function is shorthand for appending a stat sheet to a pair of wings. + void AddWingStats(float h, float a, int v, int f, string s = null) => EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(h, a, v, f, s)); + void AddWingStats2(float h, float a, int v, int f, string s = null, string lineName = null) => EditTooltipByName(lineName, (line) => line.text += WingStatsTooltip(h, a, v, f, s)); + + if (item.type == ItemID.AngelWings) + AddWingStats(6.25f, 1f, 0, 100, "+20 max life, +10 defense and +2 life regen"); + + if (item.type == ItemID.DemonWings) + AddWingStats(6.25f, 1f, 0, 100, "5% increased damage and critical strike chance"); + + if (item.type == ItemID.Jetpack) + AddWingStats(6.5f, 1f, 0, 115); + + if (item.type == ItemID.ButterflyWings) + AddWingStats(6.75f, 1f, 0, 130, "+20 max mana, 5% decreased mana usage,\n" + + "5% increased magic damage and magic critical strike chance"); + + if (item.type == ItemID.FairyWings) + AddWingStats(6.75f, 1f, 0, 130, "+60 max life"); + + if (item.type == ItemID.BeeWings) + AddWingStats(6.75f, 1f, 0, 130, "Permanently gives the Honey buff"); + + if (item.type == ItemID.HarpyWings) + AddWingStats(7f, 1f, 0, 140, "20% increased movement speed\n" + + "With Harpy Ring or Angel Treads equipped, most attacks sometimes launch feathers"); + + if (item.type == ItemID.BoneWings) + AddWingStats(7f, 1f, 0, 140, "10% increased movement speed, ranged damage and critical strike chance\n" + + "and +30 defense while wearing the Necro Armor"); + + if (item.type == ItemID.FlameWings) + AddWingStats(7.5f, 1f, 0, 160, "5% increased melee damage and critical strike chance"); + + if (item.type == ItemID.FrozenWings) + AddWingStats(7.5f, 1f, 0, 160, "2% increased melee and ranged damage\n" + + "and 1% increased melee and ranged critical strike chance\n" + + "while wearing the Frost Armor"); + + if (item.type == ItemID.GhostWings) + AddWingStats(7.5f, 1f, 0, 160, "+10 defense and 5% increased damage reduction while wearing the Spectre Hood set\n" + + "5% increased magic damage and critical strike chance while wearing the Spectre Mask set"); + + if (item.type == ItemID.BeetleWings) + AddWingStats(7.5f, 1f, 0, 160, "+10 defense and 5% increased damage reduction while wearing the Beetle Shell set\n" + + "5% increased melee damage and critical strike chance while wearing the Beetle Scale Mail set"); + + if (item.type == ItemID.FinWings) + AddWingStats(0f, 0f, 0, 100, "Gills effect and you can move freely through liquids\n" + + "You fall faster while submerged in liquid\n" + + "15% increased movement speed and 18% increased jump speed"); + + if (item.type == ItemID.FishronWings) + AddWingStats(8f, 2f, 1, 180); + + if (item.type == ItemID.SteampunkWings) + AddWingStats(7.75f, 1f, 0, 180, "+8 defense, 10% increased movement speed,\n" + "4% increased damage, and 2% increased critical strike chance"); + + if (item.type == ItemID.LeafWings) + AddWingStats(6.75f, 1f, 0, 160, "+5 defense, 5% increased damage reduction,\n" + "and permanent Dryad's Blessing while wearing the Tiki Armor"); + + if (item.type == ItemID.BatWings) + AddWingStats(0f, 0f, 0, 140, "At night or during an eclipse, you will gain the following boosts:\n" + + "10% increased movement speed, 10% increased jump speed,\n" + + "7% increased damage and 3% increased critical strike chance"); + + // All developer wings have identical stats and no special effects + if (item.type == ItemID.Yoraiz0rWings || item.type == ItemID.JimsWings || item.type == ItemID.SkiphsWings || + item.type == ItemID.LokisWings || item.type == ItemID.ArkhalisWings || item.type == ItemID.LeinforsWings || + item.type == ItemID.BejeweledValkyrieWing || item.type == ItemID.RedsWings || item.type == ItemID.DTownsWings || + item.type == ItemID.WillsWings || item.type == ItemID.CrownosWings || item.type == ItemID.CenxsWings) + { + AddWingStats(7f, 1f, 0, 150); + } + + if (item.type == ItemID.TatteredFairyWings) + AddWingStats(7.5f, 1f, 0, 180, "5% increased damage and critical strike chance"); + + if (item.type == ItemID.SpookyWings) + AddWingStats(7.5f, 1f, 0, 180, "Increased minion knockback and 5% increased minion damage while wearing the Spooky Armor"); + + if (item.type == ItemID.Hoverboard) + AddWingStats(6.25f, 1f, 0, 170, "10% increased weapon-type damage while wearing the Shroomite Armor\n" + + "The weapon type boosted matches which Shroomite helmet is worn"); + + if (item.type == ItemID.FestiveWings) + AddWingStats(7.5f, 1f, 0, 170, "+40 max life\nOrnaments rain down as you fly"); + + if (item.type == ItemID.MothronWings) + AddWingStats(0f, 0f, 0, 160, "+5 defense, 5% increased damage,\n" + + "10% increased movement speed and 12% increased jump speed"); + + if (item.type == ItemID.WingsSolar) + AddWingStats(9f, 2.5f, 2, 180, "7% increased melee damage and 3% increased melee critical strike chance\n" + + "while wearing the Solar Flare Armor"); + + if (item.type == ItemID.WingsStardust) + AddWingStats(9f, 2.5f, 2, 180, "+1 max minion and 5% increased minion damage while wearing the Stardust Armor"); + + if (item.type == ItemID.WingsVortex) + AddWingStats(6.5f, 1.5f, 1, 160, "3% increased ranged damage and 7% increased ranged critical strike chance\n" + + "while wearing the Vortex Armor"); + + if (item.type == ItemID.WingsNebula) + AddWingStats(6.5f, 1.5f, 1, 160, "+20 max mana, 5% increased magic damage and critical strike chance,\n" + + "and 5% decreased mana usage while wearing the Nebula Armor"); + + // Betsy's Wings (and dev wings) are the only wings without "Allows flight and free fall" + if (item.type == ItemID.BetsyWings) + AddWingStats2(6f, 2.5f, 1, 150, null, "Equipable"); + #endregion + + // Provide the full stats of every vanilla grappling hook + #region Grappling Hook Stat Tooltips + + // This function produces a "stat sheet" for a grappling hook from the raw stats. + string HookStatsTooltip(float reach, float launch, float reel, float pull) + { + StringBuilder sb = new StringBuilder(128); + sb.Append('\n'); + sb.Append($"Reach: {reach:N3} tiles\n"); + sb.Append($"Launch Velocity: {launch:N2}\n"); + sb.Append($"Reelback Velocity: {reel:N2}\n"); + sb.Append($"Pull Velocity: {pull:N2}"); + return sb.ToString(); + } + + // This function is shorthand for appending a stat sheet to a grappling hook. + void AddGrappleStats(float r, float l, float e, float p) => EditTooltipByName("Equipable", (line) => line.text += HookStatsTooltip(r, l, e, p)); + + if (item.type == ItemID.GrapplingHook) + AddGrappleStats(18.75f, 11.5f, 11f, 11f); + if (item.type == ItemID.AmethystHook) + AddGrappleStats(18.75f, 10f, 11f, 11f); + if (item.type == ItemID.TopazHook) + AddGrappleStats(20.625f, 10.5f, 11.75f, 11f); + if (item.type == ItemID.SapphireHook) + AddGrappleStats(22.5f, 11f, 12.5f, 11f); + if (item.type == ItemID.EmeraldHook) + AddGrappleStats(24.375f, 11.5f, 13.25f, 11f); + if (item.type == ItemID.RubyHook) + AddGrappleStats(26.25f, 12f, 14f, 11f); + if (item.type == ItemID.DiamondHook) + AddGrappleStats(28.125f, 12.5f, 14.75f, 11f); + if (item.type == ItemID.WebSlinger) + AddGrappleStats(15.625f, 10f, 11f, 11f); + if (item.type == ItemID.SkeletronHand) + AddGrappleStats(21.875f, 15f, 11f, 11f); + if (item.type == ItemID.SlimeHook) + AddGrappleStats(18.75f, 13f, 11f, 11f); + if (item.type == ItemID.FishHook) + AddGrappleStats(25f, 13f, 11f, 11f); + if (item.type == ItemID.IvyWhip) + AddGrappleStats(25f, 13f, 15f, 11f); + if (item.type == ItemID.BatHook) // TODO -- This item should be dropped by Vampires in the Eclipse. It is very overpowered. + AddGrappleStats(31.25f, 15.5f, 20f, 16f); + if (item.type == ItemID.CandyCaneHook) + AddGrappleStats(25f, 11.5f, 11f, 11f); + if (item.type == ItemID.DualHook) + AddGrappleStats(27.5f, 14f, 17f, 11f); + // these four grapple hooks are all functionally identical + if (item.type == ItemID.ThornHook || item.type == ItemID.WormHook || item.type == ItemID.TendonHook || item.type == ItemID.IlluminantHook) + AddGrappleStats(30f, 15f, 18f, 11f); + if (item.type == ItemID.AntiGravityHook) + AddGrappleStats(31.25f, 14f, 20f, 11f); + if (item.type == ItemID.SpookyHook) + AddGrappleStats(34.375f, 15.5f, 22f, 11f); + if (item.type == ItemID.ChristmasHook) + AddGrappleStats(34.375f, 15.5f, 17f, 11f); + if (item.type == ItemID.LunarHook) + AddGrappleStats(34.375f, 16f, 24f, 13f); + if (item.type == ItemID.StaticHook) + AddGrappleStats(37.5f, 16f, 24f, 0f); + #endregion + + // Beyond this point all code only applies to accessories. Skip it all if the item is not an accessory. + if (!item.accessory) + return; + + // Display the stat changes to vanilla prefixes + #region Accessory Prefix Rebalance Tooltips + + // Turns a number into a string of increased DR. + string DRString(float percent) => $"\n+{percent:N2}% damage reduction"; + + switch (item.prefix) + { + case PrefixID.Brisk: + EditTooltipByName("PrefixAccMoveSpeed", (line) => line.text = line.text.Replace("1%", "1.5%")); + return; + case PrefixID.Fleeting: + EditTooltipByName("PrefixAccMoveSpeed", (line) => line.text = line.text.Replace("2%", "3%")); + return; + case PrefixID.Hasty2: // Hasty2 is the "Hasty" for accessories + EditTooltipByName("PrefixAccMoveSpeed", (line) => line.text = line.text.Replace("3%", "4.5%")); + return; + case PrefixID.Quick2: // Quick2 is the "Quick" for accessories + EditTooltipByName("PrefixAccMoveSpeed", (line) => line.text = line.text.Replace("4%", "6%")); + return; + case PrefixID.Hard: + EditTooltipByName("PrefixAccDefense", + (line) => line.text = line.text.Replace("1", CalamityUtils.GetScalingDefense(item.prefix).ToString()) + DRString(0.25f)); + return; + case PrefixID.Guarding: + EditTooltipByName("PrefixAccDefense", + (line) => line.text = line.text.Replace("2", CalamityUtils.GetScalingDefense(item.prefix).ToString()) + DRString(0.5f)); + return; + case PrefixID.Armored: + EditTooltipByName("PrefixAccDefense", + (line) => line.text = line.text.Replace("3", CalamityUtils.GetScalingDefense(item.prefix).ToString()) + DRString(0.75f)); + return; + case PrefixID.Warding: + EditTooltipByName("PrefixAccDefense", + (line) => line.text = line.text.Replace("4", CalamityUtils.GetScalingDefense(item.prefix).ToString()) + DRString(1f)); + return; + } + #endregion + } + #endregion + + #region True Melee Damage Tooltip + private void TrueMeleeDamageTooltip(Item item, IList tooltips) + { + TooltipLine line = tooltips.FirstOrDefault((l) => l.mod == "Terraria" && l.Name == "Damage"); + + // If there somehow isn't a damage tooltip line, do not try to perform any edits. + if (line is null) + return; + + // Start with the existing line of melee damage. + StringBuilder sb = new StringBuilder(64); + sb.Append(line.text).Append(" : "); + + Player p = Main.LocalPlayer; + float itemCurrentDamage = item.damage * p.MeleeDamage(); + double trueMeleeBoost = 1D + p.Calamity().trueMeleeDamage; + double imprecisionRoundingCorrection = 5E-06D; + int damageToDisplay = (int)(itemCurrentDamage * trueMeleeBoost + imprecisionRoundingCorrection); + sb.Append(damageToDisplay); + + // These two pieces are split apart for ease of translation + sb.Append(' '); + sb.Append("true melee damage"); + line.text = sb.ToString(); + } + #endregion + + #region Stealth Generation Prefix Accessory Tooltip + private void StealthGenAccessoryTooltip(Item item, IList tooltips) + { + if (!item.accessory || item.social || item.prefix <= 0) + return; + + float stealthGenBoost = item.Calamity().StealthGenBonus - 1f; + if (stealthGenBoost > 0) + { + TooltipLine StealthGen = new TooltipLine(mod, "PrefixStealthGenBoost", "+" + Math.Round(stealthGenBoost * 100f) + "% stealth generation") + { + isModifier = true + }; + tooltips.Add(StealthGen); + } + } + #endregion + + #region Enchanted Rarity Text Drawing + public override bool PreDrawTooltipLine(Item item, DrawableTooltipLine line, ref int yOffset) + { + // Special enchantment line color. + if (line.Name == "ItemName" && line.mod == "Terraria" && item.IsEnchanted()) + { + Color rarityColor = line.overrideColor ?? line.color; + Vector2 basePosition = new Vector2(line.X, line.Y); + + float backInterpolant = (float)Math.Pow(Main.GlobalTime * 0.81f % 1f, 1.5f); + Vector2 backScale = line.baseScale * MathHelper.Lerp(1f, 1.2f, backInterpolant); + Color backColor = Color.Lerp(rarityColor, Color.DarkRed, backInterpolant) * (float)Math.Pow(1f - backInterpolant, 0.46f); + Vector2 backPosition = basePosition - new Vector2(1f, 0.1f) * backInterpolant * 10f; + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive); + + // Draw the back text as an ominous pulse. + for (int i = 0; i < 2; i++) + ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, line.font, line.text, backPosition, backColor, line.rotation, line.origin, backScale, line.maxWidth, line.spread); + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(); + + // Draw the front text as usual. + ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, line.font, line.text, basePosition, rarityColor, line.rotation, line.origin, line.baseScale, line.maxWidth, line.spread); + + return false; + } + return true; + } + #endregion #region Schematic Knowledge Tooltip Utility - public static void InsertKnowledgeTooltip(List tooltips, int tier, bool allowOldWorlds = false) - { - TooltipLine line = new TooltipLine(CalamityMod.Instance, "SchematicKnowledge1", "You don't have sufficient knowledge to create this yet"); - TooltipLine line2 = new TooltipLine(CalamityMod.Instance, "SchematicKnowledge2", "A specific schematic must be deciphered first"); - line.overrideColor = line2.overrideColor = Color.Cyan; + public static void InsertKnowledgeTooltip(List tooltips, int tier, bool allowOldWorlds = false) + { + TooltipLine line = new TooltipLine(CalamityMod.Instance, "SchematicKnowledge1", "You don't have sufficient knowledge to create this yet"); + TooltipLine line2 = new TooltipLine(CalamityMod.Instance, "SchematicKnowledge2", "A specific schematic must be deciphered first"); + line.overrideColor = line2.overrideColor = Color.Cyan; - bool allowedDueToOldWorld = allowOldWorlds && CalamityWorld.IsWorldAfterDraedonUpdate; - tooltips.AddWithCondition(line, !ArsenalTierGatedRecipe.HasTierBeenLearned(tier) && !allowedDueToOldWorld); - tooltips.AddWithCondition(line2, !ArsenalTierGatedRecipe.HasTierBeenLearned(tier) && !allowedDueToOldWorld); - } + bool allowedDueToOldWorld = allowOldWorlds && CalamityWorld.IsWorldAfterDraedonUpdate; + tooltips.AddWithCondition(line, !ArsenalTierGatedRecipe.HasTierBeenLearned(tier) && !allowedDueToOldWorld); + tooltips.AddWithCondition(line2, !ArsenalTierGatedRecipe.HasTierBeenLearned(tier) && !allowedDueToOldWorld); + } #endregion } } diff --git a/Items/CalamityGlobalItemTweaks.cs b/Items/CalamityGlobalItemTweaks.cs index 5aad6a48e6..cbf2eba034 100644 --- a/Items/CalamityGlobalItemTweaks.cs +++ b/Items/CalamityGlobalItemTweaks.cs @@ -99,8 +99,13 @@ namespace CalamityMod.Items { ItemID.ChristmasTreeSword, Do(AutoReuse, UseTurn, DamageExact(155)) }, { ItemID.ClingerStaff, Do(DamageRatio(1.33f)) }, { ItemID.ClockworkAssaultRifle, pointBlank }, + { ItemID.CobaltBreastplate, Do(DefenseDelta(+3)) }, { ItemID.CobaltChainsaw, Do(TrueMelee, AxePower(70), UseTimeExact(4), TileBoostExact(-1)) }, { ItemID.CobaltDrill, Do(TrueMelee, PickPower(130), UseTimeExact(5)) }, + { ItemID.CobaltHat, Do(DefenseDelta(+2)) }, + { ItemID.CobaltHelmet, Do(DefenseDelta(+5)) }, + { ItemID.CobaltLeggings, Do(DefenseDelta(+3)) }, + { ItemID.CobaltMask, Do(DefenseDelta(+3)) }, { ItemID.CobaltNaginata, Do(AutoReuse, TrueMelee, UseRatio(0.8f), DamageExact(90)) }, { ItemID.CobaltPickaxe, Do(PickPower(130), UseTimeExact(9)) }, { ItemID.CobaltRepeater, Do(PointBlank, DamageRatio(1.1f)) }, diff --git a/Items/VanillaArmorChanges/CobaltArmorSetChange.cs b/Items/VanillaArmorChanges/CobaltArmorSetChange.cs new file mode 100644 index 0000000000..89585ccf4d --- /dev/null +++ b/Items/VanillaArmorChanges/CobaltArmorSetChange.cs @@ -0,0 +1,55 @@ +using System; +using Terraria; +using Terraria.ID; + +namespace CalamityMod.Items.VanillaArmorChanges +{ + public class CobaltArmorSetChange : VanillaArmorChange + { + public override int? HeadPieceID => ItemID.CobaltHelmet; + + public override int? BodyPieceID => ItemID.CobaltBreastplate; + + public override int? LegPieceID => ItemID.CobaltLeggings; + + public override int[] AlternativeHeadPieceIDs => new int[] { ItemID.CobaltHat, ItemID.CobaltMask }; + + public override string ArmorSetName => "Cobalt"; + + public const int SpeedBoostSetBonusPercentage = 15; + public const int MaxManaBoost = 20; + public const int MovementSpeedBoostPercentageMax = 15; + public const int MovementSpeedBoostMphThreshold = 60; + + public override void ApplyHeadPieceEffect(Player player) + { + if (player.armor[0].type == ItemID.CobaltHat) + player.statManaMax2 += MaxManaBoost; + } + + public override void UpdateSetBonusText(ref string setBonusText) + { + setBonusText += $"\n{SpeedBoostSetBonusPercentage}% increased max speed and acceleration\n" + + $"You gain a damage and critical strike chance boost relative to your current movement speed, up to {SpeedBoostSetBonusPercentage}%"; + } + + public static float CalculateMovementSpeedInterpolant(Player player) + { + float milesPerHour = player.velocity.Length() * 225f / 44f; + float movementSpeedInterpolant = Utils.InverseLerp(0f, MovementSpeedBoostMphThreshold, milesPerHour, true); + return (float)Math.Pow(movementSpeedInterpolant, 5D / 3D); + } + + public static void ApplyMovementSpeedBonuses(Player player) + { + float movementSpeedInterpolant = CalculateMovementSpeedInterpolant(player); + player.allDamage += MovementSpeedBoostPercentageMax * movementSpeedInterpolant * 0.01f; + player.Calamity().AllCritBoost((int)(MovementSpeedBoostPercentageMax * movementSpeedInterpolant)); + } + + public override void ApplyArmorSetBonus(Player player) + { + player.Calamity().CobaltSet = true; + } + } +} diff --git a/Items/VanillaArmorChanges/CopperArmorSetChange.cs b/Items/VanillaArmorChanges/CopperArmorSetChange.cs new file mode 100644 index 0000000000..02e307b834 --- /dev/null +++ b/Items/VanillaArmorChanges/CopperArmorSetChange.cs @@ -0,0 +1,25 @@ +using Terraria; +using Terraria.ID; + +namespace CalamityMod.Items.VanillaArmorChanges +{ + public class CopperArmorSetChange : VanillaArmorChange + { + public override int? HeadPieceID => ItemID.CopperHelmet; + + public override int? BodyPieceID => ItemID.CopperChainmail; + + public override int? LegPieceID => ItemID.CopperGreaves; + + public override string ArmorSetName => "Copper"; + + public const int MiningSpeedPercentSetBonus = 15; + + public override void UpdateSetBonusText(ref string setBonusText) + { + setBonusText += CalamityGlobalItem.MiningSpeedString(MiningSpeedPercentSetBonus); + } + + public override void ApplyArmorSetBonus(Player player) => player.pickSpeed -= MiningSpeedPercentSetBonus * 0.01f; + } +} diff --git a/Items/VanillaArmorChanges/EskimoArmorSetChange.cs b/Items/VanillaArmorChanges/EskimoArmorSetChange.cs new file mode 100644 index 0000000000..3d74cd6765 --- /dev/null +++ b/Items/VanillaArmorChanges/EskimoArmorSetChange.cs @@ -0,0 +1,43 @@ +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.World; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.VanillaArmorChanges +{ + public class EskimoArmorSetChange : VanillaArmorChange + { + public override int? HeadPieceID => ItemID.EskimoHood; + + public override int? BodyPieceID => ItemID.EskimoCoat; + + public override int? LegPieceID => ItemID.EskimoPants; + + // The normal and Pink Eskimo set can be mixed and matched. + public override int[] AlternativeHeadPieceIDs => new int[] { ItemID.PinkEskimoHood }; + + public override int[] AlternativeBodyPieceIDs => new int[] { ItemID.PinkEskimoCoat }; + + public override int[] AlternativeLegPieceIDs => new int[] { ItemID.PinkEskimoPants }; + + public override bool NeedsToCreateSetBonusTextManually => true; + + public override string ArmorSetName => "Eskimo"; + + public override void UpdateSetBonusText(ref string setBonusText) + { + string coldImmunity = CalamityWorld.death ? "\nProvides cold protection in Death Mode" : string.Empty; + setBonusText = "All ice-themed damage over time debuffs receive a 50% damage bonus\n" + + "Cold enemies will deal reduced contact damage to the player\n" + + "Provides immunity to the Frostburn and Glacial State debuffs" + coldImmunity; + } + + public override void ApplyArmorSetBonus(Player player) + { + player.Calamity().eskimoSet = true; + player.buffImmune[BuffID.Frostburn] = true; + player.buffImmune[ModContent.BuffType()] = true; + } + } +} diff --git a/Items/VanillaArmorChanges/GladiatorArmorSetChange.cs b/Items/VanillaArmorChanges/GladiatorArmorSetChange.cs new file mode 100644 index 0000000000..e6ebff3433 --- /dev/null +++ b/Items/VanillaArmorChanges/GladiatorArmorSetChange.cs @@ -0,0 +1,56 @@ +using Terraria; +using Terraria.ID; + +namespace CalamityMod.Items.VanillaArmorChanges +{ + public class GladiatorArmorSetChange : VanillaArmorChange + { + public override int? HeadPieceID => ItemID.GladiatorHelmet; + + public override int? BodyPieceID => ItemID.GladiatorBreastplate; + + public override int? LegPieceID => ItemID.GladiatorLeggings; + + public override string ArmorSetName => "Gladiator"; + + public override bool NeedsToCreateSetBonusTextManually => true; + + public const int HelmetRogueDamageBoostPercent = 3; + public const int ChestplateRogueCritBoostPercent = 3; + public const int LeggingRogueVelocityBoostPercent = 3; + + public override void UpdateSetBonusText(ref string setBonusText) + { + setBonusText = "+3 defense\n" + + "5% increased rogue damage and 10% increased velocity\n" + + "Rogue stealth builds while not attacking and not moving, up to a max of 70\n" + + "Once you have built max stealth, you will be able to perform a Stealth Strike\n" + + "Rogue stealth only reduces when you attack, it does not reduce while moving\n" + + "The higher your rogue stealth the higher your rogue damage, crit, and movement speed"; + } + + public override void ApplyHeadPieceEffect(Player player) + { + player.Calamity().throwingDamage += HelmetRogueDamageBoostPercent * 0.01f; + } + + public override void ApplyBodyPieceEffect(Player player) + { + player.Calamity().throwingCrit += ChestplateRogueCritBoostPercent; + } + + public override void ApplyLegPieceEffect(Player player) + { + player.Calamity().throwingVelocity += LeggingRogueVelocityBoostPercent * 0.01f; + } + + public override void ApplyArmorSetBonus(Player player) + { + player.Calamity().rogueStealthMax += 0.7f; + player.Calamity().wearingRogueArmor = true; + player.Calamity().throwingDamage += 0.05f; + player.Calamity().throwingVelocity += 0.1f; + player.statDefense += 3; + } + } +} diff --git a/Items/VanillaArmorChanges/GoldArmorSetChange.cs b/Items/VanillaArmorChanges/GoldArmorSetChange.cs new file mode 100644 index 0000000000..6f7ee09a26 --- /dev/null +++ b/Items/VanillaArmorChanges/GoldArmorSetChange.cs @@ -0,0 +1,25 @@ +using Terraria; +using Terraria.ID; + +namespace CalamityMod.Items.VanillaArmorChanges +{ + public class GoldArmorSetChange : VanillaArmorChange + { + public override int? HeadPieceID => ItemID.GoldHelmet; + + public override int? BodyPieceID => ItemID.GoldChainmail; + + public override int? LegPieceID => ItemID.GoldGreaves; + + public override string ArmorSetName => "Gold"; + + public const int MiningSpeedPercentSetBonus = 45; + + public override void UpdateSetBonusText(ref string setBonusText) + { + setBonusText += CalamityGlobalItem.MiningSpeedString(MiningSpeedPercentSetBonus); + } + + public override void ApplyArmorSetBonus(Player player) => player.pickSpeed -= MiningSpeedPercentSetBonus * 0.01f; + } +} diff --git a/Items/VanillaArmorChanges/IronArmorSetChange.cs b/Items/VanillaArmorChanges/IronArmorSetChange.cs new file mode 100644 index 0000000000..f1decb6506 --- /dev/null +++ b/Items/VanillaArmorChanges/IronArmorSetChange.cs @@ -0,0 +1,27 @@ +using Terraria; +using Terraria.ID; + +namespace CalamityMod.Items.VanillaArmorChanges +{ + public class IronArmorSetChange : VanillaArmorChange + { + public override int? HeadPieceID => ItemID.IronHelmet; + + public override int? BodyPieceID => ItemID.IronChainmail; + + public override int? LegPieceID => ItemID.IronGreaves; + + public override int[] AlternativeHeadPieceIDs => new int[] { ItemID.AncientIronHelmet }; + + public override string ArmorSetName => "Iron"; + + public const int MiningSpeedPercentSetBonus = 25; + + public override void UpdateSetBonusText(ref string setBonusText) + { + setBonusText += CalamityGlobalItem.MiningSpeedString(MiningSpeedPercentSetBonus); + } + + public override void ApplyArmorSetBonus(Player player) => player.pickSpeed -= MiningSpeedPercentSetBonus * 0.01f; + } +} diff --git a/Items/VanillaArmorChanges/LeadArmorSetChange.cs b/Items/VanillaArmorChanges/LeadArmorSetChange.cs new file mode 100644 index 0000000000..b6f2070784 --- /dev/null +++ b/Items/VanillaArmorChanges/LeadArmorSetChange.cs @@ -0,0 +1,25 @@ +using Terraria; +using Terraria.ID; + +namespace CalamityMod.Items.VanillaArmorChanges +{ + public class LeadArmorSetChange : VanillaArmorChange + { + public override int? HeadPieceID => ItemID.LeadHelmet; + + public override int? BodyPieceID => ItemID.LeadChainmail; + + public override int? LegPieceID => ItemID.LeadGreaves; + + public override string ArmorSetName => "Lead"; + + public const int MiningSpeedPercentSetBonus = 20; + + public override void UpdateSetBonusText(ref string setBonusText) + { + setBonusText += CalamityGlobalItem.MiningSpeedString(MiningSpeedPercentSetBonus); + } + + public override void ApplyArmorSetBonus(Player player) => player.pickSpeed -= MiningSpeedPercentSetBonus * 0.01f; + } +} diff --git a/Items/VanillaArmorChanges/MeteorArmorSetChange.cs b/Items/VanillaArmorChanges/MeteorArmorSetChange.cs new file mode 100644 index 0000000000..52dd34a9b4 --- /dev/null +++ b/Items/VanillaArmorChanges/MeteorArmorSetChange.cs @@ -0,0 +1,28 @@ +using Terraria; +using Terraria.ID; + +namespace CalamityMod.Items.VanillaArmorChanges +{ + public class MeteorArmorSetChange : VanillaArmorChange + { + public override int? HeadPieceID => ItemID.MeteorHelmet; + + public override int? BodyPieceID => ItemID.MeteorSuit; + + public override int? LegPieceID => ItemID.MeteorLeggings; + + public override string ArmorSetName => "Meteor"; + + // Meteor Armor only makes space gun cost 50% instead of zero mana. + public override void UpdateSetBonusText(ref string setBonusText) + { + setBonusText = setBonusText.Replace("0", "50%"); + } + + public override void ApplyArmorSetBonus(Player player) + { + player.spaceGun = false; + player.Calamity().meteorSet = true; + } + } +} diff --git a/Items/VanillaArmorChanges/MoltenArmorSetChange.cs b/Items/VanillaArmorChanges/MoltenArmorSetChange.cs new file mode 100644 index 0000000000..dc23bd3a09 --- /dev/null +++ b/Items/VanillaArmorChanges/MoltenArmorSetChange.cs @@ -0,0 +1,34 @@ +using CalamityMod.World; +using Terraria; +using Terraria.ID; + +namespace CalamityMod.Items.VanillaArmorChanges +{ + public class MoltenArmorSetChange : VanillaArmorChange + { + public override int? HeadPieceID => ItemID.TinHelmet; + + public override int? BodyPieceID => ItemID.TinChainmail; + + public override int? LegPieceID => ItemID.TinGreaves; + + public override string ArmorSetName => "Molten"; + + public const int MiningSpeedPercentSetBonus = 10; + + public override void UpdateSetBonusText(ref string setBonusText) + { + string extraLine = "\n20% extra true melee damage\nGrants immunity to fire blocks and temporary immunity to lava"; + if (CalamityWorld.death) + extraLine += CalamityGlobalItem.BothProtectionLine; + setBonusText += extraLine; + } + + // TODO - The death mode immuntities are hardcoded in the misc player effects file. Perhaps make it into a generalized bool? + public override void ApplyArmorSetBonus(Player player) + { + player.fireWalk = true; + player.lavaMax += 300; + } + } +} diff --git a/Items/VanillaArmorChanges/MonkT2ArmorSetChange.cs b/Items/VanillaArmorChanges/MonkT2ArmorSetChange.cs new file mode 100644 index 0000000000..853ecfb0e7 --- /dev/null +++ b/Items/VanillaArmorChanges/MonkT2ArmorSetChange.cs @@ -0,0 +1,47 @@ +using Terraria; +using Terraria.ID; + +namespace CalamityMod.Items.VanillaArmorChanges +{ + public class MonkT2ArmorSetChange : VanillaArmorChange + { + public override int? HeadPieceID => ItemID.MonkBrows; + + public override int? BodyPieceID => ItemID.MonkShirt; + + public override int? LegPieceID => ItemID.MonkPants; + + public override string ArmorSetName => "MonkTier2"; + + public override void UpdateSetBonusText(ref string setBonusText) + { + setBonusText += "\n10% increased melee speed, crit, and damage\n" + + "15% increased minion damage"; + } + + public override void ApplyHeadPieceEffect(Player player) + { + player.meleeSpeed -= 0.1f; + } + + public override void ApplyBodyPieceEffect(Player player) + { + player.minionDamage -= 0.1f; + player.meleeDamage -= 0.1f; + } + + public override void ApplyLegPieceEffect(Player player) + { + player.minionDamage -= 0.05f; + player.meleeCrit -= 10; + } + + public override void ApplyArmorSetBonus(Player player) + { + player.minionDamage += 0.15f; + player.meleeDamage += 0.1f; + player.meleeSpeed += 0.1f; + player.meleeCrit += 10; + } + } +} diff --git a/Items/VanillaArmorChanges/ObsidianArmorSetChange.cs b/Items/VanillaArmorChanges/ObsidianArmorSetChange.cs new file mode 100644 index 0000000000..3a73ede2b0 --- /dev/null +++ b/Items/VanillaArmorChanges/ObsidianArmorSetChange.cs @@ -0,0 +1,61 @@ +using CalamityMod.World; +using Terraria; +using Terraria.ID; + +namespace CalamityMod.Items.VanillaArmorChanges +{ + public class ObsidianArmorSetChange : VanillaArmorChange + { + public override int? HeadPieceID => ItemID.ObsidianHelm; + + public override int? BodyPieceID => ItemID.ObsidianShirt; + + public override int? LegPieceID => ItemID.ObsidianPants; + + public override string ArmorSetName => "Obsidian"; + + public override bool NeedsToCreateSetBonusTextManually => true; + + public const int HelmetRogueDamageBoostPercent = 3; + public const int ChestplateRogueCritBoostPercent = 3; + public const int LeggingRogueVelocityBoostPercent = 3; + + public override void UpdateSetBonusText(ref string setBonusText) + { + string heatImmunity = CalamityWorld.death ? "\nProvides heat protection in Death Mode" : string.Empty; + setBonusText = "+2 defense\n" + + "5% increased rogue damage and critical strike chance\n" + + "Grants immunity to fire blocks and temporary immunity to lava\n" + + "Rogue stealth builds while not attacking and not moving, up to a max of 80\n" + + "Once you have built max stealth, you will be able to perform a Stealth Strike\n" + + "Rogue stealth only reduces when you attack, it does not reduce while moving\n" + + "The higher your rogue stealth the higher your rogue damage, crit, and movement speed" + heatImmunity; + } + + public override void ApplyHeadPieceEffect(Player player) + { + player.Calamity().throwingDamage += HelmetRogueDamageBoostPercent * 0.01f; + } + + public override void ApplyBodyPieceEffect(Player player) + { + player.Calamity().throwingCrit += ChestplateRogueCritBoostPercent; + } + + public override void ApplyLegPieceEffect(Player player) + { + player.Calamity().throwingVelocity += LeggingRogueVelocityBoostPercent * 0.01f; + } + + public override void ApplyArmorSetBonus(Player player) + { + player.Calamity().rogueStealthMax += 0.8f; + player.Calamity().wearingRogueArmor = true; + player.Calamity().throwingDamage += 0.05f; + player.Calamity().throwingCrit += 5; + player.statDefense += 2; + player.fireWalk = true; + player.lavaMax += 180; + } + } +} diff --git a/Items/VanillaArmorChanges/PlatinumArmorSetChange.cs b/Items/VanillaArmorChanges/PlatinumArmorSetChange.cs new file mode 100644 index 0000000000..a661d40549 --- /dev/null +++ b/Items/VanillaArmorChanges/PlatinumArmorSetChange.cs @@ -0,0 +1,25 @@ +using Terraria; +using Terraria.ID; + +namespace CalamityMod.Items.VanillaArmorChanges +{ + public class PlatinumArmorSetChange : VanillaArmorChange + { + public override int? HeadPieceID => ItemID.PlatinumHelmet; + + public override int? BodyPieceID => ItemID.PlatinumChainmail; + + public override int? LegPieceID => ItemID.PlatinumGreaves; + + public override string ArmorSetName => "Platinum"; + + public const int MiningSpeedPercentSetBonus = 40; + + public override void UpdateSetBonusText(ref string setBonusText) + { + setBonusText += CalamityGlobalItem.MiningSpeedString(MiningSpeedPercentSetBonus); + } + + public override void ApplyArmorSetBonus(Player player) => player.pickSpeed -= MiningSpeedPercentSetBonus * 0.01f; + } +} diff --git a/Items/VanillaArmorChanges/SilverArmorSetChange.cs b/Items/VanillaArmorChanges/SilverArmorSetChange.cs new file mode 100644 index 0000000000..f56890ae3f --- /dev/null +++ b/Items/VanillaArmorChanges/SilverArmorSetChange.cs @@ -0,0 +1,25 @@ +using Terraria; +using Terraria.ID; + +namespace CalamityMod.Items.VanillaArmorChanges +{ + public class SilverArmorSetChange : VanillaArmorChange + { + public override int? HeadPieceID => ItemID.SilverHelmet; + + public override int? BodyPieceID => ItemID.SilverChainmail; + + public override int? LegPieceID => ItemID.SilverGreaves; + + public override string ArmorSetName => "Silver"; + + public const int MiningSpeedPercentSetBonus = 35; + + public override void UpdateSetBonusText(ref string setBonusText) + { + setBonusText += CalamityGlobalItem.MiningSpeedString(MiningSpeedPercentSetBonus); + } + + public override void ApplyArmorSetBonus(Player player) => player.pickSpeed -= MiningSpeedPercentSetBonus * 0.01f; + } +} diff --git a/Items/VanillaArmorChanges/StardustArmorSetChange.cs b/Items/VanillaArmorChanges/StardustArmorSetChange.cs new file mode 100644 index 0000000000..952060c17a --- /dev/null +++ b/Items/VanillaArmorChanges/StardustArmorSetChange.cs @@ -0,0 +1,26 @@ +using Terraria; +using Terraria.ID; + +namespace CalamityMod.Items.VanillaArmorChanges +{ + public class StardustArmorSetChange : VanillaArmorChange + { + public override int? HeadPieceID => ItemID.StardustHelmet; + + public override int? BodyPieceID => ItemID.StardustBreastplate; + + public override int? LegPieceID => ItemID.StardustLeggings; + + public override string ArmorSetName => "Stardust"; + + public override void ApplyBodyPieceEffect(Player player) + { + player.maxMinions--; + } + + public override void ApplyLegPieceEffect(Player player) + { + player.maxMinions--; + } + } +} diff --git a/Items/VanillaArmorChanges/TinArmorSetChange.cs b/Items/VanillaArmorChanges/TinArmorSetChange.cs new file mode 100644 index 0000000000..32f3115d42 --- /dev/null +++ b/Items/VanillaArmorChanges/TinArmorSetChange.cs @@ -0,0 +1,25 @@ +using Terraria; +using Terraria.ID; + +namespace CalamityMod.Items.VanillaArmorChanges +{ + public class TinArmorSetChange : VanillaArmorChange + { + public override int? HeadPieceID => ItemID.TinHelmet; + + public override int? BodyPieceID => ItemID.TinChainmail; + + public override int? LegPieceID => ItemID.TinGreaves; + + public override string ArmorSetName => "Tin"; + + public const int MiningSpeedPercentSetBonus = 10; + + public override void UpdateSetBonusText(ref string setBonusText) + { + setBonusText += CalamityGlobalItem.MiningSpeedString(MiningSpeedPercentSetBonus); + } + + public override void ApplyArmorSetBonus(Player player) => player.pickSpeed -= MiningSpeedPercentSetBonus * 0.01f; + } +} diff --git a/Items/VanillaArmorChanges/TungstenArmorSetChange.cs b/Items/VanillaArmorChanges/TungstenArmorSetChange.cs new file mode 100644 index 0000000000..44d7ffa622 --- /dev/null +++ b/Items/VanillaArmorChanges/TungstenArmorSetChange.cs @@ -0,0 +1,25 @@ +using Terraria; +using Terraria.ID; + +namespace CalamityMod.Items.VanillaArmorChanges +{ + public class TungstenArmorSetChange : VanillaArmorChange + { + public override int? HeadPieceID => ItemID.TungstenHelmet; + + public override int? BodyPieceID => ItemID.TungstenChainmail; + + public override int? LegPieceID => ItemID.TungstenGreaves; + + public override string ArmorSetName => "Tungsten"; + + public const int MiningSpeedPercentSetBonus = 30; + + public override void UpdateSetBonusText(ref string setBonusText) + { + setBonusText += CalamityGlobalItem.MiningSpeedString(MiningSpeedPercentSetBonus); + } + + public override void ApplyArmorSetBonus(Player player) => player.pickSpeed -= MiningSpeedPercentSetBonus * 0.01f; + } +} diff --git a/Items/VanillaArmorChanges/VanillaArmorChange.cs b/Items/VanillaArmorChanges/VanillaArmorChange.cs new file mode 100644 index 0000000000..355ea685cb --- /dev/null +++ b/Items/VanillaArmorChanges/VanillaArmorChange.cs @@ -0,0 +1,61 @@ +using System.Linq; +using Terraria; +using Terraria.ID; + +namespace CalamityMod.Items.VanillaArmorChanges +{ + // Certain things are virtual instead of abstract because not all pieces of armor are explicitly a part of any particular set. + // The Wizard Hat is an example of this. The IDs are left abstract so that you don't mistakenly forget to override one of them. + public abstract class VanillaArmorChange + { + public abstract int? HeadPieceID { get; } + + public abstract int? BodyPieceID { get; } + + public abstract int? LegPieceID { get; } + + public virtual int[] AlternativeHeadPieceIDs => new int[0]; + + public virtual int[] AlternativeBodyPieceIDs => new int[0]; + + public virtual int[] AlternativeLegPieceIDs => new int[0]; + + public virtual string ArmorSetName => null; + + public virtual bool NeedsToCreateSetBonusTextManually => false; + + public virtual void UpdateSetBonusText(ref string setBonusText) { } + + public virtual void ApplyHeadPieceEffect(Player player) { } + + public virtual void ApplyBodyPieceEffect(Player player) { } + + public virtual void ApplyLegPieceEffect(Player player) { } + + public virtual void ApplyArmorSetBonus(Player player) { } + + public bool IsWearingEntireSet(Player player) + { + // Check each individual piece of armor on the player with the respective expected item ID. + // If no ID is applied/it's null, that signals that it doesn't matter, and to just fall through anyway. + if ((HeadPieceID ?? player.armor[0].type) != player.armor[0].type && !AlternativeHeadPieceIDs.Contains(player.armor[0].type)) + return false; + if ((BodyPieceID ?? player.armor[1].type) != player.armor[1].type && !AlternativeBodyPieceIDs.Contains(player.armor[1].type)) + return false; + if ((LegPieceID ?? player.armor[2].type) != player.armor[2].type && !AlternativeLegPieceIDs.Contains(player.armor[2].type)) + return false; + + return true; + } + + public void ApplyIndividualPieceEffects(Player player) + { + if ((HeadPieceID ?? ItemID.None) == player.armor[0].type || AlternativeHeadPieceIDs.Contains(player.armor[0].type)) + ApplyHeadPieceEffect(player); + if ((HeadPieceID ?? ItemID.None) == player.armor[1].type || AlternativeBodyPieceIDs.Contains(player.armor[1].type)) + ApplyBodyPieceEffect(player); + if ((HeadPieceID ?? ItemID.None) == player.armor[2].type || AlternativeLegPieceIDs.Contains(player.armor[2].type)) + ApplyLegPieceEffect(player); + } + } +} diff --git a/Items/VanillaArmorChanges/VanillaArmorChangeManager.cs b/Items/VanillaArmorChanges/VanillaArmorChangeManager.cs new file mode 100644 index 0000000000..8708ebc62a --- /dev/null +++ b/Items/VanillaArmorChanges/VanillaArmorChangeManager.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using Terraria; +using Terraria.ID; + +namespace CalamityMod.Items.VanillaArmorChanges +{ + public static class VanillaArmorChangeManager + { + internal static List ArmorChanges; + + internal static void Load() + { + ArmorChanges = new List(); + foreach (Type type in CalamityMod.Instance.Code.GetTypes()) + { + if (!type.IsSubclassOf(typeof(VanillaArmorChange)) || type.IsAbstract) + continue; + + ArmorChanges.Add((VanillaArmorChange)FormatterServices.GetUninitializedObject(type)); + } + } + + internal static void Unload() => ArmorChanges = null; + + public static void ApplySetBonusTooltipChanges(Item checkItem, ref string setBonusText) + { + for (int i = 0; i < ArmorChanges.Count; i++) + { + bool isValidHeadPiece = (ArmorChanges[i].HeadPieceID ?? ItemID.None) == checkItem.type || + ArmorChanges[i].AlternativeHeadPieceIDs.Contains(checkItem.type); + bool isValidBodyPiece = (ArmorChanges[i].BodyPieceID ?? ItemID.None) == checkItem.type || + ArmorChanges[i].AlternativeBodyPieceIDs.Contains(checkItem.type); + bool isValidLegPiece = (ArmorChanges[i].LegPieceID ?? ItemID.None) == checkItem.type || + ArmorChanges[i].AlternativeLegPieceIDs.Contains(checkItem.type); + if (isValidHeadPiece || isValidBodyPiece || isValidLegPiece) + ArmorChanges[i].UpdateSetBonusText(ref setBonusText); + } + } + + public static void CreateTooltipManuallyAsNecessary(Player player) + { + for (int i = 0; i < ArmorChanges.Count; i++) + { + if (ArmorChanges[i].IsWearingEntireSet(player) && ArmorChanges[i].NeedsToCreateSetBonusTextManually) + { + ArmorChanges[i].UpdateSetBonusText(ref player.setBonus); + return; + } + } + } + + public static string GetSetBonusName(Player player) + { + for (int i = 0; i < ArmorChanges.Count; i++) + { + if (ArmorChanges[i].IsWearingEntireSet(player)) + return ArmorChanges[i].ArmorSetName; + } + return string.Empty; + } + + public static void ApplyPotentialEffectsTo(Player player) + { + // Look through every armor change, apply individual set piece effects if pieces are being worn, and + // if the entire set is worn, apply the set bonus. + for (int i = 0; i < ArmorChanges.Count; i++) + { + ArmorChanges[i].ApplyIndividualPieceEffects(player); + if (ArmorChanges[i].IsWearingEntireSet(player)) + ArmorChanges[i].ApplyArmorSetBonus(player); + } + } + } +}