From 6807b589a333a4204e542f811dfdf2cc82d0a8d4 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 11 Oct 2020 19:10:33 -0400 Subject: [PATCH] Logic unit control tweaks --- core/src/mindustry/logic/LAssembler.java | 3 +++ core/src/mindustry/logic/LExecutor.java | 14 ++++++++++++-- core/src/mindustry/logic/LLocate.java | 3 ++- core/src/mindustry/logic/LStatements.java | 2 +- core/src/mindustry/logic/LUnitControl.java | 2 +- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/core/src/mindustry/logic/LAssembler.java b/core/src/mindustry/logic/LAssembler.java index e355416427..4f72d121aa 100644 --- a/core/src/mindustry/logic/LAssembler.java +++ b/core/src/mindustry/logic/LAssembler.java @@ -52,6 +52,9 @@ public class LAssembler{ } } + //used as a special value for any environmental solid block + putConst("@solid", Blocks.stoneWall); + putConst("@air", Blocks.air); for(UnitType type : Vars.content.units()){ diff --git a/core/src/mindustry/logic/LExecutor.java b/core/src/mindustry/logic/LExecutor.java index 93c5263a9b..3bcfaf46ee 100644 --- a/core/src/mindustry/logic/LExecutor.java +++ b/core/src/mindustry/logic/LExecutor.java @@ -6,6 +6,7 @@ import arc.util.*; import arc.util.noise.*; import mindustry.*; import mindustry.ai.types.*; +import mindustry.content.*; import mindustry.ctype.*; import mindustry.entities.*; import mindustry.game.*; @@ -251,6 +252,11 @@ public class LExecutor{ case spawn -> { res = Geometry.findClosest(unit.x, unit.y, Vars.spawner.getSpawns()); } + case damaged -> { + Building b = Units.findDamagedTile(unit.team, unit.x, unit.y); + res = b == null ? null : b.tile; + build = true; + } } if(res != null && (!build || res.build != null)){ @@ -435,12 +441,16 @@ public class LExecutor{ } case getBlock -> { float x = exec.numf(p1), y = exec.numf(p2); - if(unit.within(x, y, unit.range())){ + float range = Math.max(unit.range(), buildingRange); + if(!unit.within(x, y, range)){ exec.setobj(p3, null); + exec.setnum(p4, 0); }else{ Tile tile = world.tileWorld(x, y); - Block block = tile == null || !tile.synthetic() ? null : tile.block(); + //any environmental solid block is returned as StoneWall, aka "@solid" + Block block = tile == null ? null : !tile.synthetic() ? (tile.solid() ? Blocks.stoneWall : Blocks.air) : tile.block(); exec.setobj(p3, block); + exec.setnum(p4, tile != null && tile.build != null ? tile.build.rotation : 0); } } case itemDrop -> { diff --git a/core/src/mindustry/logic/LLocate.java b/core/src/mindustry/logic/LLocate.java index 679136e74f..84da2321f9 100644 --- a/core/src/mindustry/logic/LLocate.java +++ b/core/src/mindustry/logic/LLocate.java @@ -3,7 +3,8 @@ package mindustry.logic; public enum LLocate{ ore, building, - spawn; + spawn, + damaged; public static final LLocate[] all = values(); } diff --git a/core/src/mindustry/logic/LStatements.java b/core/src/mindustry/logic/LStatements.java index a96adaf9d9..ba4d31e9a1 100644 --- a/core/src/mindustry/logic/LStatements.java +++ b/core/src/mindustry/logic/LStatements.java @@ -889,7 +889,7 @@ public class LStatements{ table.row(); } - case spawn -> { + case spawn, damaged -> { table.row(); } } diff --git a/core/src/mindustry/logic/LUnitControl.java b/core/src/mindustry/logic/LUnitControl.java index 879578e59b..2166b00690 100644 --- a/core/src/mindustry/logic/LUnitControl.java +++ b/core/src/mindustry/logic/LUnitControl.java @@ -15,7 +15,7 @@ public enum LUnitControl{ mine("x", "y"), flag("value"), build("x", "y", "block", "rotation"), - getBlock("x", "y", "result"), + getBlock("x", "y", "result", "resRot"), within("x", "y", "radius", "result"); public final String[] params;