From 66ce0585268531c3d0002f3e2ea69cc4dbb14c8d Mon Sep 17 00:00:00 2001 From: mountaindrew10 Date: Wed, 20 Mar 2024 20:48:42 -0500 Subject: [PATCH] LIFE STEAL!!!11!!!!! --- Balancing/BalancingConstants.cs | 30 ++++++++++++++-------- CalPlayer/CalamityPlayer.cs | 14 +++------- CalPlayer/CalamityPlayerMiscEffects.cs | 11 ++++---- CalPlayer/CalamityPlayerOnHit.cs | 4 +-- Items/Weapons/Melee/Earth.cs | 8 +++--- Items/Weapons/Melee/GrandGuardian.cs | 6 ++--- Items/Weapons/Melee/IridescentExcalibur.cs | 13 +++++++--- Items/Weapons/Melee/LifehuntScythe.cs | 8 +++--- Items/Weapons/Melee/MajesticGuard.cs | 4 +-- 9 files changed, 53 insertions(+), 45 deletions(-) diff --git a/Balancing/BalancingConstants.cs b/Balancing/BalancingConstants.cs index 876212737a..9ff26f1538 100644 --- a/Balancing/BalancingConstants.cs +++ b/Balancing/BalancingConstants.cs @@ -105,22 +105,30 @@ internal static readonly float LifeStealCapReduction_Master = 10f; // The base life steal cooldowns from vanilla - internal static readonly float LifeStealRecoveryRate_Classic = 0.8f; - internal static readonly float LifeStealRecoveryRate_Expert = 0.7f; + internal static readonly float LifeStealRecoveryRate_Classic = 0.6f; + internal static readonly float LifeStealRecoveryRate_Expert = 0.5f; - // Nerfs the life steal recovery rate in Classic from 0.8/s to 0.4/s - internal static readonly float LifeStealRecoveryRateReduction_Classic = 0.4f; + // The calculations below show the time (in frames) for 10 life steal cooldown to recover in each difficulty + // Classic: 10 / 0.3 = 33.333 + // Expert: 10 / 0.2 = 50 + // Revengeance: 10 / 0.15 = 66.667 + // Death: 10 / 0.125 = 80 + // Master: 10 / 0.15 = 66.667 + // Revengeance Master: 10 / 0.1 = 100 + // Death Master: 10 / 0.075 = 133.333 + // Nerfs the life steal recovery rate in Classic from 0.6/s to 0.3/s + internal static readonly float LifeStealRecoveryRateReduction_Classic = 0.3f; - // Nerfs the life steal recovery rate in Expert from 0.7/s to 0.35/s - internal static readonly float LifeStealRecoveryRateReduction_Expert = 0.35f; + // Nerfs the life steal recovery rate in Expert from 0.5/s to 0.2/s + internal static readonly float LifeStealRecoveryRateReduction_Expert = 0.3f; - // Nerfs the life steal recovery rate in Revengeance from 0.7/s to 0.3/s - internal static readonly float LifeStealRecoveryRateReduction_Revengeance = 0.4f; + // Nerfs the life steal recovery rate in Revengeance from 0.5/s to 0.15/s + internal static readonly float LifeStealRecoveryRateReduction_Revengeance = 0.35f; - // Nerfs the life steal recovery rate in Death from 0.7/s to 0.25/s - internal static readonly float LifeStealRecoveryRateReduction_Death = 0.45f; + // Nerfs the life steal recovery rate in Death from 0.5/s to 0.125/s + internal static readonly float LifeStealRecoveryRateReduction_Death = 0.375f; - // Nerfs the life steal recovery rate in Master by 0.05/s, resulting in 0.3/s in non-Rev Master, 0.25/s in Rev Master, and 0.2/s in Death Master + // Nerfs the life steal recovery rate in Master by 0.05/s, resulting in 0.2/s in non-Rev Master, 0.15/s in Rev Master, and 0.1/s in Death Master (10 / 0.1 = 100) internal static readonly float LifeStealRecoveryRateReduction_Master = 0.05f; #endregion diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 12c315c39b..a195298298 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -3598,17 +3598,11 @@ namespace CalamityMod.CalPlayer lifeStealRecoveryRateReduction += BalancingConstants.LifeStealRecoveryRateReduction_Master; float lifeStealRecoveryRate = baseRecoveryRate - lifeStealRecoveryRateReduction; - - // This value is here to somewhat prevent the rapid cooldown flashing that happens sometimes. - float cooldownDisplayGateValue = 12f; - float displayLifeStealCooldownGateValue = lifeStealRecoveryRate * cooldownDisplayGateValue; - if (Player.lifeSteal < -displayLifeStealCooldownGateValue) + if (Player.lifeSteal < -lifeStealRecoveryRate) { - float duration = Math.Abs(Player.lifeSteal); - duration /= lifeStealRecoveryRate; - - if (!Player.HasCooldown(LifeSteal.ID) || (cooldowns[LifeSteal.ID].duration < (int)duration)) - Player.AddCooldown(LifeSteal.ID, (int)duration); + int duration = (int)Math.Ceiling(Math.Abs(Player.lifeSteal) / lifeStealRecoveryRate); + if (!Player.HasCooldown(LifeSteal.ID) || (cooldowns[LifeSteal.ID].duration < duration)) + Player.AddCooldown(LifeSteal.ID, duration); } } diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 11b09d103a..d34b260353 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -901,10 +901,10 @@ namespace CalamityMod.CalPlayer if (Player.lifeSteal > lifeStealCap) Player.lifeSteal = lifeStealCap; - // Normal Mode life steal recovery rate is 0.4/s - // Expert Mode life steal recovery rate is 0.35/s - // Revengeance Mode life steal recovery rate is 0.3/s - // Death Mode life steal recovery rate is 0.25/s + // Normal Mode life steal recovery rate is 0.3/s + // Expert Mode life steal recovery rate is 0.2/s + // Revengeance Mode life steal recovery rate is 0.15/s + // Death Mode life steal recovery rate is 0.125/s // Master Mode life steal recovery rate is nerfed by an additional 0.05/s float lifeStealRecoveryRateReduction = CalamityWorld.death ? BalancingConstants.LifeStealRecoveryRateReduction_Death : @@ -915,7 +915,8 @@ namespace CalamityMod.CalPlayer if (Main.masterMode) lifeStealRecoveryRateReduction += BalancingConstants.LifeStealRecoveryRateReduction_Master; - Player.lifeSteal -= lifeStealRecoveryRateReduction; + if (Player.lifeSteal < lifeStealCap) + Player.lifeSteal -= lifeStealRecoveryRateReduction; // Bool for drawing boss health bar small text or not if (Main.myPlayer == Player.whoAmI) diff --git a/CalPlayer/CalamityPlayerOnHit.cs b/CalPlayer/CalamityPlayerOnHit.cs index 98af33b68c..3fd9e46bd6 100644 --- a/CalPlayer/CalamityPlayerOnHit.cs +++ b/CalPlayer/CalamityPlayerOnHit.cs @@ -112,11 +112,11 @@ namespace CalamityMod.CalPlayer case ItemID.CandyCaneSword: - if (Player.moonLeech || Main.player[Main.myPlayer].lifeSteal <= 0f) + if (Player.moonLeech || Player.lifeSteal <= 0f) return; int heal = 2; - Main.player[Main.myPlayer].lifeSteal -= heal; + Player.lifeSteal -= heal; Player.statLife += heal; Player.HealEffect(heal); if (Player.statLife > Player.statLifeMax2) diff --git a/Items/Weapons/Melee/Earth.cs b/Items/Weapons/Melee/Earth.cs index e37abfb3a8..57f4c74156 100644 --- a/Items/Weapons/Melee/Earth.cs +++ b/Items/Weapons/Melee/Earth.cs @@ -84,11 +84,11 @@ namespace CalamityMod.Items.Weapons.Melee if (target.Calamity().miscDefenseLoss < target.defense) target.Calamity().miscDefenseLoss += 1; - if (player.moonLeech || Main.player[Main.myPlayer].lifeSteal <= 0f) + if (player.moonLeech || player.lifeSteal <= 0f) return; int heal = Main.rand.Next(1, 70); - Main.player[Main.myPlayer].lifeSteal -= heal; + player.lifeSteal -= heal; player.statLife += heal; player.HealEffect(heal); if (player.statLife > player.statLifeMax2) @@ -143,11 +143,11 @@ namespace CalamityMod.Items.Weapons.Melee Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, ModContent.ProjectileType(), earthDamage, Item.knockBack, player.whoAmI, 0f, (float)Main.rand.Next(10)); } - if (player.moonLeech || Main.player[Main.myPlayer].lifeSteal <= 0f) + if (player.moonLeech || player.lifeSteal <= 0f) return; int heal = Main.rand.Next(1, 70); - Main.player[Main.myPlayer].lifeSteal -= heal; + player.lifeSteal -= heal; player.statLife += heal; player.HealEffect(heal); if (player.statLife > player.statLifeMax2) diff --git a/Items/Weapons/Melee/GrandGuardian.cs b/Items/Weapons/Melee/GrandGuardian.cs index 2904c9f26e..f51a19be8c 100644 --- a/Items/Weapons/Melee/GrandGuardian.cs +++ b/Items/Weapons/Melee/GrandGuardian.cs @@ -42,11 +42,11 @@ namespace CalamityMod.Items.Weapons.Melee if (target.Calamity().miscDefenseLoss >= target.defense) { - if (player.moonLeech || Main.player[Main.myPlayer].lifeSteal <= 0f) + if (player.moonLeech || player.lifeSteal <= 0f) return; - int heal = 4; - Main.player[Main.myPlayer].lifeSteal -= heal; + int heal = 6; + player.lifeSteal -= heal; player.statLife += heal; player.HealEffect(heal); if (player.statLife > player.statLifeMax2) diff --git a/Items/Weapons/Melee/IridescentExcalibur.cs b/Items/Weapons/Melee/IridescentExcalibur.cs index 976c49ea7f..6189321d31 100644 --- a/Items/Weapons/Melee/IridescentExcalibur.cs +++ b/Items/Weapons/Melee/IridescentExcalibur.cs @@ -52,6 +52,11 @@ namespace CalamityMod.Items.Weapons.Melee Item.rare = ModContent.RarityType(); } + public override void UseStyle(Player player, Rectangle heldItemFrame) + { + player.itemLocation += new Vector2(-12f * player.direction, 2f * player.gravDir).RotatedBy(player.itemRotation); + } + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) { Item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.Request("CalamityMod/Items/Weapons/Melee/IridescentExcaliburGlow").Value); @@ -167,11 +172,11 @@ namespace CalamityMod.Items.Weapons.Melee target.AddBuff(ModContent.BuffType(), 600); target.AddBuff(ModContent.BuffType(), 60); - if (player.moonLeech || Main.player[Main.myPlayer].lifeSteal <= 0f) + if (player.moonLeech || player.lifeSteal <= 0f) return; int heal = Main.rand.Next(3) + 10; - Main.player[Main.myPlayer].lifeSteal -= heal; + player.lifeSteal -= heal; player.statLife += heal; player.HealEffect(heal); if (player.statLife > player.statLifeMax2) @@ -183,11 +188,11 @@ namespace CalamityMod.Items.Weapons.Melee target.AddBuff(ModContent.BuffType(), 600); target.AddBuff(ModContent.BuffType(), 60); - if (player.moonLeech || Main.player[Main.myPlayer].lifeSteal <= 0f) + if (player.moonLeech || player.lifeSteal <= 0f) return; int heal = Main.rand.Next(3) + 10; - Main.player[Main.myPlayer].lifeSteal -= heal; + player.lifeSteal -= heal; player.statLife += heal; player.HealEffect(heal); if (player.statLife > player.statLifeMax2) diff --git a/Items/Weapons/Melee/LifehuntScythe.cs b/Items/Weapons/Melee/LifehuntScythe.cs index 1a0fccfdd3..00573ed9ec 100644 --- a/Items/Weapons/Melee/LifehuntScythe.cs +++ b/Items/Weapons/Melee/LifehuntScythe.cs @@ -39,11 +39,11 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) { - if (player.moonLeech || Main.player[Main.myPlayer].lifeSteal <= 0f) + if (player.moonLeech || player.lifeSteal <= 0f) return; int heal = 5; - Main.player[Main.myPlayer].lifeSteal -= heal; + player.lifeSteal -= heal; player.statLife += heal; player.HealEffect(heal); if (player.statLife > player.statLifeMax2) @@ -52,11 +52,11 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitPvp(Player player, Player target, Player.HurtInfo hurtInfo) { - if (player.moonLeech || Main.player[Main.myPlayer].lifeSteal <= 0f) + if (player.moonLeech || player.lifeSteal <= 0f) return; int heal = 5; - Main.player[Main.myPlayer].lifeSteal -= heal; + player.lifeSteal -= heal; player.statLife += heal; player.HealEffect(heal); if (player.statLife > player.statLifeMax2) diff --git a/Items/Weapons/Melee/MajesticGuard.cs b/Items/Weapons/Melee/MajesticGuard.cs index c6c9ffbd3a..6d7c9706f3 100644 --- a/Items/Weapons/Melee/MajesticGuard.cs +++ b/Items/Weapons/Melee/MajesticGuard.cs @@ -31,11 +31,11 @@ namespace CalamityMod.Items.Weapons.Melee if (target.Calamity().miscDefenseLoss >= target.defense) { - if (player.moonLeech || Main.player[Main.myPlayer].lifeSteal <= 0f) + if (player.moonLeech || player.lifeSteal <= 0f) return; int heal = 3; - Main.player[Main.myPlayer].lifeSteal -= heal; + player.lifeSteal -= heal; player.statLife += heal; player.HealEffect(heal); if (player.statLife > player.statLifeMax2)