Biters ignore unmanned vehicle entity

Place to get help with not working mods / modding interface.
Post Reply
User avatar
IngoKnieto
Fast Inserter
Fast Inserter
Posts: 106
Joined: Mon Oct 03, 2016 9:29 am
Contact:

Biters ignore unmanned vehicle entity

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

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3699
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Biters ignore unmanned vehicle entity

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

User avatar
IngoKnieto
Fast Inserter
Fast Inserter
Posts: 106
Joined: Mon Oct 03, 2016 9:29 am
Contact:

Re: Biters ignore unmanned vehicle entity

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

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3699
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Biters ignore unmanned vehicle entity

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

User avatar
IngoKnieto
Fast Inserter
Fast Inserter
Posts: 106
Joined: Mon Oct 03, 2016 9:29 am
Contact:

Re: Biters ignore unmanned vehicle entity

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

Post Reply

Return to “Modding help”