v0.7.0: fixed scroll of teleport rarely getting the player stuck
This commit is contained in:
+3
-3
@@ -147,7 +147,7 @@ public class ScrollOfTeleportation extends Scroll {
|
|||||||
if (r instanceof SpecialRoom){
|
if (r instanceof SpecialRoom){
|
||||||
int terr;
|
int terr;
|
||||||
boolean locked = false;
|
boolean locked = false;
|
||||||
for (Point p : r.getPoints()){
|
for (Point p : r.charPlaceablePoints(level)){
|
||||||
terr = level.map[level.pointToCell(p)];
|
terr = level.map[level.pointToCell(p)];
|
||||||
if (terr == Terrain.LOCKED_DOOR || terr == Terrain.BARRICADE){
|
if (terr == Terrain.LOCKED_DOOR || terr == Terrain.BARRICADE){
|
||||||
locked = true;
|
locked = true;
|
||||||
@@ -160,9 +160,9 @@ public class ScrollOfTeleportation extends Scroll {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int cell;
|
int cell;
|
||||||
for (Point p : r.getPoints()){
|
for (Point p : r.charPlaceablePoints(level)){
|
||||||
cell = level.pointToCell(p);
|
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);
|
candidates.add(cell);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -263,6 +263,7 @@ public abstract class RegularLevel extends Level {
|
|||||||
if (!heroFOV[cell]
|
if (!heroFOV[cell]
|
||||||
&& Actor.findChar( cell ) == null
|
&& Actor.findChar( cell ) == null
|
||||||
&& passable[cell]
|
&& passable[cell]
|
||||||
|
&& room.canPlaceCharacter(cellToPoint(cell), this)
|
||||||
&& cell != exit) {
|
&& cell != exit) {
|
||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -308,6 +308,21 @@ public abstract class Room extends Rect implements Graph.Node, Bundlable {
|
|||||||
return points;
|
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 ****
|
// **** Graph.Node interface ****
|
||||||
|
|
||||||
|
|||||||
+5
@@ -92,4 +92,9 @@ public class SecretRunestoneRoom extends SecretRoom {
|
|||||||
public boolean canPlaceGrass(Point p) {
|
public boolean canPlaceGrass(Point p) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canPlaceCharacter(Point p, Level l) {
|
||||||
|
return super.canPlaceCharacter(p, l) && l.map[l.pointToCell(p)] != Terrain.EMPTY_SP;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
@@ -25,6 +25,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
||||||
|
import com.watabou.utils.Point;
|
||||||
|
|
||||||
public class ExitRoom extends StandardRoom {
|
public class ExitRoom extends StandardRoom {
|
||||||
|
|
||||||
@@ -51,4 +52,8 @@ public class ExitRoom extends StandardRoom {
|
|||||||
Painter.set( level, level.exit, Terrain.EXIT );
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user