From 4c8c0efd0c42976bb99e179314477d575f7af8f8 Mon Sep 17 00:00:00 2001 From: Anuken Date: Tue, 20 Sep 2022 22:51:38 -0400 Subject: [PATCH] Made Corvus/Vela no longer stop to shoot with command AI --- core/src/mindustry/ai/types/CommandAI.java | 13 ++++++++++++- core/src/mindustry/type/UnitType.java | 5 +++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/core/src/mindustry/ai/types/CommandAI.java b/core/src/mindustry/ai/types/CommandAI.java index 9fdd534af6..15861014b8 100644 --- a/core/src/mindustry/ai/types/CommandAI.java +++ b/core/src/mindustry/ai/types/CommandAI.java @@ -68,7 +68,18 @@ public class CommandAI extends AIController{ } updateVisuals(); - updateTargeting(); + //only autotarget if the unit supports it + if(targetPos == null || 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; + } + } + } if(attackTarget != null && invalid(attackTarget)){ attackTarget = null; diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index 38c1b35252..0d2e61361e 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -212,6 +212,8 @@ public class UnitType extends UnlockableContent{ bounded = true, /** if true, this unit is detected as naval - do NOT assign this manually! Initialized in init() */ naval = false, + /** if false, RTS AI controlled units do not automatically attack things while moving. This is automatically assigned. */ + autoFindTarget = true, /** if true, this modded unit always has a -outline region generated for its base. Normally, outlines are ignored if there are no top = false weapons. */ alwaysCreateOutline = false, @@ -688,6 +690,9 @@ public class UnitType extends UnlockableContent{ lightRadius = Math.max(60f, hitSize * 2.3f); } + //if a status effects slows a unit when firing, don't shoot while moving. + autoFindTarget = !weapons.contains(w -> w.shootStatus.speedMultiplier < 0.99f); + clipSize = Math.max(clipSize, lightRadius * 1.1f); singleTarget = weapons.size <= 1 && !forceMultiTarget;