From c4fea8f59873378a759611ae72e067b4248b5cdc Mon Sep 17 00:00:00 2001 From: Aaron Veden Date: Fri, 26 Nov 2021 12:25:07 -0800 Subject: [PATCH] added minimum cost building check to upgrades --- changelog.txt | 1 + libs/BaseUtils.lua | 3 ++- libs/Constants.lua | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index 89dcc13..f9077f0 100644 --- a/changelog.txt +++ b/changelog.txt @@ -10,6 +10,7 @@ Date: 23. 11. 2021 - Number of groups that can be active in aggressive AI state now scales with the number of active nests. Rougly for every 30 pollution covered nests you will get an additional attack group. - Optimized regional base upgrades so that the work is spread over many ticks reducing lag spikes - Optimized adding new chunks to the Rampant in-memory state map + - Added minimum building cost upgrade check before base upgrade performs scanning Tweaks: - Increase chance to upgrade an enemy structure from 5% to 30% - New enemy regional bases that have two factions now do 75% on one faction and 25% on the faction for building and upgrading enemy structures diff --git a/libs/BaseUtils.lua b/libs/BaseUtils.lua index 82f4935..1159e98 100644 --- a/libs/BaseUtils.lua +++ b/libs/BaseUtils.lua @@ -12,6 +12,7 @@ local mapUtils = require("MapUtils") -- constants +local MINIMUM_BUILDING_COST = constants.MINIMUM_BUILDING_COST local FACTION_MUTATION_MAPPING = constants.FACTION_MUTATION_MAPPING local MAGIC_MAXIMUM_NUMBER = constants.MAGIC_MAXIMUM_NUMBER @@ -402,7 +403,7 @@ function baseUtils.processBase(chunk, map, tick, base) point.y = chunk.y + (CHUNK_SIZE * mRandom()) local upgradeRoll = mRandom() - if (base.state == BASE_AI_STATE_ACTIVE) and (upgradeRoll < 0.30) then + if (base.state == BASE_AI_STATE_ACTIVE) and (base.points >= MINIMUM_BUILDING_COST) and (upgradeRoll < 0.30) then local entities = surface.find_entities_filtered(universe.filteredEntitiesPointQueryLimited) if #entities ~= 0 then local entity = entities[1] diff --git a/libs/Constants.lua b/libs/Constants.lua index e441a6f..b0f4f92 100644 --- a/libs/Constants.lua +++ b/libs/Constants.lua @@ -1598,6 +1598,13 @@ constants.HIVE_BUILDINGS_COST["spitter-spawner"] = constants.BASE_SPAWNER_UPGRAD constants.HIVE_BUILDINGS_COST["biter-spawner"] = constants.BASE_SPAWNER_UPGRADE constants.HIVE_BUILDINGS_COST["hive"] = constants.BASE_SPAWNER_UPGRADE * 2 +constants.MINIMUM_BUILDING_COST = constants.MAGIC_MAXIMUM_NUMBER +for _,cost in pairs(constants.HIVE_BUILDINGS_COST) do + if cost < constants.MINIMUM_BUILDING_COST then + constants.MINIMUM_BUILDING_COST = cost + end +end + constants.FACTION_MUTATION_MAPPING = {} constants.FACTION_MUTATION_MAPPING["spitter-spawner"] = {"biter-spawner", "hive"} constants.FACTION_MUTATION_MAPPING["biter-spawner"] = {"spitter-spawner", "hive"}