Bazaar developer reference

CvEspionageAI::GetCityStatePlan(PlayerTypes *)

Defined in
CvEspionageClasses.cpp, line 5882
Class
CvEspionageAI
Hook name
CivHooks::CvEspionageAI_GetCityStatePlan

Hooks

static bool BeforeCvEspionageAI_GetCityStatePlan(CvEspionageAI* self, PlayerTypes* peDiploThreat, int& result);static void AfterCvEspionageAI_GetCityStatePlan(CvEspionageAI* self, PlayerTypes* peDiploThreat, int& result);static int ReplaceCvEspionageAI_GetCityStatePlan(int (*original)(CvEspionageAI*, PlayerTypes*), CvEspionageAI* self, PlayerTypes* peDiploThreat);CivRegisterBefore<CivHooks::CvEspionageAI_GetCityStatePlan>(host, &BeforeCvEspionageAI_GetCityStatePlan);CivRegisterAfter<CivHooks::CvEspionageAI_GetCityStatePlan>(host, &AfterCvEspionageAI_GetCityStatePlan);CivRegisterReplace<CivHooks::CvEspionageAI_GetCityStatePlan>(host, &ReplaceCvEspionageAI_GetCityStatePlan);

Code

5882int CvEspionageAI::GetCityStatePlan(PlayerTypes* peDiploThreat)5883{5884	int iCurrentPlan = PLAN_PLAY_NORMAL; 5885	PlayerTypes eCurrentDiploThreat = NO_PLAYER;5886	if (m_bUNCountdownStarted)5887	{5888		int aiMajorCivVotes[MAX_MAJOR_CIVS];5889		for (uint ui = 0; ui < MAX_MAJOR_CIVS; ui++)5890		{5891			aiMajorCivVotes[ui] = 0;5892		}58935894		int iAliveMinorCivs = 0;58955896		for(uint ui = MAX_MAJOR_CIVS; ui < MAX_CIV_PLAYERS; ui++)5897		{5898			PlayerTypes eTargetPlayer = (PlayerTypes)ui;58995900			// only count minor civs5901			if (!GET_PLAYER(eTargetPlayer).isMinorCiv())5902			{5903				continue;5904			}59055906			if (!GET_PLAYER(eTargetPlayer).isAlive())5907			{5908				continue;5909			}59105911			iAliveMinorCivs++;59125913			PlayerTypes eAllyPlayer = GET_PLAYER(eTargetPlayer).GetMinorCivAI()->GetAlly();5914			if (eAllyPlayer != NO_PLAYER)5915			{5916				aiMajorCivVotes[eAllyPlayer]++;5917			}5918		}59195920		int iMaxVotes = 0;5921		for (uint ui = 0; ui < MAX_MAJOR_CIVS; ui++)5922		{5923			PlayerTypes eTargetPlayer = (PlayerTypes)ui;5924			if (aiMajorCivVotes[eTargetPlayer] > iMaxVotes)5925			{5926				iMaxVotes = aiMajorCivVotes[eTargetPlayer];5927				eCurrentDiploThreat = eTargetPlayer;5928			}5929		}59305931		if (eCurrentDiploThreat != NO_PLAYER)5932		{5933			if (iMaxVotes >= iAliveMinorCivs / 2)5934			{5935				if (eCurrentDiploThreat == m_pPlayer->GetID())5936				{5937					iCurrentPlan = PLAN_DEFEND_CS_FOR_WIN;5938				}5939				else5940				{5941					iCurrentPlan = PLAN_ATTACK_CS_TO_PREVENT_DEFEAT;5942				}5943			}5944			else if (iMaxVotes >= iAliveMinorCivs / 4)5945			{5946				iCurrentPlan = PLAN_COLLECT_VOTES;5947			}5948		}5949	}59505951	if (peDiploThreat)5952	{5953		*peDiploThreat = eCurrentDiploThreat;5954	}5955	return iCurrentPlan;5956}

Calls

Called by