Logic pathfind instruction
This commit is contained in:
@@ -2371,7 +2371,7 @@ lenum.stop = Stop moving/mining/building.
|
||||
lenum.unbind = Completely disable logic control.\nResume standard AI.
|
||||
lenum.move = Move to exact position.
|
||||
lenum.approach = Approach a position with a radius.
|
||||
lenum.pathfind = Pathfind to the enemy spawn.
|
||||
lenum.pathfind = Pathfind to the specified position.
|
||||
lenum.target = Shoot a position.
|
||||
lenum.targetp = Shoot a target with velocity prediction.
|
||||
lenum.itemdrop = Drop an item.
|
||||
|
||||
@@ -3,6 +3,7 @@ package mindustry.ai.types;
|
||||
import arc.math.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.logic.*;
|
||||
@@ -36,9 +37,18 @@ public class LogicAI extends AIController{
|
||||
public PosTeam posTarget = PosTeam.create();
|
||||
|
||||
private ObjectSet<Object> radars = new ObjectSet<>();
|
||||
private float lastMoveX, lastMoveY;
|
||||
private int lastPathId = 0;
|
||||
|
||||
@Override
|
||||
public void updateMovement(){
|
||||
if(control == LUnitControl.pathfind){
|
||||
if(!Mathf.equal(moveX, lastMoveX, 0.1f) || !Mathf.equal(moveY, lastMoveY, 0.1f)){
|
||||
lastPathId ++;
|
||||
lastMoveX = moveX;
|
||||
lastMoveY = moveY;
|
||||
}
|
||||
}
|
||||
|
||||
if(targetTimer > 0f){
|
||||
targetTimer -= Time.delta;
|
||||
@@ -62,6 +72,15 @@ public class LogicAI extends AIController{
|
||||
case approach -> {
|
||||
moveTo(Tmp.v1.set(moveX, moveY), moveRad - 7f, 7, true, null);
|
||||
}
|
||||
case pathfind -> {
|
||||
if(unit.isFlying()){
|
||||
moveTo(Tmp.v1.set(moveX, moveY), 1f, 30f);
|
||||
}else{
|
||||
if(Vars.controlPath.getPathPosition(unit, lastPathId, Tmp.v2.set(moveX, moveY), Tmp.v1, null)){
|
||||
moveTo(Tmp.v1, 1f, Tmp.v2.epsilonEquals(Tmp.v1, 4.1f) ? 30f : 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
case stop -> {
|
||||
unit.clearBuilding();
|
||||
}
|
||||
|
||||
@@ -394,7 +394,7 @@ public class LExecutor{
|
||||
case idle -> {
|
||||
ai.control = type;
|
||||
}
|
||||
case move, stop, approach -> {
|
||||
case move, stop, approach, pathfind -> {
|
||||
ai.control = type;
|
||||
ai.moveX = x1;
|
||||
ai.moveY = y1;
|
||||
|
||||
@@ -5,6 +5,7 @@ public enum LUnitControl{
|
||||
stop,
|
||||
move("x", "y"),
|
||||
approach("x", "y", "radius"),
|
||||
pathfind("x", "y"),
|
||||
boost("enable"),
|
||||
target("x", "y", "shoot"),
|
||||
targetp("unit", "shoot"),
|
||||
|
||||
@@ -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=56c0bbf95f
|
||||
archash=513474758f
|
||||
|
||||
Reference in New Issue
Block a user