From 7279e6f33b118631b917c7b624d27e25bd45cccb Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Tue, 13 Sep 2022 13:04:53 -0400 Subject: [PATCH] v1.4.0: fixed inconsistencies and honeypot errors in teleport trap logic --- .../shatteredpixeldungeon/items/Honeypot.java | 6 ++++++ .../levels/traps/DisarmingTrap.java | 12 +++++++----- .../levels/traps/GatewayTrap.java | 14 +++++++++++--- .../levels/traps/TeleportationTrap.java | 6 ++++++ 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Honeypot.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Honeypot.java index 86af62213..7bab77e7c 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Honeypot.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Honeypot.java @@ -189,6 +189,12 @@ public class Honeypot extends Item { } } + public void movePot( int oldpos, int movePos){ + for (Bee bee : findBees(oldpos)){ + updateBee(bee, movePos, null); + } + } + public void destroyPot( int potPos ){ for (Bee bee : findBees(potPos)){ updateBee(bee, -1, null); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/DisarmingTrap.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/DisarmingTrap.java index ca3777445..c332709de 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/DisarmingTrap.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/DisarmingTrap.java @@ -29,6 +29,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Statue; import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.items.Heap; +import com.shatteredpixel.shatteredpixeldungeon.items.Honeypot; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; @@ -48,18 +49,19 @@ public class DisarmingTrap extends Trap{ public void activate() { Heap heap = Dungeon.level.heaps.get( pos ); - if (heap != null){ + if (heap != null && heap.type == Heap.Type.HEAP){ int cell = Dungeon.level.randomRespawnCell( null ); + Item item = heap.pickUp(); + if (cell != -1) { - Item item = heap.pickUp(); Heap dropped = Dungeon.level.drop( item, cell ); - dropped.type = heap.type; - dropped.sprite.view( dropped ); dropped.seen = true; + if (item instanceof Honeypot.ShatteredPot){ + ((Honeypot.ShatteredPot)item).movePot(pos, cell); + } for (int i : PathFinder.NEIGHBOURS9) Dungeon.level.visited[cell+i] = true; GameScene.updateFog(); - Sample.INSTANCE.play(Assets.Sounds.TELEPORT); CellEmitter.get(pos).burst(Speck.factory(Speck.LIGHT), 4); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/GatewayTrap.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/GatewayTrap.java index 72093fcc7..5c0097323 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/GatewayTrap.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/GatewayTrap.java @@ -21,13 +21,18 @@ package com.shatteredpixel.shatteredpixeldungeon.levels.traps; +import com.shatteredpixel.shatteredpixeldungeon.Assets; 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.effects.CellEmitter; +import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.items.Heap; +import com.shatteredpixel.shatteredpixeldungeon.items.Honeypot; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation; +import com.watabou.noosa.audio.Sample; import com.watabou.utils.Bundle; import com.watabou.utils.PathFinder; import com.watabou.utils.Random; @@ -129,9 +134,12 @@ public class GatewayTrap extends Trap { Heap heap = Dungeon.level.heaps.get(pos + i); if (heap != null && heap.type == Heap.Type.HEAP){ Item item = heap.pickUp(); - Heap dropped = Dungeon.level.drop( item, telePos ); - dropped.type = heap.type; - dropped.sprite.view( dropped ); + Dungeon.level.drop( item, telePos ); + if (item instanceof Honeypot.ShatteredPot){ + ((Honeypot.ShatteredPot)item).movePot(pos, telePos); + } + Sample.INSTANCE.play(Assets.Sounds.TELEPORT); + CellEmitter.get(pos).burst(Speck.factory(Speck.LIGHT), 4); } } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/TeleportationTrap.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/TeleportationTrap.java index 2916d344b..a9a8aa594 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/TeleportationTrap.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/TeleportationTrap.java @@ -30,6 +30,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.items.Heap; +import com.shatteredpixel.shatteredpixeldungeon.items.Honeypot; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; @@ -64,6 +65,11 @@ public class TeleportationTrap extends Trap { if (cell != -1) { Dungeon.level.drop( item, cell ); + if (item instanceof Honeypot.ShatteredPot){ + ((Honeypot.ShatteredPot)item).movePot(pos, cell); + } + Sample.INSTANCE.play(Assets.Sounds.TELEPORT); + CellEmitter.get(pos).burst(Speck.factory(Speck.LIGHT), 4); } } }