From 0b3176ed5501ac296f5705530cdd4fa48161d604 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Fri, 25 Apr 2025 13:50:34 -0400 Subject: [PATCH] v3.1.0: expanded standard rooms in the caves --- .../levels/painters/CavesPainter.java | 16 ++-- .../levels/rooms/standard/CirclePitRoom.java | 44 ++++++++++ .../rooms/standard/CustomDecoBridgeRoom.java | 46 ++++++++++ .../levels/rooms/standard/StandardRoom.java | 4 +- .../rooms/standard/entrance/EntranceRoom.java | 5 +- .../standard/exit/CircleWallEntranceRoom.java | 86 ++++++++++++++++++ .../standard/exit/CircleWallExitRoom.java | 87 +++++++++++++++++++ .../levels/rooms/standard/exit/ExitRoom.java | 4 +- 8 files changed, 280 insertions(+), 12 deletions(-) create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/CustomDecoBridgeRoom.java create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/CircleWallEntranceRoom.java create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/CircleWallExitRoom.java diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/painters/CavesPainter.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/painters/CavesPainter.java index 54c84aab6..66c31033a 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/painters/CavesPainter.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/painters/CavesPainter.java @@ -42,7 +42,7 @@ public class CavesPainter extends RegularPainter { for (Room r : rooms) { for (Room n : r.neigbours) { if (!r.connected.containsKey( n )) { - mergeRooms(level, r, n, null, Terrain.CHASM); + mergeRooms(level, r, n, null, Random.Int(3) == 0 ? Terrain.REGION_DECO : Terrain.CHASM); } } } @@ -59,10 +59,11 @@ public class CavesPainter extends RegularPainter { int s = room.square(); //for each corner, we have a chance to fill based on room size - //but not if filling that corner blocks a connection or places a visible trap next to a wall + //but not if filling that corner replaces solid terrain, blocks a connection, or places a visible trap next to a wall if (Random.Int( s ) > 8) { int corner = (room.left + 1) + (room.top + 1) * w; - if (map[corner-1] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner-1)) + if ((Terrain.flags[map[corner]] & Terrain.SOLID) == 0 + && map[corner-1] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner-1)) && map[corner-w] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner-w)) && map[corner+1] != Terrain.TRAP && map[corner+w] != Terrain.TRAP) { map[corner] = Terrain.WALL; @@ -72,7 +73,8 @@ public class CavesPainter extends RegularPainter { if (Random.Int( s ) > 8) { int corner = (room.right - 1) + (room.top + 1) * w; - if (map[corner+1] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner+1)) + if ((Terrain.flags[map[corner]] & Terrain.SOLID) == 0 + && map[corner+1] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner+1)) && map[corner-w] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner-w)) && map[corner-1] != Terrain.TRAP && map[corner+w] != Terrain.TRAP) { map[corner] = Terrain.WALL; @@ -82,7 +84,8 @@ public class CavesPainter extends RegularPainter { if (Random.Int( s ) > 8) { int corner = (room.left + 1) + (room.bottom - 1) * w; - if (map[corner-1] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner-1)) + if ((Terrain.flags[map[corner]] & Terrain.SOLID) == 0 + && map[corner-1] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner-1)) && map[corner+w] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner+w)) && map[corner+1] != Terrain.TRAP && map[corner-w] != Terrain.TRAP) { map[corner] = Terrain.WALL; @@ -92,7 +95,8 @@ public class CavesPainter extends RegularPainter { if (Random.Int( s ) > 8) { int corner = (room.right - 1) + (room.bottom - 1) * w; - if (map[corner+1] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner+1)) + if ((Terrain.flags[map[corner]] & Terrain.SOLID) == 0 + && map[corner+1] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner+1)) && map[corner+w] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner+w)) && map[corner-1] != Terrain.TRAP && map[corner-w] != Terrain.TRAP) { map[corner] = Terrain.WALL; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/CirclePitRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/CirclePitRoom.java index 26a7cad26..b9d2b6b11 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/CirclePitRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/CirclePitRoom.java @@ -24,6 +24,8 @@ package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; +import com.watabou.utils.Point; +import com.watabou.utils.Random; public class CirclePitRoom extends StandardRoom { @@ -58,5 +60,47 @@ public class CirclePitRoom extends StandardRoom { } Painter.fillEllipse( level, this, 3 , Terrain.CHASM ); + + //50/100% chance based on size + if (sizeCat != SizeCategory.NORMAL && Random.Int(4-sizeFactor()) == 0) { + while (true){ + //draw line from center (plus or minus one in each DIR) to side + Point center = center(); + center.x += Random.IntRange(-1, 1); + center.y += Random.IntRange(-1, 1); + + Point edge = new Point(center); + switch (Random.Int(4)){ + case 0: + edge.x = left; + break; + case 1: + edge.y = top; + break; + case 2: + edge.x = right; + break; + case 3: + edge.y = bottom; + break; + } + + boolean valid = true; + for (Point door : connected.values()){ + if (door.equals(edge)){ + valid = false; + } + } + + if (valid) { + Painter.drawLine(level, edge, center, Terrain.REGION_DECO_SP); + Painter.drawInside(level, this, edge, 1, Terrain.EMPTY_SP); + Painter.set(level, edge, Terrain.WALL); + + //TODO pick a random cell to make empty_sp? + } + break; + } + } } } 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/CustomDecoBridgeRoom.java new file mode 100644 index 000000000..3123652c5 --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/CustomDecoBridgeRoom.java @@ -0,0 +1,46 @@ +/* + * 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; + +import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; + +//doesn't look much like a bridge, but can easily use it internally +public class CustomDecoBridgeRoom extends StandardBridgeRoom { + + //can be large because the line breaks the space up + public float[] sizeCatProbs(){ + return new float[]{2, 1, 0}; + } + + protected int maxBridgeWidth( int roomDimension ) { + return 1; + } + + protected int spaceTile(){ + return Terrain.REGION_DECO_SP; + } + + @Override + protected int bridgeTile() { + return Terrain.EMPTY_SP; + } +} 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 e1372b55c..217fa79c5 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 @@ -140,7 +140,7 @@ public abstract class StandardRoom extends Room { rooms.add(CavesFissureRoom.class); rooms.add(CirclePitRoom.class); rooms.add(CircleWallRoom.class); - rooms.add(EmptyRoom.class); + rooms.add(CustomDecoBridgeRoom.class); rooms.add(HallwayRoom.class); rooms.add(StatuesRoom.class); @@ -177,7 +177,7 @@ public abstract class StandardRoom extends Room { chances[6] = new float[]{0,5,0, 0,0,0,0,0, 10,10,10,5,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 1,1,1,1,1,1,1,1,1,1}; chances[10] = chances[9] = chances[8] = chances[7] = chances[6]; - chances[11] = new float[]{0,5,0, 0,0,0,0,0, 0,0,0,0,0, 15,10,5,5,0, 0,0,0,0,0, 0,0,0,0,0, 1,1,1,1,1,1,1,1,1,1}; + chances[11] = new float[]{0,5,0, 0,0,0,0,0, 0,0,0,0,0, 15,5,5,5,5, 0,0,0,0,0, 0,0,0,0,0, 1,1,1,1,1,1,1,1,1,1}; chances[15] = chances[14] = chances[13] = chances[12] = chances[11]; chances[16] = new float[]{0,0,5, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 10,10,10,5,0, 0,0,0,0,0, 1,1,1,1,1,1,1,1,1,1}; 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 7d1124815..f764a3581 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 @@ -32,6 +32,7 @@ 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.StandardRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.exit.CircleWallEntranceRoom; import com.watabou.utils.Point; import com.watabou.utils.Random; import com.watabou.utils.Reflection; @@ -143,7 +144,7 @@ public class EntranceRoom extends StandardRoom { rooms.add(CaveEntranceRoom.class); rooms.add(CavesFissureEntranceRoom.class); - rooms.add(EntranceRoom.class); //TODO + rooms.add(CircleWallEntranceRoom.class); rooms.add(HallwayEntranceRoom.class); rooms.add(StatuesEntranceRoom.class); @@ -165,7 +166,7 @@ public class EntranceRoom extends StandardRoom { chances[6] = new float[]{0,2,0, 0,0,0, 4,4,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, 4,4,0, 0,0,0, 0,0,0}; + chances[11] = new float[]{0,3,0, 0,0,0, 0,0,0, 3,2,2, 0,0,0, 0,0,0}; chances[15] = chances[14] = chances[13] = chances[12] = chances[11]; chances[16] = new float[]{0,0,2, 0,0,0, 0,0,0, 0,0,0, 4,4,0, 0,0,0}; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/CircleWallEntranceRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/CircleWallEntranceRoom.java new file mode 100644 index 000000000..bc44f9eaa --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/CircleWallEntranceRoom.java @@ -0,0 +1,86 @@ +/* + * 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.CircleWallRoom; +import com.watabou.utils.PathFinder; +import com.watabou.utils.Point; +import com.watabou.utils.Random; + +public class CircleWallEntranceRoom extends CircleWallRoom { + + @Override + public int minWidth() { + return Math.max(super.minWidth(), 11); + } + + @Override + public int minHeight() { + return Math.max(super.minHeight(), 11); + } + + @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); + + Point p = center(); + + int cell = level.pointToCell(p); + for (int i : PathFinder.NEIGHBOURS8){ + if (level.map[cell+2*i] == Terrain.WALL){ + Painter.set(level, cell+i, Terrain.EMPTY); + } + } + Painter.set(level, p, Terrain.ENTRANCE); + level.transitions.add(new LevelTransition(level, level.pointToCell(p), LevelTransition.Type.REGULAR_ENTRANCE)); + + int xDir = 0, yDir = 0; + if (Random.Int(2) == 0) { + xDir = Random.Int(2) == 0 ? 1 : -1; + } else { + yDir = Random.Int(2) == 0 ? 1 : -1; + } + + p.x += 2*xDir; + p.y += 2*yDir; + + while (level.map[level.pointToCell(p)] == Terrain.WALL){ + Painter.set(level, p, Terrain.EMPTY); + p.x += xDir; + p.y += yDir; + } + } +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/CircleWallExitRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/CircleWallExitRoom.java new file mode 100644 index 000000000..97bd5d113 --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/CircleWallExitRoom.java @@ -0,0 +1,87 @@ +/* + * 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.CircleWallRoom; +import com.watabou.utils.PathFinder; +import com.watabou.utils.Point; +import com.watabou.utils.Random; + +public class CircleWallExitRoom extends CircleWallRoom { + + @Override + public int minWidth() { + return Math.max(super.minWidth(), 11); + } + + @Override + public int minHeight() { + return Math.max(super.minHeight(), 11); + } + + @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); + + Point p = center(); + + int cell = level.pointToCell(p); + for (int i : PathFinder.NEIGHBOURS8){ + if (level.map[cell+2*i] == Terrain.WALL){ + Painter.set(level, cell+i, Terrain.EMPTY); + } + } + Painter.set(level, p, Terrain.EXIT); + level.transitions.add(new LevelTransition(level, level.pointToCell(p), LevelTransition.Type.REGULAR_EXIT)); + + int xDir = 0, yDir = 0; + if (Random.Int(2) == 0) { + xDir = Random.Int(2) == 0 ? 1 : -1; + } else { + yDir = Random.Int(2) == 0 ? 1 : -1; + } + + p.x += 2*xDir; + p.y += 2*yDir; + + while (level.map[level.pointToCell(p)] == Terrain.WALL){ + Painter.set(level, p, Terrain.EMPTY); + p.x += xDir; + p.y += yDir; + } + } + +} 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 5e77b4b9e..bec1c4eed 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 @@ -86,7 +86,7 @@ public class ExitRoom extends StandardRoom { rooms.add(CaveExitRoom.class); rooms.add(CavesFissureExitRoom.class); - rooms.add(ExitRoom.class); //todo + rooms.add(CircleWallExitRoom.class); rooms.add(HallwayExitRoom.class); rooms.add(StatuesExitRoom.class); @@ -107,7 +107,7 @@ public class ExitRoom extends StandardRoom { chances[6] = new float[]{0,2,0, 0,0,0, 4,4,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, 4,4,0, 0,0,0, 0,0,0}; + chances[11] = new float[]{0,2,0, 0,0,0, 0,0,0, 3,3,2, 0,0,0, 0,0,0}; chances[15] = chances[14] = chances[13] = chances[12] = chances[11]; chances[16] = new float[]{0,0,2, 0,0,0, 0,0,0, 0,0,0, 4,4,0, 0,0,0};