From f0257790b8bf6900ff35ed4787194eda06089686 Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 7 May 2025 15:47:57 -0400 Subject: [PATCH] Core fill items rule --- core/assets/bundles/bundle.properties | 1 + core/src/mindustry/ai/ControlPathfinder.java | 2 +- core/src/mindustry/core/Logic.java | 16 ++++++++++------ core/src/mindustry/game/Rules.java | 2 ++ .../mindustry/ui/dialogs/CustomRulesDialog.java | 1 + 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index c3c84b0d2b..0cdad46949 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -1405,6 +1405,7 @@ mode.custom = Custom Rules rules.invaliddata = Invalid clipboard data. rules.hidebannedblocks = Hide Banned Blocks rules.infiniteresources = Infinite Resources +rules.fillitems = Fill Core With Items rules.onlydepositcore = Only Allow Core Depositing rules.derelictrepair = Allow Derelict Block Repair rules.reactorexplosions = Reactor Explosions diff --git a/core/src/mindustry/ai/ControlPathfinder.java b/core/src/mindustry/ai/ControlPathfinder.java index 6e75e73b7a..7d55148cb1 100644 --- a/core/src/mindustry/ai/ControlPathfinder.java +++ b/core/src/mindustry/ai/ControlPathfinder.java @@ -1429,7 +1429,7 @@ public class ControlPathfinder implements Runnable{ private static boolean nearPassable(int initialCost, int team, PathCost cost, int pos){ int amount = cost.getCost(team, pathfinder.tiles[pos]); - return amount != impassable && amount < Math.max(50, initialCost + 1); + return amount != impassable && amount < Math.min(Math.max(50, initialCost + 1), solidCap); } private static boolean solid(int team, PathCost type, int x, int y){ diff --git a/core/src/mindustry/core/Logic.java b/core/src/mindustry/core/Logic.java index bc2e533946..7246fcc43d 100644 --- a/core/src/mindustry/core/Logic.java +++ b/core/src/mindustry/core/Logic.java @@ -3,6 +3,7 @@ package mindustry.core; import arc.*; import arc.math.*; import arc.util.*; +import mindustry.*; import mindustry.ai.*; import mindustry.annotations.Annotations.*; import mindustry.core.GameState.*; @@ -133,6 +134,7 @@ public class Logic implements ApplicationListener{ state.rules.coreIncinerates = true; state.rules.allowEditWorldProcessors = false; state.rules.waveTeam.rules().infiniteResources = true; + state.rules.waveTeam.rules().fillItems = true; state.rules.waveTeam.rules().buildSpeedMultiplier *= state.getPlanet().enemyBuildSpeedMultiplier; } @@ -438,12 +440,6 @@ public class Logic implements ApplicationListener{ } if(state.isCampaign()){ - //always fill enemy core with items - if(state.rules.waveTeam.cores().size > 0){ - var core = state.rules.waveTeam.core(); - content.items().each(i -> core.items.set(i, core.getMaximumAccepted(i))); - } - state.rules.sector.info.update(); } @@ -459,6 +455,14 @@ public class Logic implements ApplicationListener{ updateWeather(); for(TeamData data : state.teams.getActive()){ + if(data.team.rules().fillItems && data.cores.size > 0){ + var core = data.cores.first(); + content.items().each(i -> { + if(i.isOnPlanet(Vars.state.getPlanet())){ + core.items.set(i, core.getMaximumAccepted(i)); + } + }); + } //does not work on PvP so built-in attack maps can have it on by default without issues if(data.team.rules().buildAi && !state.rules.pvp){ if(data.buildAi == null) data.buildAi = new BaseBuilderAI(data); diff --git a/core/src/mindustry/game/Rules.java b/core/src/mindustry/game/Rules.java index 890b69a7e2..14b2880cb2 100644 --- a/core/src/mindustry/game/Rules.java +++ b/core/src/mindustry/game/Rules.java @@ -299,6 +299,8 @@ public class Rules{ public boolean aiCoreSpawn = true; /** If true, blocks don't require power or resources. */ public boolean cheat; + /** If true, the core is always filled to capacity with all items. */ + public boolean fillItems; /** If true, resources are not consumed when building. */ public boolean infiniteResources; /** If true, this team has infinite unit ammo. */ diff --git a/core/src/mindustry/ui/dialogs/CustomRulesDialog.java b/core/src/mindustry/ui/dialogs/CustomRulesDialog.java index 64563389ae..0232e08526 100644 --- a/core/src/mindustry/ui/dialogs/CustomRulesDialog.java +++ b/core/src/mindustry/ui/dialogs/CustomRulesDialog.java @@ -313,6 +313,7 @@ public class CustomRulesDialog extends BaseDialog{ number("@rules.extracorebuildradius", f -> teams.extraCoreBuildRadius = f * tilesize, () -> Math.min(teams.extraCoreBuildRadius / tilesize, 200), () -> !rules.polygonCoreProtection); check("@rules.infiniteresources", b -> teams.infiniteResources = b, () -> teams.infiniteResources); + check("@rules.fillitems", b -> teams.fillItems = b, () -> teams.fillItems); number("@rules.buildspeedmultiplier", f -> teams.buildSpeedMultiplier = f, () -> teams.buildSpeedMultiplier, 0.001f, 50f); number("@rules.unitdamagemultiplier", f -> teams.unitDamageMultiplier = f, () -> teams.unitDamageMultiplier);