v2.4.0: improve behavior for existing entrance/exit rooms
This commit is contained in:
@@ -260,7 +260,7 @@ public class Dungeon {
|
|||||||
QuickSlotButton.reset();
|
QuickSlotButton.reset();
|
||||||
Toolbar.swappedQuickslots = false;
|
Toolbar.swappedQuickslots = false;
|
||||||
|
|
||||||
depth = 15;
|
depth = 1;
|
||||||
branch = 0;
|
branch = 0;
|
||||||
generatedLevels.clear();
|
generatedLevels.clear();
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -49,7 +49,7 @@ public class ShrapnelBomb extends Bomb {
|
|||||||
|
|
||||||
boolean[] FOV = new boolean[Dungeon.level.length()];
|
boolean[] FOV = new boolean[Dungeon.level.length()];
|
||||||
Point c = Dungeon.level.cellToPoint(cell);
|
Point c = Dungeon.level.cellToPoint(cell);
|
||||||
ShadowCaster.castShadow(c.x, c.y, FOV, Dungeon.level.losBlocking, 8);
|
ShadowCaster.castShadow(c.x, c.y, Dungeon.level.width(), FOV, Dungeon.level.losBlocking, 8);
|
||||||
|
|
||||||
ArrayList<Char> affected = new ArrayList<>();
|
ArrayList<Char> affected = new ArrayList<>();
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -113,7 +113,7 @@ public class ScrollOfChallenge extends ExoticScroll {
|
|||||||
|
|
||||||
boolean[] visibleCells = new boolean[Dungeon.level.length()];
|
boolean[] visibleCells = new boolean[Dungeon.level.length()];
|
||||||
Point c = Dungeon.level.cellToPoint(pos);
|
Point c = Dungeon.level.cellToPoint(pos);
|
||||||
ShadowCaster.castShadow(c.x, c.y, visibleCells, Dungeon.level.losBlocking, 8);
|
ShadowCaster.castShadow(c.x, c.y, Dungeon.level.width(), visibleCells, Dungeon.level.losBlocking, 8);
|
||||||
int count=0;
|
int count=0;
|
||||||
for (boolean b : visibleCells){
|
for (boolean b : visibleCells){
|
||||||
if (b) count++;
|
if (b) count++;
|
||||||
|
|||||||
+1
-1
@@ -47,7 +47,7 @@ public class StoneOfDisarming extends Runestone {
|
|||||||
protected void activate(final int cell) {
|
protected void activate(final int cell) {
|
||||||
boolean[] FOV = new boolean[Dungeon.level.length()];
|
boolean[] FOV = new boolean[Dungeon.level.length()];
|
||||||
Point c = Dungeon.level.cellToPoint(cell);
|
Point c = Dungeon.level.cellToPoint(cell);
|
||||||
ShadowCaster.castShadow(c.x, c.y, FOV, Dungeon.level.losBlocking, DIST);
|
ShadowCaster.castShadow(c.x, c.y, Dungeon.level.width(), FOV, Dungeon.level.losBlocking, DIST);
|
||||||
|
|
||||||
int sX = Math.max(0, c.x - DIST);
|
int sX = Math.max(0, c.x - DIST);
|
||||||
int eX = Math.min(Dungeon.level.width()-1, c.x + DIST);
|
int eX = Math.min(Dungeon.level.width()-1, c.x + DIST);
|
||||||
|
|||||||
@@ -1290,7 +1290,7 @@ public abstract class Level implements Bundlable {
|
|||||||
viewDist *= 1f + 0.25f*((Hero) c).pointsInTalent(Talent.FARSIGHT);
|
viewDist *= 1f + 0.25f*((Hero) c).pointsInTalent(Talent.FARSIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
ShadowCaster.castShadow( cx, cy, fieldOfView, blocking, viewDist );
|
ShadowCaster.castShadow( cx, cy, width(), fieldOfView, blocking, viewDist );
|
||||||
} else {
|
} else {
|
||||||
BArray.setFalse(fieldOfView);
|
BArray.setFalse(fieldOfView);
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-2
@@ -61,9 +61,9 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.MagicalFire
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.PitRoom;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.PitRoom;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.ShopRoom;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.ShopRoom;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.SpecialRoom;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.SpecialRoom;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.entrance.EntranceRoom;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.entrance.EntranceRoom;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.exit.ExitRoom;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.exit.ExitRoom;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.BlazingTrap;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.BlazingTrap;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.BurningTrap;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.BurningTrap;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ChillingTrap;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ChillingTrap;
|
||||||
@@ -73,6 +73,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.traps.FrostTrap;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.PitfallTrap;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.PitfallTrap;
|
||||||
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.mechanics.ShadowCaster;
|
||||||
import com.watabou.utils.Bundle;
|
import com.watabou.utils.Bundle;
|
||||||
import com.watabou.utils.Point;
|
import com.watabou.utils.Point;
|
||||||
import com.watabou.utils.Random;
|
import com.watabou.utils.Random;
|
||||||
@@ -213,7 +214,7 @@ public abstract class RegularLevel extends Level {
|
|||||||
|
|
||||||
ArrayList<Room> stdRooms = new ArrayList<>();
|
ArrayList<Room> stdRooms = new ArrayList<>();
|
||||||
for (Room room : rooms) {
|
for (Room room : rooms) {
|
||||||
if (room instanceof StandardRoom && room != roomEntrance) {
|
if (room instanceof StandardRoom) {
|
||||||
for (int i = 0; i < ((StandardRoom) room).mobSpawnWeight(); i++) {
|
for (int i = 0; i < ((StandardRoom) room).mobSpawnWeight(); i++) {
|
||||||
stdRooms.add(room);
|
stdRooms.add(room);
|
||||||
}
|
}
|
||||||
@@ -222,6 +223,10 @@ public abstract class RegularLevel extends Level {
|
|||||||
Random.shuffle(stdRooms);
|
Random.shuffle(stdRooms);
|
||||||
Iterator<Room> stdRoomIter = stdRooms.iterator();
|
Iterator<Room> stdRoomIter = stdRooms.iterator();
|
||||||
|
|
||||||
|
boolean[] entranceFOV = new boolean[length()];
|
||||||
|
Point c = cellToPoint(entrance());
|
||||||
|
ShadowCaster.castShadow(c.x, c.y, width(), entranceFOV, losBlocking, 8);
|
||||||
|
|
||||||
while (mobsToSpawn > 0) {
|
while (mobsToSpawn > 0) {
|
||||||
Mob mob = createMob();
|
Mob mob = createMob();
|
||||||
Room roomToSpawn;
|
Room roomToSpawn;
|
||||||
@@ -236,6 +241,7 @@ public abstract class RegularLevel extends Level {
|
|||||||
mob.pos = pointToCell(roomToSpawn.random());
|
mob.pos = pointToCell(roomToSpawn.random());
|
||||||
tries--;
|
tries--;
|
||||||
} while (tries >= 0 && (findMob(mob.pos) != null
|
} while (tries >= 0 && (findMob(mob.pos) != null
|
||||||
|
|| entranceFOV[mob.pos] || (roomToSpawn.isEntrance() && distance(entrance(), mob.pos) <= 5)
|
||||||
|| !passable[mob.pos]
|
|| !passable[mob.pos]
|
||||||
|| solid[mob.pos]
|
|| solid[mob.pos]
|
||||||
|| !roomToSpawn.canPlaceCharacter(cellToPoint(mob.pos), this)
|
|| !roomToSpawn.canPlaceCharacter(cellToPoint(mob.pos), this)
|
||||||
@@ -256,6 +262,7 @@ public abstract class RegularLevel extends Level {
|
|||||||
mob.pos = pointToCell(roomToSpawn.random());
|
mob.pos = pointToCell(roomToSpawn.random());
|
||||||
tries--;
|
tries--;
|
||||||
} while (tries >= 0 && (findMob(mob.pos) != null
|
} while (tries >= 0 && (findMob(mob.pos) != null
|
||||||
|
|| entranceFOV[mob.pos] || (roomToSpawn.isEntrance() && distance(entrance(), mob.pos) <= 5)
|
||||||
|| !passable[mob.pos]
|
|| !passable[mob.pos]
|
||||||
|| solid[mob.pos]
|
|| solid[mob.pos]
|
||||||
|| !roomToSpawn.canPlaceCharacter(cellToPoint(mob.pos), this)
|
|| !roomToSpawn.canPlaceCharacter(cellToPoint(mob.pos), this)
|
||||||
|
|||||||
+22
-10
@@ -30,18 +30,24 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition;
|
|||||||
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.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret.SecretRoom;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret.SecretRoom;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.CaveRoom;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.tiles.CustomTilemap;
|
import com.shatteredpixel.shatteredpixeldungeon.tiles.CustomTilemap;
|
||||||
import com.watabou.noosa.Image;
|
import com.watabou.noosa.Image;
|
||||||
import com.watabou.noosa.Tilemap;
|
import com.watabou.noosa.Tilemap;
|
||||||
import com.watabou.utils.GameMath;
|
import com.watabou.utils.GameMath;
|
||||||
|
import com.watabou.utils.PathFinder;
|
||||||
import com.watabou.utils.Point;
|
import com.watabou.utils.Point;
|
||||||
import com.watabou.utils.Random;
|
import com.watabou.utils.Random;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class MineEntrance extends StandardRoom {
|
public class MineEntrance extends CaveRoom {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float[] sizeCatProbs() {
|
||||||
|
return new float[]{1, 0, 0};
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int minWidth() {
|
public int minWidth() {
|
||||||
@@ -60,19 +66,24 @@ public class MineEntrance extends StandardRoom {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paint(Level level) {
|
public void paint(Level level) {
|
||||||
Painter.fill( level, this, Terrain.WALL );
|
super.paint(level);
|
||||||
Painter.fill( level, this, 1, Terrain.EMPTY );
|
|
||||||
|
|
||||||
for (Door door : connected.values()) {
|
|
||||||
door.set( Door.Type.REGULAR );
|
|
||||||
}
|
|
||||||
|
|
||||||
int entrance;
|
int entrance;
|
||||||
|
boolean valid = false;
|
||||||
do {
|
do {
|
||||||
entrance = level.pointToCell(random(3));
|
entrance = level.pointToCell(random(3));
|
||||||
} while (level.findMob(entrance) != null || level.map[entrance] == Terrain.WALL);
|
for (int i : PathFinder.NEIGHBOURS9){
|
||||||
|
if (level.map[entrance+i] != Terrain.WALL){
|
||||||
|
valid = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while (level.findMob(entrance) != null || !valid);
|
||||||
Painter.set( level, entrance, Terrain.ENTRANCE );
|
Painter.set( level, entrance, Terrain.ENTRANCE );
|
||||||
|
|
||||||
|
for (int i : PathFinder.NEIGHBOURS8){
|
||||||
|
Painter.set( level, entrance+i, Terrain.EMPTY );
|
||||||
|
}
|
||||||
|
|
||||||
QuestExit vis = new QuestExit();
|
QuestExit vis = new QuestExit();
|
||||||
Point e = level.cellToPoint(entrance);
|
Point e = level.cellToPoint(entrance);
|
||||||
vis.pos(e.x - 1, e.y - 1);
|
vis.pos(e.x - 1, e.y - 1);
|
||||||
@@ -88,7 +99,8 @@ public class MineEntrance extends StandardRoom {
|
|||||||
if (Blacksmith.Quest.Type() == Blacksmith.Quest.CRYSTAL){
|
if (Blacksmith.Quest.Type() == Blacksmith.Quest.CRYSTAL){
|
||||||
for (int i = 0; i < width()*height()/2; i ++){
|
for (int i = 0; i < width()*height()/2; i ++){
|
||||||
Point r = random(1);
|
Point r = random(1);
|
||||||
if (level.distance(level.pointToCell(r), entrance) > 1) {
|
if (level.distance(level.pointToCell(r), entrance) > 1
|
||||||
|
&& level.map[level.pointToCell(r)] != Terrain.WALL) {
|
||||||
Painter.set(level, r, Terrain.MINE_CRYSTAL);
|
Painter.set(level, r, Terrain.MINE_CRYSTAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-1
@@ -54,7 +54,11 @@ public class EntranceRoom extends StandardRoom {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canMerge(Level l, Point p, int mergeTerrain) {
|
public boolean canMerge(Level l, Point p, int mergeTerrain) {
|
||||||
return false;
|
if (Dungeon.depth <= 2) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return super.canMerge(l, p, mergeTerrain);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+6
-1
@@ -40,7 +40,12 @@ public class ExitRoom extends StandardRoom {
|
|||||||
public int minHeight() {
|
public int minHeight() {
|
||||||
return Math.max(super.minHeight(), 5);
|
return Math.max(super.minHeight(), 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isExit() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public void paint(Level level) {
|
public void paint(Level level) {
|
||||||
|
|
||||||
Painter.fill( level, this, Terrain.WALL );
|
Painter.fill( level, this, Terrain.WALL );
|
||||||
|
|||||||
+16
-17
@@ -21,7 +21,6 @@
|
|||||||
|
|
||||||
package com.shatteredpixel.shatteredpixeldungeon.mechanics;
|
package com.shatteredpixel.shatteredpixeldungeon.mechanics;
|
||||||
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||||
import com.watabou.utils.BArray;
|
import com.watabou.utils.BArray;
|
||||||
|
|
||||||
@@ -46,7 +45,7 @@ public final class ShadowCaster {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void castShadow( int x, int y, boolean[] fieldOfView, boolean[] blocking, int distance ) {
|
public static void castShadow( int x, int y, int w, boolean[] fieldOfView, boolean[] blocking, int distance ) {
|
||||||
|
|
||||||
if (distance >= MAX_DISTANCE){
|
if (distance >= MAX_DISTANCE){
|
||||||
distance = MAX_DISTANCE;
|
distance = MAX_DISTANCE;
|
||||||
@@ -55,18 +54,18 @@ public final class ShadowCaster {
|
|||||||
BArray.setFalse(fieldOfView);
|
BArray.setFalse(fieldOfView);
|
||||||
|
|
||||||
//set source cell to true
|
//set source cell to true
|
||||||
fieldOfView[y * Dungeon.level.width() + x] = true;
|
fieldOfView[y * w + x] = true;
|
||||||
|
|
||||||
//scans octants, clockwise
|
//scans octants, clockwise
|
||||||
try {
|
try {
|
||||||
scanOctant(distance, fieldOfView, blocking, 1, x, y, 0.0, 1.0, +1, -1, false);
|
scanOctant(distance, fieldOfView, blocking, 1, x, y, w, 0.0, 1.0, +1, -1, false);
|
||||||
scanOctant(distance, fieldOfView, blocking, 1, x, y, 0.0, 1.0, -1, +1, true);
|
scanOctant(distance, fieldOfView, blocking, 1, x, y, w, 0.0, 1.0, -1, +1, true);
|
||||||
scanOctant(distance, fieldOfView, blocking, 1, x, y, 0.0, 1.0, +1, +1, true);
|
scanOctant(distance, fieldOfView, blocking, 1, x, y, w, 0.0, 1.0, +1, +1, true);
|
||||||
scanOctant(distance, fieldOfView, blocking, 1, x, y, 0.0, 1.0, +1, +1, false);
|
scanOctant(distance, fieldOfView, blocking, 1, x, y, w, 0.0, 1.0, +1, +1, false);
|
||||||
scanOctant(distance, fieldOfView, blocking, 1, x, y, 0.0, 1.0, -1, +1, false);
|
scanOctant(distance, fieldOfView, blocking, 1, x, y, w, 0.0, 1.0, -1, +1, false);
|
||||||
scanOctant(distance, fieldOfView, blocking, 1, x, y, 0.0, 1.0, +1, -1, true);
|
scanOctant(distance, fieldOfView, blocking, 1, x, y, w, 0.0, 1.0, +1, -1, true);
|
||||||
scanOctant(distance, fieldOfView, blocking, 1, x, y, 0.0, 1.0, -1, -1, true);
|
scanOctant(distance, fieldOfView, blocking, 1, x, y, w, 0.0, 1.0, -1, -1, true);
|
||||||
scanOctant(distance, fieldOfView, blocking, 1, x, y, 0.0, 1.0, -1, -1, false);
|
scanOctant(distance, fieldOfView, blocking, 1, x, y, w, 0.0, 1.0, -1, -1, false);
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
ShatteredPixelDungeon.reportException(e);
|
ShatteredPixelDungeon.reportException(e);
|
||||||
BArray.setFalse(fieldOfView);
|
BArray.setFalse(fieldOfView);
|
||||||
@@ -77,7 +76,7 @@ public final class ShadowCaster {
|
|||||||
//scans a single 45 degree octant of the FOV.
|
//scans a single 45 degree octant of the FOV.
|
||||||
//This can add up to a whole FOV by mirroring in X(mX), Y(mY), and X=Y(mXY)
|
//This can add up to a whole FOV by mirroring in X(mX), Y(mY), and X=Y(mXY)
|
||||||
private static void scanOctant(int distance, boolean[] fov, boolean[] blocking, int row,
|
private static void scanOctant(int distance, boolean[] fov, boolean[] blocking, int row,
|
||||||
int x, int y, double lSlope, double rSlope,
|
int x, int y, int w, double lSlope, double rSlope,
|
||||||
int mX, int mY, boolean mXY){
|
int mX, int mY, boolean mXY){
|
||||||
|
|
||||||
boolean inBlocking = false;
|
boolean inBlocking = false;
|
||||||
@@ -112,11 +111,11 @@ public final class ShadowCaster {
|
|||||||
(int)Math.ceil((row + 0.5) * rSlope - 0.499));
|
(int)Math.ceil((row + 0.5) * rSlope - 0.499));
|
||||||
|
|
||||||
//coordinates of source
|
//coordinates of source
|
||||||
int cell = x + y*Dungeon.level.width();
|
int cell = x + y*w;
|
||||||
|
|
||||||
//plus coordinates of current cell (including mirroring in x, y, and x=y)
|
//plus coordinates of current cell (including mirroring in x, y, and x=y)
|
||||||
if (mXY) cell += mX*start*Dungeon.level.width() + mY*row;
|
if (mXY) cell += mX*start*w + mY*row;
|
||||||
else cell += mX*start + mY*row*Dungeon.level.width();
|
else cell += mX*start + mY*row*w;
|
||||||
|
|
||||||
//for each column in this row, which
|
//for each column in this row, which
|
||||||
for (col = start; col <= end; col++){
|
for (col = start; col <= end; col++){
|
||||||
@@ -136,7 +135,7 @@ public final class ShadowCaster {
|
|||||||
|
|
||||||
//start a new scan, 1 row deeper, ending at the left side of current cell
|
//start a new scan, 1 row deeper, ending at the left side of current cell
|
||||||
if (col != start){
|
if (col != start){
|
||||||
scanOctant(distance, fov, blocking, row+1, x, y, lSlope,
|
scanOctant(distance, fov, blocking, row+1, x, y, w, lSlope,
|
||||||
//change in x over change in y
|
//change in x over change in y
|
||||||
(col - 0.5) / (row + 0.5),
|
(col - 0.5) / (row + 0.5),
|
||||||
mX, mY, mXY);
|
mX, mY, mXY);
|
||||||
@@ -155,7 +154,7 @@ public final class ShadowCaster {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!mXY) cell += mX;
|
if (!mXY) cell += mX;
|
||||||
else cell += mX*Dungeon.level.width();
|
else cell += mX*w;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user