I'm probably pretty close to figuring out how to modify the biters to not even consider rails a target. It looks like in the onBuild(event) function, there is code that registers entities. If entity.type == "resource" or entity.force.name == "neutral" then it doesn't run accountPlayerEntity(). I can make it not account safe entities as a player entity at all and this might work. The only problem is that this function only seems to run when an item is built and doesn't apply to already built stuff such as my extensive train network. I can't seem to find how the mod re-accounts for "safe entities" upon config change but onBuild doesn't seem to be it.
Edit: I was unsuccessful in modding in the fix for this. I was trying to either:
-
find the code that "accounts the player entities" that probably runs when the mod runs for the first time. Then I make a custom command to re-register all the stuff only leave out the safe buildings so the ai doesn't even know they exist. Then do the thing I mentioned where building a new safe entity doesn't count toward accounted player buildings. This method was unsuccessful because I could not find the where this is run upon first load anywhere. I couldn't even find or understand the database that accountPlayerEntity loads stuff into.
-
add some type of code right before a biter attacks something that basically does "if targeted thing is safe building, don't do it". I couldn't seem to understand entirely how the target acquisition logic works. It seems that it ranks stuff with points based on chunks and attacks the general chunk they calculate is best.
this issue is incredibly annoying.