v0.9.3: various tweaks and improvements to directable allies
This commit is contained in:
parent
d16f1b8ab7
commit
4bf8ac0383
|
@ -4,10 +4,7 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.DriedRose;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
|
||||||
import com.watabou.utils.Bundle;
|
import com.watabou.utils.Bundle;
|
||||||
import com.watabou.utils.Random;
|
|
||||||
|
|
||||||
public class DirectableAlly extends NPC {
|
public class DirectableAlly extends NPC {
|
||||||
|
|
||||||
|
@ -15,12 +12,15 @@ public class DirectableAlly extends NPC {
|
||||||
alignment = Char.Alignment.ALLY;
|
alignment = Char.Alignment.ALLY;
|
||||||
intelligentAlly = true;
|
intelligentAlly = true;
|
||||||
WANDERING = new Wandering();
|
WANDERING = new Wandering();
|
||||||
|
state = WANDERING;
|
||||||
|
|
||||||
//before other mobs
|
//before other mobs
|
||||||
actPriority = MOB_PRIO + 1;
|
actPriority = MOB_PRIO + 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean attacksAutomatically = true;
|
||||||
|
|
||||||
protected int defendingPos = -1;
|
protected int defendingPos = -1;
|
||||||
protected boolean movingToDefendPos = false;
|
protected boolean movingToDefendPos = false;
|
||||||
|
|
||||||
|
@ -73,23 +73,6 @@ public class DirectableAlly extends NPC {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Char chooseEnemy() {
|
|
||||||
Char enemy = super.chooseEnemy();
|
|
||||||
|
|
||||||
int targetPos = defendingPos != -1 ? defendingPos : Dungeon.hero.pos;
|
|
||||||
|
|
||||||
//will never attack something far from their target
|
|
||||||
if (enemy != null
|
|
||||||
&& Dungeon.level.mobs.contains(enemy)
|
|
||||||
&& (Dungeon.level.distance(enemy.pos, targetPos) <= 8)){
|
|
||||||
return enemy;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String DEFEND_POS = "defend_pos";
|
private static final String DEFEND_POS = "defend_pos";
|
||||||
private static final String MOVING_TO_DEFEND = "moving_to_defend";
|
private static final String MOVING_TO_DEFEND = "moving_to_defend";
|
||||||
|
|
||||||
|
@ -111,7 +94,7 @@ public class DirectableAlly extends NPC {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean act( boolean enemyInFOV, boolean justAlerted ) {
|
public boolean act( boolean enemyInFOV, boolean justAlerted ) {
|
||||||
if ( enemyInFOV && !movingToDefendPos ) {
|
if ( enemyInFOV && !movingToDefendPos && attacksAutomatically) {
|
||||||
|
|
||||||
enemySeen = true;
|
enemySeen = true;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user