From 764b1c27bfd8342b4777fa9444d30324a3a918a2 Mon Sep 17 00:00:00 2001 From: Anuken Date: Fri, 22 Apr 2022 17:46:47 -0400 Subject: [PATCH] Configurable min squad size --- core/assets/bundles/bundle.properties | 1 + core/src/mindustry/ai/RtsAI.java | 6 ++---- core/src/mindustry/game/Rules.java | 2 ++ core/src/mindustry/ui/dialogs/CustomRulesDialog.java | 1 + gradle.properties | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index e9fc433c1a..6c31ed8934 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -1079,6 +1079,7 @@ rules.wavetimer = Wave Timer rules.waves = Waves rules.attack = Attack Mode rules.rtsai = RTS AI +rules.rtsminsquadsize = Min Squad Size rules.cleanupdeadteams = Clean Up Defeated Team Buildings (PvP) rules.corecapture = Capture Core On Destruction rules.polygoncoreprotection = Polygonal Core Protection diff --git a/core/src/mindustry/ai/RtsAI.java b/core/src/mindustry/ai/RtsAI.java index 556d04480d..aa2c46157e 100644 --- a/core/src/mindustry/ai/RtsAI.java +++ b/core/src/mindustry/ai/RtsAI.java @@ -34,8 +34,6 @@ public class RtsAI{ //in order of priority?? static final BlockFlag[] flags = {BlockFlag.generator, BlockFlag.factory, BlockFlag.core, BlockFlag.battery}; static final ObjectFloatMap weights = new ObjectFloatMap<>(); - //TODO configurable, perhaps - static final int minSquadSize = 4; //TODO max squad size static final boolean debug = OS.hasProp("mindustry.debug"); @@ -172,7 +170,7 @@ public class RtsAI{ //defend when close, or this is the only squad defending //TODO will always rush to defense no matter what - if(best instanceof CoreBuild || units.size >= minSquadSize || best.within(ax, ay, 500f)){ + if(best instanceof CoreBuild || units.size >= data.team.rules().rtsAiMinSquadSize || best.within(ax, ay, 500f)){ defend = best; if(debug){ @@ -239,7 +237,7 @@ public class RtsAI{ } @Nullable Building findTarget(float x, float y, int total, float dps, float health){ - if(total < minSquadSize) return null; + if(total < data.team.rules().rtsAiMinSquadSize) return null; //flag priority? //1. generator diff --git a/core/src/mindustry/game/Rules.java b/core/src/mindustry/game/Rules.java index 0f92bfb781..2217cc408f 100644 --- a/core/src/mindustry/game/Rules.java +++ b/core/src/mindustry/game/Rules.java @@ -224,6 +224,8 @@ public class Rules{ /** Enables "RTS" unit AI. TODO wip */ public boolean rtsAi; + /** Minimum size of attack squads. */ + public int rtsAiMinSquadSize = 4; /** How fast unit factories build units. */ public float unitBuildSpeedMultiplier = 1f; diff --git a/core/src/mindustry/ui/dialogs/CustomRulesDialog.java b/core/src/mindustry/ui/dialogs/CustomRulesDialog.java index 9d9712f1a3..c536bc8648 100644 --- a/core/src/mindustry/ui/dialogs/CustomRulesDialog.java +++ b/core/src/mindustry/ui/dialogs/CustomRulesDialog.java @@ -253,6 +253,7 @@ public class CustomRulesDialog extends BaseDialog{ number("@rules.blockdamagemultiplier", f -> teams.blockDamageMultiplier = f, () -> teams.blockDamageMultiplier); check("@rules.rtsai", b -> teams.rtsAi = b, () -> teams.rtsAi, () -> team != rules.defaultTeam); + numberi("@rules.rtsminsquadsize", f -> teams.rtsAiMinSquadSize = f, () -> teams.rtsAiMinSquadSize, () -> teams.rtsAi, 0, 100); check("@rules.infiniteresources", b -> teams.infiniteResources = b, () -> teams.infiniteResources); number("@rules.buildspeedmultiplier", f -> teams.buildSpeedMultiplier = f, () -> teams.buildSpeedMultiplier, 0.001f, 50f); diff --git a/gradle.properties b/gradle.properties index 55f4b48e62..28fe5ac058 100644 --- a/gradle.properties +++ b/gradle.properties @@ -25,4 +25,4 @@ org.gradle.caching=true #used for slow jitpack builds; TODO see if this actually works org.gradle.internal.http.socketTimeout=100000 org.gradle.internal.http.connectionTimeout=100000 -archash=b2eb1dd566 +archash=99ceda8bf2