diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java index ca6c045e9..20c783f46 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java @@ -132,6 +132,16 @@ public abstract class Char extends Actor { effectiveDamage = attackProc( enemy, effectiveDamage ); effectiveDamage = enemy.defenseProc( this, effectiveDamage ); + if (visibleFight) { + Sample.INSTANCE.play( Assets.SND_HIT, 1, 1, Random.Float( 0.8f, 1.25f ) ); + } + + // If the enemy is already dead, interrupt the attack. + // This matters as defence procs can sometimes inflict self-damage, such as armor glyphs. + if (!enemy.isAlive()){ + return true; + } + //TODO: consider revisiting this and shaking in more cases. float shake = 0f; if (enemy == Dungeon.hero) @@ -141,10 +151,6 @@ public abstract class Char extends Actor { Camera.main.shake( GameMath.gate( 1, shake, 5), 0.3f ); enemy.damage( effectiveDamage, this ); - - if (visibleFight) { - Sample.INSTANCE.play( Assets.SND_HIT, 1, 1, Random.Float( 0.8f, 1.25f ) ); - } if (buff(FireImbue.class) != null) buff(FireImbue.class).proc(enemy); @@ -153,17 +159,10 @@ public abstract class Char extends Actor { enemy.sprite.bloodBurstA( sprite.center(), effectiveDamage ); enemy.sprite.flash(); - + if (!enemy.isAlive() && visibleFight) { if (enemy == Dungeon.hero) { - - if (Dungeon.hero.killerGlyph != null) { - // FIXME - // Dungeon.fail( Utils.format( ResultDescriptions.GLYPH, Dungeon.hero.killerGlyph.name(), Dungeon.depth ) ); - // GLog.n( TXT_KILL, Dungeon.hero.killerGlyph.name() ); - - } else { if ( this instanceof Yog ) { Dungeon.fail( Utils.format( ResultDescriptions.NAMED, name) ); } if (Bestiary.isUnique( this )) { @@ -173,7 +172,6 @@ public abstract class Char extends Actor { } GLog.n( TXT_KILL, name ); - } } else { GLog.i( TXT_DEFEAT, name, enemy.name ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java index 3ebfc9899..a3543a8c7 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java @@ -61,7 +61,6 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Heap; import com.shatteredpixel.shatteredpixeldungeon.items.Heap.Type; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon; -import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor; import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Viscosity; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.CapeOfThorns; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.DriedRose; @@ -155,8 +154,6 @@ public class Hero extends Char { private Char enemy; - public Armor.Glyph killerGlyph = null; - private Item theKey; public boolean restoreHealth = false; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/Armor.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/Armor.java index aa980e1aa..9d1f4375a 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/Armor.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/Armor.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import com.shatteredpixel.shatteredpixeldungeon.Badges; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; +import com.shatteredpixel.shatteredpixeldungeon.ResultDescriptions; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem; @@ -372,8 +373,10 @@ public class Armor extends EquipableItem { public boolean checkOwner( Char owner ) { if (!owner.isAlive() && owner instanceof Hero) { - - ((Hero)owner).killerGlyph = this; + + Dungeon.fail( Utils.format( ResultDescriptions.GLYPH, name() ) ); + GLog.n( "%s killed you...", name() ); + Badges.validateDeathFromGlyph(); return true;