Bazaar developer reference

CvPlayerAI::GetDirectiveMerchant(CvUnit *)

Defined in
CvPlayerAI.cpp, line 1258
Class
CvPlayerAI
Hook name
CivHooks::CvPlayerAI_GetDirectiveMerchant

Hooks

static bool BeforeCvPlayerAI_GetDirectiveMerchant(CvPlayerAI* self, CvUnit* pGreatMerchant, GreatPeopleDirectiveTypes& result);static void AfterCvPlayerAI_GetDirectiveMerchant(CvPlayerAI* self, CvUnit* pGreatMerchant, GreatPeopleDirectiveTypes& result);static GreatPeopleDirectiveTypes ReplaceCvPlayerAI_GetDirectiveMerchant(GreatPeopleDirectiveTypes (*original)(CvPlayerAI*, CvUnit*), CvPlayerAI* self, CvUnit* pGreatMerchant);CivRegisterBefore<CivHooks::CvPlayerAI_GetDirectiveMerchant>(host, &BeforeCvPlayerAI_GetDirectiveMerchant);CivRegisterAfter<CivHooks::CvPlayerAI_GetDirectiveMerchant>(host, &AfterCvPlayerAI_GetDirectiveMerchant);CivRegisterReplace<CivHooks::CvPlayerAI_GetDirectiveMerchant>(host, &ReplaceCvPlayerAI_GetDirectiveMerchant);

Code

1258GreatPeopleDirectiveTypes CvPlayerAI::GetDirectiveMerchant(CvUnit* pGreatMerchant)1259{1260	GreatPeopleDirectiveTypes eDirective = NO_GREAT_PEOPLE_DIRECTIVE_TYPE;12611262	bool bTheVeniceException = false;1263	if (GetPlayerTraits()->IsNoAnnexing())1264	{1265		bTheVeniceException = true;1266	}12671268	// if the merchant is in an army, he's already marching to a destination, so don't evaluate him1269	if(pGreatMerchant->getArmyID() != FFreeList::INVALID_INDEX)1270	{1271		return NO_GREAT_PEOPLE_DIRECTIVE_TYPE;1272	}12731274#if defined(MOD_AI_SMART_V3)1275	// Create improvement only for first quarter of the game, and not with venice powers. 1276	int iMultiplier = MOD_AI_SMART_V3 ? 1 : 2;1277	if (eDirective == NO_GREAT_PEOPLE_DIRECTIVE_TYPE && GC.getGame().getGameTurn() <= ((GC.getGame().getEstimateEndTurn() * iMultiplier) / 4))1278#else1279	if (eDirective == NO_GREAT_PEOPLE_DIRECTIVE_TYPE && GC.getGame().getGameTurn() <= ((GC.getGame().getEstimateEndTurn() * 2) / 4))1280#endif1281	{1282#if defined(MOD_AI_SMART_V3)1283		if ((MOD_AI_SMART_V3 || GetDiplomacyAI()->IsGoingForDiploVictory()) && !bTheVeniceException)1284#else1285		if (GetDiplomacyAI()->IsGoingForDiploVictory() && !bTheVeniceException)1286#endif1287		{1288			eDirective = GREAT_PEOPLE_DIRECTIVE_CONSTRUCT_IMPROVEMENT;1289		}1290	}12911292	// Attempt a run to a minor civ1293	if(eDirective == NO_GREAT_PEOPLE_DIRECTIVE_TYPE && IsSafe(this))1294	{1295		CvPlot* pTarget = FindBestMerchantTargetPlot(pGreatMerchant, true);1296		if(pTarget)1297		{1298			eDirective = GREAT_PEOPLE_DIRECTIVE_USE_POWER;1299		}1300	}13011302	if(eDirective == NO_GREAT_PEOPLE_DIRECTIVE_TYPE && (GC.getGame().getGameTurn() - pGreatMerchant->getGameTurnCreated()) >= GC.getAI_HOMELAND_GREAT_PERSON_TURNS_TO_WAIT() && !bTheVeniceException)1303	{1304		eDirective = GREAT_PEOPLE_DIRECTIVE_CONSTRUCT_IMPROVEMENT;1305	}13061307	return eDirective;1308}

Calls

Called by