From dfabe5e9944e3b4c023d3cb4e4ff795d2f51e656 Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Wed, 28 Oct 2020 18:35:25 -0400 Subject: [PATCH] Bloodflare Core total rework --- CalPlayer/CalamityPlayer.cs | 25 ++++++++++++++ CalPlayer/CalamityPlayerMiscEffects.cs | 48 +++++++++++++++++--------- Items/Accessories/BloodflareCore.cs | 4 +-- Items/Accessories/CoreOfTheBloodGod.cs | 1 - 4 files changed, 58 insertions(+), 20 deletions(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 90cc1d859f..62725f5897 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -497,6 +497,7 @@ namespace CalamityMod.CalPlayer public bool bloodPact = false; public bool bloodPactBoost = false; public bool bloodflareCore = false; + public int bloodflareCoreLostDefense = 0; public bool coreOfTheBloodGod = false; public bool elementalHeart = false; public bool crownJewel = false; @@ -2383,6 +2384,7 @@ namespace CalamityMod.CalPlayer brimlashBusterBoost = false; animusBoost = 1f; potionTimer = 0; + bloodflareCoreLostDefense = 0; if (BossRushEvent.BossRushActive) { @@ -7804,6 +7806,29 @@ namespace CalamityMod.CalPlayer { player.AddBuff(ModContent.BuffType(), 300, true); } + + // Bloodflare Core defense shattering + if (bloodflareCore) + { + // Shattered defense caps at half of total defense. Every hit adds its damage as shattered defense. + bloodflareCoreLostDefense = Math.Min(bloodflareCoreLostDefense + (int)damage, player.statDefense / 2); + + // Play a sound and make dust to signify that defense has been shattered + Main.PlaySound(SoundID.DD2_MonkStaffGroundImpact, player.Center); + for (int i = 0; i < 36; ++i) + { + float speed = Main.rand.NextFloat(1.8f, 8f); + Vector2 dustVel = new Vector2(speed, speed); + Dust d = Dust.NewDustDirect(player.position, player.width, player.height, 90); + d.velocity = dustVel; + d.noGravity = true; + d.scale *= Main.rand.NextFloat(1.1f, 1.4f); + Dust.CloneDust(d).velocity = dustVel.RotatedBy(MathHelper.PiOver2); + Dust.CloneDust(d).velocity = dustVel.RotatedBy(MathHelper.Pi); + Dust.CloneDust(d).velocity = dustVel.RotatedBy(MathHelper.Pi * 1.5f); + } + } + bool hardMode = Main.hardMode; int iFramesToAdd = 0; if (player.whoAmI == Main.myPlayer) diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index a8e6dbf954..2e35e34429 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -3415,22 +3415,6 @@ namespace CalamityMod.CalPlayer player.endurance += 0.08f; player.allDamage += 0.08f; } - else if (modPlayer.bloodflareCore) - { - if (player.statDefense < 100) - player.allDamage += 0.15f; - - if (player.statLife <= (int)(player.statLifeMax2 * 0.15)) - { - player.endurance += 0.1f; - player.allDamage += 0.2f; - } - else if (player.statLife <= (int)(player.statLifeMax2 * 0.5)) - { - player.endurance += 0.05f; - player.allDamage += 0.1f; - } - } if (modPlayer.godSlayerThrowing) { @@ -3931,6 +3915,38 @@ namespace CalamityMod.CalPlayer (modPlayer.yInsignia ? 0.1 : 0) + (modPlayer.badgeOfBraveryRare ? 0.2 : 0); modPlayer.trueMeleeDamage += damageAdd; + + // Intentionally at the end: Bloodflare Core's defense reduction (after all other boosting effects and whatnot) + // This defense still comes back over time if you take off Bloodflare Core while you're missing defense. + // However, removing the item means you won't get healed as the defense comes back. + ref int lostDef = ref modPlayer.bloodflareCoreLostDefense; + if (lostDef > 0) + { + // Defense regeneration occurs every four frames while defense is missing + if (player.miscCounter % 4 == 0) + { + --lostDef; + if (modPlayer.bloodflareCore) + { + player.statLife += 1; + player.HealEffect(1, false); + + // Produce an implosion of blood themed dust so it's obvious an effect is occurring + for (int i = 0; i < 3; ++i) + { + Vector2 offset = Main.rand.NextVector2Unit() * Main.rand.NextFloat(23f, 33f); + Vector2 dustPos = player.Center + offset; + Vector2 dustVel = offset * -0.08f; + Dust d = Dust.NewDustDirect(dustPos, 0, 0, 90, 0.08f, 0.08f); + d.velocity = dustVel; + d.noGravity = true; + } + } + } + + // Actually apply the defense reduction + player.statDefense -= lostDef; + } } #endregion diff --git a/Items/Accessories/BloodflareCore.cs b/Items/Accessories/BloodflareCore.cs index f7418a508c..ce0995e20b 100644 --- a/Items/Accessories/BloodflareCore.cs +++ b/Items/Accessories/BloodflareCore.cs @@ -10,9 +10,7 @@ namespace CalamityMod.Items.Accessories public override void SetStaticDefaults() { DisplayName.SetDefault("Bloodflare Core"); - Tooltip.SetDefault("When below 50% life you gain 5% increased damage reduction and 10% increased damage\n" + - "When below 15% life you gain 10% increased damage reduction and 20% increased damage\n" + - "When below 100 defense you gain 15% increased damage"); + Tooltip.SetDefault("You lose up to half your defense after taking damage\n" + "Lost defense regenerates over time\n" + "You gain 1 health for every 1 defense gained as it regenerates"); } public override void SetDefaults() diff --git a/Items/Accessories/CoreOfTheBloodGod.cs b/Items/Accessories/CoreOfTheBloodGod.cs index a28fde6da9..a518c0a659 100644 --- a/Items/Accessories/CoreOfTheBloodGod.cs +++ b/Items/Accessories/CoreOfTheBloodGod.cs @@ -41,7 +41,6 @@ namespace CalamityMod.Items.Accessories recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType(), 5); recipe.AddIngredient(ModContent.ItemType()); recipe.AddTile(ModContent.TileType());