v0.9.0: improved logic for ripper demon leaping

This commit is contained in:
Evan Debenham 2020-09-16 16:05:58 -04:00
parent de9d629a7f
commit 3c4cb08cd2

View File

@ -135,20 +135,21 @@ public class RipperDemon extends Mob {
public boolean act( boolean enemyInFOV, boolean justAlerted ) {
if (leapPos != -1){
//do leap
sprite.visible = Dungeon.level.heroFOV[pos] || Dungeon.level.heroFOV[leapPos];
sprite.jump(pos, leapPos, new Callback() {
@Override
public void call() {
Char ch = Actor.findChar(leapPos);
if (ch != null){
if (alignment != ch.alignment){
Buff.affect(ch, Bleeding.class).set(0.75f*damageRoll());
ch.sprite.flash();
Sample.INSTANCE.play(Assets.Sounds.HIT);
leapCooldown = Random.NormalIntRange(2, 4);
Ballistica b = new Ballistica(pos, leapPos, Ballistica.STOP_TARGET | Ballistica.STOP_SOLID);
//check if leap pos is not obstructed by terrain
if (b.collisionPos != leapPos){
leapPos = -1;
return true;
}
//bounce to a random safe pos(if possible)
final Char leapVictim = Actor.findChar(leapPos);
final int endPos;
//ensure there is somewhere to land after leaping
if (leapVictim != null){
int bouncepos = -1;
for (int i : PathFinder.NEIGHBOURS8){
if ((bouncepos == -1 || Dungeon.level.trueDistance(pos, leapPos+i) < Dungeon.level.trueDistance(pos, bouncepos))
@ -156,18 +157,34 @@ public class RipperDemon extends Mob {
bouncepos = leapPos+i;
}
}
if (bouncepos != -1) {
pos = bouncepos;
Actor.addDelayed(new Pushing(RipperDemon.this, leapPos, bouncepos), -1);
if (bouncepos == -1) {
leapPos = -1;
return true;
} else {
pos = leapPos;
endPos = bouncepos;
}
} else {
pos = leapPos;
endPos = leapPos;
}
//do leap
sprite.visible = Dungeon.level.heroFOV[pos] || Dungeon.level.heroFOV[leapPos] || Dungeon.level.heroFOV[endPos];
sprite.jump(pos, leapPos, new Callback() {
@Override
public void call() {
if (leapVictim != null && alignment != leapVictim.alignment){
Buff.affect(leapVictim, Bleeding.class).set(0.75f*damageRoll());
leapVictim.sprite.flash();
Sample.INSTANCE.play(Assets.Sounds.HIT);
}
if (endPos != leapPos){
Actor.addDelayed(new Pushing(RipperDemon.this, leapPos, endPos), -1);
}
pos = endPos;
leapPos = -1;
leapCooldown = Random.NormalIntRange(2, 4);
sprite.idle();
Dungeon.level.occupyCell(RipperDemon.this);
next();