From 4ffd6f9c83c8b6bd1c253f0d1725c3fd9a5178a6 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Thu, 6 Oct 2016 22:11:19 -0400 Subject: [PATCH] v0.4.3: added more rules for items spawning ontop of traps --- .../levels/RegularLevel.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java index 8c5c144af..46d173051 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java @@ -30,11 +30,14 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; import com.shatteredpixel.shatteredpixeldungeon.items.Generator; import com.shatteredpixel.shatteredpixeldungeon.items.Heap; import com.shatteredpixel.shatteredpixeldungeon.items.Item; +import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfWealth; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll; import com.shatteredpixel.shatteredpixeldungeon.levels.Room.Type; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.ShopPainter; +import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ChillingTrap; +import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ExplosiveTrap; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.FireTrap; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.WornTrap; @@ -690,13 +693,20 @@ public abstract class RegularLevel extends Level { } for (Item item : itemsToSpawn) { - int cell = randomDropCell(); - if (item instanceof Scroll) { - while ((map[cell] == Terrain.TRAP || map[cell] == Terrain.SECRET_TRAP) - && traps.get( cell ) instanceof FireTrap) { - cell = randomDropCell(); + int cell; + do { + cell = randomDropCell(); + if (item instanceof Scroll) { + while (traps.get(cell) instanceof FireTrap) { + cell = randomDropCell(); + } + + } else if (item instanceof Potion) { + while (traps.get(cell) instanceof ChillingTrap) { + cell = randomDropCell(); + } } - } + } while (traps.get(cell) instanceof ExplosiveTrap); drop( item, cell ).type = Heap.Type.HEAP; }