diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 53a6fbde73..4f79d6b6fe 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -333,6 +333,7 @@ namespace CalamityMod.CalPlayer #endregion #region Rage + public bool RageEnabled => CalamityWorld.revenge || shatteredCommunity; public bool rageModeActive = false; public float rage = 0f; public float rageMax = 100f; // 0 to 100% by default @@ -349,6 +350,7 @@ namespace CalamityMod.CalPlayer #endregion #region Adrenaline + public bool AdrenalineEnabled => CalamityWorld.revenge || draedonsHeart; public bool adrenalineModeActive = false; public float adrenaline = 0f; public float adrenalineMax = 100f; // 0 to 100% by default @@ -432,6 +434,7 @@ namespace CalamityMod.CalPlayer public bool laudanum = false; public bool heartOfDarkness = false; public bool draedonsHeart = false; + public int nanomachinesTimer = 0; public bool vexation = false; public bool dodgeScarf = false; public bool evasionScarf = false; @@ -2312,6 +2315,7 @@ namespace CalamityMod.CalPlayer triumph = false; penumbra = false; shadow = false; + nanomachinesTimer = 0; photosynthesis = false; astralInjection = false; gravityNormalizer = false; @@ -3002,7 +3006,7 @@ namespace CalamityMod.CalPlayer } // Trigger for pressing the Adrenaline hotkey. - if (CalamityKeybinds.AdrenalineHotKey.JustPressed && CalamityWorld.revenge) + if (CalamityKeybinds.AdrenalineHotKey.JustPressed && AdrenalineEnabled) { if (adrenaline == adrenalineMax && !adrenalineModeActive) { @@ -4503,8 +4507,8 @@ namespace CalamityMod.CalPlayer if (witheredDebuff && witheringWeaponEnchant) damageMult += 0.6; - if (CalamityWorld.revenge) - CalamityUtils.ApplyRippersToDamage(this, isTrueMelee, ref damageMult); + // Rippers are always checked for application, because there are ways to get rippers outside of Rev now + CalamityUtils.ApplyRippersToDamage(this, isTrueMelee, ref damageMult); damage = (int)(damage * damageMult); #endregion @@ -4608,8 +4612,8 @@ namespace CalamityMod.CalPlayer if (witheredDebuff) damageMult += 0.6; - if (CalamityWorld.revenge) - CalamityUtils.ApplyRippersToDamage(this, isTrueMelee, ref damageMult); + // Rippers are always checked for application, because there are ways to get rippers outside of Rev now + CalamityUtils.ApplyRippersToDamage(this, isTrueMelee, ref damageMult); if (filthyGlove && proj.Calamity().stealthStrike && proj.CountsAsClass()) { @@ -5025,7 +5029,8 @@ namespace CalamityMod.CalPlayer theBeeCooldown = 600; } - if (CalamityWorld.revenge) + // Full Adrenaline DR does not apply when using Draedon's Heart + if (AdrenalineEnabled && !draedonsHeart) { if (adrenaline == adrenalineMax && !adrenalineModeActive) { @@ -5269,7 +5274,8 @@ namespace CalamityMod.CalPlayer theBeeCooldown = 600; } - if (CalamityWorld.revenge) + // Full Adrenaline DR does not apply when using Draedon's Heart + if (AdrenalineEnabled && !draedonsHeart) { if (adrenaline == adrenalineMax && !adrenalineModeActive) { @@ -5948,7 +5954,7 @@ namespace CalamityMod.CalPlayer // Shattered Community makes the player gain rage based on the amount of damage taken. // Also set the Rage gain cooldown to prevent bizarre abuse cases. - if (CalamityWorld.revenge && shatteredCommunity && rageGainCooldown == 0) + if (shatteredCommunity && rageGainCooldown == 0) { float HPRatio = (float)damage / Player.statLifeMax2; float rageConversionRatio = 0.8f; @@ -5979,7 +5985,7 @@ namespace CalamityMod.CalPlayer modStealth = 1f; // Give Rage combat frames because being hurt counts as combat. - if (CalamityWorld.revenge) + if (RageEnabled) rageCombatFrames = RageCombatDelayTime; if (Player.whoAmI == Main.myPlayer) @@ -6031,7 +6037,8 @@ namespace CalamityMod.CalPlayer witheringDamageDone = 0; } - if (CalamityWorld.revenge) + // Lose adrenaline on hit, unless using Draedon's Heart. + if (AdrenalineEnabled && !draedonsHeart) { if (!adrenalineModeActive && damage > 0) // To prevent paladin's shield ruining adren even with 0 dmg taken { diff --git a/CalPlayer/CalamityPlayerDrawEffects.cs b/CalPlayer/CalamityPlayerDrawEffects.cs index 3c9b153fad..70e98bab89 100644 --- a/CalPlayer/CalamityPlayerDrawEffects.cs +++ b/CalPlayer/CalamityPlayerDrawEffects.cs @@ -706,16 +706,6 @@ namespace CalamityMod.CalPlayer 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) diff --git a/CalPlayer/CalamityPlayerLifeRegen.cs b/CalPlayer/CalamityPlayerLifeRegen.cs index 020b0c2646..412dab6f9a 100644 --- a/CalPlayer/CalamityPlayerLifeRegen.cs +++ b/CalPlayer/CalamityPlayerLifeRegen.cs @@ -871,24 +871,6 @@ namespace CalamityMod.CalPlayer } } } - else if (draedonsHeart) - { - boostedRegen = true; - if (Player.lifeRegen > 0 && Player.statLife < actualMaxLife) - { - if (Main.rand.Next(30000) < Player.lifeRegenTime || Main.rand.NextBool(2)) - { - int regen = Dust.NewDust(Player.position, Player.width, Player.height, 107, 0f, 0f, 200, default, 1f); - Main.dust[regen].noGravity = true; - Main.dust[regen].fadeIn = 1.3f; - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 50f, 100f, 0.04f); - Main.dust[regen].velocity = velocity; - velocity.Normalize(); - velocity *= 34f; - Main.dust[regen].position = Player.Center - velocity; - } - } - } else if (photosynthesis) { boostedRegen = true; @@ -962,8 +944,8 @@ namespace CalamityMod.CalPlayer if (Player.statLife < actualMaxLife) { // The soft cap doesn't apply if the player is not moving and not using a weapon while having any of the following: - // Shiny Stone, Draedon's Heart, Cosmic Freeze buff from the Cosmic Discharge, Demonshade Armor, Photosynthesis Potion buff or The Camper. - bool noLifeRegenCap = (Player.shinyStone || draedonsHeart || cFreeze || shadeRegen || photosynthesis || camper) && + // Shiny Stone, Cosmic Freeze buff from the Cosmic Discharge, Demonshade Armor, Photosynthesis Potion buff or The Camper. + bool noLifeRegenCap = (Player.shinyStone || cFreeze || shadeRegen || photosynthesis || camper) && Player.StandingStill() && Player.itemAnimation == 0; if (!noLifeRegenCap) diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 6d898078cb..f2cf6b5144 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -172,8 +172,8 @@ namespace CalamityMod.CalPlayer { // player.rangedCrit already contains the crit stat of the held item, no need to grab it separately. // Don't store the base 4% because you're not removing it. - spiritOriginConvertedCrit = (int)(Player.GetCritChance() - 4); - Player.GetCritChance() = 4; + spiritOriginConvertedCrit = (int)(Player.GetTotalCritChance() - 4); + Player.GetCritChance() = -spiritOriginConvertedCrit; } if (Player.ActiveItem().type == ModContent.ItemType()) @@ -191,7 +191,7 @@ namespace CalamityMod.CalPlayer #region Revengeance Effects private void RevengeanceModeMiscEffects() { - if (CalamityWorld.revenge || BossRushEvent.BossRushActive) + if (CalamityWorld.revenge) { // Adjusts the life steal cap in rev/death float lifeStealCap = (CalamityWorld.malice || BossRushEvent.BossRushActive) ? 30f : CalamityWorld.death ? 45f : 60f; @@ -221,23 +221,16 @@ namespace CalamityMod.CalPlayer if (Player.hurtCooldowns[k] > immuneTimeLimit) Player.hurtCooldowns[k] = immuneTimeLimit; } - - // Adrenaline and Rage - if (CalamityWorld.revenge) - UpdateRippers(); } } - // If Revengeance Mode is not active, then set rippers to zero - else if (Player.whoAmI == Main.myPlayer) - { - rage = 0; - adrenaline = 0; - } + // Adrenaline and Rage + UpdateRippers(); } private void UpdateRippers() { + #region Rage // Figure out Rage's current duration based on boosts. if (rageBoostOne) RageDuration += RageDurationPerBooster; @@ -364,31 +357,37 @@ namespace CalamityMod.CalPlayer rageDiff -= rageMax / RageFadeTime; // Apply the rage change and cap rage in both directions. - rage += rageDiff; - if (rage < 0) - rage = 0; - - if (rage >= rageMax) + // Changes are only applied if the Rage mechanic is available. + if (RageEnabled) { - // If Rage is not active, it is capped at 100%. - if (!rageModeActive) - rage = rageMax; + rage += rageDiff; + if (rage < 0) + rage = 0; - // If using the Shattered Community, Rage is capped at 200% while it's active. - // This prevents infinitely stacking rage before a fight by standing on spikes/lava with a regen build or the Nurse handy. - else if (shatteredCommunity && rage >= 2f * rageMax) - rage = 2f * rageMax; - - // Play a sound when the Rage Meter is full - if (playFullRageSound) + if (rage >= rageMax) { - playFullRageSound = false; - SoundEngine.PlaySound(RageFilledSound, Player.position); - } - } - else - playFullRageSound = true; + // If Rage is not active, it is capped at 100%. + if (!rageModeActive) + rage = rageMax; + // If using the Shattered Community, Rage is capped at 200% while it's active. + // This prevents infinitely stacking rage before a fight by standing on spikes/lava with a regen build or the Nurse handy. + else if (shatteredCommunity && rage >= 2f * rageMax) + rage = 2f * rageMax; + + // Play a sound when the Rage Meter is full + if (playFullRageSound) + { + playFullRageSound = false; + SoundEngine.PlaySound(RageFilledSound, Player.position); + } + } + else + playFullRageSound = true; + } + #endregion + + #region Adrenaline // This is how much Adrenaline will be changed by this frame. float adrenalineDiff = 0; bool SCalAlive = NPC.AnyNPCs(ModContent.NPCType()); @@ -414,23 +413,28 @@ namespace CalamityMod.CalPlayer adrenalineDiff *= 0.67f; // Apply the adrenaline change and cap adrenaline in both directions. - adrenaline += adrenalineDiff; - if (adrenaline < 0) - adrenaline = 0; - - if (adrenaline >= adrenalineMax) + // Changes are only applied if the Adrenaline mechanic is available. + if (AdrenalineEnabled) { - adrenaline = adrenalineMax; + adrenaline += adrenalineDiff; + if (adrenaline < 0) + adrenaline = 0; - // Play a sound when the Adrenaline Meter is full - if (playFullAdrenalineSound) + if (adrenaline >= adrenalineMax) { - playFullAdrenalineSound = false; - SoundEngine.PlaySound(AdrenalineFilledSound, Player.position); + adrenaline = adrenalineMax; + + // Play a sound when the Adrenaline Meter is full + if (playFullAdrenalineSound) + { + playFullAdrenalineSound = false; + SoundEngine.PlaySound(AdrenalineFilledSound, Player.position); + } } + else + playFullAdrenalineSound = true; } - else - playFullAdrenalineSound = true; + #endregion } #endregion @@ -3682,13 +3686,6 @@ namespace CalamityMod.CalPlayer } } - // Draedon's Heart bonus - if (draedonsHeart) - { - if (Player.StandingStill() && Player.itemAnimation == 0) - Player.statDefense += (int)(Player.statDefense * 0.75); - } - // Endurance reductions EnduranceReductions(); diff --git a/Items/Accessories/DraedonsHeart.cs b/Items/Accessories/DraedonsHeart.cs index f026431b6c..6cc3fdcc72 100644 --- a/Items/Accessories/DraedonsHeart.cs +++ b/Items/Accessories/DraedonsHeart.cs @@ -3,18 +3,27 @@ using Terraria; using Terraria.ID; using Terraria.DataStructures; using Terraria.ModLoader; +using System.Collections.Generic; +using System.Linq; +using CalamityMod.World; namespace CalamityMod.Items.Accessories { public class DraedonsHeart : ModItem { + private const double ContactDamageReduction = 0.15D; + public override void SetStaticDefaults() { SacrificeTotal = 1; DisplayName.SetDefault("Draedon's Heart"); - Tooltip.SetDefault("Reduces the amount of defense damage you take by 50%\n" + - "Standing still regenerates your life quickly, reduces your damage by 50% and boosts your defense by 75%\n" + - "Nanomachines, son"); + Tooltip.SetDefault(@"15% reduced contact damage from enemies +Reduces defense damage taken by 50% +Replaces Adrenaline with the Nanomachines meter +Unlike Adrenaline, you lose no Nanomachines when you take damage, but it stops generating for 4 seconds +With full Nanomachines, press & to heal 300 health over 2 seconds +While healing, wings are disabled and your mobility is crippled +Nanomachines, son"); Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(5, 11)); } @@ -23,6 +32,7 @@ namespace CalamityMod.Items.Accessories Item.width = 52; Item.height = 68; Item.accessory = true; + Item.defense = 48; Item.rare = ItemRarityID.Red; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; Item.Calamity().customRarity = CalamityRarity.Violet; @@ -32,6 +42,29 @@ namespace CalamityMod.Items.Accessories { CalamityPlayer modPlayer = player.Calamity(); modPlayer.draedonsHeart = true; + modPlayer.contactDamageReduction += ContactDamageReduction; + } + + public override void ModifyTooltips(List list) + { + // The 3rd tooltip line "Replaces Adrenaline..." is replaced on Normal or Expert + TooltipLine nanomachineMeterLine = list.FirstOrDefault(x => x.Mod == "Terraria" && x.Name == "Tooltip2"); + if (nanomachineMeterLine != null && !CalamityWorld.revenge) + nanomachineMeterLine.Text = "Adds the Nanomachines meter"; + + // The 4th tooltip line "Unlike Adrenaline..." is replaced on Normal or Expert + TooltipLine doesntStopOnDamageLine = list.FirstOrDefault(x => x.Mod == "Terraria" && x.Name == "Tooltip3"); + if (doesntStopOnDamageLine != null && !CalamityWorld.revenge) + doesntStopOnDamageLine.Text = "Nanomachines generates over time when fighting bosses\nTaking damage stops its generation for 4 seconds"; + + // The 5th tooltip line "With full Nanomachines" has the & replaced with the hotkey. + string adrenKey = CalamityKeybinds.AdrenalineHotKey.TooltipHotkeyString(); + TooltipLine hotkeyLine = list.FirstOrDefault(x => x.Mod == "Terraria" && x.Name == "Tooltip4"); + if (hotkeyLine != null) + { + string tooltipWithHotkey = hotkeyLine.Text.Replace("&", adrenKey); + hotkeyLine.Text = tooltipWithHotkey; + } } } } diff --git a/Items/Accessories/ShatteredCommunity.cs b/Items/Accessories/ShatteredCommunity.cs index 2f9fb0e317..c1bbda5f7e 100644 --- a/Items/Accessories/ShatteredCommunity.cs +++ b/Items/Accessories/ShatteredCommunity.cs @@ -1,14 +1,16 @@ -using CalamityMod.CalPlayer; -using Microsoft.Xna.Framework; -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; +using System.Linq; using System.Text; +using CalamityMod.CalPlayer; +using CalamityMod.World; +using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; using Terraria.ModLoader.IO; -using Terraria.Audio; namespace CalamityMod.Items.Accessories { @@ -155,6 +157,11 @@ namespace CalamityMod.Items.Accessories // Stat tooltips are added dynamically. StringBuilder sb = new StringBuilder(256); + // Line 1: If not on Rev+, note that the accessory enables Rage. + TooltipLine rageOverTimeLine = tooltips.FirstOrDefault(x => x.Mod == "Terraria" && x.Name == "Tooltip1"); + if (rageOverTimeLine != null && !CalamityWorld.revenge) + rageOverTimeLine.Text = "Adds the Rage meter\n" + rageOverTimeLine.Text; + // Line 6: Current level sb.Append("Current level: "); sb.Append(level); diff --git a/UI/RipperUI.cs b/UI/RipperUI.cs index b751417d83..4af5ce45e3 100644 --- a/UI/RipperUI.cs +++ b/UI/RipperUI.cs @@ -96,10 +96,6 @@ namespace CalamityMod.UI public static void Draw(SpriteBatch spriteBatch, Player player) { - // If Revengeance isn't on, or Rage and Adrenaline are turned off, don't draw anything. - if (!CalamityWorld.revenge) - return; - // If for some reason either of the bars has been thrown into the corner (likely to 0,0 by default), put them at their default positions CheckGarbageCornerPos(); @@ -111,8 +107,10 @@ namespace CalamityMod.UI // Grab the ModPlayer object and then start drawing CalamityPlayer modPlayer = player.Calamity(); - DrawRageBar(spriteBatch, modPlayer); - DrawAdrenalineBar(spriteBatch, modPlayer); + if (modPlayer.RageEnabled) + DrawRageBar(spriteBatch, modPlayer); + if (modPlayer.AdrenalineEnabled) + DrawAdrenalineBar(spriteBatch, modPlayer); HandleMouseInteraction(modPlayer, rageBorderTex.Size(), adrenBorderTex.Size()); }