From 430ba4bcbe862bc2a8292467f9f34612214151d7 Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Wed, 17 Apr 2024 19:29:37 -0400 Subject: [PATCH] 1 - Reverted Fargo's based shield iframe exploit fix and replaced it with an actual bugfix instead of a rewrite. 2 - Made the application of all immunity frames consistent with vanilla rules. 3 - Added balancing constants and utility helper functions for all immunity frame calculations. 4 - Buffed many dodges, reflects, and other dodge-like effects to benefit from Cross Necklace like vanilla dodges. 5 - Permafrost's Concoction now is buffed by Cross Necklace. 6 - Significantly buffed the immunity frames granted by Spectral Veil and all reflects by making them consistent with vanilla. 7 - Significantly buffed the immunity frames granted by Ark line parries by making them consistent with vanilla. --- Balancing/BalancingConstants.cs | 12 ++ Buffs/StatBuffs/Encased.cs | 9 +- CalPlayer/CalamityPlayer.cs | 3 +- CalPlayer/CalamityPlayerDashEffects.cs | 4 +- CalPlayer/CalamityPlayerHitHurt.cs | 121 +++++++++--------- CalPlayer/CalamityPlayerMiscEffects.cs | 4 +- ILEditing/MechanicILChanges.cs | 3 +- Items/Accessories/GravistarSabaton.cs | 1 + Items/Accessories/PermafrostsConcoction.cs | 3 + Items/Accessories/SpectralVeil.cs | 6 +- .../Melee/ArkOfTheAncients_ParryHoldout.cs | 8 +- .../Melee/ArkOfTheCosmos_BlastAttack.cs | 4 +- .../Melee/ArkOfTheCosmos_ParryHoldout.cs | 8 +- .../Melee/ArkOfTheElements_ParryHoldout.cs | 8 +- .../Melee/BrokenBiomeBlade_AridGrandeur.cs | 6 +- .../Melee/BrokenBiomeBlade_DecaysRetort.cs | 5 +- Projectiles/Melee/Galaxia_AndromedasStride.cs | 4 +- Projectiles/Melee/Galaxia_PolarisGaze.cs | 12 +- .../MendedBiomeBlade_ExtantAbhorrence.cs | 4 +- .../MendedBiomeBlade_TrueAridGrandeur.cs | 5 +- .../MendedBiomeBlade_TrueDecaysRetort.cs | 11 +- .../Melee/PhosphorescentGauntletPunches.cs | 4 +- .../Melee/Spears/RedtideSpearProjectile.cs | 8 +- .../TrueArkOfTheAncients_ParryHoldout.cs | 8 +- .../Melee/TrueBiomeBlade_MercurialTides.cs | 4 +- .../Melee/TrueBiomeBlade_SanguineFury.cs | 12 +- Utilities/PlayerUtils.cs | 110 +++++++++++++++- 27 files changed, 291 insertions(+), 96 deletions(-) diff --git a/Balancing/BalancingConstants.cs b/Balancing/BalancingConstants.cs index cc2458beae..2bc76824c8 100644 --- a/Balancing/BalancingConstants.cs +++ b/Balancing/BalancingConstants.cs @@ -18,6 +18,18 @@ internal const float BalloonJumpSpeedBoost = 0.75f; #endregion + #region Immunity Frames + // Default immunity frame rules + internal const int VanillaDefaultIFrames = 40; + internal const int VanillaParryIFrames = 60; + internal const int VanillaDodgeIFrames = 80; + + // In vanilla, the Cross Necklace grants +40 iframes to all hits except for in PvP (where it does nothing) + // and Brand of the Inferno (where it only gives +30 instead). + internal const int CrossNecklaceIFrameBoost = 40; + internal const int CrossNecklaceIFrameBoost_Parry = 30; + #endregion + #region Dashes and Dodges // Dash cooldowns (in frames) internal const int UniversalDashCooldown = 30; diff --git a/Buffs/StatBuffs/Encased.cs b/Buffs/StatBuffs/Encased.cs index 25a9de731b..251d0489a8 100644 --- a/Buffs/StatBuffs/Encased.cs +++ b/Buffs/StatBuffs/Encased.cs @@ -1,4 +1,6 @@ -using Terraria; +using CalamityMod.Balancing; +using CalamityMod.Items.Accessories; +using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -20,7 +22,10 @@ namespace CalamityMod.Buffs.StatBuffs if (player.buffTime[buffIndex] == 2) { SoundEngine.PlaySound(SoundID.Item27, player.Center); - player.GiveIFrames(90, true); + + // 17APR2024: Ozzatron: Permafrost's Concoction gives true invulnerability to everything and is boosted by Cross Necklace. + int encasedIFrames = PermafrostsConcoction.EncasedIFrames + (player.longInvince ? BalancingConstants.CrossNecklaceIFrameBoost : 0); + player.GiveUniversalIFrames(encasedIFrames, true); } } } diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 8c7a662f4c..ab0614aa70 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -415,6 +415,7 @@ namespace CalamityMod.CalPlayer #region Energy Shields public bool HasAnyEnergyShield => roverDrive || lunicCorpsSet || ((pSoulArtifact && !profanedCrystal) || profanedCrystalBuffs) || sponge; + public bool freeDodgeFromShieldAbsorption = false; public bool drawnAnyShieldThisFrame = false; // TODO -- Some way to show the player their total shield points. @@ -2801,7 +2802,7 @@ namespace CalamityMod.CalPlayer Main.dust[dustIndex].noLight = true; } - spectralVeilImmunity = 45; + spectralVeilImmunity = SpectralVeil.VeilIFrames; } } } diff --git a/CalPlayer/CalamityPlayerDashEffects.cs b/CalPlayer/CalamityPlayerDashEffects.cs index 072d6a1070..302f69fc37 100644 --- a/CalPlayer/CalamityPlayerDashEffects.cs +++ b/CalPlayer/CalamityPlayerDashEffects.cs @@ -566,8 +566,10 @@ namespace CalamityMod.CalPlayer if (Player.whoAmI == Main.myPlayer) Player.ApplyDamageToNPC(n, (int)Damage, Knockback, hitDirection, false); + // 17APR2024: Ozzatron: Dash iframes are not boosted by Cross Necklace at all and are fixed. n.Calamity().dashImmunityTime[Player.whoAmI] = NPCImmuneTime; - Player.GiveIFrames(PlayerImmuneTime, false); + Player.GiveUniversalIFrames(PlayerImmuneTime, false); + totalHurtNPCs++; break; } diff --git a/CalPlayer/CalamityPlayerHitHurt.cs b/CalPlayer/CalamityPlayerHitHurt.cs index ba60ac2d1c..f5c320f416 100644 --- a/CalPlayer/CalamityPlayerHitHurt.cs +++ b/CalPlayer/CalamityPlayerHitHurt.cs @@ -54,7 +54,9 @@ namespace CalamityMod.CalPlayer #region Dodges private void SpectralVeilDodge() { - Player.GiveIFrames(spectralVeilImmunity, true); //Set immunity before setting this variable to 0 + // 17APR2024: Ozzatron: Spectral Veil counts as a dodge. It uses vanilla dodge iframes and benefits from Cross Necklace. + int spectralVeilIFrames = spectralVeilImmunity + (Player.longInvince ? BalancingConstants.CrossNecklaceIFrameBoost : 0); + Player.GiveUniversalIFrames(spectralVeilIFrames, true); rogueStealth = rogueStealthMax; spectralVeilImmunity = 0; @@ -79,7 +81,10 @@ namespace CalamityMod.CalPlayer private void GodSlayerDodge() { - Player.GiveIFrames(Player.longInvince ? 100 : 60, true); + // 17APR2024: Ozzatron: God Slayer Dodge is a dodge. It uses vanilla dodge iframes and benefits from Cross Necklace. + int godSlayerDodgeIFrames = Player.ComputeDodgeIFrames(); + Player.GiveUniversalIFrames(godSlayerDodgeIFrames, true); + SoundEngine.PlaySound(SoundID.Item67, Player.Center); for (int j = 0; j < 30; j++) @@ -114,7 +119,9 @@ namespace CalamityMod.CalPlayer Player.AddCooldown(Cooldowns.CounterScarf.ID, duration); } - Player.GiveIFrames(Player.longInvince ? 100 : 60, true); + // 17APR2024: Ozzatron: Counter Scarf is a dodge. It uses vanilla dodge iframes and benefits from Cross Necklace. + int counterScarfIFrames = Player.ComputeDodgeIFrames(); + Player.GiveUniversalIFrames(counterScarfIFrames, true); for (int j = 0; j < 100; j++) { @@ -151,10 +158,10 @@ namespace CalamityMod.CalPlayer int cooldownDuration = (int)MathHelper.Lerp(BalancingConstants.MirrorDodgeCooldownMin, BalancingConstants.MirrorDodgeCooldownMax, cooldownDurationScalar); Player.AddCooldown(GlobalDodge.ID, cooldownDuration, true, "abyssmirror"); - // TODO -- why is this here? - Player.noKnockback = true; + // 17APR2024: Ozzatron: Abyssal Mirror is a dodge. It uses vanilla dodge iframes and benefits from Cross Necklace. + int abyssalMirrorDodgeIFrames = Player.ComputeDodgeIFrames(); + Player.GiveUniversalIFrames(abyssalMirrorDodgeIFrames, true); - Player.GiveIFrames(Player.longInvince ? 100 : 60, true); rogueStealth += 0.5f; SoundEngine.PlaySound(SilvaHeadSummon.ActivationSound, Player.Center); @@ -195,10 +202,10 @@ namespace CalamityMod.CalPlayer int cooldownDuration = (int)MathHelper.Lerp(BalancingConstants.MirrorDodgeCooldownMin, BalancingConstants.MirrorDodgeCooldownMax, cooldownDurationScalar); Player.AddCooldown(GlobalDodge.ID, cooldownDuration, true, "eclipsemirror"); - // TODO -- why is this here? - Player.noKnockback = true; + // 17APR2024: Ozzatron: Eclipse Mirror is a dodge. It uses vanilla dodge iframes and benefits from Cross Necklace. + int eclipseMirrorDodgeIFrames = Player.ComputeDodgeIFrames(); + Player.GiveUniversalIFrames(eclipseMirrorDodgeIFrames, true); - Player.GiveIFrames(Player.longInvince ? 100 : 60, true); rogueStealth += 0.5f; SoundEngine.PlaySound(SoundID.Item68, Player.Center); @@ -915,7 +922,10 @@ namespace CalamityMod.CalPlayer proj.velocity *= -2f; proj.extraUpdates += 1; proj.penetrate = 1; - Player.GiveIFrames(20, false); + + // 17APR2024: Ozzatron: The Evolution is a reflect which also functions as a dodge. It uses vanilla dodge iframes and benefits from Cross Necklace. + int evolutionIFrames = Player.ComputeReflectIFrames(); + Player.GiveUniversalIFrames(evolutionIFrames, true); modifiers.SetMaxDamage(1); evolutionLifeRegenCounter = 300; @@ -1420,7 +1430,10 @@ namespace CalamityMod.CalPlayer proj.velocity *= -1f; proj.damage = (int)Player.GetBestClassDamage().ApplyTo(proj.damage * 8); proj.penetrate = 1; - Player.GiveIFrames(20, false); + + // 17APR2024: Ozzatron: The Transformer is a reflect which also functions as a dodge. It uses vanilla dodge iframes and benefits from Cross Necklace. + int transformerIFrames = Player.ComputeReflectIFrames(); + Player.GiveUniversalIFrames(transformerIFrames, true); } } @@ -1445,7 +1458,10 @@ namespace CalamityMod.CalPlayer proj.friendly = true; proj.velocity *= -1f; proj.penetrate = 1; - Player.GiveIFrames(20, false); + + // 17APR2024: Ozzatron: The Daedalus Reflect set bonus also functions as a dodge. It uses vanilla dodge iframes and benefits from Cross Necklace. + int daedalusReflectIFrames = Player.ComputeReflectIFrames(); + Player.GiveUniversalIFrames(daedalusReflectIFrames, true); int cooldownDuration = (int)MathHelper.Lerp(BalancingConstants.DaedalusReflectCooldownMin, BalancingConstants.DaedalusReflectCooldownMax, cooldownDurationScalar); Player.AddCooldown(GlobalDodge.ID, cooldownDuration); @@ -1467,6 +1483,17 @@ namespace CalamityMod.CalPlayer if (info.Damage < 1 /* || (godSlayerDamage && info.Damage <= 80) */) return true; + // If this hit was marked to be completely ignored due to shield absorption, then process Adrenaline changes and ignore it. + if (freeDodgeFromShieldAbsorption) + { + freeDodgeFromShieldAbsorption = false; + + // 20FEB2024: Ozzatron: Hits fully absorbed by shields remove half of your current Adrenaline. + // If using Draedon's Heart, it pauses for half the typical duration. + LoseAdrenalineOnHurt(info, true); + return true; + } + // Gravistar Sabaton fall ram gives you a free dodge as long as you're slamming through NPCs // This also strikes the NPCs as a side effect if (gSabatonFalling) @@ -1488,8 +1515,11 @@ namespace CalamityMod.CalPlayer Projectile.NewProjectile(Player.GetSource_FromThis(), n.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0, Main.myPlayer); + // 17APR2024: Ozzatron: Gravistar Sabaton gives iframes when passing through enemies for projectile safety. + // This is a fixed and intentionally very low number of iframes, and is not boosted by Cross Necklace. n.Calamity().dashImmunityTime[Player.whoAmI] = 4; - Player.GiveIFrames(5, false); + Player.GiveUniversalIFrames(GravistarSabaton.PassthroughIFrames, false); + return true; } } @@ -1668,8 +1698,12 @@ namespace CalamityMod.CalPlayer { if (!Player.HasCooldown(ParryCooldown.ID)) { - Player.GiveIFrames(60, true); + // 17APR2024: Ozzatron: Blazing Core is a parry. It uses vanilla parry iframes and benefits from Cross Necklace. + int blazingCoreParryIFrames = Player.ComputeParryIFrames(); + Player.GiveUniversalIFrames(blazingCoreParryIFrames, true); + blazingCoreEmpoweredParry = true; + modifiers.SetMaxDamage(1); //ONLY REDUCE DAMAGE IF NOT ON COOLDOWN modifiers.DisableSound(); //prevents hurt sound from playing, had no idea this was a thing } @@ -1688,8 +1722,12 @@ namespace CalamityMod.CalPlayer { if (!Player.HasCooldown(ParryCooldown.ID)) { - Player.GiveIFrames(60, true); + // 17APR2024: Ozzatron: Flame-Licked Shell is a parry. It uses vanilla parry iframes and benefits from Cross Necklace. + int flameLickedShellParryIFrames = Player.ComputeParryIFrames(); + Player.GiveUniversalIFrames(flameLickedShellParryIFrames, true); + flameLickedShellEmpoweredParry = true; + modifiers.FinalDamage *= 0.1f; //90% dr modifiers.DisableSound(); } @@ -1872,8 +1910,9 @@ namespace CalamityMod.CalPlayer Rectangle location = new Rectangle((int)Player.position.X, (int)Player.position.Y - 16, Player.width, Player.height); CombatText.NewText(location, Color.LightBlue, Language.GetTextValue(shieldDamageText)); - // Give the player iframes for taking the a shield hit, regardless of whether or not the shields broke - Player.GiveIFrames(Player.longInvince ? 100 : 60, true); + // Give the player iframes for taking a shield hit, regardless of whether or not the shields broke. + int shieldHitIFrames = Player.ComputeHitIFrames(info); + Player.GiveIFrames(info.CooldownCounter, shieldHitIFrames, true); // Spawn particles when hit with the shields up, regardless of whether or not the shields broke. // More particles spawn if a shield broke. @@ -1915,7 +1954,7 @@ namespace CalamityMod.CalPlayer masterChefDurabilityCD.timeLeft = LunicCorpsShieldDurability; // Update PSA/PSC durability on the cooldown rack - if ((pSoulArtifact && (!profanedCrystal || profanedCrystalBuffs)) && cooldowns.TryGetValue(Cooldowns.ProfanedSoulShield.ID, out var profanedSoulDurabilityCD)) + if (pSoulArtifact && (!profanedCrystal || profanedCrystalBuffs) && cooldowns.TryGetValue(Cooldowns.ProfanedSoulShield.ID, out var profanedSoulDurabilityCD)) profanedSoulDurabilityCD.timeLeft = pSoulShieldDurability; // Update Sponge durability on the cooldown rack. @@ -1944,20 +1983,12 @@ namespace CalamityMod.CalPlayer } // If the shields completely absorbed the hit, then delete the hit using reflection. - // 17APR2024: Ozzatron: Use Fargo's hit-nulling methodology instead of a Free Dodge so improper iframes are not granted if (shieldsFullyAbsorbedHit) { - info.NullifyHit(); - - // Give the appropriate immunity frames. - Player.GiveIFrames(info.CooldownCounter, Player.longInvince ? 100 : 60, true); + freeDodgeFromShieldAbsorption = true; // Cancel defense damage, if it was going to occur this frame. nextHitDealsDefenseDamage = false; - - // 20FEB2024: Ozzatron: Hits fully absorbed by shields remove half of your current Adrenaline. - // If using Draedon's Heart, it pauses for half the typical duration. - LoseAdrenalineOnHurt(info, true); } } @@ -2372,40 +2403,8 @@ namespace CalamityMod.CalPlayer if (Player.whoAmI == Main.myPlayer) { - int iFramesToAdd = 0; - if (godSlayerThrowing && hurtInfo.Damage > 80) - iFramesToAdd += 30; - if (statigelSet && hurtInfo.Damage > 100) - iFramesToAdd += 30; - - // Deific Amulet provides 10 to 40 bonus immunity frames when you get hit which scale with your missing health. - // If you only take 1 damage, you get 5 iframes. - // This effect is inherited by Rampart of Deities. - if (dAmulet) - { - if (hurtInfo.Damage > 1) - { - float lifeRatio = (float)Player.statLife / Player.statLifeMax2; - float iframeEffectivenessRatio = Utils.GetLerpValue(1.0f, 0.25f, lifeRatio, true); - - iFramesToAdd += (int)(iframeEffectivenessRatio * DeificAmulet.MaxBonusIFrames); - } - else - iFramesToAdd += 5; - } - - // Ozzatron 20FEB2024: Moved extra iframes from Seraph Tracers to Rampart of Deities to counteract its loss of Charm of Myths - // This stacks with the above Deific Amulet effect - if (rampartOfDeities && hurtInfo.Damage > 200) - iFramesToAdd += 30; - - if (fabsolVodka) - { - if (hurtInfo.Damage == 1) - iFramesToAdd += 5; - else - iFramesToAdd += 10; - } + // Add extra iframes on hit based on various Calamity effects. + int iFramesToAdd = Player.GetExtraHitIFrames(hurtInfo); // Give bonus immunity frames based on the type of damage dealt if (hurtInfo.CooldownCounter != -1) diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index e969f0e30c..7f57930ad9 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -1656,8 +1656,10 @@ namespace CalamityMod.CalPlayer if (tarraThrowing) { // The iframes from the evasion are disabled by dodge disabling effects. + // 17APR2024: Ozzatron: Tarragon Immunity is meant to be a full invulnerability effect, so universal iframes are granted throughout its duration. + // It has no interaction with Cross Necklace. if (tarragonImmunity && !disableAllDodges) - Player.GiveIFrames(2, true); + Player.GiveUniversalIFrames(2, true); if (tarraThrowingCrits >= 50) { diff --git a/ILEditing/MechanicILChanges.cs b/ILEditing/MechanicILChanges.cs index e5207bc4e2..de1419da6f 100644 --- a/ILEditing/MechanicILChanges.cs +++ b/ILEditing/MechanicILChanges.cs @@ -78,7 +78,8 @@ namespace CalamityMod.ILEditing cursor.Remove(); // Emit a delegate which calls the Calamity utility to consistently provide iframes. - cursor.EmitDelegate>((p, frames) => CalamityUtils.GiveIFrames(p, frames, false)); + // 17APR2024: Ozzatron: Consistent shield slam iframes are not boosted by Cross Necklace at all and are fixed. + cursor.EmitDelegate>((p, frames) => CalamityUtils.GiveUniversalIFrames(p, frames, false)); } private static readonly Func CalamityDashEquipped = (Player p) => p.Calamity().HasCustomDash ? 1 : 0; diff --git a/Items/Accessories/GravistarSabaton.cs b/Items/Accessories/GravistarSabaton.cs index 2c85b5f2c1..75426f282b 100644 --- a/Items/Accessories/GravistarSabaton.cs +++ b/Items/Accessories/GravistarSabaton.cs @@ -11,6 +11,7 @@ namespace CalamityMod.Items.Accessories public static readonly int PassthroughDamage = 150; public static readonly int SlamDamage = 300; + public static readonly int PassthroughIFrames = 5; public override void SetDefaults() { diff --git a/Items/Accessories/PermafrostsConcoction.cs b/Items/Accessories/PermafrostsConcoction.cs index bba253f32d..281ad986d6 100644 --- a/Items/Accessories/PermafrostsConcoction.cs +++ b/Items/Accessories/PermafrostsConcoction.cs @@ -6,6 +6,9 @@ namespace CalamityMod.Items.Accessories { public class PermafrostsConcoction : ModItem, ILocalizedModType { + // Boosted by Cross Necklace. + internal static readonly int EncasedIFrames = 90; + public new string LocalizationCategory => "Items.Accessories"; public override void SetDefaults() { diff --git a/Items/Accessories/SpectralVeil.cs b/Items/Accessories/SpectralVeil.cs index 5fe959bfda..f09b8a8ee7 100644 --- a/Items/Accessories/SpectralVeil.cs +++ b/Items/Accessories/SpectralVeil.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; +using CalamityMod.Balancing; using CalamityMod.Rarities; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -10,6 +10,10 @@ namespace CalamityMod.Items.Accessories { public new string LocalizationCategory => "Items.Accessories"; public const float TeleportRange = 845f; + + // Boosted by Cross Necklace. + internal static readonly int VeilIFrames = BalancingConstants.VanillaDodgeIFrames; + public override void SetDefaults() { Item.width = 30; diff --git a/Projectiles/Melee/ArkOfTheAncients_ParryHoldout.cs b/Projectiles/Melee/ArkOfTheAncients_ParryHoldout.cs index cdb9e452ff..af6256b14a 100644 --- a/Projectiles/Melee/ArkOfTheAncients_ParryHoldout.cs +++ b/Projectiles/Melee/ArkOfTheAncients_ParryHoldout.cs @@ -65,9 +65,13 @@ namespace CalamityMod.Projectiles.Melee GeneralParryEffects(); - //only get iframes if the enemy has contact damage :) + // 17APR2024: Ozzatron: Ark of the Ancients is a parry. It uses vanilla parry iframes and benefits from Cross Necklace. + // However, iframes are only granted if the target has contact damage. This means it won't work on Providence. Too bad. I have no sympathy for you if you are using this weapon line. if (target.damage > 0) - Owner.GiveIFrames(35); + { + int arkParryIFrames = Owner.ComputeParryIFrames(); + Owner.GiveUniversalIFrames(arkParryIFrames, false); + } Vector2 particleOrigin = target.Hitbox.Size().Length() < 140 ? target.Center : Projectile.Center + Projectile.rotation.ToRotationVector2() * 60f; Particle spark = new GenericSparkle(particleOrigin, Vector2.Zero, Color.White, Color.HotPink, 1.2f, 35, 0.1f, 2); diff --git a/Projectiles/Melee/ArkOfTheCosmos_BlastAttack.cs b/Projectiles/Melee/ArkOfTheCosmos_BlastAttack.cs index 6bbe56582f..e2b1ac7c17 100644 --- a/Projectiles/Melee/ArkOfTheCosmos_BlastAttack.cs +++ b/Projectiles/Melee/ArkOfTheCosmos_BlastAttack.cs @@ -121,9 +121,9 @@ namespace CalamityMod.Projectiles.Melee //Check for the up arrow once more so if the player has good reflexes they can avoid the dash. Gives them more control if (Owner.controlUp && Charge >= 5) { - Owner.GiveIFrames(ArkoftheCosmos.DashIframes); + // 17APR2024: Ozzatron: Dash iframes are not boosted by Cross Necklace at all and are fixed. + Owner.GiveUniversalIFrames(ArkoftheCosmos.DashIframes); Dashing = true; - } for (int i = 0; i < 20; i++) diff --git a/Projectiles/Melee/ArkOfTheCosmos_ParryHoldout.cs b/Projectiles/Melee/ArkOfTheCosmos_ParryHoldout.cs index fca0947b30..3e652c4683 100644 --- a/Projectiles/Melee/ArkOfTheCosmos_ParryHoldout.cs +++ b/Projectiles/Melee/ArkOfTheCosmos_ParryHoldout.cs @@ -82,9 +82,13 @@ namespace CalamityMod.Projectiles.Melee GeneralParryEffects(); - //only get iframes if the enemy has contact damage :) + // 17APR2024: Ozzatron: Ark of the Cosmos is a parry. It uses vanilla parry iframes and benefits from Cross Necklace. + // However, iframes are only granted if the target has contact damage. This means it won't work on Providence. Too bad. I have no sympathy for you if you are using this weapon line. if (target.damage > 0) - Owner.GiveIFrames(35); + { + int arkParryIFrames = Owner.ComputeParryIFrames(); + Owner.GiveUniversalIFrames(arkParryIFrames, false); + } Vector2 particleOrigin = target.Hitbox.Size().Length() < 140 ? target.Center : Projectile.Center + Projectile.rotation.ToRotationVector2() * 60f; Particle spark = new GenericSparkle(particleOrigin, Vector2.Zero, Color.White, Color.HotPink, 1.2f, 35, 0.1f, 2); diff --git a/Projectiles/Melee/ArkOfTheElements_ParryHoldout.cs b/Projectiles/Melee/ArkOfTheElements_ParryHoldout.cs index a9049e3f6f..d2d6ff0273 100644 --- a/Projectiles/Melee/ArkOfTheElements_ParryHoldout.cs +++ b/Projectiles/Melee/ArkOfTheElements_ParryHoldout.cs @@ -82,9 +82,13 @@ namespace CalamityMod.Projectiles.Melee GeneralParryEffects(); - //only get iframes if the enemy has contact damage :) + // 17APR2024: Ozzatron: Ark of the Elements is a parry. It uses vanilla parry iframes and benefits from Cross Necklace. + // However, iframes are only granted if the target has contact damage. This means it won't work on Providence. Too bad. I have no sympathy for you if you are using this weapon line. if (target.damage > 0) - Owner.GiveIFrames(35); + { + int arkParryIFrames = Owner.ComputeParryIFrames(); + Owner.GiveUniversalIFrames(arkParryIFrames, false); + } Vector2 particleOrigin = target.Hitbox.Size().Length() < 140 ? target.Center : Projectile.Center + Projectile.rotation.ToRotationVector2() * 60f; Particle spark = new GenericSparkle(particleOrigin, Vector2.Zero, Color.White, Color.HotPink, 1.2f, 35, 0.1f, 2); diff --git a/Projectiles/Melee/BrokenBiomeBlade_AridGrandeur.cs b/Projectiles/Melee/BrokenBiomeBlade_AridGrandeur.cs index 107ac41320..52e1b475a3 100644 --- a/Projectiles/Melee/BrokenBiomeBlade_AridGrandeur.cs +++ b/Projectiles/Melee/BrokenBiomeBlade_AridGrandeur.cs @@ -182,7 +182,11 @@ namespace CalamityMod.Projectiles.Melee Shred += 62; //Augment the shredspeed if (Owner.velocity.Y > 0) Owner.velocity.Y = -2f; //Get "stuck" into the enemy partly - Owner.GiveIFrames(BrokenBiomeBlade.HotAttunement_ShredIFrames); // i framez. + + // 17APR2024: Ozzatron: Broken Biome Blade's pogo gives iframes when striking enemies in a similar manner to a bonk dash. + // This is a fixed and intentionally very low number of iframes, and is not boosted by Cross Necklace. + Owner.GiveUniversalIFrames(BrokenBiomeBlade.HotAttunement_ShredIFrames); + PogoCooldown = 20; } } diff --git a/Projectiles/Melee/BrokenBiomeBlade_DecaysRetort.cs b/Projectiles/Melee/BrokenBiomeBlade_DecaysRetort.cs index 270fc9796e..805df34b78 100644 --- a/Projectiles/Melee/BrokenBiomeBlade_DecaysRetort.cs +++ b/Projectiles/Melee/BrokenBiomeBlade_DecaysRetort.cs @@ -113,7 +113,10 @@ namespace CalamityMod.Projectiles.Melee bounceStrength *= Owner.velocity.Y == 0 ? 0.2f : 1f; //Reduce the bounce if the player is on the ground Owner.velocity = -direction.SafeNormalize(Vector2.Zero) * MathHelper.Clamp(bounceStrength, 0f, 22f); CanBounce = 0f; - Owner.GiveIFrames(BrokenBiomeBlade.EvilAttunement_BounceIFrames); // i frames for free! + + // 17APR2024: Ozzatron: Broken Biome Blade's lunge gives iframes when striking enemies in a similar manner to a bonk dash. + // This is a fixed and intentionally very low number of iframes, and is not boosted by Cross Necklace. + Owner.GiveUniversalIFrames(BrokenBiomeBlade.EvilAttunement_BounceIFrames); } public override bool PreDraw(ref Color lightColor) diff --git a/Projectiles/Melee/Galaxia_AndromedasStride.cs b/Projectiles/Melee/Galaxia_AndromedasStride.cs index 4dee359b04..63dde30024 100644 --- a/Projectiles/Melee/Galaxia_AndromedasStride.cs +++ b/Projectiles/Melee/Galaxia_AndromedasStride.cs @@ -261,7 +261,9 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - Owner.GiveIFrames(FourSeasonsGalaxia.AndromedaAttunement_DashHitIFrames); + // 17APR2024: Ozzatron: Galaxia's dash gives iframes when striking enemies in a similar manner to a ram dash. + // This is a fixed and intentionally very low number of iframes, and is not boosted by Cross Necklace. + Owner.GiveUniversalIFrames(FourSeasonsGalaxia.AndromedaAttunement_DashHitIFrames); } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) diff --git a/Projectiles/Melee/Galaxia_PolarisGaze.cs b/Projectiles/Melee/Galaxia_PolarisGaze.cs index 0f0d6f1402..fc1201ae05 100644 --- a/Projectiles/Melee/Galaxia_PolarisGaze.cs +++ b/Projectiles/Melee/Galaxia_PolarisGaze.cs @@ -82,7 +82,11 @@ namespace CalamityMod.Projectiles.Melee Dashing = true; DashStart = Owner.Center; Wheel.timeLeft = 60; - Owner.GiveIFrames(FourSeasonsGalaxia.PolarisAttunement_SlashIFrames); + + // 17APR2024: Ozzatron: Galaxia's spiral gives iframes when striking enemies in a similar manner to a ram dash. + // This is a fixed and intentionally very low number of iframes, and is not boosted by Cross Necklace. + Owner.GiveUniversalIFrames(FourSeasonsGalaxia.PolarisAttunement_SlashIFrames); + break; } } @@ -269,7 +273,11 @@ namespace CalamityMod.Projectiles.Melee Shred += 80; //Augment the shredspeed if (Owner.velocity.Y > 0) Owner.velocity.Y = -2f; //Get "stuck" into the enemy partly - Owner.GiveIFrames(FourSeasonsGalaxia.PolarisAttunement_ShredIFrames); // i framez. + + // 17APR2024: Ozzatron: Galaxia's pogo gives iframes when striking enemies in a similar manner to a bonk dash. + // This is a fixed and intentionally very low number of iframes, and is not boosted by Cross Necklace. + Owner.GiveUniversalIFrames(FourSeasonsGalaxia.PolarisAttunement_ShredIFrames); + HitChargeCooldown = 20; } } diff --git a/Projectiles/Melee/MendedBiomeBlade_ExtantAbhorrence.cs b/Projectiles/Melee/MendedBiomeBlade_ExtantAbhorrence.cs index 898512a111..54251e3ace 100644 --- a/Projectiles/Melee/MendedBiomeBlade_ExtantAbhorrence.cs +++ b/Projectiles/Melee/MendedBiomeBlade_ExtantAbhorrence.cs @@ -235,7 +235,9 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - Owner.GiveIFrames(TrueBiomeBlade.AstralAttunement_DashHitIFrames); + // 17APR2024: Ozzatron: Biome Blade's astral slam gives iframes when striking enemies in a similar manner to a ram dash. + // This is a fixed and intentionally very low number of iframes, and is not boosted by Cross Necklace. + Owner.GiveUniversalIFrames(TrueBiomeBlade.AstralAttunement_DashHitIFrames); } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) diff --git a/Projectiles/Melee/MendedBiomeBlade_TrueAridGrandeur.cs b/Projectiles/Melee/MendedBiomeBlade_TrueAridGrandeur.cs index 6962226acb..f5e092058f 100644 --- a/Projectiles/Melee/MendedBiomeBlade_TrueAridGrandeur.cs +++ b/Projectiles/Melee/MendedBiomeBlade_TrueAridGrandeur.cs @@ -202,7 +202,10 @@ namespace CalamityMod.Projectiles.Melee Shred += 62; //Augment the shredspeed if (Owner.velocity.Y > 0) Owner.velocity.Y = -2f; //Get "stuck" into the enemy partly - Owner.GiveIFrames(TrueBiomeBlade.HotAttunement_ShredIFrames); // i framez. Do 5 iframes even matter? idk but you get a lot of em so lol... + + // 17APR2024: Ozzatron: Biome Blade's pogo gives iframes when striking enemies in a similar manner to a bonk dash. + // This is a fixed and intentionally very low number of iframes, and is not boosted by Cross Necklace. + Owner.GiveUniversalIFrames(TrueBiomeBlade.HotAttunement_ShredIFrames); PogoCooldown = 20; } } diff --git a/Projectiles/Melee/MendedBiomeBlade_TrueDecaysRetort.cs b/Projectiles/Melee/MendedBiomeBlade_TrueDecaysRetort.cs index df30ba3975..43accf8d45 100644 --- a/Projectiles/Melee/MendedBiomeBlade_TrueDecaysRetort.cs +++ b/Projectiles/Melee/MendedBiomeBlade_TrueDecaysRetort.cs @@ -132,7 +132,10 @@ namespace CalamityMod.Projectiles.Melee Owner.Calamity().LungingDown = true; PowerLungeStart = Owner.Center; dashTimer = 1f; - Owner.GiveIFrames(TrueBiomeBlade.EvilAttunement_SlashIFrames); + + // 17APR2024: Ozzatron: Biome Blade's lunge gives iframes when striking enemies in a similar manner to a ram dash. + // This is a fixed and intentionally very low number of iframes, and is not boosted by Cross Necklace. + Owner.GiveUniversalIFrames(TrueBiomeBlade.EvilAttunement_SlashIFrames); } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => OnHitEffects(Main.player[Projectile.owner].moonLeech); @@ -160,7 +163,11 @@ namespace CalamityMod.Projectiles.Melee bounceStrength *= Owner.velocity.Y == 0 ? 0.2f : 1f; //Reduce the bounce if the player is on the ground Owner.velocity = -direction.SafeNormalize(Vector2.Zero) * MathHelper.Clamp(bounceStrength, 0f, 22f); CanBounce = 0f; - Owner.GiveIFrames(TrueBiomeBlade.EvilAttunement_BounceIFrames); // i frames for free! + + // 17APR2024: Ozzatron: Biome Blade's bounce gives iframes when striking enemies in a similar manner to a bonk dash. + // This is a fixed and intentionally very low number of iframes, and is not boosted by Cross Necklace. + Owner.GiveUniversalIFrames(TrueBiomeBlade.EvilAttunement_BounceIFrames); + if (Owner.whoAmI == Main.myPlayer) { if (Owner.HeldItem.ModItem is TrueBiomeBlade sword) diff --git a/Projectiles/Melee/PhosphorescentGauntletPunches.cs b/Projectiles/Melee/PhosphorescentGauntletPunches.cs index 61eff43989..7a9214bfd4 100644 --- a/Projectiles/Melee/PhosphorescentGauntletPunches.cs +++ b/Projectiles/Melee/PhosphorescentGauntletPunches.cs @@ -73,7 +73,9 @@ namespace CalamityMod.Projectiles.Melee internal void ReelBack() { - Owner.GiveIFrames(PhosphorescentGauntlet.OnHitIFrames); + // 17APR2024: Ozzatron: Phosphorescent Gauntlet gives iframes when striking enemies in a similar manner to a bonk dash. + // This is a fixed and intentionally very low number of iframes, and is not boosted by Cross Necklace. + Owner.GiveUniversalIFrames(PhosphorescentGauntlet.OnHitIFrames); // Create some visual effects. if (!Main.dedServ) diff --git a/Projectiles/Melee/Spears/RedtideSpearProjectile.cs b/Projectiles/Melee/Spears/RedtideSpearProjectile.cs index 10c628b7f9..b887c914cc 100644 --- a/Projectiles/Melee/Spears/RedtideSpearProjectile.cs +++ b/Projectiles/Melee/Spears/RedtideSpearProjectile.cs @@ -307,9 +307,13 @@ namespace CalamityMod.Projectiles.Melee.Spears target.AddBuff(BuffID.Poisoned, 180); - //Give a sliver of iframes to the player so its safer to ram into hordes (which is fun and should be encouraged) if (CurrentAttackState == AttackState.RunAttack) - Owner.GiveIFrames(5); + { + // 17APR2024: Ozzatron: Redtide Spear's charge gives iframes when striking enemies in a similar manner to a ram dash. + // This is a fixed and intentionally very low number of iframes, and is not boosted by Cross Necklace. + int redtideRamIFrames = 5; + Owner.GiveUniversalIFrames(redtideRamIFrames); + } } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) diff --git a/Projectiles/Melee/TrueArkOfTheAncients_ParryHoldout.cs b/Projectiles/Melee/TrueArkOfTheAncients_ParryHoldout.cs index 63ca3d30d8..1bd5336742 100644 --- a/Projectiles/Melee/TrueArkOfTheAncients_ParryHoldout.cs +++ b/Projectiles/Melee/TrueArkOfTheAncients_ParryHoldout.cs @@ -65,9 +65,13 @@ namespace CalamityMod.Projectiles.Melee GeneralParryEffects(); - //only get iframes if the enemy has contact damage :) + // 17APR2024: Ozzatron: True Ark of the Ancients is a parry. It uses vanilla parry iframes and benefits from Cross Necklace. + // However, iframes are only granted if the target has contact damage. This means it won't work on Providence. Too bad. I have no sympathy for you if you are using this weapon line. if (target.damage > 0) - Owner.GiveIFrames(35); + { + int arkParryIFrames = Owner.ComputeParryIFrames(); + Owner.GiveUniversalIFrames(arkParryIFrames, false); + } Vector2 particleOrigin = target.Hitbox.Size().Length() < 140 ? target.Center : Projectile.Center + Projectile.rotation.ToRotationVector2() * 60f; Particle spark = new GenericSparkle(particleOrigin, Vector2.Zero, Color.White, Color.HotPink, 1.2f, 35, 0.1f, 2); diff --git a/Projectiles/Melee/TrueBiomeBlade_MercurialTides.cs b/Projectiles/Melee/TrueBiomeBlade_MercurialTides.cs index 24dafd7d89..a0183dbc9b 100644 --- a/Projectiles/Melee/TrueBiomeBlade_MercurialTides.cs +++ b/Projectiles/Melee/TrueBiomeBlade_MercurialTides.cs @@ -234,7 +234,9 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - Owner.GiveIFrames(OmegaBiomeBlade.ShockwaveAttunement_DashHitIFrames); + // 17APR2024: Ozzatron: True Biome Blade's shockwave slam gives iframes when striking enemies in a similar manner to a ram dash. + // This is a fixed and intentionally very low number of iframes, and is not boosted by Cross Necklace. + Owner.GiveUniversalIFrames(OmegaBiomeBlade.ShockwaveAttunement_DashHitIFrames); } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) diff --git a/Projectiles/Melee/TrueBiomeBlade_SanguineFury.cs b/Projectiles/Melee/TrueBiomeBlade_SanguineFury.cs index 518562598a..e7b182dc10 100644 --- a/Projectiles/Melee/TrueBiomeBlade_SanguineFury.cs +++ b/Projectiles/Melee/TrueBiomeBlade_SanguineFury.cs @@ -116,7 +116,11 @@ namespace CalamityMod.Projectiles.Melee Dashing = true; DashStart = Owner.Center; Wheel.timeLeft = 60; - Owner.GiveIFrames(OmegaBiomeBlade.SuperPogoAttunement_SlashIFrames); + + // 17APR2024: Ozzatron: True Biome Blade's pogo gives iframes when striking enemies in a similar manner to a bonk dash. + // This is a fixed and intentionally very low number of iframes, and is not boosted by Cross Necklace. + Owner.GiveUniversalIFrames(OmegaBiomeBlade.SuperPogoAttunement_SlashIFrames); + break; } } @@ -256,7 +260,11 @@ namespace CalamityMod.Projectiles.Melee Shred += 62; //Augment the shredspeed if (Owner.velocity.Y > 0) Owner.velocity.Y = -2f; //Get "stuck" into the enemy partly - Owner.GiveIFrames(OmegaBiomeBlade.SuperPogoAttunement_ShredIFrames); // i framez. + + // 17APR2024: Ozzatron: True Biome Blade's shred pogo gives iframes when striking enemies in a similar manner to a bonk dash. + // This is a fixed and intentionally very low number of iframes, and is not boosted by Cross Necklace. + Owner.GiveUniversalIFrames(OmegaBiomeBlade.SuperPogoAttunement_ShredIFrames); + PogoCooldown = 20; } } diff --git a/Utilities/PlayerUtils.cs b/Utilities/PlayerUtils.cs index dc0f5bbe5d..a471077f7b 100644 --- a/Utilities/PlayerUtils.cs +++ b/Utilities/PlayerUtils.cs @@ -5,6 +5,7 @@ using CalamityMod.Balancing; using CalamityMod.CalPlayer; using CalamityMod.Cooldowns; using CalamityMod.Events; +using CalamityMod.Items.Accessories; using CalamityMod.Items.Potions.Alcohol; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -413,6 +414,103 @@ namespace CalamityMod #endregion #region Immunity Frames + /// + /// Computes the appropriate amount of immunity frames to grant a player when they are struck by an attack.
+ /// Accounts for all Calamity effects, but not effects from other mods. + ///
+ /// The player whose immunity frames are being computed. + /// The amount of immunity frames the player should receive if struck. + public static int ComputeHitIFrames(this Player player, HurtInfo hurtInfo) + { + // Start with vanilla immunity frames. + int iframes = BalancingConstants.VanillaDefaultIFrames + (player.longInvince ? BalancingConstants.CrossNecklaceIFrameBoost : 0); + + // Add on all Calamity effects. + int calBonusIFrames = player.GetExtraHitIFrames(hurtInfo); + + return iframes + calBonusIFrames; + } + + /// + /// Gets the total amount of extra immunity frames from a hit granted by various Calamity effects. + /// + /// The player whose extra immunity frames are being computed. + /// The amount of extra immunity frames to grant. + public static int GetExtraHitIFrames(this Player player, HurtInfo hurtInfo) + { + CalamityPlayer modPlayer = player.Calamity(); + + int extraIFrames = 0; + if (modPlayer.godSlayerThrowing && hurtInfo.Damage > 80) + extraIFrames += 30; + if (modPlayer.statigelSet && hurtInfo.Damage > 100) + extraIFrames += 30; + + // Deific Amulet provides 10 to 40 bonus immunity frames when you get hit which scale with your missing health. + // If you only take 1 damage, you get 5 iframes. + // This effect is inherited by Rampart of Deities. + if (modPlayer.dAmulet) + { + if (hurtInfo.Damage > 1) + { + float lifeRatio = (float)player.statLife / player.statLifeMax2; + float iframeEffectivenessRatio = Utils.GetLerpValue(1.0f, 0.25f, lifeRatio, true); + + extraIFrames += (int)(iframeEffectivenessRatio * DeificAmulet.MaxBonusIFrames); + } + else + extraIFrames += 5; + } + + // Ozzatron 20FEB2024: Moved extra iframes from Seraph Tracers to Rampart of Deities to counteract its loss of Charm of Myths + // This stacks with the above Deific Amulet effect + if (modPlayer.rampartOfDeities && hurtInfo.Damage > 200) + extraIFrames += 30; + + if (modPlayer.fabsolVodka) + { + if (hurtInfo.Damage == 1) + extraIFrames += 5; + else + extraIFrames += 10; + } + + return extraIFrames; + } + + /// + /// Computes the appropriate amount of immunity frames to grant a player when they activate a dodge.
+ /// Accounts for all Calamity effects, but not effects from other mods. + ///
+ /// The player whose immunity frames are being computed. + /// The amount of immunity frames the player should receive upon dodging. + public static int ComputeDodgeIFrames(this Player player) + { + int iframes = BalancingConstants.VanillaDodgeIFrames + (player.longInvince ? BalancingConstants.CrossNecklaceIFrameBoost : 0); + return iframes; + } + + /// + /// Computes the appropriate amount of immunity frames to grant a player when they activate a parry.
+ /// Accounts for all Calamity effects, but not effects from other mods. + ///
+ /// The player whose immunity frames are being computed. + /// The amount of immunity frames the player should receive upon parrying. + public static int ComputeParryIFrames(this Player player) + { + int iframes = BalancingConstants.VanillaParryIFrames + (player.longInvince ? BalancingConstants.CrossNecklaceIFrameBoost_Parry : 0); + return iframes; + } + + // Currently, reflects are functionally equivalent to dodges. + /// + /// Computes the appropriate amount of immunity frames to grant a player when they activate a reflect.
+ /// Accounts for all Calamity effects, but not effects from other mods. + ///
+ /// The player whose immunity frames are being computed. + /// The amount of immunity frames the player should receive upon reflecting an attack. + public static int ComputeReflectIFrames(this Player player) => player.ComputeDodgeIFrames(); + /// /// Checks whether the player has any kind of immunity frames (or "iframes" for short) available. /// @@ -433,7 +531,10 @@ namespace CalamityMod } /// - /// Gives the player the specified number of immunity frames (or "iframes" for short).
If the player already has more iframes than you want to give them, this function does nothing. + /// Gives the player the specified number of immunity frames (or "iframes" for short) to a specific cooldown slot.
+ /// If the player already has more iframes than you want to give them, this function does nothing.
+ ///
+ /// This should be used for effects that need to mock or mimic the iframes that would be granted by getting hit. ///
/// The player who should be given immunity frames. /// The immunity cooldown slot to use. See TML documentation for which is which. @@ -461,13 +562,16 @@ namespace CalamityMod } /// - /// Gives the player the specified number of immunity frames (or "iframes" for short).
If the player already has more iframes than you want to give them, this function does nothing. + /// Gives the player the specified number of immunity frames (or "iframes" for short) to all cooldown slots.
+ /// If the player already has more iframes than you want to give them, this function does nothing.
+ ///
+ /// This should be used for effects like dodges or true invulnerability that should prevent the player from being hit for a predetermined time. ///
/// The player who should be given immunity frames. /// The number of immunity frames to give. /// Whether or not the player should be blinking during this time. /// Whether or not any immunity frames were given. - public static bool GiveIFrames(this Player player, int frames, bool blink = false) + public static bool GiveUniversalIFrames(this Player player, int frames, bool blink = false) { // Check to see if there is any way for the player to get iframes from this operation. bool anyIFramesWouldBeGiven = false;