From 4c1300aa21ca3bfd29b90e2e26e0401b48dda616 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 11 Aug 2021 18:28:14 -0400 Subject: [PATCH] v0.9.4: fixed various specific effects not respecting lost inventory --- .../actors/buffs/Burning.java | 8 ++-- .../actors/buffs/Frost.java | 8 ++-- .../actors/hero/Belongings.java | 37 ++++++++++--------- 3 files changed, 30 insertions(+), 23 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Burning.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Burning.java index 9d34d1020..df6c00024 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Burning.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Burning.java @@ -104,9 +104,11 @@ public class Burning extends Buff implements Hero.Doom { ArrayList burnable = new ArrayList<>(); //does not reach inside of containers - for (Item i : hero.belongings.backpack.items){ - if (!i.unique && (i instanceof Scroll || i instanceof MysteryMeat || i instanceof FrozenCarpaccio)){ - burnable.add(i); + if (hero.buff(LostInventory.class) != null) { + for (Item i : hero.belongings.backpack.items) { + if (!i.unique && (i instanceof Scroll || i instanceof MysteryMeat || i instanceof FrozenCarpaccio)) { + burnable.add(i); + } } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Frost.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Frost.java index 1ac1166c0..87108d584 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Frost.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Frost.java @@ -61,9 +61,11 @@ public class Frost extends FlavourBuff { Hero hero = (Hero)target; ArrayList freezable = new ArrayList<>(); //does not reach inside of containers - for (Item i : hero.belongings.backpack.items){ - if (!i.unique && (i instanceof Potion || i instanceof MysteryMeat)){ - freezable.add(i); + if (hero.buff(LostInventory.class) != null) { + for (Item i : hero.belongings.backpack.items) { + if (!i.unique && (i instanceof Potion || i instanceof MysteryMeat)) { + freezable.add(i); + } } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Belongings.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Belongings.java index 11432f796..bc44dcdff 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Belongings.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Belongings.java @@ -299,7 +299,8 @@ public class Belongings implements Iterable { return result; } - + + //triggers when a run ends, so ignores lost inventory effects public void identify() { for (Item item : this) { item.identify(); @@ -307,25 +308,25 @@ public class Belongings implements Iterable { } public void observe() { - if (weapon != null) { - weapon.identify(); - Badges.validateItemLevelAquired( weapon ); + if (weapon() != null) { + weapon().identify(); + Badges.validateItemLevelAquired(weapon()); } - if (armor != null) { - armor.identify(); - Badges.validateItemLevelAquired( armor ); + if (armor() != null) { + armor().identify(); + Badges.validateItemLevelAquired(armor()); } - if (artifact != null) { - artifact.identify(); - Badges.validateItemLevelAquired(artifact); + if (artifact() != null) { + artifact().identify(); + Badges.validateItemLevelAquired(artifact()); } - if (misc != null) { - misc.identify(); - Badges.validateItemLevelAquired(misc); + if (misc() != null) { + misc().identify(); + Badges.validateItemLevelAquired(misc()); } - if (ring != null) { - ring.identify(); - Badges.validateItemLevelAquired(ring); + if (ring() != null) { + ring().identify(); + Badges.validateItemLevelAquired(ring()); } for (Item item : backpack) { if (item instanceof EquipableItem || item instanceof Wand) { @@ -335,10 +336,12 @@ public class Belongings implements Iterable { } public void uncurseEquipped() { - ScrollOfRemoveCurse.uncurse( owner, armor, weapon, artifact, misc, ring); + ScrollOfRemoveCurse.uncurse( owner, armor(), weapon(), artifact(), misc(), ring()); } public Item randomUnequipped() { + if (owner.buff(LostInventory.class) != null) return null; + return Random.element( backpack.items ); }