Bazaar developer reference

CvDiplomacyAI::IsPlayerRecklessExpander(PlayerTypes)

Defined in
CvDiplomacyAI.cpp, line 7774
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_IsPlayerRecklessExpander

Hooks

static bool BeforeCvDiplomacyAI_IsPlayerRecklessExpander(CvDiplomacyAI* self, PlayerTypes ePlayer, bool& result);static void AfterCvDiplomacyAI_IsPlayerRecklessExpander(CvDiplomacyAI* self, PlayerTypes ePlayer, bool& result);static bool ReplaceCvDiplomacyAI_IsPlayerRecklessExpander(bool (*original)(CvDiplomacyAI*, PlayerTypes), CvDiplomacyAI* self, PlayerTypes ePlayer);CivRegisterBefore<CivHooks::CvDiplomacyAI_IsPlayerRecklessExpander>(host, &BeforeCvDiplomacyAI_IsPlayerRecklessExpander);CivRegisterAfter<CivHooks::CvDiplomacyAI_IsPlayerRecklessExpander>(host, &AfterCvDiplomacyAI_IsPlayerRecklessExpander);CivRegisterReplace<CivHooks::CvDiplomacyAI_IsPlayerRecklessExpander>(host, &ReplaceCvDiplomacyAI_IsPlayerRecklessExpander);

Code

7773/// Is ePlayer expanding recklessly?7774bool CvDiplomacyAI::IsPlayerRecklessExpander(PlayerTypes ePlayer)7775{7776	// If the player is too far away from us, we don't care7777	if(GetPlayer()->GetProximityToPlayer(ePlayer) < PLAYER_PROXIMITY_CLOSE)7778		return false;77797780	// If the player has too few cities, don't worry about it7781	int iNumCities = GET_PLAYER(ePlayer).getNumCities();7782	if(iNumCities < 4)7783		return false;77847785	double fAverageNumCities = 0;7786	int iNumPlayers = 0;77877788	// Find out what the average is (minus the player we're looking at)7789	PlayerTypes eLoopPlayer;7790	CvPlayer* pPlayer;7791	for(int iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)7792	{7793		eLoopPlayer = (PlayerTypes) iPlayerLoop;7794		pPlayer = &GET_PLAYER(eLoopPlayer);77957796		// Not alive7797		if(!pPlayer->isAlive())7798			continue;77997800		// Not the guy we're looking at7801		if(eLoopPlayer == ePlayer)7802			continue;78037804		iNumPlayers++;7805		fAverageNumCities += pPlayer->getNumCities();7806	}78077808	// Not sure how this would happen, but we'll be safe anyways since we'll be dividing by this value7809	if(iNumPlayers == 0)7810	{7811		CvAssertMsg(false, "0 players to evaluate when trying to identify if someone is a reckless expander. Not sure how this would happen without the game being over yet.");7812		return false;7813	}78147815	fAverageNumCities /= iNumPlayers;78167817	// Must have way more cities than the average player in the game7818	if(iNumCities < fAverageNumCities * 1.5)7819		return false;78207821	// If this guy's military is as big as ours, then it probably means he's just stronger than us7822	if(GetPlayerMilitaryStrengthComparedToUs(ePlayer) >= STRENGTH_AVERAGE)7823		return false;78247825	return true;7826}

Calls

Called by