diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Pushing.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Pushing.java index 926c16311..3255900a6 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Pushing.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Pushing.java @@ -39,6 +39,7 @@ public class Pushing extends Actor { private int to; private Effect effect; + private Char ch; private Callback callback; @@ -47,6 +48,7 @@ public class Pushing extends Actor { } public Pushing( Char ch, int from, int to ) { + this.ch = ch; sprite = ch.sprite; this.from = from; this.to = to; @@ -86,6 +88,15 @@ public class Pushing extends Actor { } + public static boolean pushingExistsForChar(Char ch) { + for (Actor a : all()){ + if (a instanceof Pushing && ((Pushing)a).ch == ch){ + return true; + } + } + return false; + } + public class Effect extends Visual { private static final float DELAY = 0.15f; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/Spear.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/Spear.java index 51fa09884..c085b3973 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/Spear.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/Spear.java @@ -27,6 +27,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; +import com.shatteredpixel.shatteredpixeldungeon.effects.Pushing; import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfBlastWave; import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; @@ -101,8 +102,9 @@ public class Spear extends MeleeWeapon { wep.beforeAbilityUsed(hero, enemy); AttackIndicator.target(enemy); int oldPos = enemy.pos; + //do not push if enemy has moved, or another push is active (e.g. elastic) if (hero.attack(enemy, dmgMulti, dmgBoost, Char.INFINITE_ACCURACY)) { - if (enemy.isAlive() && enemy.pos == oldPos){ + if (enemy.isAlive() && enemy.pos == oldPos && !Pushing.pushingExistsForChar(enemy)){ //trace a ballistica to our target (which will also extend past them Ballistica trajectory = new Ballistica(hero.pos, enemy.pos, Ballistica.STOP_TARGET); //trim it to just be the part that goes past them