v0.3.1: quickslot autotarget now targets the closet enemy in multi-enemy situations
This commit is contained in:
parent
9b906353ad
commit
d7e849b3ab
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue
Block a user