How to identify a vassal for events

liwy

Chieftain
Joined
Nov 15, 2009
Messages
63
Location
Brussels
There are two two things I want to do here.

1/ I want to check if the player as a vassal, simple as that. I presume that using "isAVassal()" would work but I am not really sure on how to identify the vassal player correctly.

2/ I want something to happen to the vassal if the conditions are met for the master.
The goal is to have an harmonisation of the political regimes between vassals and masters, especially if they are communist or fascists. I had orignially planned to do this using events (I already have nice/terrifying (depending on how seriously you take it) descriptions for those)
So the basic formula would be if X is the master of Y and has State property, Y gains State property.
 
You need to check the status of the player team. Something along the lines of
Code:
	for iPlayer in range(gc.getMAX_PLAYERS()):
		ppPlayer = gc.getPlayer(iPlayer)
		if ppPlayer.isAlive() and not ppPlayer.isBarbarian():
			if gc.getTeam(ppPlayer.getTeam()).isVassal(iTeam):

Colonies are also vassals and I don't know how to tell them appart.
 
Here is a check function that returns True or False

Code:
def confirmIsVassal(iPlayer1, iPlayer2):
	pPlayer1 = gc.getPlayer(iPlayer1)
	pPlayer2 = gc.getPlayer(iPlayer2)
	bVassal = False
		
	if (pPlayer1.getTeam() != TeamTypes.NO_TEAM and pPlayer2.getTeam() != TeamTypes.NO_TEAM):
		if (gc.getTeam(pPlayer1.getTeam()).isVassal(pPlayer2.getTeam())):	
			bVassal = True
	
	return bVassal
 
Ok that seems good but I would like to be sure:

1) In wich file do I put it.

2) Now that I can use bVassal identify the relation between players but in the end I need to use it in events and that's still not entirely clear.
 
Ok that seems good but I would like to be sure:

1) In wich file do I put it.

2) Now that I can use bVassal identify the relation between players but in the end I need to use it in events and that's still not entirely clear.


Place the unzipped attached file in your mod's python folder. Then call the function from your event function like this:

If you are looking for the return to be True:

Code:
if (StandardFunctions.confirmIsVassal(iPlayer1, iPlayer2)):


If you are looking for the return to be False:

Code:
if not (StandardFunctions.confirmIsVassal(iPlayer1, iPlayer2)):
 

Attachments

Back
Top Bottom