From ac88d8432231dc7094253a2fa141286d6c859cd6 Mon Sep 17 00:00:00 2001 From: Anuken Date: Tue, 8 Sep 2020 16:25:01 -0400 Subject: [PATCH] Various base generation tweaks --- core/src/mindustry/ai/BaseRegistry.java | 2 +- .../maps/generators/BaseGenerator.java | 22 +++++++++++++------ .../maps/planet/SerpuloPlanetGenerator.java | 10 +++++---- core/src/mindustry/type/Planet.java | 2 +- core/src/mindustry/type/Sector.java | 1 + .../mindustry/ui/dialogs/PlanetDialog.java | 3 ++- .../mindustry/ui/fragments/HudFragment.java | 2 +- gradle.properties | 2 +- 8 files changed, 28 insertions(+), 16 deletions(-) diff --git a/core/src/mindustry/ai/BaseRegistry.java b/core/src/mindustry/ai/BaseRegistry.java index 98e4744da0..bc470b9096 100644 --- a/core/src/mindustry/ai/BaseRegistry.java +++ b/core/src/mindustry/ai/BaseRegistry.java @@ -92,7 +92,7 @@ public class BaseRegistry{ } } - cores.sort(Structs.comps(Structs.comparingFloat(b -> b.core.health), Structs.comparingFloat(b -> b.tier))); + cores.sort(b -> b.tier); parts.sort(); reqParts.each((key, arr) -> arr.sort()); } diff --git a/core/src/mindustry/maps/generators/BaseGenerator.java b/core/src/mindustry/maps/generators/BaseGenerator.java index f1a508d4c2..4c416cc1b8 100644 --- a/core/src/mindustry/maps/generators/BaseGenerator.java +++ b/core/src/mindustry/maps/generators/BaseGenerator.java @@ -15,6 +15,7 @@ import mindustry.world.blocks.defense.*; import mindustry.world.blocks.environment.*; import mindustry.world.blocks.power.*; import mindustry.world.blocks.production.*; +import mindustry.world.meta.*; import static mindustry.Vars.*; @@ -29,7 +30,7 @@ public class BaseGenerator{ private ObjectMap oreFloors = new ObjectMap<>(); private Seq cores; - public void generate(Tiles tiles, Seq cores, Tile spawn, Team team, Sector sector){ + public void generate(Tiles tiles, Seq cores, Tile spawn, Team team, Sector sector, float difficulty){ this.tiles = tiles; this.team = team; this.cores = cores; @@ -50,10 +51,16 @@ public class BaseGenerator{ //TODO limit base size float costBudget = 1000; - Seq wallsSmall = content.blocks().select(b -> b instanceof Wall && b.size == 1); - Seq wallsLarge = content.blocks().select(b -> b instanceof Wall && b.size == 2); + Seq wallsSmall = content.blocks().select(b -> b instanceof Wall && b.size == 1 && b.buildVisibility == BuildVisibility.shown && !(b instanceof Door)); + Seq wallsLarge = content.blocks().select(b -> b instanceof Wall && b.size == 2 && b.buildVisibility == BuildVisibility.shown && !(b instanceof Door)); - float bracket = 0.1f; + //sort by cost for correct fraction + wallsSmall.sort(b -> b.buildCost); + wallsLarge.sort(b -> b.buildCost); + + //TODO proper difficulty selection + float bracket = difficulty; + float bracketRange = 0.2f; int wallAngle = 70; //180 for full coverage double resourceChance = 0.5; double nonResourceChance = 0.0005; @@ -80,14 +87,15 @@ public class BaseGenerator{ || (tile.floor().liquidDrop != null && Mathf.chance(nonResourceChance * 2))) && Mathf.chance(resourceChance)){ Seq parts = bases.forResource(tile.drop() != null ? tile.drop() : tile.floor().liquidDrop); if(!parts.isEmpty()){ - tryPlace(parts.random(), tile.x, tile.y); + tryPlace(parts.getFrac(bracket + Mathf.range(bracketRange)), tile.x, tile.y); } }else if(Mathf.chance(nonResourceChance)){ - tryPlace(bases.parts.random(), tile.x, tile.y); + tryPlace(bases.parts.getFrac(bracket + Mathf.range(bracketRange)), tile.x, tile.y); } }); - //replace walls with the correct type + //replace walls with the correct type (disabled) + if(false) pass(tile -> { if(tile.block() instanceof Wall && tile.team() == team && tile.block() != wall && tile.block() != wallLarge){ tile.setBlock(tile.block().size == 2 ? wallLarge : wall, team); diff --git a/core/src/mindustry/maps/planet/SerpuloPlanetGenerator.java b/core/src/mindustry/maps/planet/SerpuloPlanetGenerator.java index f136d81e8f..851b7e25cb 100644 --- a/core/src/mindustry/maps/planet/SerpuloPlanetGenerator.java +++ b/core/src/mindustry/maps/planet/SerpuloPlanetGenerator.java @@ -284,11 +284,11 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{ float difficulty = sector.baseCoverage; if(sector.hasEnemyBase()){ - basegen.generate(tiles, enemies.map(r -> tiles.getn(r.x, r.y)), tiles.get(spawn.x, spawn.y), state.rules.waveTeam, sector); + basegen.generate(tiles, enemies.map(r -> tiles.getn(r.x, r.y)), tiles.get(spawn.x, spawn.y), state.rules.waveTeam, sector, difficulty); state.rules.attackMode = true; }else{ - state.rules.winWave = 15 * (int)Math.max(difficulty, 1); + state.rules.winWave = 15 * (int)Math.max(difficulty * 5, 1); } state.rules.waves = true; @@ -296,11 +296,13 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{ //TODO better waves state.rules.spawns = defaultWaves.get(); + float waveScaling = 1f + difficulty*2; + //scale up the spawning base on difficulty (this is just for testing) for(SpawnGroup group : state.rules.spawns){ - group.unitAmount *= difficulty; + group.unitAmount *= waveScaling; if(group.unitScaling != SpawnGroup.never){ - group.unitScaling /= difficulty; + group.unitScaling /= waveScaling; } } } diff --git a/core/src/mindustry/type/Planet.java b/core/src/mindustry/type/Planet.java index e217b3431e..570671de4f 100644 --- a/core/src/mindustry/type/Planet.java +++ b/core/src/mindustry/type/Planet.java @@ -205,7 +205,7 @@ public class Planet extends UnlockableContent{ sum += 2f; } - sector.baseCoverage = sum; + sector.baseCoverage = Mathf.clamp(sum / 5f); } } diff --git a/core/src/mindustry/type/Sector.java b/core/src/mindustry/type/Sector.java index 7b6dbbcc15..856dd2219d 100644 --- a/core/src/mindustry/type/Sector.java +++ b/core/src/mindustry/type/Sector.java @@ -32,6 +32,7 @@ public class Sector{ public @Nullable SaveSlot save; public @Nullable SectorPreset preset; + /** Number 0-1 indicating the difficulty based on nearby bases. */ public float baseCoverage; //TODO implement a dynamic launch period diff --git a/core/src/mindustry/ui/dialogs/PlanetDialog.java b/core/src/mindustry/ui/dialogs/PlanetDialog.java index 197bc29200..4cd4f61877 100644 --- a/core/src/mindustry/ui/dialogs/PlanetDialog.java +++ b/core/src/mindustry/ui/dialogs/PlanetDialog.java @@ -127,10 +127,11 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{ //draw all sector stuff for(Sector sec : planet.sectors){ + if(selectAlpha > 0.01f){ if(canLaunch(sec) || sec.unlocked()){ if(sec.baseCoverage > 0){ - planets.fill(sec, Tmp.c1.set(Team.crux.color).a(0.1f * sec.baseCoverage * selectAlpha), -0.002f); + planets.fill(sec, Tmp.c1.set(Team.crux.color).a(0.5f * sec.baseCoverage * selectAlpha), -0.002f); } Color color = diff --git a/core/src/mindustry/ui/fragments/HudFragment.java b/core/src/mindustry/ui/fragments/HudFragment.java index 5102b2ebf4..a2adb4a41d 100644 --- a/core/src/mindustry/ui/fragments/HudFragment.java +++ b/core/src/mindustry/ui/fragments/HudFragment.java @@ -219,7 +219,7 @@ public class HudFragment extends Fragment{ //core items parent.fill(t -> { t.top().add(coreItems); - t.visible(() -> Core.settings.getBool("coreitems") && !mobile && !state.isPaused()); + t.visible(() -> Core.settings.getBool("coreitems") && !mobile && !state.isPaused() && shown); }); //spawner warning diff --git a/gradle.properties b/gradle.properties index c160066854..49caf1cddb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xms256m -Xmx1024m -archash=5c7c5e8d8728880e20f9c39a888ee03612dc1071 +archash=fc3cc66e77ebf7d10ac13e615403d29783028b8e