From ba90e140c1a02f291685b253c2ca63aecb73d21f Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Tue, 16 Apr 2024 13:06:16 -0400 Subject: [PATCH] v2.4.0: removed cases of game directly using dungeon seed for levelgen --- .../shatteredpixeldungeon/Dungeon.java | 46 ++++++++++++++++++- .../items/trinkets/TrapMechanism.java | 20 ++++---- .../shatteredpixeldungeon/levels/Level.java | 14 +++--- .../levels/rooms/special/SpecialRoom.java | 5 +- 4 files changed, 64 insertions(+), 21 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java index d9cecc88b..ad3c52800 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java @@ -102,6 +102,10 @@ public class Dungeon { STRENGTH_POTIONS, UPGRADE_SCROLLS, ARCANE_STYLI, + ENCH_STONE, + INT_STONE, + TRINKET_CATA, + LAB_ROOM, //actually a room, but logic is the same //Health potion sources //enemies @@ -256,7 +260,7 @@ public class Dungeon { QuickSlotButton.reset(); Toolbar.swappedQuickslots = false; - depth = 1; + depth = 15; branch = 0; generatedLevels.clear(); @@ -554,6 +558,46 @@ public class Dungeon { return Random.Int(5 - floorThisSet) < asLeftThisSet; } + public static boolean enchStoneNeeded(){ + //1 enchantment stone, spawns on chapter 2 or 3 + if (!LimitedDrops.ENCH_STONE.dropped()){ + int region = 1+depth/5; + if (region > 1){ + int floorsVisited = depth - 5; + if (floorsVisited > 4) floorsVisited--; //skip floor 10 + return Random.Int(9-floorsVisited) == 0; //1/8 chance each floor + } + } + return false; + } + + public static boolean intStoneNeeded(){ + //one stone on floors 1-3 + return !LimitedDrops.INT_STONE.dropped() && Random.Int(4-depth) == 0; + } + + public static boolean trinketCataNeeded(){ + //one trinket catalyst on floors 1-3 + return !LimitedDrops.TRINKET_CATA.dropped() && Random.Int(4-depth) == 0; + } + + public static boolean labRoomNeeded(){ + //one laboratory each floor set, in floor 3 or 4, 1/2 chance each floor + int region = 1+depth/5; + if (region > LimitedDrops.LAB_ROOM.count){ + int floorThisRegion = depth%5; + if (floorThisRegion >= 4 || (floorThisRegion == 3 && Random.Int(2) == 0)){ + return true; + } + } + return false; + } + + // 1/4 + // 3/4 * 1/3 = 3/12 = 1/4 + // 3/4 * 2/3 * 1/2 = 6/24 = 1/4 + // 1/4 + private static final String INIT_VER = "init_ver"; private static final String VERSION = "version"; private static final String SEED = "seed"; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/trinkets/TrapMechanism.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/trinkets/TrapMechanism.java index edd957225..adfb7f05f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/trinkets/TrapMechanism.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/trinkets/TrapMechanism.java @@ -70,16 +70,16 @@ public class TrapMechanism extends Trinket { } if (mech.levelFeels.isEmpty()){ Random.pushGenerator(Dungeon.seed+1); - mech.levelFeels.add(true); - mech.levelFeels.add(true); - mech.levelFeels.add(true); - mech.levelFeels.add(false); - mech.levelFeels.add(false); - mech.levelFeels.add(false); - for (int i = 0; i <= mech.shuffles; i++) { - Random.shuffle(mech.levelFeels); - } - mech.shuffles++; + mech.levelFeels.add(true); + mech.levelFeels.add(true); + mech.levelFeels.add(true); + mech.levelFeels.add(false); + mech.levelFeels.add(false); + mech.levelFeels.add(false); + for (int i = 0; i <= mech.shuffles; i++) { + Random.shuffle(mech.levelFeels); + } + mech.shuffles++; Random.popGenerator(); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java index a5baf1a17..9e77ca432 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java @@ -219,18 +219,16 @@ public abstract class Level implements Bundlable { Dungeon.LimitedDrops.ARCANE_STYLI.count++; addItemToSpawn( new Stylus() ); } - //one scroll of transmutation is guaranteed to spawn somewhere on chapter 2-4 - int enchChapter = (int)((Dungeon.seed / 10) % 3) + 1; - if ( Dungeon.depth / 5 == enchChapter && - Dungeon.seed % 4 + 1 == Dungeon.depth % 5){ + if ( Dungeon.enchStoneNeeded() ){ + Dungeon.LimitedDrops.ENCH_STONE.drop(); addItemToSpawn( new StoneOfEnchantment() ); } - - if ( Dungeon.depth == ((Dungeon.seed % 3) + 1)){ + if ( Dungeon.intStoneNeeded() ){ + Dungeon.LimitedDrops.INT_STONE.drop(); addItemToSpawn( new StoneOfIntuition() ); } - - if ( Dungeon.depth == (((Dungeon.seed+1) % 3) + 1)){ + if ( Dungeon.trinketCataNeeded() ){ + Dungeon.LimitedDrops.TRINKET_CATA.drop(); addItemToSpawn( new TrinketCatalyst()); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/SpecialRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/SpecialRoom.java index 779501fea..6b11b5e0c 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/SpecialRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/SpecialRoom.java @@ -131,8 +131,9 @@ public abstract class SpecialRoom extends Room { public static void initForFloor(){ floorSpecials = (ArrayList>) runSpecials.clone(); - //laboratory rooms spawn at set intervals every chapter, on 3rd or 4th floor - if (Dungeon.depth%5 == (Dungeon.seed%2 + 3)){ + //laboratory rooms spawn on floor 3 or 4 each chapter + if (Dungeon.labRoomNeeded()){ + Dungeon.LimitedDrops.LAB_ROOM.count++; floorSpecials.add(0, LaboratoryRoom.class); } }