Difficulty & AI tweaks

This commit is contained in:
Anuken 2024-09-14 09:22:56 -04:00
parent 6b93873fce
commit a15a0d945f
4 changed files with 33 additions and 6 deletions

View File

@ -462,17 +462,19 @@ public class Pathfinder implements Runnable{
@Override
protected void getPositions(IntSeq out){
if(state.rules.randomWaveAI && team == state.rules.waveTeam){
rand.setSeed(state.rules.waves ? state.wave : (int)(state.tick / (5400)));
rand.setSeed(state.rules.waves ? state.wave : (int)(state.tick / (5400)) + hashCode());
//maximum amount of different target flag types they will attack
int max = 2;
int max = 1;
for(int attempt = 0; attempt < 5 && max > 0; attempt++){
var targets = indexer.getEnemy(team, randomTargets[rand.random(randomTargets.length - 1)]);
if(!targets.isEmpty()){
max --;
for(Building other : targets){
out.add(other.tile.array());
if((other.items != null && other.items.any()) || other.status() != BlockStatus.noInput){
out.add(other.tile.array());
}
}
}
}

View File

@ -2,6 +2,7 @@ package mindustry.ai.types;
import arc.math.*;
import mindustry.entities.units.*;
import mindustry.game.*;
import mindustry.gen.*;
import mindustry.world.meta.*;
@ -29,6 +30,30 @@ public class FlyingAI extends AIController{
}
}
@Override
public Teamc targetFlag(float x, float y, BlockFlag flag, boolean enemy){
if(state.rules.randomWaveAI){
if(unit.team == Team.derelict) return null;
var list = enemy ? indexer.getEnemy(unit.team, flag) : indexer.getFlagged(unit.team, flag);
if(list.isEmpty()) return null;
Building closest = null;
float cdist = 0f;
for(Building t : list){
if((t.items != null && t.items.any()) || t.status() != BlockStatus.noInput){
float dst = t.dst2(x, y);
if(closest == null || dst < cdist){
closest = t;
cdist = dst;
}
}
}
return closest;
}else{
return super.targetFlag(x, y, flag, enemy);
}
}
@Override
public Teamc findTarget(float x, float y, float range, boolean air, boolean ground){
var result = findMainTarget(x, y, range, air, ground);

View File

@ -6,8 +6,8 @@ public enum Difficulty{
//TODO these need tweaks
easy(1f, 0.75f, 1.5f),
normal(1f, 1f, 1f),
hard(1.25f, 1.5f, 0.75f),
eradication(1.5f, 2f, 0.5f);
hard(1.25f, 1.5f, 0.8f),
eradication(1.5f, 2f, 0.6f);
public static final Difficulty[] all = values();

View File

@ -26,4 +26,4 @@ org.gradle.caching=true
org.gradle.internal.http.socketTimeout=100000
org.gradle.internal.http.connectionTimeout=100000
android.enableR8.fullMode=false
archash=8073823706
archash=25e8455084