From 559c3d0473c285227514f099b9d7c0ae13f7e3e4 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Tue, 18 Mar 2025 12:28:28 -0400 Subject: [PATCH] v3.0.2: improved damage rounding logic in hero.damage() --- .../actors/hero/Hero.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java index 90bffbe5a..5a4cd2388 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java @@ -1561,34 +1561,41 @@ public class Hero extends Char { GLog.w( Messages.get(this, "pain_resist") ); } + //temporarily assign to a float to avoid rounding a bunch + float damage = dmg; + Endure.EndureTracker endure = buff(Endure.EndureTracker.class); if (!(src instanceof Char)){ //reduce damage here if it isn't coming from a character (if it is we already reduced it) if (endure != null){ - dmg = Math.round(endure.adjustDamageTaken(dmg)); + damage = endure.adjustDamageTaken(dmg); } //the same also applies to challenge scroll damage reduction if (buff(ScrollOfChallenge.ChallengeArena.class) != null){ - dmg *= 0.67f; + damage *= 0.67f; } //and to monk meditate damage reduction if (buff(MonkEnergy.MonkAbility.Meditate.MeditateResistance.class) != null){ - dmg *= 0.2f; + damage *= 0.2f; } } + //unused, could be removed CapeOfThorns.Thorns thorns = buff( CapeOfThorns.Thorns.class ); if (thorns != null) { - dmg = thorns.proc(dmg, (src instanceof Char ? (Char)src : null), this); + damage = thorns.proc((int)damage, (src instanceof Char ? (Char)src : null), this); } - dmg = (int)Math.ceil(dmg * RingOfTenacity.damageMultiplier( this )); - if (buff(Talent.WarriorFoodImmunity.class) != null){ - if (pointsInTalent(Talent.IRON_STOMACH) == 1) dmg = Math.round(dmg*0.25f); - else if (pointsInTalent(Talent.IRON_STOMACH) == 2) dmg = Math.round(dmg*0.00f); + if (pointsInTalent(Talent.IRON_STOMACH) == 1) damage /= 4f; + else if (pointsInTalent(Talent.IRON_STOMACH) == 2) damage = 0; } + dmg = Math.round(damage); + + //we ceil this one to avoid letting the player easily take 0 dmg from tenacity early + dmg = (int)Math.ceil(dmg * RingOfTenacity.damageMultiplier( this )); + int preHP = HP + shielding(); if (src instanceof Hunger) preHP -= shielding(); super.damage( dmg, src );