v0.8.2b: fixed crashes caused by new respawn behaviour and questgivers
This commit is contained in:
parent
0b53953294
commit
422288d857
|
@ -534,17 +534,25 @@ public abstract class Level implements Bundlable {
|
||||||
|
|
||||||
if (count < Dungeon.level.nMobs()) {
|
if (count < Dungeon.level.nMobs()) {
|
||||||
|
|
||||||
|
PathFinder.buildDistanceMap(Dungeon.hero.pos, BArray.or(Dungeon.level.passable, Dungeon.level.avoid, null));
|
||||||
|
|
||||||
Mob mob = Dungeon.level.createMob();
|
Mob mob = Dungeon.level.createMob();
|
||||||
mob.state = mob.WANDERING;
|
mob.state = mob.WANDERING;
|
||||||
mob.pos = Dungeon.level.randomRespawnCell( mob );
|
mob.pos = Dungeon.level.randomRespawnCell( mob );
|
||||||
if (Dungeon.hero.isAlive() && mob.pos != -1) {
|
if (Dungeon.hero.isAlive() && mob.pos != -1 && PathFinder.distance[mob.pos] >= 12) {
|
||||||
GameScene.add( mob );
|
GameScene.add( mob );
|
||||||
if (Statistics.amuletObtained) {
|
if (Statistics.amuletObtained) {
|
||||||
mob.beckon( Dungeon.hero.pos );
|
mob.beckon( Dungeon.hero.pos );
|
||||||
}
|
}
|
||||||
|
spend(Dungeon.level.respawnCooldown());
|
||||||
|
} else {
|
||||||
|
//try again in 1 turn
|
||||||
|
spend(TICK);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
spend(Dungeon.level.respawnCooldown());
|
||||||
}
|
}
|
||||||
spend(Dungeon.level.respawnCooldown());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,9 +55,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ExplosiveTrap;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.FrostTrap;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.FrostTrap;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.WornDartTrap;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.WornDartTrap;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.utils.BArray;
|
|
||||||
import com.watabou.utils.Bundle;
|
import com.watabou.utils.Bundle;
|
||||||
import com.watabou.utils.PathFinder;
|
|
||||||
import com.watabou.utils.Random;
|
import com.watabou.utils.Random;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -232,38 +230,33 @@ public abstract class RegularLevel extends Level {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int randomRespawnCell( Char ch ) {
|
public int randomRespawnCell( Char ch ) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int cell = -1;
|
int cell = -1;
|
||||||
|
|
||||||
PathFinder.buildDistanceMap(Dungeon.hero.pos, BArray.or(passable, avoid, null));
|
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
||||||
if (++count > 30) {
|
if (++count > 30) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Room room = randomRoom( StandardRoom.class );
|
Room room = randomRoom( StandardRoom.class );
|
||||||
if (room == null || room == roomEntrance) {
|
if (room == null || room == roomEntrance) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
cell = pointToCell(room.random(1));
|
cell = pointToCell(room.random(1));
|
||||||
if (Actor.findChar( cell ) == null
|
if (!heroFOV[cell]
|
||||||
|
&& Actor.findChar( cell ) == null
|
||||||
&& passable[cell]
|
&& passable[cell]
|
||||||
&& (!Char.hasProp(ch, Char.Property.LARGE) || openSpace[cell])
|
&& (!Char.hasProp(ch, Char.Property.LARGE) || openSpace[cell])
|
||||||
&& room.canPlaceCharacter(cellToPoint(cell), this)
|
&& room.canPlaceCharacter(cellToPoint(cell), this)
|
||||||
&& cell != exit) {
|
&& cell != exit) {
|
||||||
|
|
||||||
if (heroFOV[cell] || PathFinder.distance[cell] < 12){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user