From fc6039728169d8a12bffd820d539f591c0564176 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Thu, 27 Aug 2020 11:36:33 -0400 Subject: [PATCH] v0.8.2c: improved piranha surprise attack logic --- .../actors/mobs/Piranha.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Piranha.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Piranha.java index 28b1e9bc6..5ad66861f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Piranha.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Piranha.java @@ -84,15 +84,17 @@ public class Piranha extends Mob { public int drRoll() { return Random.NormalIntRange(0, Dungeon.depth); } - + @Override - public int defenseSkill( Char enemy ) { - enemySeen = state != SLEEPING - && this.enemy != null - && fieldOfView != null - && fieldOfView[this.enemy.pos] - && this.enemy.invisible == 0; - return super.defenseSkill( enemy ); + public boolean surprisedBy(Char enemy) { + if (enemy == Dungeon.hero){ + if (fieldOfView == null || fieldOfView.length != Dungeon.level.length()){ + fieldOfView = new boolean[Dungeon.level.length()]; + Dungeon.level.updateFieldOfView( this, fieldOfView ); + } + return state == SLEEPING || !fieldOfView[enemy.pos] || enemy.invisible > 0; + } + return super.surprisedBy(enemy); } @Override