From 7b3c7aa46d8f916f26ce850a979310ceea4b89c9 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Thu, 20 Aug 2015 09:54:34 -0400 Subject: [PATCH] v0.3.1a: fixed spear traps dealing negative damage, also added a safety check for dealing negative damage. --- src/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java | 2 +- .../shatteredpixeldungeon/levels/traps/SpearTrap.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java index 59718f725..7826f05c8 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java @@ -241,7 +241,7 @@ public abstract class Char extends Actor { public void damage( int dmg, Object src ) { - if (HP <= 0) { + if (HP <= 0 || dmg < 0) { return; } if (this.buff(Frost.class) != null){ diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/levels/traps/SpearTrap.java b/src/com/shatteredpixel/shatteredpixeldungeon/levels/traps/SpearTrap.java index a64df8733..1c775bdf4 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/levels/traps/SpearTrap.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/levels/traps/SpearTrap.java @@ -60,7 +60,7 @@ public class SpearTrap extends Trap { if (ch != null){ int damage = Random.NormalIntRange(Dungeon.depth, Dungeon.depth*2); damage -= Random.IntRange( 0, ch.dr()); - ch.damage( damage , this); + ch.damage( Math.max(damage, 0) , this); if (!ch.isAlive() && ch == Dungeon.hero){ Dungeon.fail(Utils.format(ResultDescriptions.TRAP, name)); GLog.n("You were skewered by the spear trap...");