v0.4.0: fixed bugs with projecting enchant on thrown weapons
This commit is contained in:
parent
ef278003fd
commit
db23db28c5
|
@ -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;
|
return new Ballistica( user.pos, dst, Ballistica.PROJECTILE ).collisionPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfSharpshooting;
|
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfSharpshooting;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
|
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Projecting;
|
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.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||||
import com.watabou.utils.Random;
|
import com.watabou.utils.Random;
|
||||||
|
|
||||||
|
@ -55,13 +55,10 @@ abstract public class MissileWeapon extends Weapon {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int throwPos(Hero user, int dst) {
|
public int throwPos(Hero user, int dst) {
|
||||||
int defaultPos = super.throwPos(user, dst);
|
if (hasEnchant(Projecting.class)
|
||||||
if (defaultPos == dst) return dst;
|
&& !Level.solid[dst] && Level.distance(user.pos, dst) <= 4){
|
||||||
else if (hasEnchant(Projecting.class)){
|
return dst;
|
||||||
Ballistica ProjectingTrajectory = new Ballistica( user.pos, dst, Ballistica.STOP_TARGET );
|
|
||||||
if (ProjectingTrajectory.dist <= 4) return ProjectingTrajectory.collisionPos;
|
|
||||||
else return super.throwPos(user, dst);
|
|
||||||
} else {
|
} else {
|
||||||
return super.throwPos(user, dst);
|
return super.throwPos(user, dst);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,6 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||||
|
@ -76,7 +75,7 @@ public class QuickSlotButton extends Button implements WndBag.Listener {
|
||||||
@Override
|
@Override
|
||||||
protected void onClick() {
|
protected void onClick() {
|
||||||
if (targeting) {
|
if (targeting) {
|
||||||
int cell = autoAim(lastTarget);
|
int cell = autoAim(lastTarget, select(slotNum));
|
||||||
|
|
||||||
if (cell != -1){
|
if (cell != -1){
|
||||||
GameScene.handleCell(cell);
|
GameScene.handleCell(cell);
|
||||||
|
@ -191,14 +190,20 @@ public class QuickSlotButton extends Button implements WndBag.Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int autoAim(Char target){
|
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
|
//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;
|
return target.pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Otherwise pick nearby tiles to try and 'angle' the shot, auto-aim basically.
|
//Otherwise pick nearby tiles to try and 'angle' the shot, auto-aim basically.
|
||||||
for (int i : Level.NEIGHBOURS9DIST2) {
|
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;
|
return target.pos+i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user