v0.6.2: fixed issues with traps that have delayed visual effects

This commit is contained in:
Evan Debenham 2017-09-30 22:32:08 -04:00
parent 3e5c69b25e
commit 26ec69ae9a
3 changed files with 98 additions and 50 deletions

View File

@ -66,35 +66,53 @@ public class GrimTrap extends Trap {
if (target != null){ if (target != null){
final Char finalTarget = target; final Char finalTarget = target;
final GrimTrap trap = this; final GrimTrap trap = this;
((MagicMissile)target.sprite.parent.recycle(MagicMissile.class)).reset( int damage;
MagicMissile.SHADOW,
DungeonTilemap.tileCenterToWorld(pos), //almost kill the player
target.sprite.center(), if (finalTarget == Dungeon.hero && ((float)finalTarget.HP/finalTarget.HT) >= 0.9f){
new Callback() { damage = finalTarget.HP-1;
@Override //kill 'em
public void call() { } else {
if (!finalTarget.isAlive()) return; damage = finalTarget.HP;
if (finalTarget == Dungeon.hero) { }
//almost kill the player
if (((float)finalTarget.HP/finalTarget.HT) >= 0.9f){ final int finalDmg = damage;
finalTarget.damage((finalTarget.HP-1), trap);
//kill 'em Actor.add(new Actor() {
} else {
finalTarget.damage(finalTarget.HP, trap); {
//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()) { return false;
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();
}
});
} else { } else {
CellEmitter.get(pos).burst(ShadowParticle.UP, 10); CellEmitter.get(pos).burst(ShadowParticle.UP, 10);
Sample.INSTANCE.play(Assets.SND_BURNING); Sample.INSTANCE.play(Assets.SND_BURNING);

View File

@ -66,22 +66,37 @@ public class PoisonDartTrap extends Trap {
final Char finalTarget = target; final Char finalTarget = target;
final PoisonDartTrap trap = this; final PoisonDartTrap trap = this;
if (Dungeon.level.heroFOV[pos] || Dungeon.level.heroFOV[target.pos]) { if (Dungeon.level.heroFOV[pos] || Dungeon.level.heroFOV[target.pos]) {
((MissileSprite) ShatteredPixelDungeon.scene().recycle(MissileSprite.class)). Actor.add(new Actor() {
reset(pos, target.sprite, new Dart(), new Callback() {
@Override {
public void call() { //it's a visual effect, gets priority no matter what
int dmg = Random.NormalIntRange(1, 4) - finalTarget.drRoll(); actPriority = Integer.MIN_VALUE;
finalTarget.damage(dmg, trap); }
if (finalTarget == Dungeon.hero && !finalTarget.isAlive()){
Dungeon.fail( getClass() ); @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) ); return false;
Sample.INSTANCE.play(Assets.SND_HIT, 1, 1, Random.Float(0.8f, 1.25f)); }
finalTarget.sprite.bloodBurstA(finalTarget.sprite.center(), dmg); });
finalTarget.sprite.flash();
}
});
} else { } else {
finalTarget.damage(Random.NormalIntRange(1, 4) - finalTarget.drRoll(), trap); finalTarget.damage(Random.NormalIntRange(1, 4) - finalTarget.drRoll(), trap);
Buff.affect( finalTarget, Poison.class ) Buff.affect( finalTarget, Poison.class )

View File

@ -64,20 +64,35 @@ public class WornDartTrap extends Trap {
final Char finalTarget = target; final Char finalTarget = target;
final WornDartTrap trap = this; final WornDartTrap trap = this;
if (Dungeon.level.heroFOV[pos] || Dungeon.level.heroFOV[target.pos]) { if (Dungeon.level.heroFOV[pos] || Dungeon.level.heroFOV[target.pos]) {
((MissileSprite) ShatteredPixelDungeon.scene().recycle(MissileSprite.class)). Actor.add(new Actor() {
reset(pos, target.sprite, new Dart(), new Callback() {
@Override {
public void call() { //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(); int dmg = Random.NormalIntRange(1, 4) - finalTarget.drRoll();
finalTarget.damage(dmg, trap); finalTarget.damage(dmg, trap);
if (finalTarget == Dungeon.hero && !finalTarget.isAlive()){ 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)); Sample.INSTANCE.play(Assets.SND_HIT, 1, 1, Random.Float(0.8f, 1.25f));
finalTarget.sprite.bloodBurstA(finalTarget.sprite.center(), dmg); finalTarget.sprite.bloodBurstA(finalTarget.sprite.center(), dmg);
finalTarget.sprite.flash(); finalTarget.sprite.flash();
} Actor.remove(toRemove);
}); next();
}
});
return false;
}
});
} else { } else {
finalTarget.damage(Random.NormalIntRange(1, 4) - finalTarget.drRoll(), trap); finalTarget.damage(Random.NormalIntRange(1, 4) - finalTarget.drRoll(), trap);
} }