v0.3.1: quickslot autotarget now targets the closet enemy in multi-enemy situations

This commit is contained in:
Evan Debenham 2015-08-14 17:01:55 -04:00
parent 9b906353ad
commit d7e849b3ab
2 changed files with 13 additions and 4 deletions

View File

@ -939,18 +939,27 @@ public class Hero extends Char {
ArrayList<Mob> visible = new ArrayList<Mob>();
boolean newMob = false;
Mob closest = null;
for (Mob m : Dungeon.level.mobs) {
if (Level.fieldOfView[ m.pos ] && m.hostile) {
visible.add( m );
if (!visibleEnemies.contains( m )) {
newMob = true;
}
if (closest == null){
closest = m;
} else if (distance(closest) > distance(m)) {
closest = m;
}
}
}
if (visible.size() == 1){
QuickSlotButton.target(visible.get(0));
if (closest != null && (QuickSlotButton.lastTarget == null ||
!QuickSlotButton.lastTarget.isAlive() ||
!Dungeon.visible[QuickSlotButton.lastTarget.pos])){
QuickSlotButton.target(closest);
}
if (newMob) {

View File

@ -48,7 +48,7 @@ public class QuickSlotButton extends Button implements WndBag.Listener {
private static Image crossM;
private static boolean targeting = false;
private static Char lastTarget= null;
public static Char lastTarget = null;
public QuickSlotButton( int slotNum ) {
super();