From 1c135bc16b47522ce64c11c23e62477989b25b16 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Thu, 1 May 2025 13:32:29 -0400 Subject: [PATCH] v3.1.0: final adjustments to entrance/exit rooms --- .../levels/rooms/standard/CellBlockRoom.java | 8 +- ...dgeRoom.java => RegionDecoBridgeRoom.java} | 2 +- .../rooms/standard/RegionDecoPatchRoom.java | 5 - .../levels/rooms/standard/RuinsRoom.java | 10 +- .../levels/rooms/standard/StandardRoom.java | 4 +- .../entrance/CellBlockEntranceRoom.java | 71 +++++++++++++++ .../rooms/standard/entrance/EntranceRoom.java | 27 +++--- .../entrance/LibraryHallEntranceRoom.java | 56 ++++++++++++ .../RegionDecoBridgeEntranceRoom.java | 74 +++++++++++++++ .../entrance/RegionDecoPatchEntranceRoom.java | 31 ++++++- .../standard/entrance/RuinsEntranceRoom.java | 84 +++++++++++++++++ .../entrance/WaterBridgeEntranceRoom.java | 27 +++++- .../standard/exit/CellBlockExitRoom.java | 76 ++++++++++++++++ .../levels/rooms/standard/exit/ExitRoom.java | 27 +++--- .../standard/exit/LibraryHallExitRoom.java | 61 +++++++++++++ .../exit/RegionDecoBridgeExitRoom.java | 80 ++++++++++++++++ .../exit/RegionDecoPatchExitRoom.java | 4 +- .../rooms/standard/exit/RuinsExitRoom.java | 91 +++++++++++++++++++ 18 files changed, 692 insertions(+), 46 deletions(-) rename core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/{CustomDecoBridgeRoom.java => RegionDecoBridgeRoom.java} (95%) create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/CellBlockEntranceRoom.java create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/LibraryHallEntranceRoom.java create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/RegionDecoBridgeEntranceRoom.java create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/RuinsEntranceRoom.java create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/CellBlockExitRoom.java create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/LibraryHallExitRoom.java create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/RegionDecoBridgeExitRoom.java create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/RuinsExitRoom.java diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/CellBlockRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/CellBlockRoom.java index 41affe100..8b52381ed 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/CellBlockRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/CellBlockRoom.java @@ -65,6 +65,11 @@ public class CellBlockRoom extends StandardRoom { topBottomDoors = null; } + int openRooms = rows*cols; + if (openRooms == 9) openRooms--; + //if we're an entrance or exit, one room must be open + boolean guaranteeOpenRoom = isEntrance() || isExit(); + for (int x = 0; x < rows; x++){ for (int y = 0; y < cols; y++){ //no center room @@ -73,8 +78,9 @@ public class CellBlockRoom extends StandardRoom { int left = internal.left + 1 + (x * (w + Wspacing)); int top = internal.top + 1 + (y * (h + Hspacing)); - if (Random.Int(w*h) == 0){ + if (Random.Int(w*h) == 0 && (!guaranteeOpenRoom || openRooms > 1)){ Painter.fill(level, left, top, w, h, Terrain.REGION_DECO); + openRooms--; } else { Painter.fill(level, left, top, w, h, Terrain.EMPTY_SP); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/CustomDecoBridgeRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/RegionDecoBridgeRoom.java similarity index 95% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/CustomDecoBridgeRoom.java rename to core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/RegionDecoBridgeRoom.java index a46cf8e64..20939797b 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/CustomDecoBridgeRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/RegionDecoBridgeRoom.java @@ -24,7 +24,7 @@ package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; //doesn't look much like a bridge, but can easily use it internally -public class CustomDecoBridgeRoom extends StandardBridgeRoom { +public class RegionDecoBridgeRoom extends StandardBridgeRoom { //can be large because the line breaks the space up public float[] sizeCatProbs(){ diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/RegionDecoPatchRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/RegionDecoPatchRoom.java index 44be4ffaf..07781f48d 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/RegionDecoPatchRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/RegionDecoPatchRoom.java @@ -28,11 +28,6 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; public class RegionDecoPatchRoom extends PatchRoom { - @Override - public float[] sizeCatProbs() { - return new float[]{4, 1, 0}; - } - @Override public int minHeight() { return Math.max(5, super.minHeight()); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/RuinsRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/RuinsRoom.java index b490d501b..60a397e5c 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/RuinsRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/RuinsRoom.java @@ -42,12 +42,12 @@ public class RuinsRoom extends PatchRoom { @Override protected float fill() { - //fill scales from ~20% at 4x4, to ~50% at 18x18 - // normal ~20% to ~30% - // large ~30% to ~40% - // giant ~40% to ~50% + //fill scales from ~30% at 4x4, to ~60% at 18x18 + // normal ~30% to ~40% + // large ~40% to ~50% + // giant ~50% to ~60% int scale = Math.min(width()*height(), 18*18); - return 0.20f + scale/1024f; + return 0.30f + scale/1024f; } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StandardRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StandardRoom.java index 7cac206f1..05a48c8a3 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StandardRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StandardRoom.java @@ -126,14 +126,14 @@ public abstract class StandardRoom extends Room { rooms.add(WaterBridgeRoom.class); rooms.add(CircleBasinRoom.class); - rooms.add(SegmentedRoom.class); rooms.add(RegionDecoLineRoom.class); + rooms.add(SegmentedRoom.class); rooms.add(PillarsRoom.class); rooms.add(ChasmBridgeRoom.class); rooms.add(CellBlockRoom.class); rooms.add(CaveRoom.class); - rooms.add(CustomDecoBridgeRoom.class); + rooms.add(RegionDecoBridgeRoom.class); rooms.add(CavesFissureRoom.class); rooms.add(CirclePitRoom.class); rooms.add(CircleWallRoom.class); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/CellBlockEntranceRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/CellBlockEntranceRoom.java new file mode 100644 index 000000000..e25670016 --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/CellBlockEntranceRoom.java @@ -0,0 +1,71 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2025 Evan Debenham + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + */ + +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.entrance; + +import com.shatteredpixel.shatteredpixeldungeon.levels.Level; +import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; +import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition; +import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.CellBlockRoom; +import com.watabou.utils.PathFinder; +import com.watabou.utils.Point; + +public class CellBlockEntranceRoom extends CellBlockRoom { + + @Override + public float[] sizeCatProbs() { + return new float[]{0, 1, 0}; + } + + @Override + public boolean isEntrance() { + return true; + } + + @Override + public void paint(Level level) { + super.paint(level); + + while (true){ + Point p = random(3); + + if (level.map[level.pointToCell(p)] == Terrain.EMPTY_SP){ + boolean valid = true; + for (int i : PathFinder.NEIGHBOURS8){ + if (level.map[level.pointToCell(p)+i] == Terrain.DOOR){ + valid = false; + } + } + + if (valid){ + int entrance = level.pointToCell(p); + Painter.set( level, entrance, Terrain.ENTRANCE_SP ); + + level.transitions.add(new LevelTransition(level, entrance, LevelTransition.Type.REGULAR_ENTRANCE)); + return; + } + } + } + + } + +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/EntranceRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/EntranceRoom.java index cd7938068..a969c8619 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/EntranceRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/EntranceRoom.java @@ -130,49 +130,50 @@ public class EntranceRoom extends StandardRoom { private static ArrayList> rooms = new ArrayList<>(); static { - rooms.add(EntranceRoom.class); - rooms.add(RegionDecoLineEntranceRoom.class); - rooms.add(StatueLineEntranceRoom.class); - + rooms.add(RegionDecoPatchEntranceRoom.class); rooms.add(WaterBridgeEntranceRoom.class); - rooms.add(CircleBasinEntranceRoom.class); rooms.add(RingEntranceRoom.class); + rooms.add(CircleBasinEntranceRoom.class); + rooms.add(RegionDecoLineEntranceRoom.class); rooms.add(ChasmBridgeEntranceRoom.class); rooms.add(PillarsEntranceRoom.class); - rooms.add(EntranceRoom.class); //TODO + rooms.add(CellBlockEntranceRoom.class); rooms.add(CaveEntranceRoom.class); + rooms.add(RegionDecoBridgeEntranceRoom.class); rooms.add(CavesFissureEntranceRoom.class); rooms.add(CircleWallEntranceRoom.class); rooms.add(HallwayEntranceRoom.class); rooms.add(StatuesEntranceRoom.class); + rooms.add(LibraryHallEntranceRoom.class); rooms.add(LibraryRingEntranceRoom.class); + rooms.add(RegionDecoPatchEntranceRoom.class); + rooms.add(RuinsEntranceRoom.class); rooms.add(ChasmEntranceRoom.class); rooms.add(RitualEntranceRoom.class); - rooms.add(RegionDecoPatchEntranceRoom.class); } private static float[][] chances = new float[27][]; static { //first 2 floors only use simpler entrance rooms - chances[1] = new float[]{1,1,0, 1,0,0, 0,0,0, 0,0,0, 0,0,0, 0,0,0}; + chances[1] = new float[]{4,3,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0}; chances[2] = chances[1]; - chances[3] = new float[]{0,4,0, 4,1,1, 0,0,0, 0,0,0, 0,0,0, 0,0,0}; + chances[3] = new float[]{4,3,2,1, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0}; chances[5] = chances[4] = chances[3]; - chances[6] = new float[]{0,2,0, 0,0,0, 4,4,0, 0,0,0, 0,0,0, 0,0,0}; + chances[6] = new float[]{0,0,0,0, 4,3,2,1, 0,0,0,0, 0,0,0,0, 0,0,0,0}; chances[10] = chances[9] = chances[8] = chances[7] = chances[6]; - chances[11] = new float[]{0,3,0, 0,0,0, 0,0,0, 3,2,2, 0,0,0, 0,0,0}; + chances[11] = new float[]{0,0,0,0, 0,0,0,0, 4,3,2,1, 0,0,0,0, 0,0,0,0}; chances[15] = chances[14] = chances[13] = chances[12] = chances[11]; - chances[16] = new float[]{0,0,3, 0,0,0, 0,0,0, 0,0,0, 3,2,2, 0,0,0}; + chances[16] = new float[]{0,0,0,0, 0,0,0,0, 0,0,0,0, 4,3,2,1, 0,0,0,0}; chances[20] = chances[19] = chances[18] = chances[17] = chances[16]; - chances[21] = new float[]{0,0,2, 0,0,0, 0,0,0, 0,0,0, 0,0,0, 3,2,3}; + chances[21] = new float[]{0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 4,3,2,1}; chances[26] = chances[25] = chances[24] = chances[23] = chances[22] = chances[21]; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/LibraryHallEntranceRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/LibraryHallEntranceRoom.java new file mode 100644 index 000000000..0f9ae9e26 --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/LibraryHallEntranceRoom.java @@ -0,0 +1,56 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2025 Evan Debenham + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + */ + +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.entrance; + +import com.shatteredpixel.shatteredpixeldungeon.levels.Level; +import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; +import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition; +import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.LibraryHallRoom; +import com.watabou.utils.Point; + +public class LibraryHallEntranceRoom extends LibraryHallRoom { + + @Override + public boolean isEntrance() { + return true; + } + + @Override + public void paint(Level level) { + super.paint(level); + + while (true){ + Point p = random(2); + + if (level.map[level.pointToCell(p)] == Terrain.REGION_DECO){ + int entrance = level.pointToCell(p); + Painter.set( level, entrance, Terrain.ENTRANCE ); + + level.transitions.add(new LevelTransition(level, entrance, LevelTransition.Type.REGULAR_ENTRANCE)); + return; + } + } + + } + +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/RegionDecoBridgeEntranceRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/RegionDecoBridgeEntranceRoom.java new file mode 100644 index 000000000..fe3b3a02e --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/RegionDecoBridgeEntranceRoom.java @@ -0,0 +1,74 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2025 Evan Debenham + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + */ + +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.entrance; + +import com.shatteredpixel.shatteredpixeldungeon.levels.Level; +import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; +import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition; +import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.RegionDecoBridgeRoom; +import com.watabou.utils.PathFinder; + +public class RegionDecoBridgeEntranceRoom extends RegionDecoBridgeRoom { + + @Override + public int minWidth() { + return Math.max(8, super.minWidth()); + } + + @Override + public int minHeight() { + return Math.max(8, super.minHeight()); + } + + @Override + public boolean isEntrance() { + return true; + } + + @Override + public void paint(Level level) { + super.paint(level); + + int entrance; + boolean valid; + do { + valid = true; + entrance = level.pointToCell(random(2)); + + if (spaceRect.inside(level.cellToPoint(entrance))){ + valid = false; + } else { + for (int i : PathFinder.NEIGHBOURS8){ + if (level.map[entrance+i] == Terrain.REGION_DECO_ALT){ + valid = false; + } + } + } + + } while (!valid); + + Painter.set( level, entrance, Terrain.ENTRANCE ); + level.transitions.add(new LevelTransition(level, entrance, LevelTransition.Type.REGULAR_ENTRANCE)); + } + +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/RegionDecoPatchEntranceRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/RegionDecoPatchEntranceRoom.java index fe0d6b483..b7cb96029 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/RegionDecoPatchEntranceRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/RegionDecoPatchEntranceRoom.java @@ -21,12 +21,15 @@ package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.entrance; +import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.RegionDecoPatchRoom; import com.watabou.utils.PathFinder; +import com.watabou.utils.Point; public class RegionDecoPatchEntranceRoom extends RegionDecoPatchRoom { @@ -45,6 +48,24 @@ public class RegionDecoPatchEntranceRoom extends RegionDecoPatchRoom { return true; } + @Override + public boolean canMerge(Level l, Room other, Point p, int mergeTerrain) { + if (Dungeon.depth <= 2) { + return false; + } else { + return super.canMerge(l, other, p, mergeTerrain); + } + } + + @Override + public boolean canPlaceTrap(Point p) { + if (Dungeon.depth == 1) { + return false; + } else { + return super.canPlaceTrap(p); + } + } + @Override public void paint(Level level) { super.paint(level); @@ -57,11 +78,11 @@ public class RegionDecoPatchEntranceRoom extends RegionDecoPatchRoom { //need extra logic here as these rooms can spawn small and cramped in very rare cases if (tries-- > 0){ - valid = level.map[entrance] != Terrain.WALL && level.findMob(entrance) == null; + valid = level.map[entrance] != Terrain.REGION_DECO && level.findMob(entrance) == null; } else { valid = false; for (int i : PathFinder.NEIGHBOURS4){ - if (level.map[entrance+i] != Terrain.WALL){ + if (level.map[entrance+i] != Terrain.REGION_DECO){ valid = true; } } @@ -74,7 +95,11 @@ public class RegionDecoPatchEntranceRoom extends RegionDecoPatchRoom { Painter.set( level, entrance+i, Terrain.EMPTY ); } - level.transitions.add(new LevelTransition(level, entrance, LevelTransition.Type.REGULAR_ENTRANCE)); + if (Dungeon.depth == 1){ + level.transitions.add(new LevelTransition(level, entrance, LevelTransition.Type.SURFACE)); + } else { + level.transitions.add(new LevelTransition(level, entrance, LevelTransition.Type.REGULAR_ENTRANCE)); + } } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/RuinsEntranceRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/RuinsEntranceRoom.java new file mode 100644 index 000000000..c163ce1fc --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/RuinsEntranceRoom.java @@ -0,0 +1,84 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2025 Evan Debenham + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + */ + +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.entrance; + +import com.shatteredpixel.shatteredpixeldungeon.levels.Level; +import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; +import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition; +import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.RuinsRoom; +import com.watabou.utils.PathFinder; + +public class RuinsEntranceRoom extends RuinsRoom { + + @Override + public int minWidth() { + return Math.max(super.minWidth(), 7); + } + + @Override + public int minHeight() { + return Math.max(super.minHeight(), 7); + } + + @Override + public boolean isEntrance() { + return true; + } + + @Override + public float[] sizeCatProbs() { + return new float[]{2, 1, 0}; + } + + @Override + public void paint(Level level) { + super.paint(level); + + int entrance; + int tries = 30; + boolean valid; + do { + entrance = level.pointToCell(random(2)); + + //need extra logic here as these rooms can spawn small and cramped in very rare cases + if (tries-- > 0){ + valid = level.map[entrance] != Terrain.WALL && level.findMob(entrance) == null; + } else { + valid = false; + for (int i : PathFinder.NEIGHBOURS4){ + if (level.map[entrance+i] != Terrain.WALL && level.map[entrance+i] != Terrain.REGION_DECO){ + valid = true; + } + } + valid = valid && level.findMob(entrance) == null; + } + } while (!valid); + Painter.set( level, entrance, Terrain.ENTRANCE ); + + for (int i : PathFinder.NEIGHBOURS8){ + Painter.set( level, entrance+i, Terrain.EMPTY ); + } + + level.transitions.add(new LevelTransition(level, entrance, LevelTransition.Type.REGULAR_ENTRANCE)); + } +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/WaterBridgeEntranceRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/WaterBridgeEntranceRoom.java index e135a607c..84c3a0d5e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/WaterBridgeEntranceRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/WaterBridgeEntranceRoom.java @@ -21,12 +21,15 @@ package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.entrance; +import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.WaterBridgeRoom; import com.watabou.utils.PathFinder; +import com.watabou.utils.Point; public class WaterBridgeEntranceRoom extends WaterBridgeRoom { @@ -45,6 +48,24 @@ public class WaterBridgeEntranceRoom extends WaterBridgeRoom { return true; } + @Override + public boolean canMerge(Level l, Room other, Point p, int mergeTerrain) { + if (Dungeon.depth <= 2) { + return false; + } else { + return super.canMerge(l, other, p, mergeTerrain); + } + } + + @Override + public boolean canPlaceTrap(Point p) { + if (Dungeon.depth == 1) { + return false; + } else { + return super.canPlaceTrap(p); + } + } + @Override public void paint(Level level) { super.paint(level); @@ -60,6 +81,10 @@ public class WaterBridgeEntranceRoom extends WaterBridgeRoom { } Painter.set( level, entrance, Terrain.ENTRANCE ); - level.transitions.add(new LevelTransition(level, entrance, LevelTransition.Type.REGULAR_ENTRANCE)); + if (Dungeon.depth == 1){ + level.transitions.add(new LevelTransition(level, entrance, LevelTransition.Type.SURFACE)); + } else { + level.transitions.add(new LevelTransition(level, entrance, LevelTransition.Type.REGULAR_ENTRANCE)); + } } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/CellBlockExitRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/CellBlockExitRoom.java new file mode 100644 index 000000000..4b60901b5 --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/CellBlockExitRoom.java @@ -0,0 +1,76 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2025 Evan Debenham + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + */ + +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.exit; + +import com.shatteredpixel.shatteredpixeldungeon.levels.Level; +import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; +import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition; +import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.CellBlockRoom; +import com.watabou.utils.PathFinder; +import com.watabou.utils.Point; + +public class CellBlockExitRoom extends CellBlockRoom { + + @Override + public float[] sizeCatProbs() { + return new float[]{0, 1, 0}; + } + + @Override + public boolean isExit() { + return true; + } + + @Override + public void paint(Level level) { + super.paint(level); + + while (true){ + Point p = random(3); + + if (level.map[level.pointToCell(p)] == Terrain.EMPTY_SP){ + boolean valid = true; + for (int i : PathFinder.NEIGHBOURS8){ + if (level.map[level.pointToCell(p)+i] == Terrain.DOOR){ + valid = false; + } + } + + if (valid){ + int entrance = level.pointToCell(p); + Painter.set( level, entrance, Terrain.EXIT ); + + level.transitions.add(new LevelTransition(level, entrance, LevelTransition.Type.REGULAR_EXIT)); + return; + } + } + } + + } + + @Override + public boolean canPlaceCharacter(Point p, Level l) { + return super.canPlaceCharacter(p, l) && l.pointToCell(p) != l.exit(); + } + +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/ExitRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/ExitRoom.java index a5684dcd7..729df6679 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/ExitRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/ExitRoom.java @@ -72,48 +72,49 @@ public class ExitRoom extends StandardRoom { private static ArrayList> rooms = new ArrayList<>(); static { - rooms.add(ExitRoom.class); - rooms.add(RegionDecoLineExitRoom.class); - rooms.add(StatueLineExitRoom.class); - + rooms.add(RegionDecoPatchExitRoom.class); rooms.add(WaterBridgeExitRoom.class); - rooms.add(CircleBasinExitRoom.class); rooms.add(RingExitRoom.class); + rooms.add(CircleBasinExitRoom.class); + rooms.add(RegionDecoLineExitRoom.class); rooms.add(ChasmBridgeExitRoom.class); rooms.add(PillarsExitRoom.class); - rooms.add(ExitRoom.class); //todo + rooms.add(CellBlockExitRoom.class); rooms.add(CaveExitRoom.class); + rooms.add(RegionDecoBridgeExitRoom.class); rooms.add(CavesFissureExitRoom.class); rooms.add(CircleWallExitRoom.class); rooms.add(HallwayExitRoom.class); rooms.add(StatuesExitRoom.class); + rooms.add(LibraryHallExitRoom.class); rooms.add(LibraryRingExitRoom.class); + rooms.add(RegionDecoPatchExitRoom.class); + rooms.add(RuinsExitRoom.class); rooms.add(ChasmExitRoom.class); rooms.add(RitualExitRoom.class); - rooms.add(RegionDecoPatchExitRoom.class); } private static float[][] chances = new float[27][]; static { //floor 1 only uses simpler exit rooms - chances[1] = new float[]{1,1,0, 1,0,0, 0,0,0, 0,0,0, 0,0,0, 0,0,0}; - chances[2] = new float[]{0,4,0, 4,1,1, 0,0,0, 0,0,0, 0,0,0, 0,0,0}; + chances[1] = new float[]{4,3,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0}; + chances[2] = new float[]{4,3,2,1, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0}; chances[5] = chances[4] = chances[3] = chances[2]; - chances[6] = new float[]{0,2,0, 0,0,0, 4,4,0, 0,0,0, 0,0,0, 0,0,0}; + chances[6] = new float[]{0,0,0,0, 4,3,2,1, 0,0,0,0, 0,0,0,0, 0,0,0,0}; chances[10] = chances[9] = chances[8] = chances[7] = chances[6]; - chances[11] = new float[]{0,2,0, 0,0,0, 0,0,0, 3,3,2, 0,0,0, 0,0,0}; + chances[11] = new float[]{0,0,0,0, 0,0,0,0, 4,3,2,1, 0,0,0,0, 0,0,0,0}; chances[15] = chances[14] = chances[13] = chances[12] = chances[11]; - chances[16] = new float[]{0,0,3, 0,0,0, 0,0,0, 0,0,0, 3,2,2, 0,0,0}; + chances[16] = new float[]{0,0,0,0, 0,0,0,0, 0,0,0,0, 4,3,2,1, 0,0,0,0}; chances[20] = chances[19] = chances[18] = chances[17] = chances[16]; - chances[21] = new float[]{0,0,2, 0,0,0, 0,0,0, 0,0,0, 0,0,0, 3,2,3}; + chances[21] = new float[]{0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 4,3,2,1}; chances[26] = chances[25] = chances[24] = chances[23] = chances[22] = chances[21]; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/LibraryHallExitRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/LibraryHallExitRoom.java new file mode 100644 index 000000000..ccc77a6dc --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/LibraryHallExitRoom.java @@ -0,0 +1,61 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2025 Evan Debenham + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + */ + +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.exit; + +import com.shatteredpixel.shatteredpixeldungeon.levels.Level; +import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; +import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition; +import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.LibraryHallRoom; +import com.watabou.utils.Point; + +public class LibraryHallExitRoom extends LibraryHallRoom { + + @Override + public boolean isExit() { + return true; + } + + @Override + public void paint(Level level) { + super.paint(level); + + while (true){ + Point p = random(2); + + if (level.map[level.pointToCell(p)] == Terrain.REGION_DECO){ + int exit = level.pointToCell(p); + Painter.set( level, exit, Terrain.EXIT ); + + level.transitions.add(new LevelTransition(level, exit, LevelTransition.Type.REGULAR_EXIT)); + return; + } + } + + } + + @Override + public boolean canPlaceCharacter(Point p, Level l) { + return super.canPlaceCharacter(p, l) && l.pointToCell(p) != l.exit(); + } + +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/RegionDecoBridgeExitRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/RegionDecoBridgeExitRoom.java new file mode 100644 index 000000000..ca6ebe793 --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/RegionDecoBridgeExitRoom.java @@ -0,0 +1,80 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2025 Evan Debenham + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + */ + +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.exit; + +import com.shatteredpixel.shatteredpixeldungeon.levels.Level; +import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; +import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition; +import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.RegionDecoBridgeRoom; +import com.watabou.utils.PathFinder; +import com.watabou.utils.Point; + +public class RegionDecoBridgeExitRoom extends RegionDecoBridgeRoom { + + @Override + public int minWidth() { + return Math.max(8, super.minWidth()); + } + + @Override + public int minHeight() { + return Math.max(8, super.minHeight()); + } + + @Override + public boolean isExit() { + return true; + } + + @Override + public void paint(Level level) { + super.paint(level); + + int exit; + boolean valid; + do { + valid = true; + exit = level.pointToCell(random(2)); + + if (spaceRect.inside(level.cellToPoint(exit))){ + valid = false; + } else { + for (int i : PathFinder.NEIGHBOURS8){ + if (level.map[exit+i] == Terrain.REGION_DECO_ALT){ + valid = false; + } + } + } + + } while (!valid); + + Painter.set( level, exit, Terrain.EXIT ); + level.transitions.add(new LevelTransition(level, exit, LevelTransition.Type.REGULAR_EXIT)); + } + + @Override + public boolean canPlaceCharacter(Point p, Level l) { + return super.canPlaceCharacter(p, l) && l.pointToCell(p) != l.exit(); + } + +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/RegionDecoPatchExitRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/RegionDecoPatchExitRoom.java index 3c3646baf..43077513f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/RegionDecoPatchExitRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/RegionDecoPatchExitRoom.java @@ -58,11 +58,11 @@ public class RegionDecoPatchExitRoom extends RegionDecoPatchRoom { //need extra logic here as these rooms can spawn small and cramped in very rare cases if (tries-- > 0){ - valid = level.map[exit] != Terrain.WALL && level.findMob(exit) == null; + valid = level.map[exit] != Terrain.REGION_DECO && level.findMob(exit) == null; } else { valid = false; for (int i : PathFinder.NEIGHBOURS4){ - if (level.map[exit+i] != Terrain.WALL){ + if (level.map[exit+i] != Terrain.REGION_DECO){ valid = true; } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/RuinsExitRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/RuinsExitRoom.java new file mode 100644 index 000000000..a83bab223 --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/RuinsExitRoom.java @@ -0,0 +1,91 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2025 Evan Debenham + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + */ + +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.exit; + +import com.shatteredpixel.shatteredpixeldungeon.levels.Level; +import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; +import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition; +import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.RuinsRoom; +import com.watabou.utils.PathFinder; +import com.watabou.utils.Point; + +public class RuinsExitRoom extends RuinsRoom { + + @Override + public int minWidth() { + return Math.max(super.minWidth(), 7); + } + + @Override + public int minHeight() { + return Math.max(super.minHeight(), 7); + } + + @Override + public boolean isExit() { + return true; + } + + @Override + public float[] sizeCatProbs() { + return new float[]{2, 1, 0}; + } + + @Override + public void paint(Level level) { + super.paint(level); + + int exit; + int tries = 30; + boolean valid; + do { + exit = level.pointToCell(random(2)); + + //need extra logic here as these rooms can spawn small and cramped in very rare cases + if (tries-- > 0){ + valid = level.map[exit] != Terrain.WALL && level.findMob(exit) == null; + } else { + valid = false; + for (int i : PathFinder.NEIGHBOURS4){ + if (level.map[exit+i] != Terrain.WALL && level.map[exit+i] != Terrain.REGION_DECO){ + valid = true; + } + } + valid = valid && level.findMob(exit) == null; + } + } while (!valid); + Painter.set( level, exit, Terrain.EXIT ); + + for (int i : PathFinder.NEIGHBOURS8){ + Painter.set( level, exit+i, Terrain.EMPTY ); + } + + level.transitions.add(new LevelTransition(level, exit, LevelTransition.Type.REGULAR_EXIT)); + } + + @Override + public boolean canPlaceCharacter(Point p, Level l) { + return super.canPlaceCharacter(p, l) && l.pointToCell(p) != l.exit(); + } + +}