There's a religionFounded event in Python that receives the ID of the founding player (iFounder). The DLL creates this event after assigning the Holy City, probably while processing new tech at the end of a player's or team's turn (in most cases). Declaring a war at that point probably won't cause any chaos. If it did, the war declaration could instead be handled in on BeginPlayerTurn. But let's try in in response to 'religionFounded':
Untested as usual, hopefully I got the syntax right. canDeclareWar should take care of all the sanity tests. It'll also mean that peace treaties prevent the war (even if the peace treaties is just 1 turn from expiring). DOGPILE should be the most heplful (for the AI) war plan type, which iirc is also used for the wars caused by the Apostolic Palace. The number 1 in your code would correspond to a defensively oriented WARPLAN_ATTACKED_RECENT. "False" for bNewDiplo should mean that there's no diplo popup.
Edit: MAX_CIV_PLAYERS corrected to MAX_CIV_TEAMS
Python:
iReligion, iFounder = argsList
iTarget = gc.getPlayer(iFounder).getTeam()
for iTeam in range(gc.getMAX_CIV_TEAMS()):
if gc.getTeam(iTeam).canDeclareWar(iTarget):
gc.getTeam(iTeam).declareWar(iTarget, False, WarPlanTypes.WARPLAN_DOGPILE)
Edit: MAX_CIV_PLAYERS corrected to MAX_CIV_TEAMS
Last edited: