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

View File

@ -466,7 +466,7 @@ public class Item implements Bundlable {
}
}
protected int throwPos( Hero user, int dst){
public int throwPos( Hero user, int dst){
return new Ballistica( user.pos, dst, Ballistica.PROJECTILE ).collisionPos;
}

View File

@ -31,7 +31,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfSharpshooting;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Projecting;
import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.watabou.utils.Random;
@ -55,13 +55,10 @@ abstract public class MissileWeapon extends Weapon {
}
@Override
protected int throwPos(Hero user, int dst) {
int defaultPos = super.throwPos(user, dst);
if (defaultPos == dst) return dst;
else if (hasEnchant(Projecting.class)){
Ballistica ProjectingTrajectory = new Ballistica( user.pos, dst, Ballistica.STOP_TARGET );
if (ProjectingTrajectory.dist <= 4) return ProjectingTrajectory.collisionPos;
else return super.throwPos(user, dst);
public int throwPos(Hero user, int dst) {
if (hasEnchant(Projecting.class)
&& !Level.solid[dst] && Level.distance(user.pos, dst) <= 4){
return dst;
} else {
return super.throwPos(user, dst);
}

View File

@ -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;
}
}