Bazaar developer reference

CvDiplomacyAI::DoUpdateEstimateOtherPlayerLandDisputeLevels()

Defined in
CvDiplomacyAI.cpp, line 8278
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_DoUpdateEstimateOtherPlayerLandDisputeLevels

Hooks

static bool BeforeCvDiplomacyAI_DoUpdateEstimateOtherPlayerLandDisputeLevels(CvDiplomacyAI* self);static void AfterCvDiplomacyAI_DoUpdateEstimateOtherPlayerLandDisputeLevels(CvDiplomacyAI* self);static void ReplaceCvDiplomacyAI_DoUpdateEstimateOtherPlayerLandDisputeLevels(void (*original)(CvDiplomacyAI*), CvDiplomacyAI* self);CivRegisterBefore<CivHooks::CvDiplomacyAI_DoUpdateEstimateOtherPlayerLandDisputeLevels>(host, &BeforeCvDiplomacyAI_DoUpdateEstimateOtherPlayerLandDisputeLevels);CivRegisterAfter<CivHooks::CvDiplomacyAI_DoUpdateEstimateOtherPlayerLandDisputeLevels>(host, &AfterCvDiplomacyAI_DoUpdateEstimateOtherPlayerLandDisputeLevels);CivRegisterReplace<CivHooks::CvDiplomacyAI_DoUpdateEstimateOtherPlayerLandDisputeLevels>(host, &ReplaceCvDiplomacyAI_DoUpdateEstimateOtherPlayerLandDisputeLevels);

Code

