v0.6.3: corrected distNoDiag function, now named trueDistance
This commit is contained in:
parent
9f78c6b6c2
commit
608a09a92c
core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels
|
@ -950,12 +950,13 @@ public abstract class Level implements Bundlable {
|
|||
return distance( a, b ) == 1;
|
||||
}
|
||||
|
||||
public int distNoDiag( int a, int b){
|
||||
//uses pythagorean theorum for true distance, as if there was no movement grid
|
||||
public float trueDistance(int a, int b){
|
||||
int ax = a % width();
|
||||
int ay = a / width();
|
||||
int bx = b % width();
|
||||
int by = b / width();
|
||||
return Math.abs( ax - bx ) + Math.abs( ay - by );
|
||||
return (float)Math.sqrt(Math.pow(Math.abs( ax - bx ), 2) + Math.pow(Math.abs( ay - by ), 2));
|
||||
}
|
||||
|
||||
//returns true if the input is a valid tile within the level
|
||||
|
|
|
@ -60,7 +60,7 @@ public class DisintegrationTrap extends Trap {
|
|||
for (Char ch : Actor.chars()){
|
||||
Ballistica bolt = new Ballistica(pos, ch.pos, Ballistica.PROJECTILE);
|
||||
if (bolt.collisionPos == ch.pos &&
|
||||
(target == null || Dungeon.level.distNoDiag(pos, ch.pos) < Dungeon.level.distNoDiag(pos, target.pos))){
|
||||
(target == null || Dungeon.level.trueDistance(pos, ch.pos) < Dungeon.level.trueDistance(pos, target.pos))){
|
||||
target = ch;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class GrimTrap extends Trap {
|
|||
for (Char ch : Actor.chars()){
|
||||
Ballistica bolt = new Ballistica(pos, ch.pos, Ballistica.PROJECTILE);
|
||||
if (bolt.collisionPos == ch.pos &&
|
||||
(target == null || Dungeon.level.distNoDiag(pos, ch.pos) < Dungeon.level.distNoDiag(pos, target.pos))){
|
||||
(target == null || Dungeon.level.trueDistance(pos, ch.pos) < Dungeon.level.trueDistance(pos, target.pos))){
|
||||
target = ch;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class PoisonDartTrap extends Trap {
|
|||
for (Char ch : Actor.chars()){
|
||||
Ballistica bolt = new Ballistica(pos, ch.pos, Ballistica.PROJECTILE);
|
||||
if (bolt.collisionPos == ch.pos &&
|
||||
(target == null || Dungeon.level.distNoDiag(pos, ch.pos) < Dungeon.level.distNoDiag(pos, target.pos))){
|
||||
(target == null || Dungeon.level.trueDistance(pos, ch.pos) < Dungeon.level.trueDistance(pos, target.pos))){
|
||||
target = ch;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public class WornDartTrap extends Trap {
|
|||
for (Char ch : Actor.chars()){
|
||||
Ballistica bolt = new Ballistica(pos, ch.pos, Ballistica.PROJECTILE);
|
||||
if (bolt.collisionPos == ch.pos &&
|
||||
(target == null || Dungeon.level.distNoDiag(pos, ch.pos) < Dungeon.level.distNoDiag(pos, target.pos))){
|
||||
(target == null || Dungeon.level.trueDistance(pos, ch.pos) < Dungeon.level.trueDistance(pos, target.pos))){
|
||||
target = ch;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user