From 3bf01334c9c24ccc6cc211888e63e65b0630dccb Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 27 Sep 2020 17:15:31 -0400 Subject: [PATCH] Many things --- .../misc/LogicStatementProcessor.java | 2 +- core/src/mindustry/content/Blocks.java | 3 +- core/src/mindustry/core/GameState.java | 2 +- .../mindustry/entities/comp/WeaponsComp.java | 4 +- core/src/mindustry/game/DefaultWaves.java | 62 +++++++++++++++++-- core/src/mindustry/logic/ConditionOp.java | 3 +- core/src/mindustry/logic/LStatements.java | 30 ++++++--- core/src/mindustry/type/UnitType.java | 5 ++ 8 files changed, 90 insertions(+), 21 deletions(-) diff --git a/annotations/src/main/java/mindustry/annotations/misc/LogicStatementProcessor.java b/annotations/src/main/java/mindustry/annotations/misc/LogicStatementProcessor.java index eca5d84387..64adc37c89 100644 --- a/annotations/src/main/java/mindustry/annotations/misc/LogicStatementProcessor.java +++ b/annotations/src/main/java/mindustry/annotations/misc/LogicStatementProcessor.java @@ -67,7 +67,7 @@ public class LogicStatementProcessor extends BaseProcessor{ int index = 0; for(Svar field : fields){ - if(field.is(Modifier.TRANSIENT)) continue; + if(field.isAny(Modifier.TRANSIENT, Modifier.STATIC)) continue; writer.addStatement("out.append(\" \")"); writer.addStatement("out.append((($T)obj).$L$L)", c.mirror(), field.name(), diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index 41090e1de3..615f27aaf4 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -866,7 +866,8 @@ public class Blocks implements ContentList{ size = 2; reload = 250f; range = 85f; - healPercent = 14f; + healPercent = 11f; + phaseBoost = 15f; health = 80 * size * size; consumes.item(Items.phasefabric).boost(); }}; diff --git a/core/src/mindustry/core/GameState.java b/core/src/mindustry/core/GameState.java index 15061641e0..84b408b135 100644 --- a/core/src/mindustry/core/GameState.java +++ b/core/src/mindustry/core/GameState.java @@ -52,7 +52,7 @@ public class GameState{ /** @return whether the player is in a campaign and they are out of sector time */ public boolean isOutOfTime(){ - return isCampaign() && isGame() && getSector().getTimeSpent() >= turnDuration; + return isCampaign() && isGame() && getSector().getTimeSpent() >= turnDuration && !net.active(); } public boolean hasSector(){ diff --git a/core/src/mindustry/entities/comp/WeaponsComp.java b/core/src/mindustry/entities/comp/WeaponsComp.java index fd22fc7add..d826ba555f 100644 --- a/core/src/mindustry/entities/comp/WeaponsComp.java +++ b/core/src/mindustry/entities/comp/WeaponsComp.java @@ -18,8 +18,6 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc, Velc, Statusc{ @Import Vec2 vel; @Import UnitType type; - /** minimum cursor distance from unit, fixes 'cross-eyed' shooting */ - static final float minAimDst = 18f; /** temporary weapon sequence number */ static int sequenceNum = 0; @@ -67,7 +65,7 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc, Velc, Statusc{ /** Aim at something. This will make all mounts point at it. */ void aim(float x, float y){ Tmp.v1.set(x, y).sub(this.x, this.y); - if(Tmp.v1.len() < minAimDst) Tmp.v1.setLength(minAimDst); + if(Tmp.v1.len() < type.aimDst) Tmp.v1.setLength(type.aimDst); x = Tmp.v1.x + this.x; y = Tmp.v1.y + this.y; diff --git a/core/src/mindustry/game/DefaultWaves.java b/core/src/mindustry/game/DefaultWaves.java index 5fa6c439a1..a889f9d4ba 100644 --- a/core/src/mindustry/game/DefaultWaves.java +++ b/core/src/mindustry/game/DefaultWaves.java @@ -1,6 +1,8 @@ package mindustry.game; +import arc.math.*; import arc.struct.*; +import arc.util.*; import mindustry.content.*; import mindustry.type.*; @@ -197,7 +199,8 @@ public class DefaultWaves{ return spawns == null ? new Seq<>() : spawns; } - private static void generate(){ + //TODO move elsewhere + public static Seq generate(){ UnitType[][] species = { {dagger, mace, fortress, scepter, reign}, {nova, pulsar, quasar, vela, corvus}, @@ -208,16 +211,63 @@ public class DefaultWaves{ }; //required progression: - //- main progression of units, up to wave ~20 - //- changes from //- extra periodic patterns - + Seq out = new Seq<>(); //max reasonable wave, after which everything gets boring - int cap = 300; - for(int i = 0; i < cap; i++){ + int cap = 400; + //main sequence + float shieldStart = 30, shieldsPerWave = 12; + UnitType[] curSpecies = Structs.random(species); + int curTier = 0; + + for(int i = 0; i < cap;){ + int f = i; + int next = Mathf.random(15, 25); + + float shieldAmount = Math.max((i - shieldStart) * shieldsPerWave, 0); + + //main progression + out.add(new SpawnGroup(curSpecies[Math.min(curTier, curSpecies.length - 1)]){{ + unitAmount = f == 0 ? 1 : 10; + begin = f; + end = f + next >= cap ? never : f + next; + max = 16; + unitScaling = Mathf.random(1f, 2f); + shields = shieldAmount; + shieldScaling = shieldsPerWave; + }}); + + //extra progression that tails out, blends in + out.add(new SpawnGroup(curSpecies[Math.min(curTier, curSpecies.length - 1)]){{ + unitAmount = 6; + begin = f + next; + end = f + next + Mathf.random(8, 12); + max = 10; + unitScaling = Mathf.random(2f); + spacing = Mathf.random(2, 3); + shields = shieldAmount; + shieldScaling = shieldsPerWave; + }}); + + i += next; + if(curTier < 3 || Mathf.chance(0.2)){ + curTier ++; + } + + //do not spawn bosses + curTier = Math.min(curTier, 3); + + //small chance to switch species + if(Mathf.chance(0.2)){ + curSpecies = Structs.random(species); + } } + + + + return out; } } diff --git a/core/src/mindustry/logic/ConditionOp.java b/core/src/mindustry/logic/ConditionOp.java index 2661509c7e..0954567c06 100644 --- a/core/src/mindustry/logic/ConditionOp.java +++ b/core/src/mindustry/logic/ConditionOp.java @@ -6,7 +6,8 @@ public enum ConditionOp{ lessThan("<", (a, b) -> a < b), lessThanEq("<=", (a, b) -> a <= b), greaterThan(">", (a, b) -> a > b), - greaterThanEq(">=", (a, b) -> a >= b); + greaterThanEq(">=", (a, b) -> a >= b), + always("always", (a, b) -> true); public static final ConditionOp[] all = values(); diff --git a/core/src/mindustry/logic/LStatements.java b/core/src/mindustry/logic/LStatements.java index 1a8abf221b..6d57f2c079 100644 --- a/core/src/mindustry/logic/LStatements.java +++ b/core/src/mindustry/logic/LStatements.java @@ -1,6 +1,7 @@ package mindustry.logic; import arc.func.*; +import arc.graphics.*; import arc.scene.style.*; import arc.scene.ui.*; import arc.scene.ui.layout.*; @@ -633,6 +634,8 @@ public class LStatements{ @RegisterStatement("jump") public static class JumpStatement extends LStatement{ + private static Color last = new Color(); + public transient StatementElem dest; public int destIndex; @@ -644,19 +647,30 @@ public class LStatements{ public void build(Table table){ table.add("if ").padLeft(4); - field(table, value, str -> value = str); - - table.button(b -> { - b.label(() -> op.symbol); - b.clicked(() -> showSelect(b, ConditionOp.all, op, o -> op = o)); - }, Styles.logict, () -> {}).size(48f, 40f).pad(4f).color(table.color); - - field(table, compare, str -> compare = str); + last = table.color; + table.table(this::rebuild); table.add().growX(); table.add(new JumpButton(() -> dest, s -> dest = s)).size(30).right().padLeft(-8); } + void rebuild(Table table){ + table.clearChildren(); + table.setColor(last); + + if(op != ConditionOp.always) field(table, value, str -> value = str); + + table.button(b -> { + b.label(() -> op.symbol); + b.clicked(() -> showSelect(b, ConditionOp.all, op, o -> { + op = o; + rebuild(table); + })); + }, Styles.logict, () -> {}).size(op == ConditionOp.always ? 80f : 48f, 40f).pad(4f).color(table.color); + + if(op != ConditionOp.always) field(table, compare, str -> compare = str); + } + //elements need separate conversion logic @Override public void setupUI(){ diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index da7fb49b7c..7b17ca53e4 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -51,6 +51,7 @@ public class UnitType extends UnlockableContent{ public boolean destructibleWreck = true; public float groundLayer = Layer.groundUnit; public float payloadCapacity = 8; + public float aimDst = -1f; public int commandLimit = 24; public float visualElevation = -1f; public boolean allowLegStep = false; @@ -218,6 +219,10 @@ public class UnitType extends UnlockableContent{ mechStride = 4f + (hitSize -8f)/2.1f; } + if(aimDst < 0){ + aimDst = weapons.contains(w -> !w.rotate) ? hitSize * 2f : hitSize / 2f; + } + if(mechStepShake < 0){ mechStepShake = Mathf.round((hitSize - 11f) / 9f); mechStepParticles = hitSize > 15f;