This commit is contained in:
Anuken
2022-07-06 07:37:17 -04:00
parent 69a26900fe
commit 9c7eb36431
2 changed files with 8 additions and 2 deletions

View File

@@ -129,8 +129,12 @@ public class RtsAI{
boolean handleSquad(Seq<Unit> units, boolean noDefenders){
float health = 0f, dps = 0f;
float ax = 0f, ay = 0f;
boolean targetAir = true, targetGround = true;
for(var unit : units){
if(!unit.type.targetAir) targetAir = false;
if(!unit.type.targetGround) targetGround = false;
ax += unit.x;
ay += unit.y;
health += unit.health;
@@ -176,6 +180,8 @@ public class RtsAI{
}
}
boolean tair = targetAir, tground = targetGround;
//find aggressor, or else, the thing being attacked
Vec2 defendPos = null;
Teamc defendTarget = null;
@@ -183,7 +189,7 @@ public class RtsAI{
float checkRange = 260f;
//TODO could be made faster by storing bullet shooter
Unit aggressor = Units.closestEnemy(data.team, defend.x, defend.y, checkRange, u -> true);
Unit aggressor = Units.closestEnemy(data.team, defend.x, defend.y, checkRange, u -> u.checkTarget(tair, tground));
if(aggressor != null){
defendTarget = aggressor;
}else if(false){ //TODO currently ignored, no use defending against nothing

View File

@@ -129,7 +129,7 @@ public class CommandAI extends AIController{
@Override
public void hit(Bullet bullet){
if(unit.team.isAI() && bullet.owner instanceof Teamc teamc && teamc.team() != unit.team && attackTarget == null){
if(unit.team.isAI() && bullet.owner instanceof Teamc teamc && teamc.team() != unit.team && attackTarget == null && !(teamc instanceof Unit u && !u.checkTarget(unit.type.targetAir, unit.type.targetGround))){
commandTarget(teamc, true);
}
}