v3.0.2: improved damage rounding logic in hero.damage()

This commit is contained in:
Evan Debenham
2025-03-18 12:28:28 -04:00
parent 6b61425cd8
commit 559c3d0473

View File

@@ -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 );