Program: 163917
Project: 163917
Buggy source:
@Override public void activate(){
  Char target=Actor.findChar(pos);
  if (target == null) {
    for (    Char ch : Actor.chars()) {
      Ballistica bolt=new Ballistica(pos,ch.pos,Ballistica.PROJECTILE);
      if (bolt.collisionPos == ch.pos && (target == null || Dungeon.level.distance(pos,ch.pos) < Dungeon.level.distance(pos,target.pos))) {
        target=ch;
      }
    }
  }
  if (target != null) {
    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());
          }
          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();
        }
      }
);
    }
 else {
      finalTarget.damage(Random.NormalIntRange(1,4) - finalTarget.drRoll(),trap);
      Buff.affect(finalTarget,Poison.class).set(Poison.durationFactor(finalTarget) * (4 + Dungeon.depth));
    }
  }
}

Fixed version (ground truth):
@Override public void activate(){
  Char target=Actor.findChar(pos);
  if (target == null) {
    for (    Char ch : Actor.chars()) {
      Ballistica bolt=new Ballistica(pos,ch.pos,Ballistica.PROJECTILE);
      if (bolt.collisionPos == ch.pos && (target == null || Dungeon.level.distance(pos,ch.pos) < Dungeon.level.distance(pos,target.pos))) {
        target=ch;
      }
    }
  }
  if (target != null) {
    final Char finalTarget=target;
    final PoisonDartTrap trap=this;
    if (Dungeon.level.heroFOV[pos] || Dungeon.level.heroFOV[target.pos]) {
      Actor.add(new Actor(){
{
          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();
            }
          }
);
          return false;
        }
      }
);
    }
 else {
      finalTarget.damage(Random.NormalIntRange(1,4) - finalTarget.drRoll(),trap);
      Buff.affect(finalTarget,Poison.class).set(Poison.durationFactor(finalTarget) * (4 + Dungeon.depth));
    }
  }
}