v0.7.4a: fixed respawn cells on special levels not checking for chars

This commit is contained in:
Evan Debenham 2019-07-27 14:33:47 -04:00
parent 97ebb16c81
commit b9be1a6a05
7 changed files with 26 additions and 15 deletions

View File

@ -203,10 +203,10 @@ public class CavesBossLevel extends Level {
@Override
public int randomRespawnCell() {
int cell = entrance + PathFinder.NEIGHBOURS8[Random.Int(8)];
while (!passable[cell]){
int cell;
do {
cell = entrance + PathFinder.NEIGHBOURS8[Random.Int(8)];
}
} while (!passable[cell] || Actor.findChar(cell) != null);
return cell;
}

View File

@ -174,10 +174,10 @@ public class CityBossLevel extends Level {
@Override
public int randomRespawnCell() {
int cell = entrance + PathFinder.NEIGHBOURS8[Random.Int(8)];
while (!passable[cell]){
int cell;
do {
cell = entrance + PathFinder.NEIGHBOURS8[Random.Int(8)];
}
} while (!passable[cell] || Actor.findChar(cell) != null);
return cell;
}

View File

@ -164,10 +164,10 @@ public class HallsBossLevel extends Level {
@Override
public int randomRespawnCell() {
int pos = entrance == -1 ? stairs : entrance;
int cell = pos + PathFinder.NEIGHBOURS8[Random.Int(8)];
while (!passable[cell]){
int cell;
do {
cell = pos + PathFinder.NEIGHBOURS8[Random.Int(8)];
}
} while (!passable[cell] || Actor.findChar(cell) != null);
return cell;
}

View File

@ -131,10 +131,10 @@ public class LastLevel extends Level {
@Override
public int randomRespawnCell() {
int cell = entrance + PathFinder.NEIGHBOURS8[Random.Int(8)];
while (!passable[cell]){
int cell;
do {
cell = entrance + PathFinder.NEIGHBOURS8[Random.Int(8)];
}
} while (!passable[cell] || Actor.findChar(cell) != null);
return cell;
}

View File

@ -37,6 +37,8 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.ExitRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.ImpShopRoom;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.watabou.noosa.Group;
import com.watabou.utils.PathFinder;
import com.watabou.utils.Random;
import java.util.ArrayList;
@ -127,7 +129,11 @@ public class LastShopLevel extends RegularLevel {
@Override
public int randomRespawnCell() {
return pointToCell( roomEntrance.random() );
int cell;
do {
cell = pointToCell( roomEntrance.random() );
} while (!passable[cell] || Actor.findChar(cell) != null);
return cell;
}
@Override

View File

@ -210,7 +210,12 @@ public class PrisonBossLevel extends Level {
@Override
public int randomRespawnCell() {
return 5+2*32 + PathFinder.NEIGHBOURS8[Random.Int(8)]; //random cell adjacent to the entrance.
int pos = 5+2*32; //random cell adjacent to the entrance.
int cell;
do {
cell = pos + PathFinder.NEIGHBOURS8[Random.Int(8)];
} while (!passable[cell] || Actor.findChar(cell) != null);
return cell;
}
@Override

View File

@ -130,7 +130,7 @@ public class SewerBossLevel extends SewerLevel {
int pos;
do {
pos = pointToCell(roomEntrance.random());
} while (pos == entrance || solid[pos]);
} while (pos == entrance || !passable[pos] || Actor.findChar(pos) != null);
return pos;
}