1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-02-09 13:37:02 +02:00

Merge pull request #103 from galestar306/biterevothreshold

biters don't attack low research towns based on evo
This commit is contained in:
MewMew 2019-12-28 14:03:17 +01:00 committed by GitHub
commit ff8583f8c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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