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

View File

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

View File

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