From 6b0b4f60e1dade829c5c6818dbde39df46a2a204 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 18 Dec 2019 17:26:22 -0500 Subject: [PATCH] v0.8.0: various bugfixes and small functionality tweaks: - ankhs are now blessed when thrown into water of health - demon spawners are no longer removed by unblessed ankhs - golems now interrupt the hero when teleporting them - fixed mimics not revealing themselves in some cases where they should - tweaked when a space is considered open for large enemies - fixed further AI weirdness with retreating characters --- .../java/com/watabou/utils/PathFinder.java | 6 +++--- .../actors/blobs/WaterOfHealth.java | 4 ++++ .../actors/mobs/DemonSpawner.java | 5 +++++ .../actors/mobs/Golem.java | 6 ++++++ .../actors/mobs/Mimic.java | 11 ++++++++++ .../shatteredpixeldungeon/items/Ankh.java | 8 ++++++-- .../shatteredpixeldungeon/levels/Level.java | 20 +++++++++++++++---- 7 files changed, 51 insertions(+), 9 deletions(-) diff --git a/SPD-classes/src/main/java/com/watabou/utils/PathFinder.java b/SPD-classes/src/main/java/com/watabou/utils/PathFinder.java index 39f47762d..59b7a715c 100644 --- a/SPD-classes/src/main/java/com/watabou/utils/PathFinder.java +++ b/SPD-classes/src/main/java/com/watabou/utils/PathFinder.java @@ -129,7 +129,7 @@ public class PathFinder { public static int getStepBack( int cur, int from, boolean[] passable ) { - int d = buildEscapeDistanceMap( cur, from, 5f, passable ); + int d = buildEscapeDistanceMap( cur, from, 5, passable ); for (int i=0; i < size; i++) { goals[i] = distance[i] == d; } @@ -285,7 +285,7 @@ public class PathFinder { return pathFound; } - private static int buildEscapeDistanceMap( int cur, int from, float factor, boolean[] passable ) { + private static int buildEscapeDistanceMap( int cur, int from, int lookAhead, boolean[] passable ) { System.arraycopy(maxVal, 0, distance, 0, maxVal.length); @@ -311,7 +311,7 @@ public class PathFinder { } if (step == cur) { - destDist = (int)(dist * factor) + 1; + destDist = dist + lookAhead; } int nextDistance = dist + 1; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/WaterOfHealth.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/WaterOfHealth.java index 647fa84ac..bf9e20ea4 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/WaterOfHealth.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/WaterOfHealth.java @@ -30,6 +30,7 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShadowParticle; import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShaftParticle; +import com.shatteredpixel.shatteredpixeldungeon.items.Ankh; import com.shatteredpixel.shatteredpixeldungeon.items.DewVial; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing; @@ -71,6 +72,9 @@ public class WaterOfHealth extends WellWater { CellEmitter.get( pos ).start( Speck.factory( Speck.HEALING ), 0.4f, 4 ); } else if (ScrollOfRemoveCurse.uncurse( null, item )){ CellEmitter.get( pos ).start( ShadowParticle.UP, 0.05f, 10 ); + } if ( item instanceof Ankh && !(((Ankh) item).isBlessed())){ + ((Ankh) item).bless(); + CellEmitter.get( pos ).start(Speck.factory(Speck.LIGHT), 0.2f, 3); } Sample.INSTANCE.play( Assets.SND_DRINK ); return item; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/DemonSpawner.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/DemonSpawner.java index 3bca3d895..420a89415 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/DemonSpawner.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/DemonSpawner.java @@ -67,6 +67,11 @@ public class DemonSpawner extends Mob { //do nothing } + @Override + public boolean reset() { + return true; + } + private float spawnCooldown = 50; @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Golem.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Golem.java index e5073eece..1ca7f387d 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Golem.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Golem.java @@ -27,6 +27,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Amok; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Sleep; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Terror; +import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Imp; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation; import com.shatteredpixel.shatteredpixeldungeon.sprites.GolemSprite; @@ -107,6 +108,8 @@ public class Golem extends Mob { if (Actor.findChar(target) == null) { ScrollOfTeleportation.appear(this, target); selfTeleCooldown = 30; + } else { + target = Dungeon.level.randomDestination(this); } teleporting = false; spend(TICK); @@ -134,6 +137,9 @@ public class Golem extends Mob { if (bestPos != enemy.pos){ ScrollOfTeleportation.appear(enemy, bestPos); + if (enemy instanceof Hero){ + ((Hero) enemy).interrupt(); + } } enemyTeleCooldown = 20; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mimic.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mimic.java index 5bbebdc8a..a7677cf46 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mimic.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mimic.java @@ -109,6 +109,17 @@ public class Mimic extends Mob { } } + @Override + protected boolean act() { + if (alignment == Alignment.NEUTRAL && state != PASSIVE){ + alignment = Alignment.ENEMY; + GLog.w(Messages.get(this, "reveal") ); + CellEmitter.get(pos).burst(Speck.factory(Speck.STAR), 10); + Sample.INSTANCE.play(Assets.SND_MIMIC); + } + return super.act(); + } + @Override public CharSprite sprite() { MimicSprite sprite = (MimicSprite) super.sprite(); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Ankh.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Ankh.java index ae75f1028..54401d692 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Ankh.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Ankh.java @@ -46,7 +46,7 @@ public class Ankh extends Item { bones = true; } - private Boolean blessed = false; + private boolean blessed = false; @Override public boolean isUpgradable() { @@ -98,10 +98,14 @@ public class Ankh extends Item { return super.desc(); } - public Boolean isBlessed(){ + public boolean isBlessed(){ return blessed; } + public void bless(){ + blessed = true; + } + private static final Glowing WHITE = new Glowing( 0xFFFFCC ); @Override 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 356e1bb6e..dc2d8defd 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java @@ -630,11 +630,21 @@ public abstract class Level implements Bundlable { } //an open space is large enough to fit large mobs. A space is open when it is not solid - // and there also aren't solid spaces above&below, or left&right + // and there is a group of 3 or more adjacent cells which aren't solid for (int i=0; i < length(); i++) { - openSpace[i] = !solid[i] && - (!solid[i-1] || !solid[i+1]) && - (!solid[i-width()] || !solid[i+width()]); + if (solid[i]){ + openSpace[i] = false; + } else { + for (int j = 0; j < PathFinder.CIRCLE8.length; j++){ + if (solid[i+PathFinder.CIRCLE8[j]]) { + openSpace[i] = false; + } else if (!solid[i+PathFinder.CIRCLE8[(j+1)%8]] + && !solid[i+PathFinder.CIRCLE8[(j+2)%8]]){ + openSpace[i] = true; + break; + } + } + } } } @@ -693,6 +703,8 @@ public abstract class Level implements Bundlable { if (s != null && s.volume > 0){ level.losBlocking[cell] = level.losBlocking[cell] || s.cur[cell] > 0; } + + //TODO update openSpace here too } public Heap drop( Item item, int cell ) {