Fixed #10887
This commit is contained in:
@@ -141,6 +141,8 @@ public class RtsAI{
|
|||||||
boolean handleSquad(Seq<Unit> units, boolean noDefenders){
|
boolean handleSquad(Seq<Unit> units, boolean noDefenders){
|
||||||
if(units.isEmpty()) return false;
|
if(units.isEmpty()) return false;
|
||||||
|
|
||||||
|
boolean naval = units.first() instanceof WaterMovec;
|
||||||
|
|
||||||
float health = 0f, dps = 0f;
|
float health = 0f, dps = 0f;
|
||||||
float ax = 0f, ay = 0f;
|
float ax = 0f, ay = 0f;
|
||||||
boolean targetAir = true, targetGround = true;
|
boolean targetAir = true, targetGround = true;
|
||||||
@@ -165,7 +167,7 @@ public class RtsAI{
|
|||||||
boolean defendingCore = false;
|
boolean defendingCore = false;
|
||||||
|
|
||||||
//there is something to defend, see if it's worth the time
|
//there is something to defend, see if it's worth the time
|
||||||
if(damaged.size > 0){
|
if(damaged.size > 0 && !naval){
|
||||||
//TODO do the weights matter at all?
|
//TODO do the weights matter at all?
|
||||||
//for(var build : damaged){
|
//for(var build : damaged){
|
||||||
//float w = estimateStats(ax, ay, dps, health);
|
//float w = estimateStats(ax, ay, dps, health);
|
||||||
@@ -251,7 +253,7 @@ public class RtsAI{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var build = anyDefend ? null : findTarget(ax, ay, units.size, dps, health, units.first().flag == 0, units.first().isFlying());
|
var build = anyDefend ? null : findTarget(ax, ay, units.size, dps, health, units.first().flag == 0, units.first().isFlying(), naval);
|
||||||
|
|
||||||
if(build != null || anyDefend){
|
if(build != null || anyDefend){
|
||||||
for(var unit : units){
|
for(var unit : units){
|
||||||
@@ -274,7 +276,7 @@ public class RtsAI{
|
|||||||
return anyDefend;
|
return anyDefend;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable Building findTarget(float x, float y, int total, float dps, float health, boolean checkWeight, boolean air){
|
@Nullable Building findTarget(float x, float y, int total, float dps, float health, boolean checkWeight, boolean air, boolean naval){
|
||||||
if(total < data.team.rules().rtsMinSquad) return null;
|
if(total < data.team.rules().rtsMinSquad) return null;
|
||||||
|
|
||||||
//flag priority?
|
//flag priority?
|
||||||
@@ -282,8 +284,13 @@ public class RtsAI{
|
|||||||
//2. factory
|
//2. factory
|
||||||
//3. core
|
//3. core
|
||||||
targets.clear();
|
targets.clear();
|
||||||
for(var flag : flags){
|
if(naval){
|
||||||
targets.addAll(Vars.indexer.getEnemy(data.team, flag));
|
//naval units can only target enemy cores, because those are assumed to always be reachable. other blocks may not be!
|
||||||
|
targets.addAll(Vars.indexer.getEnemy(data.team, BlockFlag.core));
|
||||||
|
}else{
|
||||||
|
for(var flag : flags){
|
||||||
|
targets.addAll(Vars.indexer.getEnemy(data.team, flag));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
targets.removeAll(b -> assignedTargets.contains(b.id) || invalidTarget.contains(b.pos()));
|
targets.removeAll(b -> assignedTargets.contains(b.id) || invalidTarget.contains(b.pos()));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user