CommandAI counter-attack timer
This commit is contained in:
@@ -14,7 +14,6 @@ public class UnitCommand{
|
|||||||
|
|
||||||
public static final UnitCommand
|
public static final UnitCommand
|
||||||
|
|
||||||
//TODO they do not use the command "interface" or designation at all
|
|
||||||
moveCommand = new UnitCommand("move", "right", u -> null),
|
moveCommand = new UnitCommand("move", "right", u -> null),
|
||||||
repairCommand = new UnitCommand("repair", "modeSurvival", u -> new RepairAI()),
|
repairCommand = new UnitCommand("repair", "modeSurvival", u -> new RepairAI()),
|
||||||
rebuildCommand = new UnitCommand("rebuild", "hammer", u -> new BuilderAI()),
|
rebuildCommand = new UnitCommand("rebuild", "hammer", u -> new BuilderAI()),
|
||||||
@@ -25,9 +24,6 @@ public class UnitCommand{
|
|||||||
}),
|
}),
|
||||||
mineCommand = new UnitCommand("mine", "production", u -> new MinerAI());
|
mineCommand = new UnitCommand("mine", "production", u -> new MinerAI());
|
||||||
|
|
||||||
/** Default set of specified commands. */
|
|
||||||
public static final UnitCommand[] defaultCommands = {moveCommand};
|
|
||||||
|
|
||||||
/** Unique ID number. */
|
/** Unique ID number. */
|
||||||
public final int id;
|
public final int id;
|
||||||
/** Named used for tooltip/description. */
|
/** Named used for tooltip/description. */
|
||||||
|
|||||||
@@ -168,7 +168,9 @@ 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 && !(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);
|
commandTarget(teamc, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user