mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-10 07:07:03 +07:00
More experimental changes / Better RTS AI
This commit is contained in:
parent
0d66c7dec7
commit
9f95dc6e47
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.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.logic.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.defense.turrets.Turret.*;
|
||||
@ -170,7 +171,8 @@ public class RtsAI{
|
||||
});
|
||||
|
||||
//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;
|
||||
|
||||
if(debug){
|
||||
@ -183,8 +185,10 @@ public class RtsAI{
|
||||
Vec2 defendPos = null;
|
||||
Teamc defendTarget = null;
|
||||
if(defend != null){
|
||||
float checkRange = 260f;
|
||||
|
||||
//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){
|
||||
defendTarget = aggressor;
|
||||
}else if(false){ //TODO currently ignored, no use defending against nothing
|
||||
@ -193,6 +197,24 @@ public class RtsAI{
|
||||
if(closest != null){
|
||||
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;
|
||||
|
||||
ruleSetter = r -> {
|
||||
r.placeRangeCheck = true;
|
||||
r.placeRangeCheck = false; //TODO true or false?
|
||||
r.attributes.set(Attribute.heat, 0.8f);
|
||||
r.showSpawns = true;
|
||||
r.fog = true;
|
||||
|
@ -175,7 +175,8 @@ public class OverlayRenderer{
|
||||
Draw.color();
|
||||
}else{
|
||||
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);
|
||||
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));
|
||||
|
Loading…
Reference in New Issue
Block a user