PythonCanDo when 2 specific civs are at war

wotan321

Emperor
Joined
Oct 25, 2001
Messages
1,228
Location
NC, USA
I know this question has been asked a few dozen times somewhere in this thread but I sure can't find it.

I simply want some python to PythonCanDo in the event trigger when two specific civs are at war. I want the event to trigger when they first go to war.

Thanks for any help you provide.
 
I'm assuming you will do the event yourself. If you want it to trigger when they first go to war, the event should have an iPercentGamesActive of 100, an iWeight of -1 (always happen) and a bRecurring of 0 (happens only once).

That's how I would do the Python (to be inserted in Python/EntryPoints/CvRandomEventInterface.py):
Code:
def canTriggerWotan(argsList): 
	kTriggeredData = argsList[0]
	player = gc.getPlayer(kTriggeredData.ePlayer)
	iCiv1 = gc.getInfoTypeForString("CIVILIZATION_CHINA")
	iCiv2 = gc.getInfoTypeForString("CIVILIZATION_MONGOL")
	iTeam1 = -1
	iTeam2 = -1
	if (player.getCivilizationType() == iCiv1) or (player.getCivilizationType() == iCiv2):
		for iPlayer in xrange(gc.getMAX_CIV_PLAYERS()):
			pPlayer = gc.getPlayer(iPlayer)
			if pPlayer.getCivilizationType() == iCiv1:
				iTeam1 = pPlayer.getTeam()
				pTeam1 = gc.getTeam(iTeam1)
			if pPlayer.getCivilizationType() == iCiv2:
				iTeam2 = pPlayer.getTeam()
				pTeam2 = gc.getTeam(iTeam2)
		if iTeam1 > -1 and iTeam2 > -1:
			if pTeam1.isAtWar(iTeam2):
				return true
	return false

EDIT: added declarations for iTeam1 and iTeam2
 
Top Bottom