v0.6.1: further improved imp spawning logic, reverted changes to regular spawning logic

This commit is contained in:
Evan Debenham 2017-07-29 14:44:07 -04:00 committed by Evan Debenham
parent 591b1b570e
commit d407144e28
2 changed files with 11 additions and 8 deletions
core/src/main/java/com/shatteredpixel/shatteredpixeldungeon
actors/mobs/npcs
levels

View File

@ -32,12 +32,14 @@ import com.shatteredpixel.shatteredpixeldungeon.items.quest.DwarfToken;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring; import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring;
import com.shatteredpixel.shatteredpixeldungeon.journal.Notes; import com.shatteredpixel.shatteredpixeldungeon.journal.Notes;
import com.shatteredpixel.shatteredpixeldungeon.levels.CityLevel; import com.shatteredpixel.shatteredpixeldungeon.levels.CityLevel;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ImpSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ImpSprite;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndImp; import com.shatteredpixel.shatteredpixeldungeon.windows.WndImp;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndQuest; import com.shatteredpixel.shatteredpixeldungeon.windows.WndQuest;
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;
public class Imp extends NPC { public class Imp extends NPC {
@ -184,7 +186,13 @@ public class Imp extends NPC {
Imp npc = new Imp(); Imp npc = new Imp();
do { do {
npc.pos = level.randomRespawnCell(); npc.pos = level.randomRespawnCell();
} while (npc.pos == -1 || level.heaps.get( npc.pos ) != null || level.findMob( npc.pos ) != null); } while (
npc.pos == -1 ||
level.heaps.get( npc.pos ) != null ||
level.findMob( npc.pos ) != null ||
//The imp doesn't move, so he cannot obstruct a passageway
!(Level.passable[npc.pos + PathFinder.CIRCLE4[0]] && Level.passable[npc.pos + PathFinder.CIRCLE4[2]]) ||
!(Level.passable[npc.pos + PathFinder.CIRCLE4[1]] && Level.passable[npc.pos + PathFinder.CIRCLE4[3]]));
level.mobs.add( npc ); level.mobs.add( npc );
spawned = true; spawned = true;

View File

@ -255,13 +255,8 @@ public abstract class RegularLevel extends Level {
if (room == null || room == roomEntrance) { if (room == null || room == roomEntrance) {
continue; continue;
} }
//if we can avoid it, don't place along the perimiter cell = pointToCell(room.random(1));
if (room.width() >= 6 && room.height() >= 6) {
cell = pointToCell(room.random(2));
} else {
cell = pointToCell(room.random(1));
}
if (!Dungeon.visible[cell] if (!Dungeon.visible[cell]
&& Actor.findChar( cell ) == null && Actor.findChar( cell ) == null
&& Level.passable[cell] && Level.passable[cell]