From dc4b05be4328ed0226e932a090a9b2944d8b1ede Mon Sep 17 00:00:00 2001 From: Evan Debenham <Evan@ShatteredPixel.com> Date: Fri, 4 Sep 2020 21:56:38 -0400 Subject: [PATCH] v0.9.0: fixed shadows buff detaching on mind vision enemies --- .../actors/blobs/Foliage.java | 11 +++------ .../actors/buffs/Shadows.java | 24 ++++++++++++++++--- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/Foliage.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/Foliage.java index 63c78fc88..6ecfc809b 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/Foliage.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/Foliage.java @@ -21,7 +21,6 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.blobs; -import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Shadows; @@ -32,7 +31,6 @@ import com.shatteredpixel.shatteredpixeldungeon.journal.Notes; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; -import com.watabou.noosa.audio.Sample; public class Foliage extends Blob { @@ -66,12 +64,9 @@ public class Foliage extends Blob { } Hero hero = Dungeon.hero; - if (hero.isAlive() && hero.visibleEnemies() == 0 && cur[hero.pos] > 0) { - Shadows s = hero.buff(Shadows.class); - if (s == null){ - Buff.affect( hero, Shadows.class ).prolong(); - Sample.INSTANCE.play( Assets.Sounds.MELD ); - } else { + if (hero.isAlive() && cur[hero.pos] > 0) { + Shadows s = Buff.affect( hero, Shadows.class ); + if (s != null){ s.prolong(); } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Shadows.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Shadows.java index 4eacf3200..98d664608 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Shadows.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Shadows.java @@ -21,10 +21,13 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.buffs; +import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; +import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; +import com.watabou.noosa.audio.Sample; import com.watabou.utils.Bundle; public class Shadows extends Invisibility { @@ -52,9 +55,18 @@ public class Shadows extends Invisibility { @Override public boolean attachTo( Char target ) { + if (Dungeon.level != null) { + for (Mob m : Dungeon.level.mobs) { + if (Dungeon.level.adjacent(m.pos, target.pos) && m.alignment != target.alignment) { + return false; + } + } + } if (super.attachTo( target )) { - if (Dungeon.level != null) + if (Dungeon.level != null) { + Sample.INSTANCE.play( Assets.Sounds.MELD ); Dungeon.observe(); + } return true; } else { return false; @@ -71,11 +83,17 @@ public class Shadows extends Invisibility { public boolean act() { if (target.isAlive()) { - spend( TICK * 2 ); + spend( TICK ); - if (--left <= 0 || Dungeon.hero.visibleEnemies() > 0) { + if (--left <= 0) { detach(); } + + for (Mob m : Dungeon.level.mobs){ + if (Dungeon.level.adjacent(m.pos, target.pos) && m.alignment != target.alignment){ + detach(); + } + } } else {