Make Base AI walls correspond to tier

This commit is contained in:
Anuken 2021-09-10 21:11:57 -04:00
parent decc570867
commit cccce6badd
2 changed files with 14 additions and 10 deletions

View File

@ -12,6 +12,7 @@ import mindustry.game.*;
import mindustry.game.Schematic.*;
import mindustry.game.Teams.*;
import mindustry.gen.*;
import mindustry.maps.generators.*;
import mindustry.type.*;
import mindustry.world.*;
import mindustry.world.blocks.defense.*;
@ -25,7 +26,6 @@ import static mindustry.Vars.*;
public class BaseAI{
private static final Vec2 axis = new Vec2(), rotator = new Vec2();
private static final float correctPercent = 0.5f;
private static final int attempts = 4;
private static final float emptyChance = 0.01f;
private static final int timerStep = 0, timerSpawn = 1, timerRefreshPath = 2;
@ -46,6 +46,7 @@ public class BaseAI{
boolean calculating, startedCalculating;
int calcCount = 0;
int totalCalcs = 0;
Block wallType;
public BaseAI(TeamData data){
this.data = data;
@ -53,6 +54,10 @@ public class BaseAI{
public void update(){
if(wallType == null){
wallType = BaseGenerator.getDifficultyWall(1, data.team.rules().aiTier / 0.8f);
}
if(data.team.rules().aiCoreSpawn && timer.get(timerSpawn, 60 * 2.5f) && data.hasCore()){
CoreBlock block = (CoreBlock)data.core().block;
int coreUnits = Groups.unit.count(u -> u.team == data.team && u.type == block.unitType);
@ -271,7 +276,7 @@ public class BaseAI{
}
private void tryWalls(){
Block wall = Blocks.copperWall;
Block wall = wallType;
Building spawnt = state.rules.defaultTeam.core() != null ? state.rules.defaultTeam.core() : data.team.core();
Tile spawn = spawnt == null ? null : spawnt.tile;

View File

@ -30,6 +30,12 @@ public class BaseGenerator{
private Tiles tiles;
private Seq<Tile> cores;
public static Block getDifficultyWall(int size, float difficulty){
Seq<Block> wallsSmall = content.blocks().select(b -> b instanceof Wall && b.size == size && !b.insulated && b.buildVisibility == BuildVisibility.shown && !(b instanceof Door));
wallsSmall.sort(b -> b.buildCost);
return wallsSmall.getFrac(difficulty * 0.91f);
}
public void generate(Tiles tiles, Seq<Tile> cores, Tile spawn, Team team, Sector sector, float difficulty){
this.tiles = tiles;
this.cores = cores;
@ -39,13 +45,6 @@ public class BaseGenerator{
Mathf.rand.setSeed(sector.id);
Seq<Block> wallsSmall = content.blocks().select(b -> b instanceof Wall && b.size == 1 && !b.insulated && b.buildVisibility == BuildVisibility.shown && !(b instanceof Door));
Seq<Block> wallsLarge = content.blocks().select(b -> b instanceof Wall && b.size == 2 && !b.insulated && b.buildVisibility == BuildVisibility.shown && !(b instanceof Door));
//sort by cost for correct fraction
wallsSmall.sort(b -> b.buildCost);
wallsLarge.sort(b -> b.buildCost);
float bracketRange = 0.17f;
float baseChance = Mathf.lerp(0.7f, 2.1f, difficulty);
int wallAngle = 70; //180 for full coverage
@ -54,7 +53,7 @@ public class BaseGenerator{
BasePart coreschem = bases.cores.getFrac(difficulty);
int passes = difficulty < 0.4 ? 1 : difficulty < 0.8 ? 2 : 3;
Block wall = wallsSmall.getFrac(difficulty * 0.91f), wallLarge = wallsLarge.getFrac(difficulty * 0.91f);
Block wall = getDifficultyWall(1, difficulty), wallLarge = getDifficultyWall(2, difficulty);
for(Tile tile : cores){
tile.clearOverlay();