From a97bfd0c196c72f60dde740d8ca482d84f956d32 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 28 Dec 2022 20:48:09 -0500 Subject: [PATCH] v2.0.0: fixed teleport effects not being affected by magic immunity --- .../items/armor/glyphs/AntiMagic.java | 2 ++ .../items/scrolls/ScrollOfTeleportation.java | 14 +++++++------- .../shatteredpixeldungeon/plants/Fadeleaf.java | 4 ++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/AntiMagic.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/AntiMagic.java index 6e65c67dd..b51e05b42 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/AntiMagic.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/AntiMagic.java @@ -37,6 +37,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.YogFist; import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor; import com.shatteredpixel.shatteredpixeldungeon.items.bombs.Bomb; import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfArcana; +import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.exotic.ScrollOfPsionicBlast; import com.shatteredpixel.shatteredpixeldungeon.items.wands.CursedWand; import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfBlastWave; @@ -78,6 +79,7 @@ public class AntiMagic extends Armor.Glyph { RESISTS.add( Bomb.MagicalBomb.class ); RESISTS.add( ScrollOfPsionicBlast.class ); + RESISTS.add( ScrollOfTeleportation.class ); RESISTS.add( CursedWand.class ); RESISTS.add( WandOfBlastWave.class ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfTeleportation.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfTeleportation.java index 9d775bbfe..3c12a219f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfTeleportation.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfTeleportation.java @@ -84,18 +84,18 @@ public class ScrollOfTeleportation extends Scroll { return true; } - - public static boolean teleportHero( Hero hero ) { - return teleportChar( hero ); - } - + public static boolean teleportChar( Char ch ) { + return teleportChar( ch, ScrollOfTeleportation.class ); + } + + public static boolean teleportChar( Char ch, Class source ) { if (!(Dungeon.level instanceof RegularLevel)){ return teleportInNonRegularLevel( ch, false ); } - if (Char.hasProp(ch, Char.Property.IMMOVABLE)){ + if (Char.hasProp(ch, Char.Property.IMMOVABLE) || ch.isImmune(source)){ GLog.w( Messages.get(ScrollOfTeleportation.class, "no_tele") ); return false; } @@ -205,7 +205,7 @@ public class ScrollOfTeleportation extends Scroll { //teleports to a random pathable location on the floor //prefers not seen(optional) > not visible > visible - public static boolean teleportInNonRegularLevel(Char ch, boolean preferNotSeen ){ + private static boolean teleportInNonRegularLevel(Char ch, boolean preferNotSeen ){ if (Char.hasProp(ch, Char.Property.IMMOVABLE)){ GLog.w( Messages.get(ScrollOfTeleportation.class, "no_tele") ); 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 b09fcf413..30e256089 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Fadeleaf.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Fadeleaf.java @@ -65,12 +65,12 @@ public class Fadeleaf extends Plant { Game.switchScene( InterlevelScene.class ); } else { - ScrollOfTeleportation.teleportChar((Hero) ch); + ScrollOfTeleportation.teleportChar(ch, Fadeleaf.class); } } else if (ch instanceof Mob && !ch.properties().contains(Char.Property.IMMOVABLE)) { - ScrollOfTeleportation.teleportChar(ch); + ScrollOfTeleportation.teleportChar(ch, Fadeleaf.class); }