From d99e206b0e97f7b4b965531182a79f00138b9954 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sun, 19 Jul 2015 02:41:44 -0400 Subject: [PATCH] v0.3.1: toolbar auto-target now actually auto-targets --- .../ui/QuickSlotButton.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/ui/QuickSlotButton.java b/src/com/shatteredpixel/shatteredpixeldungeon/ui/QuickSlotButton.java index 2863bac92..b5093ab3f 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/ui/QuickSlotButton.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/ui/QuickSlotButton.java @@ -22,6 +22,8 @@ package com.shatteredpixel.shatteredpixeldungeon.ui; import com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem; import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand; +import com.shatteredpixel.shatteredpixeldungeon.levels.Level; +import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica; import com.watabou.noosa.Image; import com.watabou.noosa.ui.Button; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; @@ -77,6 +79,21 @@ public class QuickSlotButton extends Button implements WndBag.Listener { @Override protected void onClick() { if (targeting) { + //first try to directly target + if (new Ballistica(Dungeon.hero.pos, lastTarget.pos, Ballistica.PROJECTILE).collisionPos == lastTarget.pos) { + GameScene.handleCell(lastTarget.pos); + return; + } + + //Otherwise pick nearby tiles to try and 'angle' the shot, auto-aim basically. + for (int i : Level.NEIGHBOURS9DIST2) { + if (new Ballistica(Dungeon.hero.pos, lastTarget.pos+i, Ballistica.PROJECTILE).collisionPos == lastTarget.pos){ + GameScene.handleCell( lastTarget.pos+i ); + return; + } + } + + //couldn't find anything, just have it directly target GameScene.handleCell( lastTarget.pos ); } else { Item item = select(slotNum);