From 2014d066e5f6825fa3f35cc458ef79cbe7538629 Mon Sep 17 00:00:00 2001 From: Anuken Date: Fri, 15 Apr 2022 19:26:12 -0400 Subject: [PATCH] Less aggressive AI pursuit --- core/src/mindustry/ai/RtsAI.java | 3 ++- core/src/mindustry/ai/types/CommandAI.java | 12 +++++++++++- core/src/mindustry/graphics/FloorRenderer.java | 2 +- gradle.properties | 2 +- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/core/src/mindustry/ai/RtsAI.java b/core/src/mindustry/ai/RtsAI.java index e13a8624f6..556d04480d 100644 --- a/core/src/mindustry/ai/RtsAI.java +++ b/core/src/mindustry/ai/RtsAI.java @@ -228,7 +228,8 @@ public class RtsAI{ if(defendPos != null){ unit.command().commandPosition(defendPos); }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); } } } diff --git a/core/src/mindustry/ai/types/CommandAI.java b/core/src/mindustry/ai/types/CommandAI.java index c08fb5c5f5..a9e2c2ac7c 100644 --- a/core/src/mindustry/ai/types/CommandAI.java +++ b/core/src/mindustry/ai/types/CommandAI.java @@ -18,6 +18,7 @@ public class CommandAI extends AIController{ public @Nullable Vec2 targetPos; public @Nullable Teamc attackTarget; + private boolean stopAtTarget; private Vec2 lastTargetPos; private int pathId = -1; private Seq local = new Seq<>(false); @@ -86,6 +87,11 @@ public class CommandAI extends AIController{ //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()){ unit.lookAt(targetPos); }else{ @@ -194,8 +200,12 @@ public class CommandAI extends AIController{ } public void commandTarget(Teamc moveTo){ - //TODO + commandTarget(moveTo, false); + } + + public void commandTarget(Teamc moveTo, boolean stopAtTarget){ attackTarget = moveTo; + this.stopAtTarget = stopAtTarget; pathId = Vars.controlPath.nextTargetId(); } } diff --git a/core/src/mindustry/graphics/FloorRenderer.java b/core/src/mindustry/graphics/FloorRenderer.java index faac3456e4..fb2354e63d 100644 --- a/core/src/mindustry/graphics/FloorRenderer.java +++ b/core/src/mindustry/graphics/FloorRenderer.java @@ -19,7 +19,7 @@ import static mindustry.Vars.*; * general implementation: * * 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) * 3. create mesh for this chunk based on buffer size, copy buffer into mesh * diff --git a/gradle.properties b/gradle.properties index 2b287249ec..8921ff667d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -25,4 +25,4 @@ org.gradle.caching=true #used for slow jitpack builds; TODO see if this actually works org.gradle.internal.http.socketTimeout=100000 org.gradle.internal.http.connectionTimeout=100000 -archash=faf0ac24dd +archash=f21eb00d2e