From 8e2340b1235299008ce1aaf8d62a59366745f4ae Mon Sep 17 00:00:00 2001 From: EggleEgg <125359838+EggleEgg@users.noreply.github.com> Date: Mon, 19 Jan 2026 18:22:02 +0100 Subject: [PATCH] should work well now --- core/src/mindustry/content/Blocks.java | 16 ++++++++++++++++ core/src/mindustry/world/Block.java | 6 ++++++ .../mindustry/world/blocks/ConstructBlock.java | 13 +++++++++++++ 3 files changed, 35 insertions(+) diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index 93338bddf1..71c6323a4c 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -2646,6 +2646,7 @@ public class Blocks{ ambientSound = Sounds.loopPulse; ambientSoundVolume = 0.08f; liquidCapacity = 80f; + constructHealthMultiplier = 0.5f; consumePower(25f); consumeItem(Items.blastCompound); @@ -2807,6 +2808,7 @@ public class Blocks{ requirements(Category.power, with(Items.tungsten, 750, Items.carbide, 300, Items.oxide, 150, Items.silicon, 500, Items.phaseFabric, 150, Items.surgeAlloy, 200)); size = 5; + constructHealthMultiplier = 0.5f; liquidCapacity = 80f; outputLiquid = new LiquidStack(Liquids.neoplasm, 20f / 60f); explodeOnFull = true; @@ -3138,6 +3140,7 @@ public class Blocks{ isFirstTier = true; unitType = UnitTypes.alpha; health = 1100; + constructHealthMultiplier = 0.65f; itemCapacity = 4000; size = 3; buildCostMultiplier = 2f; @@ -3150,6 +3153,7 @@ public class Blocks{ unitType = UnitTypes.beta; health = 3500; + constructHealthMultiplier = 0.65f; itemCapacity = 9000; size = 4; thrusterLength = 34/4f; @@ -3163,6 +3167,7 @@ public class Blocks{ unitType = UnitTypes.gamma; health = 6000; + constructHealthMultiplier = 0.65f; itemCapacity = 13000; size = 5; thrusterLength = 40/4f; @@ -3178,6 +3183,7 @@ public class Blocks{ isFirstTier = true; unitType = UnitTypes.evoke; health = 4500; + constructHealthMultiplier = 0.65f; itemCapacity = 2000; size = 4; thrusterLength = 34/4f; @@ -3198,6 +3204,7 @@ public class Blocks{ unitType = UnitTypes.incite; health = 16000; + constructHealthMultiplier = 0.65f; itemCapacity = 3000; size = 5; thrusterLength = 40/4f; @@ -3216,6 +3223,7 @@ public class Blocks{ unitType = UnitTypes.emanate; health = 30000; + constructHealthMultiplier = 0.65f; itemCapacity = 4000; size = 6; thrusterLength = 48/4f; @@ -4242,6 +4250,7 @@ public class Blocks{ coolantMultiplier = 0.4f; liquidCapacity = 60f; scaledHealth = 150; + constructHealthMultiplier = 0.5f; coolant = consumeCoolant(1f); depositCooldown = 2.0f; @@ -4309,6 +4318,7 @@ public class Blocks{ shootSound = Sounds.shootSpectre; scaledHealth = 160; + constructHealthMultiplier = 0.5f; coolant = consumeCoolant(1f); depositCooldown = 2.0f; @@ -4346,6 +4356,7 @@ public class Blocks{ }}; scaledHealth = 200; + constructHealthMultiplier = 0.5f; liquidCapacity = 60f; coolant = consumeCoolant(0.5f); consumePower(17f); @@ -5590,6 +5601,7 @@ public class Blocks{ range = 1350; shootCone = 1f; scaledHealth = 220; + constructHealthMultiplier = 0.5f; rotateSpeed = 0.9f; coolant = consume(new ConsumeLiquid(Liquids.water, 15f / 60f)); @@ -5857,6 +5869,7 @@ public class Blocks{ trackingRange = range * 1.4f; shootCone = 30f; scaledHealth = 350; + constructHealthMultiplier = 0.5f; rotateSpeed = 1.5f; coolant = consume(new ConsumeLiquid(Liquids.water, 15f / 60f)); @@ -6200,6 +6213,7 @@ public class Blocks{ trackingRange = range * 1.4f; shootCone = 100f; scaledHealth = 370; + constructHealthMultiplier = 0.5f; rotateSpeed = 2.6f; recoil = 0.5f; recoilTime = 30f; @@ -6287,6 +6301,7 @@ public class Blocks{ requirements(Category.units, with(Items.lead, 2000, Items.silicon, 1000, Items.titanium, 2000, Items.thorium, 750, Items.plastanium, 450, Items.phaseFabric, 600)); size = 7; + constructHealthMultiplier = 0.5f; consumePower(13f); consumeItems(with(Items.silicon, 850, Items.titanium, 750, Items.plastanium, 650)); consumeLiquid(Liquids.cryofluid, 1f); @@ -6309,6 +6324,7 @@ public class Blocks{ requirements(Category.units, with(Items.lead, 4000, Items.silicon, 3000, Items.thorium, 1000, Items.plastanium, 600, Items.phaseFabric, 600, Items.surgeAlloy, 800)); size = 9; + constructHealthMultiplier = 0.5f; consumePower(25f); consumeItems(with(Items.silicon, 1000, Items.plastanium, 600, Items.surgeAlloy, 500, Items.phaseFabric, 350)); consumeLiquid(Liquids.cryofluid, 3f); diff --git a/core/src/mindustry/world/Block.java b/core/src/mindustry/world/Block.java index fea0bfca8e..9d0d69c151 100644 --- a/core/src/mindustry/world/Block.java +++ b/core/src/mindustry/world/Block.java @@ -187,6 +187,8 @@ public class Block extends UnlockableContent implements Senseable{ public float scaledHealth = -1; /** building health; -1 to use scaledHealth */ public int health = -1; + /** Buildplan health multiplier as a fraction of its health. If this value is <0, it defaults to 10 hp */ + public float constructHealthMultiplier = -1f; /** damage absorption, similar to unit armor */ public float armor = 0f; /** base block explosiveness */ @@ -586,6 +588,10 @@ public class Block extends UnlockableContent implements Senseable{ return true; } + public float constructHealthMultiplier(){ + return constructHealthMultiplier > 0f ? health * constructHealthMultiplier : 10f; + } + public boolean rotatedOutput(int x, int y){ return rotate; } diff --git a/core/src/mindustry/world/blocks/ConstructBlock.java b/core/src/mindustry/world/blocks/ConstructBlock.java index 68a5475d19..e18406e71c 100644 --- a/core/src/mindustry/world/blocks/ConstructBlock.java +++ b/core/src/mindustry/world/blocks/ConstructBlock.java @@ -170,6 +170,8 @@ public class ConstructBlock extends Block{ public float progress = 0; public float buildCost; + public float previousHealth; + public float damaged; public @Nullable Object lastConfig; public @Nullable Unit lastBuilder; public boolean wasConstructing, activeDeconstruct; @@ -293,9 +295,11 @@ public class ConstructBlock extends Block{ maxProgress = core == null || team.rules().infiniteResources ? maxProgress : checkRequired(core.items, maxProgress, true); progress = Mathf.clamp(progress + maxProgress); + scaleHealth(progress); if(progress >= 1f || state.rules.infiniteResources){ boolean canFinish = true; + scaleHealth(1f); //look at leftover resources to consume, get them from the core if necessary, delay building if not if(!infinite){ @@ -367,6 +371,7 @@ public class ConstructBlock extends Block{ } progress = Mathf.clamp(progress - amount); + scaleHealth(progress); if(progress <= current.deconstructThreshold || state.rules.infiniteResources){ //add any leftover items that weren't obtained due to rounding errors @@ -430,6 +435,14 @@ public class ConstructBlock extends Block{ return progress; } + public void scaleHealth(float progress){ + float maxHealth = tile.build.maxHealth = current.constructHealthMultiplier() > 0f ? current.constructHealthMultiplier() : tile.block() instanceof ConstructBlock b ? b.health : 10f; + + if(previousHealth > tile.build.health + 0.001f) damaged += previousHealth - tile.build.health; + previousHealth = tile.build.health = progress * maxHealth - damaged; + tile.build.health = Mathf.clamp(tile.build.health, 0f, maxHealth); + } + public void setConstruct(Block previous, Block block){ if(block == null) return;