v0.8.0: fixed rare cases where new DM-300 would drop rocks instantly

This commit is contained in:
Evan Debenham 2020-04-09 21:54:18 -04:00
parent c26e94f656
commit e059804f8a

View File

@ -364,7 +364,7 @@ public class NewDM300 extends Mob {
public void dropRocks( Char target ) {
Dungeon.hero.interrupt();
int rockCenter = target.pos;
final int rockCenter;
if (Dungeon.level.adjacent(pos, target.pos)){
int oppositeAdjacent = target.pos + (target.pos - pos);
@ -374,8 +374,21 @@ public class NewDM300 extends Mob {
Dungeon.hero.interrupt();
}
rockCenter = trajectory.path.get(Math.min(trajectory.dist, 2));
} else {
rockCenter = target.pos;
}
//we handle this through an actor as it gives us fine-grainted control over when the blog acts vs. when the hero acts
//FIXME this is really messy to just get some fine-grained control. would be nice to build this into blob functionality, or just not use blobs for this at all
Actor a = new Actor() {
{
actPriority = HERO_PRIO+1;
}
@Override
protected boolean act() {
//pick an adjacent cell to the hero as a safe cell. This cell is less likely to be in a wall or containing hazards
int safeCell;
do {
@ -396,11 +409,16 @@ public class NewDM300 extends Mob {
//add rock cell to pos, if it is not solid, and isn't the safecell
if (!Dungeon.level.solid[pos] && pos != safeCell && Random.Int(Dungeon.level.distance(rockCenter, pos)) == 0) {
//don't want to overly punish players with slow move or attack speed
GameScene.add(Blob.seed(pos, (int)GameMath.gate(TICK, (float)Math.ceil(target.cooldown()), 3*TICK), FallingRocks.class));
GameScene.add(Blob.seed(pos, 1, FallingRocks.class));
}
pos++;
}
}
Actor.remove(this);
return true;
}
};
Actor.addDelayed(a, Math.min(target.cooldown(), 3*TICK));
}