diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/PinCushion.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/PinCushion.java index 9f23476af..0adb11b59 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/PinCushion.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/PinCushion.java @@ -45,6 +45,10 @@ public class PinCushion extends Buff { items.add(projectile); } + public ArrayList getStuckItems(){ + return new ArrayList<>(items); + } + @Override public void detach() { for (Item item : items) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/HeavyBoomerang.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/HeavyBoomerang.java index e0f79920e..9c12370f3 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/HeavyBoomerang.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/HeavyBoomerang.java @@ -93,6 +93,10 @@ public class HeavyBoomerang extends MissileWeapon { detach(); return boomerang; } + + public int activeDepth(){ + return returnDepth; + } @Override public boolean act() { 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 21e170655..1c322f07c 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java @@ -39,6 +39,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.ChampionEnemy; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.LockedFloor; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.MagicalSight; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.MindVision; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.PinCushion; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.RevealedArea; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Shadows; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; @@ -64,6 +65,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfEnchantment; import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfIntuition; import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfRegrowth; import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfWarding; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.HeavyBoomerang; import com.shatteredpixel.shatteredpixeldungeon.levels.features.Chasm; import com.shatteredpixel.shatteredpixeldungeon.levels.features.Door; import com.shatteredpixel.shatteredpixeldungeon.levels.features.HighGrass; @@ -481,6 +483,22 @@ public abstract class Level implements Bundlable { } } + public ArrayList getItemsToPreserveFromSealedResurrect(){ + ArrayList items = new ArrayList<>(); + for (Heap h : heaps.valueList()){ + if (h.type == Heap.Type.HEAP) items.addAll(h.items); + } + for (Mob m : mobs){ + for (PinCushion b : m.buffs(PinCushion.class)){ + items.addAll(b.getStuckItems()); + } + } + for (HeavyBoomerang.CircleBack b : Dungeon.hero.buffs(HeavyBoomerang.CircleBack.class)){ + if (b.activeDepth() == Dungeon.depth) items.add(b.cancel()); + } + return items; + } + public Group addVisuals() { if (visuals == null || visuals.parent == null){ visuals = new Group(); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/PrisonBossLevel.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/PrisonBossLevel.java index 2fc65a93a..dbd635186 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/PrisonBossLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/PrisonBossLevel.java @@ -307,7 +307,8 @@ public class PrisonBossLevel extends Level { } for (HeavyBoomerang.CircleBack b : Dungeon.hero.buffs(HeavyBoomerang.CircleBack.class)){ - if (safeArea == null || !safeArea.inside(cellToPoint(b.returnPos()))){ + if (b.activeDepth() == Dungeon.depth + && (safeArea == null || !safeArea.inside(cellToPoint(b.returnPos())))){ storedItems.add(b.cancel()); } } @@ -528,7 +529,22 @@ public class PrisonBossLevel extends Level { } drop(new IronKey(10), randomPrisonCellPos()); } - + + @Override + public ArrayList getItemsToPreserveFromSealedResurrect() { + ArrayList items = super.getItemsToPreserveFromSealedResurrect(); + + items.addAll(storedItems); + + for (Item i : items.toArray(new Item[0])){ + if (i instanceof Tengu.BombAbility.BombItem || i instanceof Tengu.ShockerAbility.ShockerItem){ + items.remove(i); + } + } + + return items; + } + private int randomPrisonCellPos(){ Rect room = startCells[Random.Int(startCells.length)]; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/InterlevelScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/InterlevelScene.java index bc65f747e..2b93bd0d3 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/InterlevelScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/InterlevelScene.java @@ -30,6 +30,7 @@ import com.shatteredpixel.shatteredpixeldungeon.Statistics; import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; +import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.LostBackpack; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; @@ -57,6 +58,7 @@ import com.watabou.utils.DeviceCompat; import java.io.FileNotFoundException; import java.io.IOException; +import java.util.ArrayList; public class InterlevelScene extends PixelScene { @@ -448,11 +450,18 @@ public class InterlevelScene extends PixelScene { Level level; if (Dungeon.level.locked) { + ArrayList preservedItems = Dungeon.level.getItemsToPreserveFromSealedResurrect(); + Dungeon.hero.resurrect(); Dungeon.depth--; level = Dungeon.newLevel(); Dungeon.hero.pos = level.randomRespawnCell(Dungeon.hero); + + for (Item i : preservedItems){ + level.drop(i, level.randomRespawnCell(null)); + } level.drop(new LostBackpack(), level.randomRespawnCell(null)); + } else { level = Dungeon.level; BArray.setFalse(level.heroFOV);