v1.1.0: unblessed ankh revives now persist items dropped on boss floors

This commit is contained in:
Evan Debenham 2021-11-08 21:16:00 -05:00
parent b9eb4ba54c
commit 779b82f383
5 changed files with 53 additions and 2 deletions

View File

@ -45,6 +45,10 @@ public class PinCushion extends Buff {
items.add(projectile);
}
public ArrayList<MissileWeapon> getStuckItems(){
return new ArrayList<>(items);
}
@Override
public void detach() {
for (Item item : items)

View File

@ -94,6 +94,10 @@ public class HeavyBoomerang extends MissileWeapon {
return boomerang;
}
public int activeDepth(){
return returnDepth;
}
@Override
public boolean act() {
if (returnDepth == Dungeon.depth){

View File

@ -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<Item> getItemsToPreserveFromSealedResurrect(){
ArrayList<Item> 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();

View File

@ -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());
}
}
@ -529,6 +530,21 @@ public class PrisonBossLevel extends Level {
drop(new IronKey(10), randomPrisonCellPos());
}
@Override
public ArrayList<Item> getItemsToPreserveFromSealedResurrect() {
ArrayList<Item> 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)];

View File

@ -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<Item> 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);