From ff41e5811446de95bd5d4666b59f5f0f044b287f Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Mon, 7 Oct 2019 22:21:59 -0400 Subject: [PATCH] Yharon now uses Custom DR. In-game behavior unchanged. --- NPCs/Yharon/Yharon.cs | 53 ++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/NPCs/Yharon/Yharon.cs b/NPCs/Yharon/Yharon.cs index c1c612e4ba..7e693c4ffa 100644 --- a/NPCs/Yharon/Yharon.cs +++ b/NPCs/Yharon/Yharon.cs @@ -29,6 +29,10 @@ namespace CalamityMod.NPCs.Yharon private bool spawnArena = false; private int invincibilityCounter = 0; + public static float Phase1_DR = 0.17f; + public static float Phase2_DR = 0.22f; + public static float EnragedDR = 0.9f; + public override void SetStaticDefaults() { DisplayName.SetDefault("Jungle Dragon, Yharon"); @@ -60,6 +64,7 @@ namespace CalamityMod.NPCs.Yharon npc.boss = true; NPCID.Sets.TrailCacheLength[npc.type] = 8; NPCID.Sets.TrailingMode[npc.type] = 1; + for (int k = 0; k < npc.buffImmune.Length; k++) { npc.buffImmune[k] = true; @@ -68,6 +73,13 @@ namespace CalamityMod.NPCs.Yharon npc.buffImmune[BuffID.CursedInferno] = false; npc.buffImmune[mod.BuffType("DemonFlames")] = false; npc.buffImmune[mod.BuffType("Shred")] = false; + + CalamityGlobalNPC global = npc.GetCalamityNPC(); + global.DR = Phase1_DR; + global.customDR = true; + global.flatDRReductions.Add(BuffID.Ichor, 0.05f); + global.flatDRReductions.Add(BuffID.CursedInferno, 0.05f); + npc.noGravity = true; npc.noTileCollide = true; npc.netAlways = true; @@ -341,6 +353,9 @@ namespace CalamityMod.NPCs.Yharon protectionBoost = false; } + // Set DR based on protection boost (aka enrage) + npc.GetCalamityNPC().DR = protectionBoost ? EnragedDR : Phase1_DR; + // Trigger spawn effects if (npc.localAI[0] == 0f) { @@ -1882,7 +1897,11 @@ namespace CalamityMod.NPCs.Yharon npc.timeLeft = 3600; } } - int num = -1; + + // Set DR based on protection boost (aka enrage) + npc.GetCalamityNPC().DR = protectionBoost ? EnragedDR : Phase2_DR; + + int num = -1; float num2 = 1f; int num4 = expertMode ? 110 : 125; if (phase4) @@ -2818,40 +2837,16 @@ namespace CalamityMod.NPCs.Yharon } #endregion - #region DamageFormula + #region StrikeNPC public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) { - if (damage > npc.lifeMax / 10 || (!startSecondAI && dropLoot)) + // 10% max health antibutcher. Also prevents hits which would allow skipping phase 2. + if (damage > npc.lifeMax / 10 || (!startSecondAI && dropLoot)) { damage = 0; return false; } - double newDamage = (damage + (int)((double)defense * 0.25)); - if (newDamage < 1.0) - { - newDamage = 1.0; - } - if (newDamage >= 1.0) - { - if (startSecondAI) - { - float protection = (((npc.ichor || npc.onFire2) ? 0.17f : 0.22f) + - (protectionBoost ? 0.68f : 0f)); //0.85 or 0.9 - newDamage = (double)((int)((double)(1f - protection) * newDamage)); - } - else - { - float protection = (((npc.ichor || npc.onFire2) ? 0.12f : 0.17f) + - (protectionBoost ? 0.73f : 0f)); //0.85 or 0.9 - newDamage = (double)((int)((double)(1f - protection) * newDamage)); - } - if (newDamage < 1.0) - { - newDamage = 1.0; - } - } - damage = newDamage; - return true; + return true; } #endregion