mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-11 11:17:11 +07:00
AI in custom game attack mode
This commit is contained in:
parent
d1de976dc4
commit
a7ca632c09
@ -10,10 +10,12 @@ import mindustry.content.*;
|
|||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
import mindustry.game.Schematic.*;
|
import mindustry.game.Schematic.*;
|
||||||
import mindustry.game.Teams.*;
|
import mindustry.game.Teams.*;
|
||||||
|
import mindustry.gen.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.defense.*;
|
import mindustry.world.blocks.defense.*;
|
||||||
import mindustry.world.blocks.production.*;
|
import mindustry.world.blocks.production.*;
|
||||||
|
import mindustry.world.blocks.storage.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
@ -23,6 +25,7 @@ public class BaseAI{
|
|||||||
private static final float step = 5;
|
private static final float step = 5;
|
||||||
private static final int attempts = 5;
|
private static final int attempts = 5;
|
||||||
private static final float emptyChance = 0.01f;
|
private static final float emptyChance = 0.01f;
|
||||||
|
private final static int timerStep = 0, timerSpawn = 1;
|
||||||
|
|
||||||
private static int correct = 0, incorrect = 0;
|
private static int correct = 0, incorrect = 0;
|
||||||
|
|
||||||
@ -30,16 +33,27 @@ public class BaseAI{
|
|||||||
private boolean triedWalls;
|
private boolean triedWalls;
|
||||||
|
|
||||||
TeamData data;
|
TeamData data;
|
||||||
Interval timer = new Interval();
|
Interval timer = new Interval(4);
|
||||||
|
|
||||||
public BaseAI(TeamData data){
|
public BaseAI(TeamData data){
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(){
|
public void update(){
|
||||||
|
if(timer.get(timerSpawn, 60) && data.hasCore()){
|
||||||
|
CoreBlock block = (CoreBlock)data.core().block;
|
||||||
|
|
||||||
|
//create AI core unit
|
||||||
|
if(!Groups.unit.contains(u -> u.team() == data.team && u.type() == block.unitType)){
|
||||||
|
Unitc unit = block.unitType.create(data.team);
|
||||||
|
unit.set(data.core());
|
||||||
|
unit.add();
|
||||||
|
Fx.spawn.at(unit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//only schedule when there's something to build.
|
//only schedule when there's something to build.
|
||||||
if(data.blocks.isEmpty() && timer.get(step)){
|
if(data.blocks.isEmpty() && timer.get(timerStep, step)){
|
||||||
if(!triedWalls){
|
if(!triedWalls){
|
||||||
tryWalls();
|
tryWalls();
|
||||||
triedWalls = true;
|
triedWalls = true;
|
||||||
|
@ -487,6 +487,10 @@ public class UnitTypes implements ContentList{
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
alpha = new UnitType("alpha"){{
|
alpha = new UnitType("alpha"){{
|
||||||
|
//TODO maybe these should be changed
|
||||||
|
defaultController = BuilderAI::new;
|
||||||
|
isCounted = false;
|
||||||
|
|
||||||
flying = true;
|
flying = true;
|
||||||
mineSpeed = 2f;
|
mineSpeed = 2f;
|
||||||
buildSpeed = 0.5f;
|
buildSpeed = 0.5f;
|
||||||
@ -513,7 +517,7 @@ public class UnitTypes implements ContentList{
|
|||||||
lifetime = 60f;
|
lifetime = 60f;
|
||||||
shootEffect = Fx.shootSmall;
|
shootEffect = Fx.shootSmall;
|
||||||
smokeEffect = Fx.shootSmallSmoke;
|
smokeEffect = Fx.shootSmallSmoke;
|
||||||
tileDamageMultiplier = 0.15f;
|
tileDamageMultiplier = 0.1f;
|
||||||
}};
|
}};
|
||||||
}});
|
}});
|
||||||
}};
|
}};
|
||||||
|
@ -21,6 +21,10 @@ public enum Gamemode{
|
|||||||
rules.attackMode = true;
|
rules.attackMode = true;
|
||||||
rules.waves = true;
|
rules.waves = true;
|
||||||
rules.waveTimer = true;
|
rules.waveTimer = true;
|
||||||
|
|
||||||
|
rules.waveSpacing /= 2f;
|
||||||
|
rules.teams.get(rules.waveTeam).ai = true;
|
||||||
|
rules.teams.get(rules.waveTeam).infiniteResources = true;
|
||||||
}, map -> map.teams.contains(state.rules.waveTeam.id)),
|
}, map -> map.teams.contains(state.rules.waveTeam.id)),
|
||||||
pvp(rules -> {
|
pvp(rules -> {
|
||||||
rules.pvp = true;
|
rules.pvp = true;
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
org.gradle.daemon=true
|
org.gradle.daemon=true
|
||||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||||
archash=662afc44313c42b637f9cfd9d21da7f280b27d65
|
archash=30796daec8eba235f9cde3723537431df4e4f6f5
|
||||||
|
Loading…
Reference in New Issue
Block a user