Less aggressive AI pursuit

This commit is contained in:
Anuken
2022-04-15 19:26:12 -04:00
parent 9def4b8d88
commit 2014d066e5
4 changed files with 15 additions and 4 deletions

View File

@@ -228,7 +228,8 @@ public class RtsAI{
if(defendPos != null){ if(defendPos != null){
unit.command().commandPosition(defendPos); unit.command().commandPosition(defendPos);
}else{ }else{
unit.command().commandTarget(defendTarget == null ? build : defendTarget); //TODO stopAtTarget parameter could be false, could be tweaked
unit.command().commandTarget(defendTarget == null ? build : defendTarget, true);
} }
} }
} }

View File

@@ -18,6 +18,7 @@ public class CommandAI extends AIController{
public @Nullable Vec2 targetPos; public @Nullable Vec2 targetPos;
public @Nullable Teamc attackTarget; public @Nullable Teamc attackTarget;
private boolean stopAtTarget;
private Vec2 lastTargetPos; private Vec2 lastTargetPos;
private int pathId = -1; private int pathId = -1;
private Seq<Unit> local = new Seq<>(false); private Seq<Unit> local = new Seq<>(false);
@@ -86,6 +87,11 @@ public class CommandAI extends AIController{
//calculateFlock().limit(unit.speed() * flockMult) //calculateFlock().limit(unit.speed() * flockMult)
} }
//if stopAtTarget is set, stop trying to move to the target once it is reached - used for defending
if(attackTarget != null && stopAtTarget && unit.within(attackTarget, engageRange - 1f)){
attackTarget = null;
}
if(unit.isFlying()){ if(unit.isFlying()){
unit.lookAt(targetPos); unit.lookAt(targetPos);
}else{ }else{
@@ -194,8 +200,12 @@ public class CommandAI extends AIController{
} }
public void commandTarget(Teamc moveTo){ public void commandTarget(Teamc moveTo){
//TODO commandTarget(moveTo, false);
}
public void commandTarget(Teamc moveTo, boolean stopAtTarget){
attackTarget = moveTo; attackTarget = moveTo;
this.stopAtTarget = stopAtTarget;
pathId = Vars.controlPath.nextTargetId(); pathId = Vars.controlPath.nextTargetId();
} }
} }

View File

@@ -19,7 +19,7 @@ import static mindustry.Vars.*;
* general implementation: * general implementation:
* *
* caching: * caching:
* 1. create fixed-size float array fpr rendering into * 1. create fixed-size float array for rendering into
* 2. for each chunk, cache each layer into buffer; record layer boundary indices (alternatively, create mesh per layer for fast recache) * 2. for each chunk, cache each layer into buffer; record layer boundary indices (alternatively, create mesh per layer for fast recache)
* 3. create mesh for this chunk based on buffer size, copy buffer into mesh * 3. create mesh for this chunk based on buffer size, copy buffer into mesh
* *

View File

@@ -25,4 +25,4 @@ org.gradle.caching=true
#used for slow jitpack builds; TODO see if this actually works #used for slow jitpack builds; TODO see if this actually works
org.gradle.internal.http.socketTimeout=100000 org.gradle.internal.http.socketTimeout=100000
org.gradle.internal.http.connectionTimeout=100000 org.gradle.internal.http.connectionTimeout=100000
archash=faf0ac24dd archash=f21eb00d2e