mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-08 00:39:30 +02:00
fix: waves would sometimes try to use boat spawners
This commit is contained in:
parent
ccbfff87a3
commit
bfa40aa3e0
@ -298,7 +298,7 @@ function Public.create_mail_delivery_biters() --these travel cross-map between b
|
||||
local surface = game.surfaces[Common.current_destination().surface_name]
|
||||
local enemy_force_name = memory.enemy_force_name
|
||||
|
||||
local spawners = surface.find_entities_filtered{name = 'biter-spawner', force = enemy_force_name}
|
||||
local spawners = Public.get_valid_spawners(surface)
|
||||
|
||||
local try_how_many_groups = Math.clamp(0, 4, (#spawners - 8) / 100)
|
||||
|
||||
@ -351,7 +351,7 @@ function Public.spawn_group_of_scripted_biters(fraction_of_floating_pollution, m
|
||||
local surface = game.surfaces[Common.current_destination().surface_name]
|
||||
local enemy_force_name = memory.enemy_force_name
|
||||
|
||||
local spawner = Public.get_random_spawner(surface)
|
||||
local spawner = Public.get_random_valid_spawner(surface)
|
||||
if not spawner then log('no spawner found') return end
|
||||
|
||||
local nearby_units_to_bring
|
||||
@ -574,11 +574,47 @@ end
|
||||
-- return false
|
||||
-- end
|
||||
|
||||
function Public.get_random_spawner(surface)
|
||||
function Public.get_valid_spawners(surface)
|
||||
local memory = Memory.get_crew_memory()
|
||||
|
||||
local spawners = surface.find_entities_filtered({type = 'unit-spawner', force = memory.enemy_force_name})
|
||||
if (not spawners) or (not spawners[1]) then return end
|
||||
|
||||
local boat_spawners = {}
|
||||
|
||||
if memory.enemyboats and #memory.enemyboats > 0 then
|
||||
for i = 1, #memory.enemyboats do
|
||||
local eb = memory.enemyboats[i]
|
||||
if eb.spawner and eb.spawner.valid then
|
||||
boat_spawners[#boat_spawners + 1] = eb.spawner
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local valid_spawners = {}
|
||||
for i = 1, #spawners do
|
||||
local s = spawners[i]
|
||||
local valid = true
|
||||
for j = 1, #boat_spawners do
|
||||
local bs = boat_spawners[j]
|
||||
if s == bs then
|
||||
valid = false
|
||||
break
|
||||
end
|
||||
end
|
||||
if valid then
|
||||
valid_spawners[#valid_spawners + 1] = s
|
||||
end
|
||||
end
|
||||
|
||||
return valid_spawners
|
||||
end
|
||||
|
||||
function Public.get_random_valid_spawner(surface)
|
||||
|
||||
local spawners = Public.get_valid_spawners(surface)
|
||||
|
||||
if #spawners == 0 then return end
|
||||
|
||||
return spawners[Math.random(#spawners)]
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user