mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-13 17:27:35 +07:00
More experimental changes / Better RTS AI
This commit is contained in:
Binary file not shown.
Before Width: | Height: | Size: 909 B After Width: | Height: | Size: 914 B |
@ -13,6 +13,7 @@ import mindustry.game.EventType.*;
|
|||||||
import mindustry.game.Teams.*;
|
import mindustry.game.Teams.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
|
import mindustry.logic.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.defense.turrets.Turret.*;
|
import mindustry.world.blocks.defense.turrets.Turret.*;
|
||||||
@ -170,7 +171,8 @@ public class RtsAI{
|
|||||||
});
|
});
|
||||||
|
|
||||||
//defend when close, or this is the only squad defending
|
//defend when close, or this is the only squad defending
|
||||||
if(best instanceof CoreBuild || (units.size >= minSquadSize && (noDefenders || best.within(ax, ay, 400f)))){
|
//TODO will always rush to defense no matter what
|
||||||
|
if(best instanceof CoreBuild || (/*(units.size >= minSquadSize || best.within(ax, ay, 300f)) && */(noDefenders || best.within(ax, ay, 400f)))){
|
||||||
defend = best;
|
defend = best;
|
||||||
|
|
||||||
if(debug){
|
if(debug){
|
||||||
@ -183,8 +185,10 @@ public class RtsAI{
|
|||||||
Vec2 defendPos = null;
|
Vec2 defendPos = null;
|
||||||
Teamc defendTarget = null;
|
Teamc defendTarget = null;
|
||||||
if(defend != null){
|
if(defend != null){
|
||||||
|
float checkRange = 260f;
|
||||||
|
|
||||||
//TODO could be made faster by storing bullet shooter
|
//TODO could be made faster by storing bullet shooter
|
||||||
Unit aggressor = Units.closestEnemy(data.team, defend.x, defend.y, 250f, u -> true);
|
Unit aggressor = Units.closestEnemy(data.team, defend.x, defend.y, checkRange, u -> true);
|
||||||
if(aggressor != null){
|
if(aggressor != null){
|
||||||
defendTarget = aggressor;
|
defendTarget = aggressor;
|
||||||
}else if(false){ //TODO currently ignored, no use defending against nothing
|
}else if(false){ //TODO currently ignored, no use defending against nothing
|
||||||
@ -193,6 +197,24 @@ public class RtsAI{
|
|||||||
if(closest != null){
|
if(closest != null){
|
||||||
defendPos = new Vec2(closest.worldx(), closest.worldy());
|
defendPos = new Vec2(closest.worldx(), closest.worldy());
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
float mindst = Float.MAX_VALUE;
|
||||||
|
Building build = null;
|
||||||
|
|
||||||
|
//find closest turret to attack.
|
||||||
|
for(var turret : Vars.indexer.getEnemy(data.team, BlockFlag.turret)){
|
||||||
|
if(turret.within(defend, ((Ranged)turret).range())){
|
||||||
|
float dst = turret.dst2(defend);
|
||||||
|
if(dst < mindst){
|
||||||
|
mindst = dst;
|
||||||
|
build = turret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(build != null){
|
||||||
|
defendTarget = build;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ public class Planets{
|
|||||||
updateLighting = false;
|
updateLighting = false;
|
||||||
|
|
||||||
ruleSetter = r -> {
|
ruleSetter = r -> {
|
||||||
r.placeRangeCheck = true;
|
r.placeRangeCheck = false; //TODO true or false?
|
||||||
r.attributes.set(Attribute.heat, 0.8f);
|
r.attributes.set(Attribute.heat, 0.8f);
|
||||||
r.showSpawns = true;
|
r.showSpawns = true;
|
||||||
r.fog = true;
|
r.fog = true;
|
||||||
|
@ -175,7 +175,8 @@ public class OverlayRenderer{
|
|||||||
Draw.color();
|
Draw.color();
|
||||||
}else{
|
}else{
|
||||||
state.teams.eachEnemyCore(player.team(), core -> {
|
state.teams.eachEnemyCore(player.team(), core -> {
|
||||||
if(core.wasVisible && Core.camera.bounds(Tmp.r1).overlaps(Tmp.r2.setCentered(core.x, core.y, state.rules.enemyCoreBuildRadius * 2f))){
|
//it must be clear that there is a core here.
|
||||||
|
if(/*core.wasVisible && */Core.camera.bounds(Tmp.r1).overlaps(Tmp.r2.setCentered(core.x, core.y, state.rules.enemyCoreBuildRadius * 2f))){
|
||||||
Draw.color(Color.darkGray);
|
Draw.color(Color.darkGray);
|
||||||
Lines.circle(core.x, core.y - 2, state.rules.enemyCoreBuildRadius);
|
Lines.circle(core.x, core.y - 2, state.rules.enemyCoreBuildRadius);
|
||||||
Draw.color(Pal.accent, core.team.color, 0.5f + Mathf.absin(Time.time, 10f, 0.5f));
|
Draw.color(Pal.accent, core.team.color, 0.5f + Mathf.absin(Time.time, 10f, 0.5f));
|
||||||
|
Reference in New Issue
Block a user