Made Corvus/Vela no longer stop to shoot with command AI

This commit is contained in:
Anuken 2022-09-20 22:51:38 -04:00
parent 9b7ac713ee
commit 4c8c0efd0c
2 changed files with 17 additions and 1 deletions

View File

@ -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;

View File

@ -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;