From 74762c158f52e14665d4b7fc8aac80d38c1d1bf8 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 12 Jul 2021 21:56:44 -0400 Subject: [PATCH] v0.9.4: moving between floors now disarms pressed traps, instead of ending time freeze. Warping beacon also now dispells invis after moving the hero. --- .../actors/hero/Hero.java | 16 +++++++-------- .../hero/abilities/mage/WarpBeacon.java | 10 +++++----- .../items/artifacts/LloydsBeacon.java | 8 ++++---- .../items/artifacts/TimekeepersHourglass.java | 12 ++++++++++- .../items/scrolls/exotic/ScrollOfPassage.java | 12 +++++------ .../items/spells/BeaconOfReturning.java | 10 +++++----- .../items/wands/CursedWand.java | 9 ++++----- .../levels/features/Chasm.java | 8 ++++---- .../plants/Fadeleaf.java | 10 +++++----- .../plants/Swiftthistle.java | 20 +++++++++++++++---- 10 files changed, 68 insertions(+), 47 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java index 6c2ec9dca..ba679631a 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java @@ -993,10 +993,10 @@ public class Hero extends Char { curAction = null; - Buff buff = buff(TimekeepersHourglass.timeFreeze.class); - if (buff != null) buff.detach(); - buff = Dungeon.hero.buff(Swiftthistle.TimeBubble.class); - if (buff != null) buff.detach(); + TimekeepersHourglass.timeFreeze timeFreeze = buff(TimekeepersHourglass.timeFreeze.class); + if (timeFreeze != null) timeFreeze.disarmPressedTraps(); + Swiftthistle.TimeBubble timeBubble = buff(Swiftthistle.TimeBubble.class); + if (timeBubble != null) timeBubble.disarmPressedTraps(); InterlevelScene.mode = InterlevelScene.Mode.DESCEND; Game.switchScene( InterlevelScene.class ); @@ -1046,10 +1046,10 @@ public class Hero extends Char { curAction = null; - Buff buff = buff(TimekeepersHourglass.timeFreeze.class); - if (buff != null) buff.detach(); - buff = Dungeon.hero.buff(Swiftthistle.TimeBubble.class); - if (buff != null) buff.detach(); + TimekeepersHourglass.timeFreeze timeFreeze = buff(TimekeepersHourglass.timeFreeze.class); + if (timeFreeze != null) timeFreeze.disarmPressedTraps(); + Swiftthistle.TimeBubble timeBubble = buff(Swiftthistle.TimeBubble.class); + if (timeBubble != null) timeBubble.disarmPressedTraps(); InterlevelScene.mode = InterlevelScene.Mode.ASCEND; Game.switchScene( InterlevelScene.class ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/abilities/mage/WarpBeacon.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/abilities/mage/WarpBeacon.java index 1c94c74f4..22ecfc844 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/abilities/mage/WarpBeacon.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/abilities/mage/WarpBeacon.java @@ -112,7 +112,6 @@ public class WarpBeacon extends ArmorAbility { if (tracker.depth == Dungeon.depth){ Char existing = Actor.findChar(tracker.pos); - Invisibility.dispel(); ScrollOfTeleportation.appear(hero, tracker.pos); if (existing != null && existing != hero){ @@ -153,6 +152,7 @@ public class WarpBeacon extends ArmorAbility { } } + Invisibility.dispel(); Dungeon.observe(); } else { @@ -162,11 +162,11 @@ public class WarpBeacon extends ArmorAbility { return; } + TimekeepersHourglass.timeFreeze timeFreeze = hero.buff(TimekeepersHourglass.timeFreeze.class); + if (timeFreeze != null) timeFreeze.disarmPressedTraps(); + Swiftthistle.TimeBubble timeBubble = hero.buff(Swiftthistle.TimeBubble.class); + if (timeBubble != null) timeBubble.disarmPressedTraps(); Invisibility.dispel(); - Buff buff = Dungeon.hero.buff(TimekeepersHourglass.timeFreeze.class); - if (buff != null) buff.detach(); - buff = Dungeon.hero.buff(Swiftthistle.TimeBubble.class); - if (buff != null) buff.detach(); InterlevelScene.mode = InterlevelScene.Mode.RETURN; InterlevelScene.returnDepth = tracker.depth; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/LloydsBeacon.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/LloydsBeacon.java index abec3c331..55d1e8ffc 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/LloydsBeacon.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/LloydsBeacon.java @@ -177,10 +177,10 @@ public class LloydsBeacon extends Artifact { GameScene.updateFog(); } else { - Buff buff = Dungeon.hero.buff(TimekeepersHourglass.timeFreeze.class); - if (buff != null) buff.detach(); - buff = Dungeon.hero.buff(Swiftthistle.TimeBubble.class); - if (buff != null) buff.detach(); + TimekeepersHourglass.timeFreeze timeFreeze = Dungeon.hero.buff(TimekeepersHourglass.timeFreeze.class); + if (timeFreeze != null) timeFreeze.disarmPressedTraps(); + Swiftthistle.TimeBubble timeBubble = Dungeon.hero.buff(Swiftthistle.TimeBubble.class); + if (timeBubble != null) timeBubble.disarmPressedTraps(); InterlevelScene.mode = InterlevelScene.Mode.RETURN; InterlevelScene.returnDepth = returnDepth; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/TimekeepersHourglass.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/TimekeepersHourglass.java index 7154d4b65..ea87edc1e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/TimekeepersHourglass.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/TimekeepersHourglass.java @@ -32,6 +32,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Talent; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfEnergy; +import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; @@ -334,13 +335,22 @@ public class TimekeepersHourglass extends Artifact { presses.add(cell); } - private void triggerPresses(){ + public void triggerPresses(){ for (int cell : presses) Dungeon.level.pressCell(cell); presses = new ArrayList<>(); } + public void disarmPressedTraps(){ + for (int cell : presses){ + Trap t = Dungeon.level.traps.get(cell); + if (t != null) t.disarm(); + } + + presses = new ArrayList<>(); + } + @Override public void detach(){ updateQuickslot(); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/exotic/ScrollOfPassage.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/exotic/ScrollOfPassage.java index f398b741d..861630bed 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/exotic/ScrollOfPassage.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/exotic/ScrollOfPassage.java @@ -49,12 +49,12 @@ public class ScrollOfPassage extends ExoticScroll { return; } - - Buff buff = Dungeon.hero.buff(TimekeepersHourglass.timeFreeze.class); - if (buff != null) buff.detach(); - buff = Dungeon.hero.buff(Swiftthistle.TimeBubble.class); - if (buff != null) buff.detach(); - + + TimekeepersHourglass.timeFreeze timeFreeze = Dungeon.hero.buff(TimekeepersHourglass.timeFreeze.class); + if (timeFreeze != null) timeFreeze.disarmPressedTraps(); + Swiftthistle.TimeBubble timeBubble = Dungeon.hero.buff(Swiftthistle.TimeBubble.class); + if (timeBubble != null) timeBubble.disarmPressedTraps(); + InterlevelScene.mode = InterlevelScene.Mode.RETURN; InterlevelScene.returnDepth = Math.max(1, (Dungeon.depth - 1 - (Dungeon.depth-2)%5)); InterlevelScene.returnPos = -1; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/BeaconOfReturning.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/BeaconOfReturning.java index 7ade346a4..cbd56c8ef 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/BeaconOfReturning.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/BeaconOfReturning.java @@ -141,11 +141,11 @@ public class BeaconOfReturning extends Spell { Dungeon.observe(); GameScene.updateFog(); } else { - - Buff buff = Dungeon.hero.buff(TimekeepersHourglass.timeFreeze.class); - if (buff != null) buff.detach(); - buff = Dungeon.hero.buff(Swiftthistle.TimeBubble.class); - if (buff != null) buff.detach(); + + TimekeepersHourglass.timeFreeze timeFreeze = Dungeon.hero.buff(TimekeepersHourglass.timeFreeze.class); + if (timeFreeze != null) timeFreeze.disarmPressedTraps(); + Swiftthistle.TimeBubble timeBubble = Dungeon.hero.buff(Swiftthistle.TimeBubble.class); + if (timeBubble != null) timeBubble.disarmPressedTraps(); InterlevelScene.mode = InterlevelScene.Mode.RETURN; InterlevelScene.returnDepth = returnDepth; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/CursedWand.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/CursedWand.java index 778b2e530..782cfbaa5 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/CursedWand.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/CursedWand.java @@ -299,11 +299,10 @@ public class CursedWand { for (int i = 1; i < Dungeon.depth; i++) depths[i-1] = i; int depth = 1+Random.chances(depths); - Buff buff = Dungeon.hero.buff(TimekeepersHourglass.timeFreeze.class); - if (buff != null) buff.detach(); - - buff = Dungeon.hero.buff(Swiftthistle.TimeBubble.class); - if (buff != null) buff.detach(); + TimekeepersHourglass.timeFreeze timeFreeze = Dungeon.hero.buff(TimekeepersHourglass.timeFreeze.class); + if (timeFreeze != null) timeFreeze.disarmPressedTraps(); + Swiftthistle.TimeBubble timeBubble = Dungeon.hero.buff(Swiftthistle.TimeBubble.class); + if (timeBubble != null) timeBubble.disarmPressedTraps(); InterlevelScene.mode = InterlevelScene.Mode.RETURN; InterlevelScene.returnDepth = depth; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/features/Chasm.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/features/Chasm.java index befc7deb7..537e0a4f9 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/features/Chasm.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/features/Chasm.java @@ -82,10 +82,10 @@ public class Chasm implements Hero.Doom { Sample.INSTANCE.play( Assets.Sounds.FALLING ); - Buff buff = Dungeon.hero.buff(TimekeepersHourglass.timeFreeze.class); - if (buff != null) buff.detach(); - buff = Dungeon.hero.buff(Swiftthistle.TimeBubble.class); - if (buff != null) buff.detach(); + TimekeepersHourglass.timeFreeze timeFreeze = Dungeon.hero.buff(TimekeepersHourglass.timeFreeze.class); + if (timeFreeze != null) timeFreeze.disarmPressedTraps(); + Swiftthistle.TimeBubble timeBubble = Dungeon.hero.buff(Swiftthistle.TimeBubble.class); + if (timeBubble != null) timeBubble.disarmPressedTraps(); if (Dungeon.hero.isAlive()) { Dungeon.hero.interrupt(); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Fadeleaf.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Fadeleaf.java index 50793add3..f0bb2b4d1 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Fadeleaf.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Fadeleaf.java @@ -58,11 +58,11 @@ public class Fadeleaf extends Plant { return; } - - Buff buff = Dungeon.hero.buff(TimekeepersHourglass.timeFreeze.class); - if (buff != null) buff.detach(); - buff = Dungeon.hero.buff(Swiftthistle.TimeBubble.class); - if (buff != null) buff.detach(); + + TimekeepersHourglass.timeFreeze timeFreeze = Dungeon.hero.buff(TimekeepersHourglass.timeFreeze.class); + if (timeFreeze != null) timeFreeze.disarmPressedTraps(); + Swiftthistle.TimeBubble timeBubble = Dungeon.hero.buff(Swiftthistle.TimeBubble.class); + if (timeBubble != null) timeBubble.disarmPressedTraps(); InterlevelScene.mode = InterlevelScene.Mode.RETURN; InterlevelScene.returnDepth = Math.max(1, (Dungeon.depth - 1)); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Swiftthistle.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Swiftthistle.java index 1fcca1e7f..d02e8f375 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Swiftthistle.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Swiftthistle.java @@ -27,6 +27,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Haste; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; +import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; @@ -114,16 +115,27 @@ public class Swiftthistle extends Plant { } public void setDelayedPress(int cell){ - if (!presses.contains(cell)) + if (!presses.contains(cell)) { presses.add(cell); + } } - - private void triggerPresses(){ - for (int cell : presses) + + public void triggerPresses() { + for (int cell : presses) { Dungeon.level.pressCell(cell); + } presses = new ArrayList<>(); } + + public void disarmPressedTraps(){ + for (int cell : presses){ + Trap t = Dungeon.level.traps.get(cell); + if (t != null) t.disarm(); + } + + presses = new ArrayList<>(); + } @Override public void detach(){