Fixed #7133
This commit is contained in:
@@ -129,8 +129,12 @@ public class RtsAI{
|
|||||||
boolean handleSquad(Seq<Unit> units, boolean noDefenders){
|
boolean handleSquad(Seq<Unit> units, boolean noDefenders){
|
||||||
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;
|
||||||
|
|
||||||
for(var unit : units){
|
for(var unit : units){
|
||||||
|
if(!unit.type.targetAir) targetAir = false;
|
||||||
|
if(!unit.type.targetGround) targetGround = false;
|
||||||
|
|
||||||
ax += unit.x;
|
ax += unit.x;
|
||||||
ay += unit.y;
|
ay += unit.y;
|
||||||
health += unit.health;
|
health += unit.health;
|
||||||
@@ -176,6 +180,8 @@ public class RtsAI{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean tair = targetAir, tground = targetGround;
|
||||||
|
|
||||||
//find aggressor, or else, the thing being attacked
|
//find aggressor, or else, the thing being attacked
|
||||||
Vec2 defendPos = null;
|
Vec2 defendPos = null;
|
||||||
Teamc defendTarget = null;
|
Teamc defendTarget = null;
|
||||||
@@ -183,7 +189,7 @@ public class RtsAI{
|
|||||||
float checkRange = 260f;
|
float checkRange = 260f;
|
||||||
|
|
||||||
//TODO could be made faster by storing bullet shooter
|
//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){
|
if(aggressor != null){
|
||||||
defendTarget = aggressor;
|
defendTarget = aggressor;
|
||||||
}else if(false){ //TODO currently ignored, no use defending against nothing
|
}else if(false){ //TODO currently ignored, no use defending against nothing
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ public class CommandAI extends AIController{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hit(Bullet bullet){
|
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);
|
commandTarget(teamc, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user