Modify AI behavior: vassalisation

Leoreth

Blue Period
Moderator
Joined
Aug 23, 2009
Messages
37,061
Location
東京藝術大学
Hello everyone,

I'm currently trying to make some changes in how AI determine to become a peacevassal and to whom. Especially the following features:

1) Some civilizations are in general less likely to become peacevassals (I'd like to make Netherlands and Portugal less likely to become vassals in my RFC modmod, since they are too small in game terms to stay independent like in history).

2) Civilizations can only become vassals of their neighbors until the discovery of Astronomy.

I've already scanned through the CvTeamAI and CvPlayerAI files, but haven't found anything appropriate. Can someone point me to the related functions? Is it even possible to edit that at all?

Edit: I just realized that I can achieve (1) by changing VassalRefuseAttitudeThreshold in CIV4LeaderHeadInfos.xml. Does that value also influence capitulation? And I'd still like to know where I can find the related code for the DLL.
 
iVassalPowerModifier in the XML is what influences the power ratio needed for civ to become a vassal. Setting it very high (i.e. 50 or 100) will make the AI unlikely to become a vassal except for capitulation.

For civ-civ relations, there must be a dozen ways to do it. In SoI I used the borders array, and prohibit vassals between civs that have borders value of 5 = very far. Since you probably have the code: borders are in CvRhyes, and the related code is in CvTeamAI::AI_surrenderTrade line 1999. Not a pretty solution but handy in RFC where the array is hardcoded anyway:
Code:
	if (!isAtWar(eTeam))
	{
		if (!GET_TEAM(eTeam).isParent(getID()))
		{
			if (AI_getWorstEnemy() == eTeam)
			{
				return DENIAL_WORST_ENEMY;
			}

			if (!AI_hasCitiesInPrimaryArea(eTeam) && AI_calculateAdjacentLandPlots(eTeam) == 0)
			{
				return DENIAL_TOO_FAR;
			}
			
			// edead: do not allow vassals with borders value of 5 (CvRhyes.cpp) - too distant or insignificant
			if ((borders[(int)kMasterTeam.getID()][(int)getID()]) >= 5)
			{
				return DENIAL_TOO_FAR;
			}
			// edead: end
		}
 
I completely forgot about my thread here :crazyeye:

That looks exactly like what I was looking for. Many thanks! :)
 
Top Bottom