From 31149c08eaa15e75e5519719f660bc2b663aa92b Mon Sep 17 00:00:00 2001 From: MEEPofFaith <54301439+MEEPofFaith@users.noreply.github.com> Date: Wed, 7 Sep 2022 15:54:26 -0700 Subject: [PATCH] More control over wave sending (#7442) * Wave send rule * Send natural wave command * Use a boolean * boolean selection * Revert "boolean selection" This reverts commit 01e7a8f0e0bf4c98122e1ae27f91d31022c6d8a5. * Natural wave last * I don't see why it wouldn't --- core/assets/bundles/bundle.properties | 3 ++- core/src/mindustry/game/Rules.java | 2 ++ core/src/mindustry/logic/LExecutor.java | 14 +++++++++++--- core/src/mindustry/logic/LStatements.java | 14 ++++++++------ core/src/mindustry/logic/LogicRule.java | 1 + .../mindustry/ui/dialogs/CustomRulesDialog.java | 1 + core/src/mindustry/ui/fragments/HudFragment.java | 2 +- 7 files changed, 26 insertions(+), 11 deletions(-) diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index c23c4eea49..510b62a8ca 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -1153,6 +1153,7 @@ rules.coreincinerates = Core Incinerates Overflow rules.disableworldprocessors = Disable World Processors rules.schematic = Schematics Allowed rules.wavetimer = Wave Timer +rules.wavesending = Wave Sending rules.waves = Waves rules.attack = Attack Mode rules.rtsai = RTS AI @@ -2114,7 +2115,7 @@ lst.getblock = Get tile data at any location. lst.setblock = Set tile data at any location. lst.spawnunit = Spawn unit at a location. lst.applystatus = Apply or clear a status effect from a unit. -lst.spawnwave = Simulate a wave being spawned at an arbitrary location.\nWill not increment the wave counter. +lst.spawnwave = Spawn a wave. lst.explosion = Create an explosion at a location. lst.setrate = Set processor execution speed in instructions/tick. lst.fetch = Lookup units, cores, players or buildings by index.\nIndices start at 0 and end at their returned count. diff --git a/core/src/mindustry/game/Rules.java b/core/src/mindustry/game/Rules.java index 0f3a658652..c912b59196 100644 --- a/core/src/mindustry/game/Rules.java +++ b/core/src/mindustry/game/Rules.java @@ -25,6 +25,8 @@ public class Rules{ public TeamRules teams = new TeamRules(); /** Whether the waves come automatically on a timer. If not, waves come when the play button is pressed. */ public boolean waveTimer = true; + /** Whether the waves can be manually summoned with the play button. */ + public boolean waveSending = true; /** Whether waves are spawnable at all. */ public boolean waves; /** Whether the game objective is PvP. Note that this enables automatic hosting. */ diff --git a/core/src/mindustry/logic/LExecutor.java b/core/src/mindustry/logic/LExecutor.java index 3df0e3edf6..e6b5d3c4bf 100644 --- a/core/src/mindustry/logic/LExecutor.java +++ b/core/src/mindustry/logic/LExecutor.java @@ -1409,6 +1409,7 @@ public class LExecutor{ case wave -> state.wave = exec.numi(value); case currentWaveTime -> state.wavetime = exec.numf(value) * 60f; case waves -> state.rules.waves = exec.bool(value); + case waveSending -> state.rules.waveSending = exec.bool(value); case attackMode -> state.rules.attackMode = exec.bool(value); case waveSpacing -> state.rules.waveSpacing = exec.numf(value) * 60f; case enemyCoreBuildRadius -> state.rules.enemyCoreBuildRadius = exec.numf(value) * 8f; @@ -1641,12 +1642,14 @@ public class LExecutor{ } public static class SpawnWaveI implements LInstruction{ + public int natural; public int x, y; public SpawnWaveI(){ } - public SpawnWaveI(int x, int y){ + public SpawnWaveI(int natural, int x, int y){ + this.natural = natural; this.x = x; this.y = y; } @@ -1655,9 +1658,14 @@ public class LExecutor{ public void run(LExecutor exec){ if(net.client()) return; + if(exec.bool(natural)){ + logic.skipWave(); + return; + } + float - spawnX = World.unconv(exec.numf(x)), - spawnY = World.unconv(exec.numf(y)); + spawnX = World.unconv(exec.numf(x)), + spawnY = World.unconv(exec.numf(y)); int packed = Point2.pack(exec.numi(x), exec.numi(y)); for(SpawnGroup group : state.rules.spawns){ diff --git a/core/src/mindustry/logic/LStatements.java b/core/src/mindustry/logic/LStatements.java index b57b1b3fa6..c3eb6119f8 100644 --- a/core/src/mindustry/logic/LStatements.java +++ b/core/src/mindustry/logic/LStatements.java @@ -1309,16 +1309,18 @@ public class LStatements{ @RegisterStatement("spawnwave") public static class SpawnWaveStatement extends LStatement{ - public String x = "10", y = "10"; + public String x = "10", y = "10", natural = "false"; @Override public void build(Table table){ + table.add("natural "); + fields(table, natural, str -> natural = str); - table.add("x "); - fields(table, x, str -> x = str); + table.add("x ").visible(() -> natural.equals("false")); + fields(table, x, str -> x = str).visible(() -> natural.equals("false")); - table.add(" y "); - fields(table, y, str -> y = str); + table.add(" y ").visible(() -> natural.equals("false")); + fields(table, y, str -> y = str).visible(() -> natural.equals("false")); } @Override @@ -1328,7 +1330,7 @@ public class LStatements{ @Override public LInstruction build(LAssembler builder){ - return new SpawnWaveI(builder.var(x), builder.var(y)); + return new SpawnWaveI(builder.var(natural), builder.var(x), builder.var(y)); } @Override diff --git a/core/src/mindustry/logic/LogicRule.java b/core/src/mindustry/logic/LogicRule.java index 44329eb627..8314707ff4 100644 --- a/core/src/mindustry/logic/LogicRule.java +++ b/core/src/mindustry/logic/LogicRule.java @@ -6,6 +6,7 @@ public enum LogicRule{ waves, wave, waveSpacing, + waveSending, attackMode, enemyCoreBuildRadius, dropZoneRadius, diff --git a/core/src/mindustry/ui/dialogs/CustomRulesDialog.java b/core/src/mindustry/ui/dialogs/CustomRulesDialog.java index 2e3057b2d8..a203563b20 100644 --- a/core/src/mindustry/ui/dialogs/CustomRulesDialog.java +++ b/core/src/mindustry/ui/dialogs/CustomRulesDialog.java @@ -139,6 +139,7 @@ public class CustomRulesDialog extends BaseDialog{ title("@rules.title.waves"); check("@rules.waves", b -> rules.waves = b, () -> rules.waves); check("@rules.wavetimer", b -> rules.waveTimer = b, () -> rules.waveTimer); + check("@rules.wavesending", b -> rules.waveSending = b, () -> rules.waveSending); check("@rules.waitForWaveToEnd", b -> rules.waitEnemies = b, () -> rules.waitEnemies); number("@rules.wavespacing", false, f -> rules.waveSpacing = f * 60f, () -> rules.waveSpacing / 60f, () -> rules.waveTimer, 1, Float.MAX_VALUE); //this is experimental, because it's not clear that 0 makes it default. diff --git a/core/src/mindustry/ui/fragments/HudFragment.java b/core/src/mindustry/ui/fragments/HudFragment.java index eb6c32e54c..4e0ffdd302 100644 --- a/core/src/mindustry/ui/fragments/HudFragment.java +++ b/core/src/mindustry/ui/fragments/HudFragment.java @@ -908,7 +908,7 @@ public class HudFragment{ } private boolean canSkipWave(){ - return state.rules.waves && ((net.server() || player.admin) || !net.active()) && state.enemies == 0 && !spawner.isSpawning(); + return state.rules.waves && state.rules.waveSending && ((net.server() || player.admin) || !net.active()) && state.enemies == 0 && !spawner.isSpawning(); } }