Wave balancing & AI tweaks
This commit is contained in:
@@ -17,13 +17,17 @@ public class BuilderAI extends AIController{
|
||||
@Nullable Builderc following;
|
||||
|
||||
@Override
|
||||
public void updateUnit(){
|
||||
public void updateMovement(){
|
||||
Builderc builder = (Builderc)unit;
|
||||
|
||||
if(builder.moving()){
|
||||
builder.lookAt(builder.vel().angle());
|
||||
}
|
||||
|
||||
if(target != null && shouldShoot()){
|
||||
unit.lookAt(target);
|
||||
}
|
||||
|
||||
builder.updateBuilding(true);
|
||||
|
||||
if(following != null){
|
||||
@@ -95,13 +99,29 @@ public class BuilderAI extends AIController{
|
||||
}else if(Build.validPlace(content.block(block.block), unit.team(), block.x, block.y, block.rotation)){ //it's valid.
|
||||
//add build request.
|
||||
builder.addBuild(new BuildPlan(block.x, block.y, block.rotation, content.block(block.block), block.config));
|
||||
//shift build plan to tail so next unit builds something else.
|
||||
blocks.addLast(blocks.removeFirst());
|
||||
}else{
|
||||
//shift head of queue to tail, try something else next time
|
||||
blocks.removeFirst();
|
||||
blocks.addLast(block);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AIController fallback(){
|
||||
return unit.type().flying ? new FlyingAI() : new GroundAI();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useFallback(){
|
||||
return state.rules.waves && unit.team == state.rules.waveTeam && !unit.team.rules().ai;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldShoot(){
|
||||
return !((Builderc)unit).isBuilding();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,27 +2,33 @@ package mindustry.ai.types;
|
||||
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
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 * 0.8f)){
|
||||
moveTo(target, unit.type().range * 0.8f);
|
||||
}
|
||||
if(target instanceof Building){
|
||||
boolean shoot = false;
|
||||
|
||||
if(target.within(unit, unit.type().range)){
|
||||
unit.aim(target);
|
||||
shoot = true;
|
||||
}
|
||||
|
||||
unit.controlWeapons(shoot);
|
||||
}else if(target == null){
|
||||
unit.controlWeapons(false);
|
||||
}
|
||||
|
||||
unit.controlWeapons(shoot);
|
||||
if(target != null){
|
||||
if(!target.within(unit, unit.type().range * 0.65f)){
|
||||
moveTo(target, unit.type().range * 0.65f);
|
||||
}
|
||||
|
||||
unit.lookAt(target);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -30,5 +36,10 @@ public class RepairAI extends AIController{
|
||||
target = Units.findDamagedTile(unit.team, unit.x, unit.y);
|
||||
|
||||
if(target instanceof ConstructBuild) target = null;
|
||||
|
||||
if(target == null){
|
||||
super.updateTargeting();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user