Page 1 of 1

What's the radius where enemy structures block building?

Posted: Fri Dec 17, 2021 10:54 am
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.)

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

Posted: Fri Dec 17, 2021 11:01 am
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?

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

Posted: Fri Dec 17, 2021 11:14 am
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.

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

Posted: Fri Dec 17, 2021 11:48 am
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

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

Posted: Fri Dec 17, 2021 1:02 pm
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! :-)