From d75a5a8f405db8015867d752c2c05c43be70c872 Mon Sep 17 00:00:00 2001 From: Anuken Date: Tue, 28 Jan 2025 23:41:24 -0500 Subject: [PATCH] Fixed #10444 --- core/src/mindustry/ai/types/CommandAI.java | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/core/src/mindustry/ai/types/CommandAI.java b/core/src/mindustry/ai/types/CommandAI.java index 097c464884..f8fd593794 100644 --- a/core/src/mindustry/ai/types/CommandAI.java +++ b/core/src/mindustry/ai/types/CommandAI.java @@ -132,6 +132,14 @@ public class CommandAI extends AIController{ } } + @Override + public Teamc findMainTarget(float x, float y, float range, boolean air, boolean ground){ + if(!unit.type.autoFindTarget && !(targetPos == null || nearAttackTarget(unit.x, unit.y, unit.range()))){ + return null; + } + return super.findMainTarget(x, y, range, air, ground); + } + public void defaultBehavior(){ if(!net.client() && unit instanceof Payloadc pay){ @@ -183,18 +191,7 @@ public class CommandAI extends AIController{ } updateVisuals(); - //only autotarget if the unit supports it - if((targetPos == null || nearAttackTarget(unit.x, unit.y, unit.range())) || unit.type.autoFindTarget){ - updateTargeting(); - }else if(attackTarget == null){ - //if the unit does not have an attack target, is currently moving, and does not have autotargeting, stop attacking stuff - target = null; - for(var mount : unit.mounts){ - if(mount.weapon.controllable){ - mount.target = null; - } - } - } + updateTargeting(); if(attackTarget != null && invalid(attackTarget)){ attackTarget = null;