Page 1 of 1

Biters ignore unmanned vehicle entity

Posted: Tue Aug 11, 2020 9:56 pm
by IngoKnieto
Hi everybody,

I'm working on a mod with flying attack drones, which are basically unmanned cars driven around by script.
My problem is: biters and worms ignore those entities. The drone entity and also for example the rockets used for the attack are both created with force = player.force, but that doesn't seem to be enough. How do I make the bugs attack my drones?

This is how they are created:

Code: Select all

	-- create plane
	local created_plane
	created_plane = player.surface.create_entity({
		name = drone_name,
		position = hangar.spawn_position,
		force = player.force,
		direction = spawn_direction
	})
	created_plane.get_fuel_inventory().insert({name="rocket-fuel", count=1})
Bonus question: how can I make the drones clear the fog-of-war around them - similar like around the radar stations?

Re: Biters ignore unmanned vehicle entity

Posted: Wed Aug 12, 2020 2:59 am
by DaveMcW
You need to base it on one of the military prototypes to get the auto attack behavior.

The other option is to scan the area and manually aggro any enemies, which is rather complicated and expensive.

Re: Biters ignore unmanned vehicle entity

Posted: Wed Aug 12, 2020 11:53 am
by IngoKnieto

Code: Select all

local plane_entity = table.deepcopy(data.raw.car.tank);
So this will not work, I have to use one of the prototypes mentioned in the wiki article, correct? Or is there a flag I can assing to my entity?

I couldn't find anything here https://wiki.factorio.com/Types/EntityPrototypeFlags, and the wiki article you linked says "it's a hard coded flag on certain prototypes"

Re: Biters ignore unmanned vehicle entity

Posted: Wed Aug 12, 2020 12:40 pm
by DaveMcW
Another thing you could do is give it a dummy passenger.

Code: Select all

local passenger = created_plane.surface.create_entity{name="character", force=created_plane.force, position=created_plane.position}
created_plane.set_passenger(passenger)
This requires some special code to remove the passenger when the vehicle dies.

Re: Biters ignore unmanned vehicle entity

Posted: Wed Aug 12, 2020 4:57 pm
by IngoKnieto
The passenger solution works perfect, thank you.

Last question: the passenger has no vision on the map, like the player character. How would I achieve this?