8277/// Updates what is our guess as to the levels of Dispute between other players over Land is8278void CvDiplomacyAI::DoUpdateEstimateOtherPlayerLandDisputeLevels()8279{8280	PlayerTypes eLoopOtherPlayer;8281	int iOtherPlayerLoop;82828283	PlayerTypes eLoopPlayer;8284	int iPlayerLoop;82858286	// Cache world average # of Cities to compare each player we know against later8287	int iWorldAverageNumCities = 0;8288	int iNumPlayers = 0;8289	for(iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)8290	{8291		eLoopPlayer = (PlayerTypes) iPlayerLoop;82928293		if(GET_PLAYER(eLoopPlayer).isAlive())8294		{8295			iWorldAverageNumCities += GET_PLAYER(eLoopPlayer).getNumCities();8296			iNumPlayers++;8297		}8298	}82998300	iWorldAverageNumCities *= 100;8301	iWorldAverageNumCities /= iNumPlayers;83028303	int iCityRatio;8304	int iExpansionFlavorGuess;83058306	int iLandDisputeWeight;83078308	DisputeLevelTypes eDisputeLevel;83098310	PlayerProximityTypes eProximity;83118312	// Loop through all (known) Majors8313	for(iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)8314	{8315		eLoopPlayer = (PlayerTypes) iPlayerLoop;83168317		if(IsPlayerValid(eLoopPlayer))8318		{8319			// Before looking at anyone else, try to guess how much this player values Expansion based on how many Cities he has relative the rest of the world83208321			iCityRatio = GET_PLAYER(eLoopPlayer).getNumCities() * 10000;8322			iCityRatio /= iWorldAverageNumCities;	// 100 means 1 City, which is why we multiplied by 10000 on the line above... 10000/100 = 10083238324			if(iCityRatio >= /*200*/ GC.getLAND_DISPUTE_CITY_RATIO_EXPANSION_GUESS_10())8325				iExpansionFlavorGuess = 10;8326			else if(iCityRatio >= /*180*/ GC.getLAND_DISPUTE_CITY_RATIO_EXPANSION_GUESS_9())8327				iExpansionFlavorGuess = 9;8328			else if(iCityRatio >= /*160*/ GC.getLAND_DISPUTE_CITY_RATIO_EXPANSION_GUESS_8())8329				iExpansionFlavorGuess = 8;8330			else if(iCityRatio >= /*130*/ GC.getLAND_DISPUTE_CITY_RATIO_EXPANSION_GUESS_7())8331				iExpansionFlavorGuess = 7;8332			else if(iCityRatio >= /*110*/ GC.getLAND_DISPUTE_CITY_RATIO_EXPANSION_GUESS_6())8333				iExpansionFlavorGuess = 6;8334			else if(iCityRatio >= /*90*/ GC.getLAND_DISPUTE_CITY_RATIO_EXPANSION_GUESS_5())8335				iExpansionFlavorGuess = 5;8336			else if(iCityRatio >= /*80*/ GC.getLAND_DISPUTE_CITY_RATIO_EXPANSION_GUESS_4())8337				iExpansionFlavorGuess = 4;8338			else if(iCityRatio >= /*55*/ GC.getLAND_DISPUTE_CITY_RATIO_EXPANSION_GUESS_3())8339				iExpansionFlavorGuess = 3;8340			else if(iCityRatio >= /*30*/ GC.getLAND_DISPUTE_CITY_RATIO_EXPANSION_GUESS_2())8341				iExpansionFlavorGuess = 2;8342			else8343				iExpansionFlavorGuess = 1;83448345			LogOtherPlayerExpansionGuess(eLoopPlayer, iExpansionFlavorGuess);83468347			// Now loop through every player HE knows8348			for(iOtherPlayerLoop = 0; iOtherPlayerLoop < MAX_MAJOR_CIVS; iOtherPlayerLoop++)8349			{8350				eLoopOtherPlayer = (PlayerTypes) iOtherPlayerLoop;83518352				// Don't compare a player to himself8353				if(eLoopPlayer != eLoopOtherPlayer)8354				{8355					// Do both we and the guy we're looking about know the third guy?8356					if(IsPlayerValid(eLoopOtherPlayer) && GET_PLAYER(eLoopPlayer).GetDiplomacyAI()->IsPlayerValid(eLoopOtherPlayer))8357					{8358						eDisputeLevel = DISPUTE_LEVEL_NONE;8359						iLandDisputeWeight = 0;83608361						// Look at our Proximity to the other Player8362						eProximity = GET_PLAYER(eLoopPlayer).GetProximityToPlayer(eLoopOtherPlayer);83638364						if(eProximity == PLAYER_PROXIMITY_DISTANT)8365							iLandDisputeWeight += /*0*/ GC.getLAND_DISPUTE_DISTANT();8366						else if(eProximity == PLAYER_PROXIMITY_FAR)8367							iLandDisputeWeight += /*5*/ GC.getLAND_DISPUTE_FAR();8368						else if(eProximity == PLAYER_PROXIMITY_CLOSE)8369							iLandDisputeWeight += /*20*/ GC.getLAND_DISPUTE_CLOSE();8370						else if(eProximity == PLAYER_PROXIMITY_NEIGHBORS)8371							iLandDisputeWeight += /*40*/ GC.getLAND_DISPUTE_NEIGHBORS();83728373						// Is the player already cramped?  If so, multiply our current Weight by 1.5x8374						if(GET_PLAYER(eLoopPlayer).IsCramped())8375						{8376							iLandDisputeWeight *= /*0*/ GC.getLAND_DISPUTE_CRAMPED_MULTIPLIER();8377							iLandDisputeWeight /= 100;8378						}83798380						// Add weight for Player's estimated EXPANSION preference8381						iLandDisputeWeight *= iExpansionFlavorGuess;83828383						// Max Value (Cramped, Neighbors) - 608384						// EXPANSION 10	: 6008385						// EXPANSION 5		: 3008386						// EXPANSION 1		: 6083878388						// "Typical" Value (Not Cramped, Close) - 208389						// EXPANSION 10	: 2008390						// EXPANSION 5		: 1008391						// EXPANSION 1		: 2083928393						// Now See what our new Dispute Level should be8394						if(iLandDisputeWeight >= /*300*/ GC.getLAND_DISPUTE_FIERCE_THRESHOLD())8395							eDisputeLevel = DISPUTE_LEVEL_FIERCE;8396						else if(iLandDisputeWeight >= /*200*/ GC.getLAND_DISPUTE_STRONG_THRESHOLD())8397							eDisputeLevel = DISPUTE_LEVEL_STRONG;8398						else if(iLandDisputeWeight >= /*100*/ GC.getLAND_DISPUTE_WEAK_THRESHOLD())8399							eDisputeLevel = DISPUTE_LEVEL_WEAK;84008401						// Actually set the Level8402						SetEstimateOtherPlayerLandDisputeLevel(eLoopPlayer, eLoopOtherPlayer, eDisputeLevel);8403					}8404				}8405			}8406		}8407	}8408}

Calls

Called by