if (path == null || path.isEmpty() || !Dungeon.level.adjacent(pos, path.getFirst()) || path.size() > 2*Dungeon.level.distance(pos, target)) newPath = true; else if (path.getLast() != target) { if (Dungeon.level.adjacent(target, path.getLast())) { int last = path.removeLast(); if (path.isEmpty()) { path.add(target); path.add(last); path.add(target); } else if (!path.isEmpty()) { if (path.getLast() == target) { } else if (Dungeon.level.adjacent(target, path.getLast())) { path.add(target); path.add(last); path.add(target); int lookAhead = (int)GameMath.gate(1, path.size()-1, 4); for (int i = 0; i < lookAhead; i++) { int cell = path.get(i);
if (path == null || path.isEmpty() || !Dungeon.level.adjacent(pos, path.getFirst()) || path.size() > 2*Dungeon.level.distance(pos, target)) newPath = true; else if (path.getLast() != target) { if (Dungeon.level.adjacent(target, path.getLast())) { int last = path.removeLast(); if (path.isEmpty()) { path.add(target); path.add(last); path.add(target); } else if (!path.isEmpty()) { if (path.getLast() == target) { } else if (Dungeon.level.adjacent(target, path.getLast())) { path.add(target); path.add(last); path.add(target); int lookAhead = (int)GameMath.gate(1, path.size()-1, 4); for (int i = 0; i < lookAhead; i++) { int cell = path.get(i);
if (path == null || path.isEmpty() || !Dungeon.level.adjacent(pos, path.getFirst())) newPath = true; else if (path.getLast() != target) newPath = true; else { int lookAhead = (int) GameMath.gate(0, path.size()-1, 2); for (int i = 0; i < lookAhead; i++){ int cell = path.get(i); if (!Dungeon.level.passable[cell] || (fieldOfView[cell] && Actor.findChar(cell) != null)) { newPath = true; step = path.removeFirst();
if (path == null || path.isEmpty() || !Dungeon.level.adjacent(pos, path.getFirst())) newPath = true; else if (path.getLast() != target) newPath = true; else { int lookAhead = (int) GameMath.gate(0, path.size()-1, 2); for (int i = 0; i < lookAhead; i++){ int cell = path.get(i); if (!Dungeon.level.passable[cell] || (fieldOfView[cell] && Actor.findChar(cell) != null)) { newPath = true; step = path.removeFirst();
public static Path find( int from, int to, boolean[] passable ) { if (!buildDistanceMap( from, to, passable )) { return null; } Path result = new Path(); int s = from; // From the starting position we are moving downwards, // until we reach the ending point do { int minD = distance[s]; int mins = s; for (int i=0; i < dir.length; i++) { int n = s + dir[i]; int thisD = distance[n]; if (thisD < minD) { minD = thisD; mins = n; } } s = mins; result.add( s ); } while (s != to); return result; }
public static Path find( int from, int to, boolean[] passable ) { if (!buildDistanceMap( from, to, passable )) { return null; } Path result = new Path(); int s = from; // From the starting position we are moving downwards, // until we reach the ending point do { int minD = distance[s]; int mins = s; for (int i=0; i < dir.length; i++) { int n = s + dir[i]; int thisD = distance[n]; if (thisD < minD) { minD = thisD; mins = n; } } s = mins; result.add( s ); } while (s != to); return result; }
public static Path find( int from, int to, boolean[] passable ) { if (!buildDistanceMap( from, to, passable )) { return null; } Path result = new Path(); int s = from; // From the starting position we are moving downwards, // until we reach the ending point do { int minD = distance[s]; int mins = s; for (int i=0; i < dir.length; i++) { int n = s + dir[i]; int thisD = distance[n]; if (thisD < minD) { minD = thisD; mins = n; } } s = mins; result.add( s ); } while (s != to); return result; }