[BTS] Python trade desable

Darkator

Warlord
Joined
Sep 18, 2020
Messages
224
Location
Poland,EU
I wanted to shut down the commercial relationship of one civilization and prevent all civilizations from starting or ending wars.

Just don't know how to do it.
 
You can make 2 civilizations make peace with this line of code
Code:
pAttacker.makePeace(iDefender)
To make them have a permanent peace/war I think this will work
Code:
pAttacker.setPermanentWarPeace(iDefender,True)
 
@Louis the XIV and what to do to make civilizations provoke war only when nato events allow
You could check if the civilization is allowed to declare war, and if it is then make them declare war
Code:
if pAttacker.canDeclareWar(iDefender):
    pAttacker.declareWar(iDefender, True, -1)
you can also add
Code:
if not pAttacker.isAtWar(iDefender):
if you want to check if they are already at war.
But note that if for example the attack and defender have a peace treaty then it won't declare war, since it is not allowed to.
You can check the API with all python functions for civilization here: http://civ4bug.sourceforge.net/PythonAPI/ and you can just CTRL + F and search for the word war and a lot of functions about war will come up.

EDIT:
I also found a much better method to make 2 civilizations have peace :lol:
Code:
pAttacker.makePeace(iDefender)
 
I expressed myself wrongly, my point was that civilizations should not cause any war between themselves, including the player. (the effect of the war can only be achieved through historical events) @Louis the XIV
 
I expressed myself wrongly, my point was that civilizations should not cause any war between themselves, including the player. (the effect of the war can only be achieved through historical events) @Louis the XIV
Yeah you can use the setPermanentWarPeace method as I said in the first comment to block civilizations from starting a war.
Code:
pAttacker.setPermanentWarPeace(iDefender,True)
And you can use the code I showed you in the 2nd comment to check if they are allowed to declare war, including if nato allows it or not.
 
Top Bottom