Page 1 of 1

Making units attack Artillery

Posted: Fri Jul 13, 2018 2:12 pm
by TheSAguy
Hi,

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

But then I saw "create_unit_group" and was wondering if what I did above was the best approach. Should I first maybe create a grouping of units.
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.