v2.2.0: added aggroing behaviour when crystal spire is attacked

This commit is contained in:
Evan Debenham
2023-09-21 15:26:10 -04:00
parent 6dcb16f70a
commit fac4c58515
2 changed files with 33 additions and 11 deletions

View File

@@ -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;

View File

@@ -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);
}
});