v2.4.0: fixed newborn elementals firing charged atks through walls

This commit is contained in:
Evan Debenham
2024-02-25 12:35:40 -05:00
parent 43a8eea7e9
commit 78429602f8

View File

@@ -263,7 +263,10 @@ public abstract class Elemental extends Mob {
@Override @Override
protected boolean act() { protected boolean act() {
if (targetingPos != -1){ //fire a charged attack instead of any other action, as long as it is possible to do so
if (targetingPos != -1 && state == HUNTING){
//account for bolt hitting walls, in case position suddenly changed
targetingPos = new Ballistica( pos, targetingPos, Ballistica.STOP_SOLID | Ballistica.STOP_TARGET ).collisionPos;
if (sprite != null && (sprite.visible || Dungeon.level.heroFOV[targetingPos])) { if (sprite != null && (sprite.visible || Dungeon.level.heroFOV[targetingPos])) {
sprite.zap( targetingPos ); sprite.zap( targetingPos );
return false; return false;
@@ -272,6 +275,11 @@ public abstract class Elemental extends Mob {
return true; return true;
} }
} else { } else {
if (state != HUNTING){
targetingPos = -1;
}
return super.act(); return super.act();
} }
} }
@@ -322,8 +330,15 @@ public abstract class Elemental extends Mob {
} else { } else {
rangedCooldown = 1;
return super.doAttack(enemy); if (sprite != null && (sprite.visible || Dungeon.level.heroFOV[targetingPos])) {
sprite.zap( targetingPos );
return false;
} else {
zap();
return true;
}
} }
} }