v0.7.0: fixed scroll of teleport rarely getting the player stuck
This commit is contained in:
parent
bb5b493c1b
commit
c3dec7af82
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 ****
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user