So I want to have units attack artillery. I was using the below code. (not tested):
Code: Select all
if event.force ~= nil and event.cause then
if event.cause.type == "artillery-turret" or event.cause.type == "artillery-wagon" then
local enemies = surface.find_enemy_units(pos, 10)
surface.set_multi_command{command = {type=defines.command.attack, target=event.cause, distraction=defines.distraction.by_enemy},unit_count = 10, unit_search_distance = 10}
end
end
Anything else I should do to ensure the best attack on the target?
Should I look for units in a radius around the damage or the source?
Just looking for some feedback on best way to do this.
Thanks.