What's the radius where enemy structures block building?

Place to get help with not working mods / modding interface.
Pi-C
Smart Inserter
Smart Inserter
Posts: 1759
Joined: Sun Oct 14, 2018 8:13 am
Contact:

What's the radius where enemy structures block building?

Post by Pi-C »

It's not possible to build something near a military structure of an enemy force (e.g. radars, turrets, spawners). It seems the radius where enemy military structures block building is 50 tiles. Is that indeed a hard-coded value, or could it be changed?

Use case:
I want to place invisible, indestructible entities even if that was near an enemy military structure. To circumvent the block, I'd first check if I can place the entity; if not, I'd get the force of the first entity returned by

Code: Select all

surface.find_entities_filtered{
	position = position,
	radius = 50,
	type = {"ammo-turret", "artillery-turret", "electric-turret", "fluid-turret", "turret", "radar", "unit-spawner"}
}

and use

Code: Select all

new_entity = surface.create_entity({
        name = entity_name,
        position = position,
        force = enemy_force_name,
      })
if new_entity then 
	new_entity.force = final_force_name
	new_entity.destructible = false
end
to build it. But this would only work with the correct radius. (In multiplayer games with at least two enemy forces there may be situations where the entity still couldn't be placed. The workaround for that is suggestion: Don't tell the players an entity will be placed, but that there's a chance -- with an adjustable probability of 0<p<1 -- it could be placed.)
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5408
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: What's the radius where enemy structures block building?

Post by Klonan »

Pi-C wrote: Fri Dec 17, 2021 10:54 am It's not possible to build something near a military structure of an enemy force (e.g. radars, turrets, spawners). It seems the radius where enemy military structures block building is 50 tiles. Is that indeed a hard-coded value, or could it be changed?
Thats not true, are you using some other mod that is doing that behavior? Just as AAI industries?
Pi-C
Smart Inserter
Smart Inserter
Posts: 1759
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: What's the radius where enemy structures block building?

Post by Pi-C »

Klonan wrote: Fri Dec 17, 2021 11:01 am
Pi-C wrote: Fri Dec 17, 2021 10:54 am It's not possible to build something near a military structure of an enemy force (e.g. radars, turrets, spawners). It seems the radius where enemy military structures block building is 50 tiles. Is that indeed a hard-coded value, or could it be changed?
Thats not true, are you using some other mod that is doing that behavior? Just as AAI industries?
Indeed, I've used some mods active for testing compatibility. There are your own companion/kombat/mining/transport drones, the updated construction drones mod, an alien-loot mod, AAI Programmable vehicles, and Creative mod that could be relevant.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Bilka
Factorio Staff
Factorio Staff
Posts: 3429
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: What's the radius where enemy structures block building?

Post by Bilka »

That's a feature of AAI Programmable vehicles, as Klonan said. You can take a look at the mod code, aai-programmable-vehicles_0.7.14.zip\aai-programmable-vehicles\scripts\deadzone.lua. Easiest work around is probably to always place the entity as one of the ignored forces and then just change the force of the entity, since force changing doesn't raise any events. Or don't raise the script built event :p
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Pi-C
Smart Inserter
Smart Inserter
Posts: 1759
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: What's the radius where enemy structures block building?

Post by Pi-C »

Bilka wrote: Fri Dec 17, 2021 11:48 am That's a feature of AAI Programmable vehicles, as Klonan said. You can take a look at the mod code, aai-programmable-vehicles_0.7.14.zip\aai-programmable-vehicles\scripts\deadzone.lua.
Found it. There's even a runtime-global setting "Deathzone construction denial range", set to 50 tiles, just like the value I've measured. :-)
Easiest work around is probably to always place the entity as one of the ignored forces and then just change the force of the entity, since force changing doesn't raise any events. Or don't raise the script built event :p
OK, I thought of using the procedure sketched in my first post iff AAI was active, but your solution really is way easier! Other mods really don't need to know about the invisible entity, so not raising the event should work.

Thanks to Klonan and you for setting me on the right path! :-)
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Post Reply

Return to “Modding help”