v0.7.4: some allies are now 'intelligent', and will not attack wandering, sleeping, or passive enemies
This commit is contained in:
parent
bd3b0a487f
commit
6ca288c91c
|
@ -51,7 +51,7 @@ public class PrismaticGuard extends Buff {
|
||||||
int v = hero.visibleEnemies();
|
int v = hero.visibleEnemies();
|
||||||
for (int i=0; i < v; i++) {
|
for (int i=0; i < v; i++) {
|
||||||
Mob mob = hero.visibleEnemy( 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 == null || Dungeon.level.distance(hero.pos, mob.pos) < Dungeon.level.distance(hero.pos, closest.pos))) {
|
||||||
closest = mob;
|
closest = mob;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,9 @@ public class Bee extends Mob {
|
||||||
|
|
||||||
flying = true;
|
flying = true;
|
||||||
state = WANDERING;
|
state = WANDERING;
|
||||||
|
|
||||||
|
//only applicable when the bee is charmed with elixir of honeyed healing
|
||||||
|
intelligentAlly = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int level;
|
private int level;
|
||||||
|
|
|
@ -186,6 +186,9 @@ public abstract class Mob extends Char {
|
||||||
return state.act( enemyInFOV, justAlerted );
|
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() {
|
protected Char chooseEnemy() {
|
||||||
|
|
||||||
Terror terror = buff( Terror.class );
|
Terror terror = buff( Terror.class );
|
||||||
|
@ -250,12 +253,14 @@ public abstract class Mob extends Char {
|
||||||
|
|
||||||
//if the mob is an ally...
|
//if the mob is an ally...
|
||||||
} else if ( alignment == Alignment.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)
|
for (Mob mob : Dungeon.level.mobs)
|
||||||
if (mob.alignment == Alignment.ENEMY
|
if (mob.alignment == Alignment.ENEMY && fieldOfView[mob.pos])
|
||||||
&& fieldOfView[mob.pos]
|
//intelligent allies do not target mobs which are passive, wandering, or asleep
|
||||||
&& mob.state != mob.PASSIVE)
|
if (!intelligentAlly ||
|
||||||
|
(mob.state != mob.SLEEPING && mob.state != mob.PASSIVE && mob.state != mob.WANDERING)) {
|
||||||
enemies.add(mob);
|
enemies.add(mob);
|
||||||
|
}
|
||||||
|
|
||||||
//if the mob is an enemy...
|
//if the mob is an enemy...
|
||||||
} else if (alignment == Alignment.ENEMY) {
|
} else if (alignment == Alignment.ENEMY) {
|
||||||
|
|
|
@ -51,6 +51,7 @@ public class PrismaticImage extends NPC {
|
||||||
defenseSkill = 1;
|
defenseSkill = 1;
|
||||||
|
|
||||||
alignment = Alignment.ALLY;
|
alignment = Alignment.ALLY;
|
||||||
|
intelligentAlly = true;
|
||||||
state = HUNTING;
|
state = HUNTING;
|
||||||
|
|
||||||
WANDERING = new Wandering();
|
WANDERING = new Wandering();
|
||||||
|
|
|
@ -392,7 +392,7 @@ public class DriedRose extends Artifact {
|
||||||
flying = true;
|
flying = true;
|
||||||
|
|
||||||
alignment = Alignment.ALLY;
|
alignment = Alignment.ALLY;
|
||||||
|
intelligentAlly = true;
|
||||||
WANDERING = new Wandering();
|
WANDERING = new Wandering();
|
||||||
|
|
||||||
state = HUNTING;
|
state = HUNTING;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user