What happens:
Biters are spawned but only one group is receiving the actions and are moving.
Sometimes the biters don't move at all and are just running in circles.
What I expect to happen:
All spawned biters should start moving at the designated location.
GIF showing what occurs:
https://media.giphy.com/media/hSKuKuOj8 ... /giphy.gif
The scenario in mention is located at:
fish_defender.maps.fish_defender.fish_defender.lua
The code in mention:
Code: Select all
local spawn_x = 242
local target_x = -32
local group_coords = {}
for a = -80, 80, 16 do
insert(group_coords, {spawn = {x = spawn_x, y = a * 2}, target = {x = target_x, y = a}})
end
group_coords = shuffle(group_coords)
local unit_groups = {}
if global.wave_count > 100 and math_random(1, 8) == 1 then
for i = 1, #group_coords, 1 do
unit_groups[i] = surface.create_unit_group({position = group_coords[i].spawn})
end
else
for i = 1, get_number_of_attack_groups(), 1 do
unit_groups[i] = surface.create_unit_group({position = group_coords[i].spawn})
end
end
local biter_pool = get_biter_pool()
while global.attack_wave_threat > 0 do
for i = 1, #unit_groups, 1 do
local biter = spawn_biter(unit_groups[i].position, biter_pool)
if biter then
unit_groups[i].add_member(biter)
else
break
end
end
end
for i = 1, #unit_groups, 1 do
unit_groups[i].set_command({
type = defines.command.compound,
structure_type = defines.compound_command.logical_and,
commands = {
{
type=defines.command.attack_area,
destination={group_coords[i].target.x + 192, group_coords[i].target.y},
radius=32,
distraction=defines.distraction.by_anything
},
{
type=defines.command.attack_area,
destination={group_coords[i].target.x + 128, group_coords[i].target.y},
radius=32,
distraction=defines.distraction.by_anything
},
{
type=defines.command.attack_area,
destination={group_coords[i].target.x + 64, group_coords[i].target.y},
radius=32,
distraction=defines.distraction.by_anything
},
{
type=defines.command.attack_area,
destination={group_coords[i].target.x, group_coords[i].target.y},
radius=32,
distraction=defines.distraction.by_enemy
},
{
type=defines.command.attack,
target=global.market,
distraction=defines.distraction.by_enemy
}
}
})
unit_groups[i].start_moving()
end