v0.6.2b: improved how targeting traps determine distance
This commit is contained in:
committed by
Evan Debenham
parent
be198f1907
commit
0af31996a4
@@ -949,6 +949,14 @@ public abstract class Level implements Bundlable {
|
|||||||
public boolean adjacent( int a, int b ) {
|
public boolean adjacent( int a, int b ) {
|
||||||
return distance( a, b ) == 1;
|
return distance( a, b ) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int distNoDiag( 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 );
|
||||||
|
}
|
||||||
|
|
||||||
//returns true if the input is a valid tile within the level
|
//returns true if the input is a valid tile within the level
|
||||||
public boolean insideMap( int tile ){
|
public boolean insideMap( int tile ){
|
||||||
|
|||||||
+1
-1
@@ -60,7 +60,7 @@ public class DisintegrationTrap extends Trap {
|
|||||||
for (Char ch : Actor.chars()){
|
for (Char ch : Actor.chars()){
|
||||||
Ballistica bolt = new Ballistica(pos, ch.pos, Ballistica.PROJECTILE);
|
Ballistica bolt = new Ballistica(pos, ch.pos, Ballistica.PROJECTILE);
|
||||||
if (bolt.collisionPos == ch.pos &&
|
if (bolt.collisionPos == ch.pos &&
|
||||||
(target == null || Dungeon.level.distance(pos, ch.pos) < Dungeon.level.distance(pos, target.pos))){
|
(target == null || Dungeon.level.distNoDiag(pos, ch.pos) < Dungeon.level.distNoDiag(pos, target.pos))){
|
||||||
target = ch;
|
target = ch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -57,7 +57,7 @@ public class GrimTrap extends Trap {
|
|||||||
for (Char ch : Actor.chars()){
|
for (Char ch : Actor.chars()){
|
||||||
Ballistica bolt = new Ballistica(pos, ch.pos, Ballistica.PROJECTILE);
|
Ballistica bolt = new Ballistica(pos, ch.pos, Ballistica.PROJECTILE);
|
||||||
if (bolt.collisionPos == ch.pos &&
|
if (bolt.collisionPos == ch.pos &&
|
||||||
(target == null || Dungeon.level.distance(pos, ch.pos) < Dungeon.level.distance(pos, target.pos))){
|
(target == null || Dungeon.level.distNoDiag(pos, ch.pos) < Dungeon.level.distNoDiag(pos, target.pos))){
|
||||||
target = ch;
|
target = ch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -57,7 +57,7 @@ public class PoisonDartTrap extends Trap {
|
|||||||
for (Char ch : Actor.chars()){
|
for (Char ch : Actor.chars()){
|
||||||
Ballistica bolt = new Ballistica(pos, ch.pos, Ballistica.PROJECTILE);
|
Ballistica bolt = new Ballistica(pos, ch.pos, Ballistica.PROJECTILE);
|
||||||
if (bolt.collisionPos == ch.pos &&
|
if (bolt.collisionPos == ch.pos &&
|
||||||
(target == null || Dungeon.level.distance(pos, ch.pos) < Dungeon.level.distance(pos, target.pos))){
|
(target == null || Dungeon.level.distNoDiag(pos, ch.pos) < Dungeon.level.distNoDiag(pos, target.pos))){
|
||||||
target = ch;
|
target = ch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -55,7 +55,7 @@ public class WornDartTrap extends Trap {
|
|||||||
for (Char ch : Actor.chars()){
|
for (Char ch : Actor.chars()){
|
||||||
Ballistica bolt = new Ballistica(pos, ch.pos, Ballistica.PROJECTILE);
|
Ballistica bolt = new Ballistica(pos, ch.pos, Ballistica.PROJECTILE);
|
||||||
if (bolt.collisionPos == ch.pos &&
|
if (bolt.collisionPos == ch.pos &&
|
||||||
(target == null || Dungeon.level.distance(pos, ch.pos) < Dungeon.level.distance(pos, target.pos))){
|
(target == null || Dungeon.level.distNoDiag(pos, ch.pos) < Dungeon.level.distNoDiag(pos, target.pos))){
|
||||||
target = ch;
|
target = ch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user