From af0cef90dec8581a62554f35fd4860c901e5e9e0 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sun, 23 Jul 2023 16:01:35 -0400 Subject: [PATCH] v2.2.0: bosses from the sewers quest now tend to wander towards the hero --- .../actors/mobs/FetidRat.java | 18 ++++++++++++++++++ .../actors/mobs/GnollTrickster.java | 17 +++++++++++++++++ .../actors/mobs/Golem.java | 2 +- .../actors/mobs/GreatCrab.java | 17 +++++++++++++++++ .../shatteredpixeldungeon/actors/mobs/Mob.java | 6 +++++- 5 files changed, 58 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/FetidRat.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/FetidRat.java index 4430b78d7..f33c5ace9 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/FetidRat.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/FetidRat.java @@ -21,6 +21,7 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.mobs; +import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob; import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.StenchGas; @@ -29,6 +30,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Ooze; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Ghost; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.FetidRatSprite; +import com.watabou.utils.PathFinder; import com.watabou.utils.Random; public class FetidRat extends Rat { @@ -41,6 +43,7 @@ public class FetidRat extends Rat { EXP = 4; + WANDERING = new Wandering(); state = WANDERING; properties.add(Property.MINIBOSS); @@ -81,6 +84,21 @@ public class FetidRat extends Rat { Ghost.Quest.process(); } + + protected class Wandering extends Mob.Wandering{ + @Override + protected int randomDestination() { + //of two potential wander positions, picks the one closest to the hero + int pos1 = super.randomDestination(); + int pos2 = super.randomDestination(); + PathFinder.buildDistanceMap(Dungeon.hero.pos, Dungeon.level.passable); + if (PathFinder.distance[pos2] < PathFinder.distance[pos1]){ + return pos2; + } else { + return pos1; + } + } + } { immunities.add( StenchGas.class ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/GnollTrickster.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/GnollTrickster.java index a3f1f7fea..2c3512a98 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/GnollTrickster.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/GnollTrickster.java @@ -36,6 +36,7 @@ import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.GnollTricksterSprite; import com.watabou.utils.Bundle; +import com.watabou.utils.PathFinder; import com.watabou.utils.Random; public class GnollTrickster extends Gnoll { @@ -48,6 +49,7 @@ public class GnollTrickster extends Gnoll { EXP = 5; + WANDERING = new Wandering(); state = WANDERING; //at half quantity, see createLoot() @@ -125,6 +127,21 @@ public class GnollTrickster extends Gnoll { Ghost.Quest.process(); } + protected class Wandering extends Mob.Wandering{ + @Override + protected int randomDestination() { + //of two potential wander positions, picks the one closest to the hero + int pos1 = super.randomDestination(); + int pos2 = super.randomDestination(); + PathFinder.buildDistanceMap(Dungeon.hero.pos, Dungeon.level.passable); + if (PathFinder.distance[pos2] < PathFinder.distance[pos1]){ + return pos2; + } else { + return pos1; + } + } + } + private static final String COMBO = "combo"; @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 87d61f301..bf49dc0ea 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 @@ -197,7 +197,7 @@ public class Golem extends Mob { teleporting = true; spend( 2*TICK ); } else { - target = Dungeon.level.randomDestination( Golem.this ); + target = randomDestination(); spend( TICK ); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/GreatCrab.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/GreatCrab.java index a3a8271e6..60f780e9e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/GreatCrab.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/GreatCrab.java @@ -32,6 +32,7 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.GreatCrabSprite; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.watabou.noosa.audio.Sample; +import com.watabou.utils.PathFinder; import com.watabou.utils.Random; public class GreatCrab extends Crab { @@ -45,6 +46,7 @@ public class GreatCrab extends Crab { EXP = 6; + WANDERING = new Wandering(); state = WANDERING; loot = new MysteryMeat().quantity(2); @@ -109,4 +111,19 @@ public class GreatCrab extends Crab { Ghost.Quest.process(); } + + protected class Wandering extends Mob.Wandering{ + @Override + protected int randomDestination() { + //of two potential wander positions, picks the one closest to the hero + int pos1 = super.randomDestination(); + int pos2 = super.randomDestination(); + PathFinder.buildDistanceMap(Dungeon.hero.pos, Dungeon.level.passable); + if (PathFinder.distance[pos2] < PathFinder.distance[pos1]){ + return pos2; + } else { + return pos1; + } + } + } } 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 fb8b470bf..337746399 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 @@ -1081,12 +1081,16 @@ public abstract class Mob extends Char { spend( 1 / speed() ); return moveSprite( oldPos, pos ); } else { - target = Dungeon.level.randomDestination( Mob.this ); + target = randomDestination(); spend( TICK ); } return true; } + + protected int randomDestination(){ + return Dungeon.level.randomDestination( Mob.this ); + } }