From d0ba33cbb87554ded3dabdd520332ad3c29bacf0 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sat, 29 Aug 2020 21:20:59 -0400 Subject: [PATCH] v0.8.2d: tweaked enemy surprise behaviour, fixes a bug in piranhas --- .../shatteredpixeldungeon/actors/mobs/Mob.java | 10 +++++----- .../shatteredpixeldungeon/actors/mobs/Piranha.java | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java index 16d72c3f6..754d92ede 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java @@ -532,9 +532,7 @@ public abstract class Mob extends Char { @Override public int defenseSkill( Char enemy ) { - boolean seen = (enemySeen && enemy.invisible == 0); - if (enemy == Dungeon.hero && !Dungeon.hero.canSurpriseAttack()) seen = true; - if ( seen + if ( !surprisedBy(enemy) && paralysed == 0 && !(alignment == Alignment.ALLY && enemy == Dungeon.hero)) { return this.defenseSkill; @@ -552,7 +550,7 @@ public abstract class Mob extends Char { hitWithRanged = true; } - if (surprisedBy(enemy) && Dungeon.hero.canSurpriseAttack()) { + if (surprisedBy(enemy)) { Statistics.sneakAttacks++; Badges.validateRogueUnlock(); //TODO this is somewhat messy, it would be nicer to not have to manually handle delays here @@ -594,7 +592,9 @@ public abstract class Mob extends Char { } public boolean surprisedBy( Char enemy ){ - return enemy == Dungeon.hero && (enemy.invisible > 0 || !enemySeen); + return enemy == Dungeon.hero + && (enemy.invisible > 0 || !enemySeen) + && ((Hero)enemy).canSurpriseAttack(); } public void aggro( Char ch ) { 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 5ad66861f..0e066bb67 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 @@ -26,6 +26,7 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.Statistics; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning; +import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.items.food.MysteryMeat; import com.shatteredpixel.shatteredpixeldungeon.sprites.PiranhaSprite; import com.watabou.utils.PathFinder; @@ -87,7 +88,7 @@ public class Piranha extends Mob { @Override public boolean surprisedBy(Char enemy) { - if (enemy == Dungeon.hero){ + if (enemy == Dungeon.hero && ((Hero)enemy).canSurpriseAttack()){ if (fieldOfView == null || fieldOfView.length != Dungeon.level.length()){ fieldOfView = new boolean[Dungeon.level.length()]; Dungeon.level.updateFieldOfView( this, fieldOfView );