Making units attack Artillery

Place to get help with not working mods / modding interface.
Post Reply
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1449
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Making units attack Artillery

Post 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.

Post Reply

Return to “Modding help”