From 8919b068c86a332d6c86279e4fb1ac7c3de120e7 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Thu, 12 Dec 2019 19:40:11 -0500 Subject: [PATCH] v0.8.0: added large character logic to randomDestination --- .../shatteredpixeldungeon/actors/mobs/Ghoul.java | 4 ++-- .../shatteredpixeldungeon/actors/mobs/Mob.java | 6 +++--- .../shatteredpixeldungeon/items/wands/CursedWand.java | 2 +- .../shatteredpixel/shatteredpixeldungeon/levels/Level.java | 5 +++-- .../shatteredpixeldungeon/levels/RegularLevel.java | 4 ++-- .../shatteredpixeldungeon/levels/traps/FlashingTrap.java | 2 +- .../shatteredpixeldungeon/plants/Blindweed.java | 2 +- 7 files changed, 13 insertions(+), 12 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Ghoul.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Ghoul.java index 84c5167c4..a719da483 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Ghoul.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Ghoul.java @@ -176,7 +176,7 @@ public class Ghoul extends Mob { target = enemy.pos; } else if (enemy == null) { state = WANDERING; - target = Dungeon.level.randomDestination(); + target = Dungeon.level.randomDestination( Ghoul.this ); return true; } @@ -193,7 +193,7 @@ public class Ghoul extends Mob { spend( TICK ); sprite.showLost(); state = WANDERING; - target = Dungeon.level.randomDestination(); + target = Dungeon.level.randomDestination( Ghoul.this ); //try to move closer to partner if they can't move to hero } else if (partner != null && getCloser(partner.pos)) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java index 4f241e1ec..9743fa8d2 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java @@ -794,7 +794,7 @@ public abstract class Mob extends Char { spend( 1 / speed() ); return moveSprite( oldPos, pos ); } else { - target = Dungeon.level.randomDestination(); + target = Dungeon.level.randomDestination( Mob.this ); spend( TICK ); } @@ -820,7 +820,7 @@ public abstract class Mob extends Char { target = enemy.pos; } else if (enemy == null) { state = WANDERING; - target = Dungeon.level.randomDestination(); + target = Dungeon.level.randomDestination( Mob.this ); return true; } @@ -835,7 +835,7 @@ public abstract class Mob extends Char { if (!enemyInFOV) { sprite.showLost(); state = WANDERING; - target = Dungeon.level.randomDestination(); + target = Dungeon.level.randomDestination( Mob.this ); } return true; } 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 e24d189da..8046dabe6 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 @@ -357,7 +357,7 @@ public class CursedWand { GameScene.add( Blob.seed(i, 15, Regrowth.class)); } do { - GameScene.add(Blob.seed(Dungeon.level.randomDestination(), 10, Fire.class)); + GameScene.add(Blob.seed(Dungeon.level.randomDestination(null), 10, Fire.class)); } while (Random.Int(5) != 0); new Flare(8, 32).color(0xFFFF66, true).show(user.sprite, 2f); Sample.INSTANCE.play(Assets.SND_TELEPORT); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java index 514ac90fe..356e1bb6e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java @@ -550,11 +550,12 @@ public abstract class Level implements Bundlable { return cell; } - public int randomDestination() { + public int randomDestination( Char ch ) { int cell; do { cell = Random.Int( length() ); - } while (!passable[cell]); + } while (!passable[cell] + || (Char.hasProp(ch, Char.Property.LARGE) && !openSpace[cell])); return cell; } 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 85f4b37cf..b6b6f23a1 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java @@ -250,7 +250,7 @@ public abstract class RegularLevel extends Level { } @Override - public int randomDestination() { + public int randomDestination( Char ch ) { int count = 0; int cell = -1; @@ -267,7 +267,7 @@ public abstract class RegularLevel extends Level { } cell = pointToCell(room.random()); - if (passable[cell]) { + if (passable[cell] && (!Char.hasProp(ch, Char.Property.LARGE) || openSpace[cell])) { return cell; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/FlashingTrap.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/FlashingTrap.java index ba5a435e8..a132a74b4 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/FlashingTrap.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/FlashingTrap.java @@ -66,7 +66,7 @@ public class FlashingTrap extends Trap { if (c instanceof Mob) { if (((Mob)c).state == ((Mob)c).HUNTING) ((Mob)c).state = ((Mob)c).WANDERING; - ((Mob)c).beckon( Dungeon.level.randomDestination() ); + ((Mob)c).beckon( Dungeon.level.randomDestination( c ) ); } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Blindweed.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Blindweed.java index dfea538a0..8a755fa84 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Blindweed.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Blindweed.java @@ -53,7 +53,7 @@ public class Blindweed extends Plant { Buff.prolong(ch, Cripple.class, len); if (ch instanceof Mob) { if (((Mob) ch).state == ((Mob) ch).HUNTING) ((Mob) ch).state = ((Mob) ch).WANDERING; - ((Mob) ch).beckon(Dungeon.level.randomDestination()); + ((Mob) ch).beckon(Dungeon.level.randomDestination( ch )); } } }