Please consider adding a way to make the demolisher AI ignore a building (so it will not investigate or attack such a player-built structure). It's totally fine if it runs into the object on its own (or is pulled into it by a player) that it destroys it, simply that it doesn't go out of its way to attack it. Think the equivalent of is_military_target but for demolisher AI. I believe the reason a specific api feature is needed is that anything I could think of changing to have a demolisher ignore a player-built structure would have other gameplay implications.
My first thought would be perhaps an entry in EntityPrototypeFlags, but perhaps there is a better place?
The overall desire for such a capability would be to implement things like the original demolisher FFF that implied only big miners would attract demolishers, or to have options like longer-range elevated rails able to traverse demolisher territory as long as you dodged their regular paths. There may be gameplay reasons in mods to not kill every single demolisher near the base, for instance.
Entity flag to make demolisher AI ignore a player building
Re: Entity flag to make demolisher AI ignore a player building
Feature exists: Demolishers only target Buildings on the "player" force, and ignore entities belonging to the "neutral" force.
With the debug option show-segmented-unit-movement on: Entities on the "neutral" force are still interactible, mineable, and configurable. They do not work with Deconstruction Planners, and probably have some other oddities.
create_entity conveniently accepts a force argument. You could use the on_pre_build event to detect when a Player builds an item inside of a Demolisher territory - and replace it with a Neutral one.
Good Luck!
With the debug option show-segmented-unit-movement on: Entities on the "neutral" force are still interactible, mineable, and configurable. They do not work with Deconstruction Planners, and probably have some other oddities.
create_entity conveniently accepts a force argument. You could use the on_pre_build event to detect when a Player builds an item inside of a Demolisher territory - and replace it with a Neutral one.
Good Luck!
Re: Entity flag to make demolisher AI ignore a player building
After seeing some other discussion of demolisher AI I suspected that messing with the force might change the behavior, and your post made me go test and confirm you're right making it neutral does make the segmented AI ignore it.
But, it does break a lot of normal behavior like deconstruction & upgrade planner, enough that it would mess up the normal gameplay experience. Bots don't behave properly either if the object is destroyed, they keep flying out as if they're going to replace it, but there's not really a ghost and they just keep flying back and forth forever.
There's enough that breaks using neutral force that I think there's still a need for some way to filter the types of targets the segmented AI will go after. I think it would enable some neat behavior/modifications and in theory shouldn't be too complex to implement, so I still really think it's worth considering.
But, it does break a lot of normal behavior like deconstruction & upgrade planner, enough that it would mess up the normal gameplay experience. Bots don't behave properly either if the object is destroyed, they keep flying out as if they're going to replace it, but there's not really a ghost and they just keep flying back and forth forever.
There's enough that breaks using neutral force that I think there's still a need for some way to filter the types of targets the segmented AI will go after. I think it would enable some neat behavior/modifications and in theory shouldn't be too complex to implement, so I still really think it's worth considering.

