From e09f40378da8aaae3f7381bcb3dc810c0b400018 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 16 Dec 2015 04:47:34 -0500 Subject: [PATCH] v0.3.3: added char properties, starting with IMMOVABLE implementation --- .../shatteredpixeldungeon/actors/Char.java | 12 ++++++++++++ .../shatteredpixeldungeon/actors/mobs/Guard.java | 2 +- .../shatteredpixeldungeon/actors/mobs/RotHeart.java | 2 ++ .../shatteredpixeldungeon/actors/mobs/RotLasher.java | 2 ++ .../shatteredpixeldungeon/actors/mobs/Yog.java | 2 ++ .../actors/mobs/npcs/Shopkeeper.java | 9 ++------- .../items/armor/glyphs/Bounce.java | 4 +++- .../items/artifacts/EtherealChains.java | 5 ++++- .../items/artifacts/LloydsBeacon.java | 4 +--- .../items/wands/CursedWand.java | 2 +- .../items/wands/WandOfBlastWave.java | 2 +- .../shatteredpixeldungeon/plants/Fadeleaf.java | 2 +- 12 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java index 601756740..8b210a4b3 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java @@ -447,4 +447,16 @@ public abstract class Char extends Actor { public HashSet> immunities() { return EMPTY; } + + protected HashSet properties = new HashSet<>(); + + public HashSet properties() { return properties; } + + public enum Property{ + BOSS, + MINIBOSS, + UNDEAD, + EVIL, + IMMOVABLE + } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Guard.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Guard.java index 38f6bd06b..116cb8b64 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Guard.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Guard.java @@ -82,7 +82,7 @@ public class Guard extends Mob { } private boolean chain(int target){ - if (chainsUsed) + if (chainsUsed || enemy.properties().contains(Property.IMMOVABLE)) return false; Ballistica chain = new Ballistica(pos, target, Ballistica.PROJECTILE); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/RotHeart.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/RotHeart.java index fd7ca8acd..0d1a6659d 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/RotHeart.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/RotHeart.java @@ -43,6 +43,8 @@ public class RotHeart extends Mob { EXP = 4; state = PASSIVE; + + properties.add(Property.IMMOVABLE); } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/RotLasher.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/RotLasher.java index 547a4ba25..5199e5621 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/RotLasher.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/RotLasher.java @@ -49,6 +49,8 @@ public class RotLasher extends Mob { lootChance = 1f; state = WANDERING = new Waiting(); + + properties.add(Property.IMMOVABLE); } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Yog.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Yog.java index cb5938b5d..44839c32d 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Yog.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Yog.java @@ -70,6 +70,8 @@ public class Yog extends Mob { EXP = 50; state = PASSIVE; + + properties.add(Property.IMMOVABLE); } private static final String TXT_DESC = diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Shopkeeper.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Shopkeeper.java index 09211b1ea..47e299228 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Shopkeeper.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Shopkeeper.java @@ -40,18 +40,13 @@ public class Shopkeeper extends NPC { { name = "shopkeeper"; spriteClass = ShopkeeperSprite.class; + + properties.add(Property.IMMOVABLE); } @Override protected boolean act() { - if (startPos == -1) startPos = pos; - - if (startPos != pos){ - flee(); - return true; - } - throwItem(); sprite.turnTo( pos, Dungeon.hero.pos ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/Bounce.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/Bounce.java index dec5c0ccf..0a493c473 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/Bounce.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/Bounce.java @@ -39,7 +39,9 @@ public class Bounce extends Glyph { int level = Math.max( 0, armor.level() ); - if (Level.adjacent( attacker.pos, defender.pos ) && Random.Int( level + 5) >= 4) { + if (Level.adjacent( attacker.pos, defender.pos ) + && !defender.properties().contains(Char.Property.IMMOVABLE) + && Random.Int( level + 5) >= 4) { for (int i=0; i < Level.NEIGHBOURS8.length; i++) { int ofs = Level.NEIGHBOURS8[i]; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/EtherealChains.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/EtherealChains.java index f4f08445e..af833d76c 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/EtherealChains.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/EtherealChains.java @@ -110,9 +110,12 @@ public class EtherealChains extends Artifact { final int newMobPos = newPos; final Char affected = Actor.findChar( chain.collisionPos ); int chargeUse = Level.distance(affected.pos, newMobPos); - if (chargeUse > charge){ + if (chargeUse > charge) { GLog.w("Your chains do not have enough charge."); return; + } else if (affected.properties().contains(Char.Property.IMMOVABLE)) { + GLog.w("Your chains cannot pull that target"); + return; } else { charge -= chargeUse; updateQuickslot(); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/LloydsBeacon.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/LloydsBeacon.java index 89b904902..8065cbf7a 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/LloydsBeacon.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/LloydsBeacon.java @@ -241,9 +241,7 @@ public class LloydsBeacon extends Artifact { GLog.w(ScrollOfTeleportation.TXT_NO_TELEPORT); - //FIXME: sloppy, fix when adding mob properties - } else if (ch instanceof RotLasher || ch instanceof RotHeart - || ch instanceof Shopkeeper || ch instanceof Wandmaker) { + } else if (ch.properties().contains(Char.Property.IMMOVABLE)) { GLog.w("The teleportation magic fails."); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/CursedWand.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/CursedWand.java index 7f8d059cf..6236a734c 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/CursedWand.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/CursedWand.java @@ -155,7 +155,7 @@ public class CursedWand { cursedFX(user, bolt, new Callback() { public void call() { Char ch = Actor.findChar( bolt.collisionPos ); - if (ch != null) { + if (ch != null && !ch.properties().contains(Char.Property.IMMOVABLE)) { int count = 10; int pos; do { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfBlastWave.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfBlastWave.java index 8c5ed64ee..1a118f2b8 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfBlastWave.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfBlastWave.java @@ -112,7 +112,7 @@ public class WandOfBlastWave extends Wand { if ((ch instanceof King) || (ch instanceof Golem) || (ch instanceof Yog.RottingFist)) dist /= 2; - if (dist == 0 || ch instanceof Yog || ch instanceof RotLasher || ch instanceof RotHeart) return; + if (dist == 0 || ch.properties().contains(Char.Property.IMMOVABLE)) return; if (Actor.findChar(trajectory.path.get(dist)) != null){ dist--; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/plants/Fadeleaf.java b/src/com/shatteredpixel/shatteredpixeldungeon/plants/Fadeleaf.java index 4e3e0825a..ec5098f24 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/plants/Fadeleaf.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/plants/Fadeleaf.java @@ -51,7 +51,7 @@ public class Fadeleaf extends Plant { ScrollOfTeleportation.teleportHero( (Hero)ch ); ((Hero)ch).curAction = null; - } else if (ch instanceof Mob) { + } else if (ch instanceof Mob && !ch.properties().contains(Char.Property.IMMOVABLE)) { int count = 10; int newPos;