v0.7.0: fixed scroll of teleport rarely getting the player stuck

This commit is contained in:
Evan Debenham 2018-06-24 22:42:04 -04:00
parent bb5b493c1b
commit c3dec7af82
5 changed files with 29 additions and 3 deletions

View File

@ -147,7 +147,7 @@ public class ScrollOfTeleportation extends Scroll {
if (r instanceof SpecialRoom){
int terr;
boolean locked = false;
for (Point p : r.getPoints()){
for (Point p : r.charPlaceablePoints(level)){
terr = level.map[level.pointToCell(p)];
if (terr == Terrain.LOCKED_DOOR || terr == Terrain.BARRICADE){
locked = true;
@ -160,9 +160,9 @@ public class ScrollOfTeleportation extends Scroll {
}
int cell;
for (Point p : r.getPoints()){
for (Point p : r.charPlaceablePoints(level)){
cell = level.pointToCell(p);
if (level.passable[cell] && !level.visited[cell] && Actor.findChar(cell) != null){
if (level.passable[cell] && !level.visited[cell] && Actor.findChar(cell) == null){
candidates.add(cell);
}
}

View File

@ -263,6 +263,7 @@ public abstract class RegularLevel extends Level {
if (!heroFOV[cell]
&& Actor.findChar( cell ) == null
&& passable[cell]
&& room.canPlaceCharacter(cellToPoint(cell), this)
&& cell != exit) {
return cell;
}

View File

@ -308,6 +308,21 @@ public abstract class Room extends Rect implements Graph.Node, Bundlable {
return points;
}
//whether or not a character (usually spawned) can be placed here
public boolean canPlaceCharacter(Point p, Level l){
return inside(p);
}
public final ArrayList<Point> charPlaceablePoints(Level l){
ArrayList<Point> points = new ArrayList<>();
for (int i = left; i <= right; i++) {
for (int j = top; j <= bottom; j++) {
Point p = new Point(i, j);
if (canPlaceCharacter(p, l)) points.add(p);
}
}
return points;
}
// **** Graph.Node interface ****

View File

@ -92,4 +92,9 @@ public class SecretRunestoneRoom extends SecretRoom {
public boolean canPlaceGrass(Point p) {
return false;
}
@Override
public boolean canPlaceCharacter(Point p, Level l) {
return super.canPlaceCharacter(p, l) && l.map[l.pointToCell(p)] != Terrain.EMPTY_SP;
}
}

View File

@ -25,6 +25,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
import com.watabou.utils.Point;
public class ExitRoom extends StandardRoom {
@ -51,4 +52,8 @@ public class ExitRoom extends StandardRoom {
Painter.set( level, level.exit, Terrain.EXIT );
}
@Override
public boolean canPlaceCharacter(Point p, Level l) {
return super.canPlaceCharacter(p, l) && l.pointToCell(p) != l.exit;
}
}