Erekir rebalance / RTS AI improvements
This commit is contained in:
@@ -28,7 +28,7 @@ public class RtsAI{
|
|||||||
static final float squadRadius = 120f;
|
static final float squadRadius = 120f;
|
||||||
static final int timeUpdate = 0, timerSpawn = 1;
|
static final int timeUpdate = 0, timerSpawn = 1;
|
||||||
//TODO make configurable
|
//TODO make configurable
|
||||||
static final float minWeight = 1.1f;
|
static final float minWeight = 1f;
|
||||||
|
|
||||||
//in order of priority??
|
//in order of priority??
|
||||||
static final BlockFlag[] flags = {BlockFlag.generator, BlockFlag.factory, BlockFlag.core, BlockFlag.battery};
|
static final BlockFlag[] flags = {BlockFlag.generator, BlockFlag.factory, BlockFlag.core, BlockFlag.battery};
|
||||||
@@ -232,7 +232,7 @@ public class RtsAI{
|
|||||||
weights.clear();
|
weights.clear();
|
||||||
|
|
||||||
for(var target : targets){
|
for(var target : targets){
|
||||||
weights.put(target, estimateStats(target.x, target.y, dps, health));
|
weights.put(target, estimateStats(x, y, target.x, target.y, dps, health));
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = targets.min(
|
var result = targets.min(
|
||||||
@@ -253,21 +253,22 @@ public class RtsAI{
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
float estimateStats(float x, float y, float selfDps, float selfHealth){
|
float estimateStats(float fromX, float fromY, float x, float y, float selfDps, float selfHealth){
|
||||||
float[] health = {0f}, dps = {0f};
|
float[] health = {0f}, dps = {0f};
|
||||||
float extraRadius = 15f;
|
float extraRadius = 30f;
|
||||||
|
|
||||||
//TODO this does not take into account the path to this object
|
|
||||||
for(var turret : Vars.indexer.getEnemy(data.team, BlockFlag.turret)){
|
for(var turret : Vars.indexer.getEnemy(data.team, BlockFlag.turret)){
|
||||||
if(turret.within(x, y, ((TurretBuild)turret).range() + extraRadius)){
|
if(Intersector.distanceSegmentPoint(fromX, fromY, x, y, turret.x, turret.y) <= ((TurretBuild)turret).range() + extraRadius){
|
||||||
health[0] += turret.health;
|
health[0] += turret.health;
|
||||||
dps[0] += ((TurretBuild)turret).estimateDps();
|
dps[0] += ((TurretBuild)turret).estimateDps();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Tmp.r1.set(fromX, fromY, x - fromX, y - fromY).normalize().grow(140f * 2f);
|
||||||
|
|
||||||
//add on extra radius, assume unit range is below that...?
|
//add on extra radius, assume unit range is below that...?
|
||||||
Units.nearbyEnemies(data.team, x, y, extraRadius + 140f, other -> {
|
Units.nearbyEnemies(data.team, Tmp.r1, other -> {
|
||||||
if(other.within(x, y, other.range() + extraRadius)){
|
if(Intersector.distanceSegmentPoint(fromX, fromY, x, y, other.x, other.y) <= other.range() + extraRadius){
|
||||||
health[0] += other.health;
|
health[0] += other.health;
|
||||||
dps[0] += other.type.dpsEstimate;
|
dps[0] += other.type.dpsEstimate;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,55 @@
|
|||||||
package mindustry.content;
|
package mindustry.content;
|
||||||
|
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
|
import arc.util.*;
|
||||||
|
import mindustry.entities.bullet.*;
|
||||||
import mindustry.game.Objectives.*;
|
import mindustry.game.Objectives.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
|
import mindustry.type.unit.*;
|
||||||
|
import mindustry.world.blocks.defense.turrets.*;
|
||||||
|
|
||||||
|
import static mindustry.Vars.*;
|
||||||
import static mindustry.content.Blocks.*;
|
import static mindustry.content.Blocks.*;
|
||||||
import static mindustry.content.SectorPresets.*;
|
import static mindustry.content.SectorPresets.*;
|
||||||
import static mindustry.content.TechTree.*;
|
import static mindustry.content.TechTree.*;
|
||||||
|
|
||||||
public class ErekirTechTree{
|
public class ErekirTechTree{
|
||||||
|
static IntSet balanced = new IntSet();
|
||||||
|
|
||||||
|
static void rebalanceBullet(BulletType bullet){
|
||||||
|
if(balanced.add(bullet.id)){
|
||||||
|
bullet.damage *= 0.7f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO remove this
|
||||||
|
public static void rebalance(){
|
||||||
|
for(var unit : content.units().select(u -> u instanceof ErekirUnitType)){
|
||||||
|
for(var weapon : unit.weapons){
|
||||||
|
rebalanceBullet(weapon.bullet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(var block : content.blocks()){
|
||||||
|
if(block instanceof Turret turret && Structs.contains(block.requirements, i -> !Items.serpuloItems.contains(i.item))){
|
||||||
|
if(turret instanceof ItemTurret item){
|
||||||
|
for(var bullet : item.ammoTypes.values()){
|
||||||
|
rebalanceBullet(bullet);
|
||||||
|
}
|
||||||
|
}else if(turret instanceof ContinuousTurret cont){
|
||||||
|
rebalanceBullet(cont.shootType);
|
||||||
|
}else if(turret instanceof ContinuousLiquidTurret cont){
|
||||||
|
for(var bullet : cont.ammoTypes.values()){
|
||||||
|
rebalanceBullet(bullet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void load(){
|
public static void load(){
|
||||||
|
rebalance();
|
||||||
|
|
||||||
//TODO might be unnecessary with no asteroids
|
//TODO might be unnecessary with no asteroids
|
||||||
Seq<Objective> erekirSector = Seq.with(new OnPlanet(Planets.erekir));
|
Seq<Objective> erekirSector = Seq.with(new OnPlanet(Planets.erekir));
|
||||||
|
|
||||||
|
|||||||
@@ -115,6 +115,8 @@ public class DesktopInput extends InputHandler{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(commandMode){
|
if(commandMode){
|
||||||
|
//happens sometimes
|
||||||
|
selectedUnits.removeAll(u -> !u.isCommandable());
|
||||||
|
|
||||||
//draw command overlay UI
|
//draw command overlay UI
|
||||||
for(Unit unit : selectedUnits){
|
for(Unit unit : selectedUnits){
|
||||||
|
|||||||
Reference in New Issue
Block a user