v0.4.0: fixed bugs with projecting enchant on thrown weapons

This commit is contained in:
Evan Debenham
2016-06-18 11:09:24 -04:00
parent ef278003fd
commit db23db28c5
3 changed files with 15 additions and 13 deletions
@@ -26,7 +26,6 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
@@ -76,7 +75,7 @@ public class QuickSlotButton extends Button implements WndBag.Listener {
@Override
protected void onClick() {
if (targeting) {
int cell = autoAim(lastTarget);
int cell = autoAim(lastTarget, select(slotNum));
if (cell != -1){
GameScene.handleCell(cell);
@@ -191,14 +190,20 @@ public class QuickSlotButton extends Button implements WndBag.Listener {
}
public static int autoAim(Char target){
//will use generic projectile logic if no item is specified
return autoAim(target, new Item());
}
public static int autoAim(Char target, Item item){
//first try to directly target
if (new Ballistica(Dungeon.hero.pos, target.pos, Ballistica.PROJECTILE).collisionPos == target.pos) {
if (item.throwPos(Dungeon.hero, target.pos) == target.pos) {
return target.pos;
}
//Otherwise pick nearby tiles to try and 'angle' the shot, auto-aim basically.
for (int i : Level.NEIGHBOURS9DIST2) {
if (new Ballistica(Dungeon.hero.pos, target.pos+i, Ballistica.PROJECTILE).collisionPos == target.pos){
if (item.throwPos(Dungeon.hero, target.pos) == target.pos){
return target.pos+i;
}
}