From 78429602f884cb638c4d0faa56fe26ced4200ec2 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sun, 25 Feb 2024 12:35:40 -0500 Subject: [PATCH] v2.4.0: fixed newborn elementals firing charged atks through walls --- .../actors/mobs/Elemental.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Elemental.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Elemental.java index 8ff3b3a0c..f0b5df22d 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Elemental.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Elemental.java @@ -263,7 +263,10 @@ public abstract class Elemental extends Mob { @Override 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])) { sprite.zap( targetingPos ); return false; @@ -272,6 +275,11 @@ public abstract class Elemental extends Mob { return true; } } else { + + if (state != HUNTING){ + targetingPos = -1; + } + return super.act(); } } @@ -322,8 +330,15 @@ public abstract class Elemental extends Mob { } 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; + } + } }