Mega repair AI
This commit is contained in:
@@ -214,8 +214,7 @@ public class Vars implements Loadable{
|
|||||||
|
|
||||||
if(loadLocales){
|
if(loadLocales){
|
||||||
//load locales
|
//load locales
|
||||||
String[]
|
String[] stra = Core.files.internal("locales").readString().split("\n");
|
||||||
stra = Core.files.internal("locales").readString().split("\n");
|
|
||||||
locales = new Locale[stra.length];
|
locales = new Locale[stra.length];
|
||||||
for(int i = 0; i < locales.length; i++){
|
for(int i = 0; i < locales.length; i++){
|
||||||
String code = stra[i];
|
String code = stra[i];
|
||||||
|
|||||||
@@ -12,14 +12,6 @@ public class FlyingAI extends AIController{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateMovement(){
|
public void updateMovement(){
|
||||||
if(unit.moving()){
|
|
||||||
unit.lookAt(unit.vel.angle());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(unit.isFlying()){
|
|
||||||
unit.wobble();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(target != null && unit.hasWeapons() && command() == UnitCommand.attack){
|
if(target != null && unit.hasWeapons() && command() == UnitCommand.attack){
|
||||||
if(unit.type().weapons.first().rotate){
|
if(unit.type().weapons.first().rotate){
|
||||||
moveTo(target, unit.range() * 0.8f);
|
moveTo(target, unit.range() * 0.8f);
|
||||||
|
|||||||
@@ -15,14 +15,6 @@ public class MinerAI extends AIController{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateMovement(){
|
protected void updateMovement(){
|
||||||
if(unit.moving()){
|
|
||||||
unit.lookAt(unit.vel.angle());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(unit.isFlying()){
|
|
||||||
unit.wobble();
|
|
||||||
}
|
|
||||||
|
|
||||||
Building core = unit.closestCore();
|
Building core = unit.closestCore();
|
||||||
|
|
||||||
if(!(unit instanceof Minerc) || core == null) return;
|
if(!(unit instanceof Minerc) || core == null) return;
|
||||||
|
|||||||
32
core/src/mindustry/ai/types/RepairAI.java
Normal file
32
core/src/mindustry/ai/types/RepairAI.java
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
package mindustry.ai.types;
|
||||||
|
|
||||||
|
import mindustry.entities.*;
|
||||||
|
import mindustry.entities.units.*;
|
||||||
|
import mindustry.world.blocks.ConstructBlock.*;
|
||||||
|
|
||||||
|
//note that repair AI doesn't attack anything even if it theoretically can
|
||||||
|
public class RepairAI extends AIController{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateMovement(){
|
||||||
|
boolean shoot = false;
|
||||||
|
|
||||||
|
if(target != null){
|
||||||
|
if(!target.within(unit, unit.type().range)){
|
||||||
|
moveTo(target, unit.type().range * 0.9f);
|
||||||
|
}else{
|
||||||
|
unit.aim(target);
|
||||||
|
shoot = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unit.controlWeapons(shoot);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateTargeting(){
|
||||||
|
target = Units.findDamagedTile(unit.team, unit.x, unit.y);
|
||||||
|
|
||||||
|
if(target instanceof ConstructBuild) target = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1029,6 +1029,7 @@ public class UnitTypes implements ContentList{
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
mega = new UnitType("mega"){{
|
mega = new UnitType("mega"){{
|
||||||
|
defaultController = RepairAI::new;
|
||||||
|
|
||||||
mineTier = 2;
|
mineTier = 2;
|
||||||
health = 500;
|
health = 500;
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ public class AIController implements UnitController{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateUnit(){
|
public void updateUnit(){
|
||||||
|
updateVisuals();
|
||||||
updateTargeting();
|
updateTargeting();
|
||||||
updateMovement();
|
updateMovement();
|
||||||
}
|
}
|
||||||
@@ -41,13 +42,23 @@ public class AIController implements UnitController{
|
|||||||
return unit.team.data().command;
|
return unit.team.data().command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void updateVisuals(){
|
||||||
|
|
||||||
|
if(unit.isFlying()){
|
||||||
|
unit.wobble();
|
||||||
|
|
||||||
|
if(unit.moving()){
|
||||||
|
unit.lookAt(unit.vel.angle());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void updateMovement(){
|
protected void updateMovement(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateTargeting(){
|
protected void updateTargeting(){
|
||||||
if(unit.hasWeapons()){
|
if(unit.hasWeapons()){
|
||||||
|
|
||||||
updateWeapons();
|
updateWeapons();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ public class LogicBlock extends Block{
|
|||||||
update = true;
|
update = true;
|
||||||
solid = true;
|
solid = true;
|
||||||
configurable = true;
|
configurable = true;
|
||||||
sync = true;
|
|
||||||
|
|
||||||
config(byte[].class, (LogicBuild build, byte[] data) -> build.readCompressed(data, true));
|
config(byte[].class, (LogicBuild build, byte[] data) -> build.readCompressed(data, true));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user