CommandAI counter-attack timer

This commit is contained in:
Anuken
2022-09-06 00:05:34 -04:00
parent 6a79421040
commit 90fe7b75d1
2 changed files with 3 additions and 5 deletions

View File

@@ -14,7 +14,6 @@ public class UnitCommand{
public static final UnitCommand
//TODO they do not use the command "interface" or designation at all
moveCommand = new UnitCommand("move", "right", u -> null),
repairCommand = new UnitCommand("repair", "modeSurvival", u -> new RepairAI()),
rebuildCommand = new UnitCommand("rebuild", "hammer", u -> new BuilderAI()),
@@ -25,9 +24,6 @@ public class UnitCommand{
}),
mineCommand = new UnitCommand("mine", "production", u -> new MinerAI());
/** Default set of specified commands. */
public static final UnitCommand[] defaultCommands = {moveCommand};
/** Unique ID number. */
public final int id;
/** Named used for tooltip/description. */

View File

@@ -168,7 +168,9 @@ 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 && !(teamc instanceof Unit u && !u.checkTarget(unit.type.targetAir, unit.type.targetGround))){
if(unit.team.isAI() && bullet.owner instanceof Teamc teamc && teamc.team() != unit.team && attackTarget == null &&
//can only counter-attack every few seconds to prevent rapidly changing targets
!(teamc instanceof Unit u && !u.checkTarget(unit.type.targetAir, unit.type.targetGround)) && timer.get(timerTarget4, 60f * 12f)){
commandTarget(teamc, true);
}
}