From 8d116774834ef001bc113c04fdd52e0c828b23a8 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Tue, 20 Jun 2023 11:11:53 -0400 Subject: [PATCH] v2.1.3: remains now work with dungeon branch --- .../shatteredpixeldungeon/Bones.java | 22 +++++++++++++++++-- .../levels/DeadEndLevel.java | 7 ++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Bones.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Bones.java index ae6dcbee5..7f2406b58 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Bones.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Bones.java @@ -41,9 +41,11 @@ public class Bones { private static final String BONES_FILE = "bones.dat"; private static final String LEVEL = "level"; + private static final String BRANCH = "branch"; private static final String ITEM = "item"; private static int depth = -1; + private static int branch = -1; private static Item item; public static void leave() { @@ -52,9 +54,11 @@ public class Bones { // but are capped at 5 floors above the lowest depth reached (even when ascending) depth = Math.max(Dungeon.depth, Statistics.deepestFloor-5); + branch = Dungeon.branch; + //daily runs do not interact with remains if (Dungeon.daily) { - depth = -1; + depth = branch = -1; return; } @@ -154,6 +158,7 @@ public class Bones { Bundle bundle = FileUtils.bundleFromFile(BONES_FILE); depth = bundle.getInt( LEVEL ); + branch = bundle.getInt( BRANCH ); if (depth > 0) { item = (Item) bundle.get(ITEM); } @@ -165,7 +170,7 @@ public class Bones { } } else { - if (depth == Dungeon.depth) { + if (lootAtCurLevel()) { Bundle emptyBones = new Bundle(); emptyBones.put(LEVEL, 0); @@ -228,4 +233,17 @@ public class Bones { } } } + + private static boolean lootAtCurLevel(){ + if (branch == Dungeon.branch) { + if (branch == 0) { + //always match depth exactly for main path + return depth == Dungeon.depth; + } else if (branch == 1) { + //just match the region for quest sub-floors + return depth/5 == Dungeon.depth/5; + } + } + return false; + } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/DeadEndLevel.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/DeadEndLevel.java index 8758cbe5a..e2befe488 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/DeadEndLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/DeadEndLevel.java @@ -22,10 +22,13 @@ package com.shatteredpixel.shatteredpixeldungeon.levels; import com.shatteredpixel.shatteredpixeldungeon.Assets; +import com.shatteredpixel.shatteredpixeldungeon.Bones; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; +import com.shatteredpixel.shatteredpixeldungeon.items.Heap; +import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition; public class DeadEndLevel extends Level { @@ -99,6 +102,10 @@ public class DeadEndLevel extends Level { @Override protected void createItems() { + Item item = Bones.get(); + if (item != null) { + drop( item, entrance()-width() ).setHauntedIfCursed().type = Heap.Type.REMAINS; + } } @Override