diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/GrimTrap.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/GrimTrap.java index 27215cd8f..883fc6162 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/GrimTrap.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/GrimTrap.java @@ -66,35 +66,53 @@ public class GrimTrap extends Trap { if (target != null){ final Char finalTarget = target; final GrimTrap trap = this; - ((MagicMissile)target.sprite.parent.recycle(MagicMissile.class)).reset( - MagicMissile.SHADOW, - DungeonTilemap.tileCenterToWorld(pos), - target.sprite.center(), - new Callback() { - @Override - public void call() { - if (!finalTarget.isAlive()) return; - if (finalTarget == Dungeon.hero) { - //almost kill the player - if (((float)finalTarget.HP/finalTarget.HT) >= 0.9f){ - finalTarget.damage((finalTarget.HP-1), trap); - //kill 'em - } else { - finalTarget.damage(finalTarget.HP, trap); + int damage; + + //almost kill the player + if (finalTarget == Dungeon.hero && ((float)finalTarget.HP/finalTarget.HT) >= 0.9f){ + damage = finalTarget.HP-1; + //kill 'em + } else { + damage = finalTarget.HP; + } + + final int finalDmg = damage; + + Actor.add(new Actor() { + + { + //it's a visual effect, gets priority no matter what + actPriority = Integer.MIN_VALUE; + } + + @Override + protected boolean act() { + final Actor toRemove = this; + ((MagicMissile)finalTarget.sprite.parent.recycle(MagicMissile.class)).reset( + MagicMissile.SHADOW, + DungeonTilemap.tileCenterToWorld(pos), + finalTarget.sprite.center(), + new Callback() { + @Override + public void call() { + finalTarget.damage(finalDmg, trap); + if (finalTarget == Dungeon.hero) { + Sample.INSTANCE.play(Assets.SND_CURSED); + if (!finalTarget.isAlive()) { + Dungeon.fail( GrimTrap.class ); + GLog.n( Messages.get(GrimTrap.class, "ondeath") ); + } + } else { + Sample.INSTANCE.play(Assets.SND_BURNING); + } + finalTarget.sprite.emitter().burst(ShadowParticle.UP, 10); + Actor.remove(toRemove); + next(); } - Sample.INSTANCE.play(Assets.SND_CURSED); - if (!finalTarget.isAlive()) { - Dungeon.fail( GrimTrap.class ); - GLog.n( Messages.get(GrimTrap.class, "ondeath") ); - } - } else { - finalTarget.damage(finalTarget.HP, this); - Sample.INSTANCE.play(Assets.SND_BURNING); - } - finalTarget.sprite.emitter().burst(ShadowParticle.UP, 10); - if (!finalTarget.isAlive()) finalTarget.next(); - } - }); + }); + return false; + } + }); } else { CellEmitter.get(pos).burst(ShadowParticle.UP, 10); Sample.INSTANCE.play(Assets.SND_BURNING); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/PoisonDartTrap.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/PoisonDartTrap.java index 290c74d98..cd3eb9a3f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/PoisonDartTrap.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/PoisonDartTrap.java @@ -66,22 +66,37 @@ public class PoisonDartTrap extends Trap { final Char finalTarget = target; final PoisonDartTrap trap = this; if (Dungeon.level.heroFOV[pos] || Dungeon.level.heroFOV[target.pos]) { - ((MissileSprite) ShatteredPixelDungeon.scene().recycle(MissileSprite.class)). - reset(pos, target.sprite, new Dart(), new Callback() { - @Override - public void call() { - int dmg = Random.NormalIntRange(1, 4) - finalTarget.drRoll(); - finalTarget.damage(dmg, trap); - if (finalTarget == Dungeon.hero && !finalTarget.isAlive()){ - Dungeon.fail( getClass() ); + Actor.add(new Actor() { + + { + //it's a visual effect, gets priority no matter what + actPriority = Integer.MIN_VALUE; + } + + @Override + protected boolean act() { + final Actor toRemove = this; + ((MissileSprite) ShatteredPixelDungeon.scene().recycle(MissileSprite.class)). + reset(pos, finalTarget.sprite, new Dart(), new Callback() { + @Override + public void call() { + int dmg = Random.NormalIntRange(1, 4) - finalTarget.drRoll(); + finalTarget.damage(dmg, trap); + if (finalTarget == Dungeon.hero && !finalTarget.isAlive()){ + Dungeon.fail( trap.getClass() ); + } + Buff.affect( finalTarget, Poison.class ) + .set( Poison.durationFactor( finalTarget ) * (4 + Dungeon.depth) ); + Sample.INSTANCE.play(Assets.SND_HIT, 1, 1, Random.Float(0.8f, 1.25f)); + finalTarget.sprite.bloodBurstA(finalTarget.sprite.center(), dmg); + finalTarget.sprite.flash(); + Actor.remove(toRemove); + next(); } - Buff.affect( finalTarget, Poison.class ) - .set( Poison.durationFactor( finalTarget ) * (4 + Dungeon.depth) ); - Sample.INSTANCE.play(Assets.SND_HIT, 1, 1, Random.Float(0.8f, 1.25f)); - finalTarget.sprite.bloodBurstA(finalTarget.sprite.center(), dmg); - finalTarget.sprite.flash(); - } - }); + }); + return false; + } + }); } else { finalTarget.damage(Random.NormalIntRange(1, 4) - finalTarget.drRoll(), trap); Buff.affect( finalTarget, Poison.class ) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/WornDartTrap.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/WornDartTrap.java index b22acb4cc..b003c0242 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/WornDartTrap.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/WornDartTrap.java @@ -64,20 +64,35 @@ public class WornDartTrap extends Trap { final Char finalTarget = target; final WornDartTrap trap = this; if (Dungeon.level.heroFOV[pos] || Dungeon.level.heroFOV[target.pos]) { - ((MissileSprite) ShatteredPixelDungeon.scene().recycle(MissileSprite.class)). - reset(pos, target.sprite, new Dart(), new Callback() { - @Override - public void call() { + Actor.add(new Actor() { + + { + //it's a visual effect, gets priority no matter what + actPriority = Integer.MIN_VALUE; + } + + @Override + protected boolean act() { + final Actor toRemove = this; + ((MissileSprite) ShatteredPixelDungeon.scene().recycle(MissileSprite.class)). + reset(pos, finalTarget.sprite, new Dart(), new Callback() { + @Override + public void call() { int dmg = Random.NormalIntRange(1, 4) - finalTarget.drRoll(); finalTarget.damage(dmg, trap); if (finalTarget == Dungeon.hero && !finalTarget.isAlive()){ - Dungeon.fail( getClass() ); + Dungeon.fail( trap.getClass() ); } Sample.INSTANCE.play(Assets.SND_HIT, 1, 1, Random.Float(0.8f, 1.25f)); finalTarget.sprite.bloodBurstA(finalTarget.sprite.center(), dmg); finalTarget.sprite.flash(); - } - }); + Actor.remove(toRemove); + next(); + } + }); + return false; + } + }); } else { finalTarget.damage(Random.NormalIntRange(1, 4) - finalTarget.drRoll(), trap); }