v0.7.4: some allies are now 'intelligent', and will not attack wandering, sleeping, or passive enemies

This commit is contained in:
Evan Debenham 2019-06-06 22:02:20 -04:00
parent bd3b0a487f
commit 6ca288c91c
5 changed files with 16 additions and 7 deletions

View File

@ -51,7 +51,7 @@ public class PrismaticGuard extends Buff {
int v = hero.visibleEnemies();
for (int i=0; i < v; i++) {
Mob mob = hero.visibleEnemy( i );
if ( mob.isAlive() && mob.state != mob.PASSIVE && !hero.mindVisionEnemies.contains(mob)
if ( mob.isAlive() && mob.state != mob.PASSIVE && mob.state != mob.WANDERING && mob.state != mob.SLEEPING && !hero.mindVisionEnemies.contains(mob)
&& (closest == null || Dungeon.level.distance(hero.pos, mob.pos) < Dungeon.level.distance(hero.pos, closest.pos))) {
closest = mob;
}

View File

@ -46,6 +46,9 @@ public class Bee extends Mob {
flying = true;
state = WANDERING;
//only applicable when the bee is charmed with elixir of honeyed healing
intelligentAlly = true;
}
private int level;

View File

@ -186,6 +186,9 @@ public abstract class Mob extends Char {
return state.act( enemyInFOV, justAlerted );
}
//FIXME this is sort of a band-aid correction for allies needing more intelligent behaviour
protected boolean intelligentAlly = false;
protected Char chooseEnemy() {
Terror terror = buff( Terror.class );
@ -250,12 +253,14 @@ public abstract class Mob extends Char {
//if the mob is an ally...
} else if ( alignment == Alignment.ALLY ) {
//look for hostile mobs that are not passive to attack
//look for hostile mobs to attack
for (Mob mob : Dungeon.level.mobs)
if (mob.alignment == Alignment.ENEMY
&& fieldOfView[mob.pos]
&& mob.state != mob.PASSIVE)
if (mob.alignment == Alignment.ENEMY && fieldOfView[mob.pos])
//intelligent allies do not target mobs which are passive, wandering, or asleep
if (!intelligentAlly ||
(mob.state != mob.SLEEPING && mob.state != mob.PASSIVE && mob.state != mob.WANDERING)) {
enemies.add(mob);
}
//if the mob is an enemy...
} else if (alignment == Alignment.ENEMY) {

View File

@ -51,6 +51,7 @@ public class PrismaticImage extends NPC {
defenseSkill = 1;
alignment = Alignment.ALLY;
intelligentAlly = true;
state = HUNTING;
WANDERING = new Wandering();

View File

@ -392,7 +392,7 @@ public class DriedRose extends Artifact {
flying = true;
alignment = Alignment.ALLY;
intelligentAlly = true;
WANDERING = new Wandering();
state = HUNTING;