From fac4c585157b739b787a1cbe53cbe00d3ff43968 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Thu, 21 Sep 2023 15:26:10 -0400 Subject: [PATCH] v2.2.0: added aggroing behaviour when crystal spire is attacked --- .../actors/mobs/CrystalGuardian.java | 26 +++++++++++-------- .../actors/mobs/CrystalSpire.java | 18 +++++++++++++ 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/CrystalGuardian.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/CrystalGuardian.java index 7c931931a..7745d2468 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/CrystalGuardian.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/CrystalGuardian.java @@ -26,6 +26,7 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Healing; +import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Blacksmith; import com.shatteredpixel.shatteredpixeldungeon.effects.Splash; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; @@ -54,6 +55,12 @@ public class CrystalGuardian extends Mob{ properties.add(Property.MINIBOSS); } + @Override + protected boolean act() { + if (sprite instanceof CrystalGuardianSprite) ((CrystalGuardianSprite) sprite).endCrumple(); + return super.act(); + } + @Override public int damageRoll() { return Random.NormalIntRange( 10, 20 ); @@ -76,7 +83,7 @@ public class CrystalGuardian extends Mob{ @Override public boolean isAlive() { - if (HP <= 0){ + if (HP <= 0 && !Blacksmith.Quest.bossBeaten()){ HP = 1; if (sprite != null) ((CrystalGuardianSprite)sprite).crumple(); spend(10f-cooldown()); @@ -114,12 +121,6 @@ public class CrystalGuardian extends Mob{ } } - @Override - public void beckon(int cell) { - super.beckon(cell); - state = HUNTING; - } - @Override public void move(int step, boolean travelling) { super.move(step, travelling); @@ -135,11 +136,14 @@ public class CrystalGuardian extends Mob{ @Override public boolean[] modifyPassable(boolean[] passable) { - //TODO maybe base this on passable instead of hunting? - // want to prevent one guardian randomly waking another though + //if we are hunting, and our current target is not reachable otherwise, then we can step on crystals if (state == HUNTING){ - for (int i = 0; i < Dungeon.level.length(); i++){ - passable[i] = passable[i] || Dungeon.level.map[i] == Terrain.MINE_CRYSTAL; + PathFinder.buildDistanceMap(target, passable); + + if (PathFinder.distance[pos] == Integer.MAX_VALUE) { + for (int i = 0; i < Dungeon.level.length(); i++) { + passable[i] = passable[i] || Dungeon.level.map[i] == Terrain.MINE_CRYSTAL; + } } } return passable; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/CrystalSpire.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/CrystalSpire.java index 594b29f52..1a0b698f1 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/CrystalSpire.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/CrystalSpire.java @@ -26,7 +26,9 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Amok; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Dread; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Haste; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Paralysis; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Sleep; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Terror; @@ -111,6 +113,22 @@ public class CrystalSpire extends Mob { Blacksmith.Quest.beatBoss(); } + for (Char ch : Actor.chars()){ + if (ch instanceof CrystalWisp){ + ((CrystalWisp)ch).beckon(pos); + } else if (ch instanceof CrystalGuardian){ + //TODO we want some way to encourage the player to explore first, but also not disturb guardians. + // maybe wisps alone are enough for this? + if (((CrystalGuardian) ch).state == ((CrystalGuardian) ch).SLEEPING){ + Buff.affect(ch, Haste.class, 6f); + } + ((CrystalGuardian) ch).beckon(pos); + if (((CrystalGuardian) ch).state != HUNTING){ + ((CrystalGuardian) ch).aggro(Dungeon.hero); + } + } + } + Dungeon.hero.spendAndNext(Actor.TICK); } });