/bot count and region fixes
-Fix bugs with region setting -/bot count: Count bots by name -/bot info gets closest bot
This commit is contained in:
@@ -16,7 +16,7 @@ public interface BotManager {
|
||||
|
||||
void add(Terminator bot);
|
||||
|
||||
Terminator getFirst(String name);
|
||||
Terminator getFirst(String name, Location target);
|
||||
|
||||
List<String> fetchNames();
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ public enum EnumTargetGoal {
|
||||
this.put("nearestbot", NEAREST_BOT);
|
||||
this.put("nearestbotdiffer", NEAREST_BOT_DIFFER);
|
||||
this.put("nearestbotdifferalpha", NEAREST_BOT_DIFFER_ALPHA);
|
||||
this.put("player", PLAYER);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1496,24 +1496,19 @@ public class LegacyAgent extends Agent {
|
||||
return false;
|
||||
double regionDistResult = result == null ? 0 : getWeightedRegionDist(result.getLocation());
|
||||
return loc.getWorld() == entity.getWorld() && !entity.isDead()
|
||||
&& (result == null || (loc.distance(entity.getLocation()) + regionDistEntity) < (loc.distance(result.getLocation())) + regionDistResult);
|
||||
&& (result == null || (loc.distanceSquared(entity.getLocation()) + regionDistEntity) < (loc.distanceSquared(result.getLocation())) + regionDistResult);
|
||||
}
|
||||
|
||||
private double getWeightedRegionDist(Location loc) {
|
||||
if (region == null)
|
||||
return 0;
|
||||
double diffX = Math.min(0, Math.abs(region.getCenterX() - loc.getX()) - region.getWidthX() * 0.5);
|
||||
double diffX = Math.max(0, Math.abs(region.getCenterX() - loc.getX()) - region.getWidthX() * 0.5);
|
||||
double diffY = Math.max(0, Math.abs(region.getCenterY() - loc.getY()) - region.getHeight() * 0.5);
|
||||
double diffZ = Math.max(0, Math.abs(region.getCenterZ() - loc.getZ()) - region.getWidthZ() * 0.5);
|
||||
if (regionWeightX == 0 && regionWeightY == 0 && regionWeightZ == 0) {
|
||||
if (regionWeightX == 0 && regionWeightY == 0 && regionWeightZ == 0)
|
||||
if (diffX > 0 || diffY > 0 || diffZ > 0)
|
||||
return Double.MAX_VALUE;
|
||||
} else {
|
||||
diffX *= regionWeightX;
|
||||
diffY *= regionWeightY;
|
||||
diffZ *= regionWeightZ;
|
||||
}
|
||||
return diffX * diffX + diffY * diffY + diffZ * diffZ;
|
||||
return diffX * diffX * regionWeightX + diffY * diffY * regionWeightY + diffZ * diffZ * regionWeightZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user