diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Wandmaker.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Wandmaker.java index 3845fcb55..6d15aecba 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Wandmaker.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Wandmaker.java @@ -302,9 +302,15 @@ public class Wandmaker extends NPC { Wandmaker npc = new Wandmaker(); boolean validPos; //Do not spawn wandmaker on the entrance, in front of a door, or on bad terrain. + int tries = 0; + int dist = 2; do { validPos = true; - npc.pos = level.pointToCell(room.random((room.width() > 6 && room.height() > 6) ? 2 : 1)); + if (tries > 30 && dist > 0){ + tries = 0; + dist--; + } + npc.pos = level.pointToCell(room.random(dist)); if (npc.pos == level.entrance() || level.solid[npc.pos]){ validPos = false; } @@ -318,6 +324,7 @@ public class Wandmaker extends NPC { || level.map[npc.pos] == Terrain.EMPTY_SP){ validPos = false; } + tries++; } while (!validPos); level.mobs.add( npc );