1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-08 00:39:30 +02:00

biters don't attack low research towns based on evo

This commit is contained in:
galestar306 2019-12-27 18:59:50 -05:00
parent 0bab1a1671
commit 9cf749a4b3

View File

@ -48,16 +48,22 @@ end
local function roll_market()
local r_max = 0
local town_centers = global.towny.town_centers
local research_threshold = game.forces.enemy.evolution_factor ^ 0.5 * 50
for k, town_center in pairs(town_centers) do
r_max = r_max + town_center.research_counter
if town_center.research_counter >= research_threshold then
r_max = r_max + town_center.research_counter
end
end
if r_max == 0 then return end
local r = math_random(0, r_max)
local chance = 0
for k, town_center in pairs(town_centers) do
chance = chance + town_center.research_counter
if r <= chance then return town_center end
if town_center.research_counter >= research_threshold then
chance = chance + town_center.research_counter
if r <= chance then return town_center end
end
end
end