Bazaar developer reference

CvDiplomacyAI::IsContinueCoopWar(PlayerTypes, PlayerTypes)

Defined in
CvDiplomacyAI.cpp, line 20589
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_IsContinueCoopWar

Hooks

static bool BeforeCvDiplomacyAI_IsContinueCoopWar(CvDiplomacyAI* self, PlayerTypes ePlayer, PlayerTypes eTargetPlayer, bool& result);static void AfterCvDiplomacyAI_IsContinueCoopWar(CvDiplomacyAI* self, PlayerTypes ePlayer, PlayerTypes eTargetPlayer, bool& result);static bool ReplaceCvDiplomacyAI_IsContinueCoopWar(bool (*original)(CvDiplomacyAI*, PlayerTypes, PlayerTypes), CvDiplomacyAI* self, PlayerTypes ePlayer, PlayerTypes eTargetPlayer);CivRegisterBefore<CivHooks::CvDiplomacyAI_IsContinueCoopWar>(host, &BeforeCvDiplomacyAI_IsContinueCoopWar);CivRegisterAfter<CivHooks::CvDiplomacyAI_IsContinueCoopWar>(host, &AfterCvDiplomacyAI_IsContinueCoopWar);CivRegisterReplace<CivHooks::CvDiplomacyAI_IsContinueCoopWar>(host, &ReplaceCvDiplomacyAI_IsContinueCoopWar);

Code

20588/// Do we want to continue working Target ePlayer?20589bool CvDiplomacyAI::IsContinueCoopWar(PlayerTypes ePlayer, PlayerTypes eTargetPlayer)20590{20591	CvAssertMsg(GetCoopWarAcceptedState(ePlayer, eTargetPlayer) == COOP_WAR_STATE_ACCEPTED, "Diplomacy AI: Testing whether we should continue working Target a player, but we aren't right now. Please send Jon this with your last 5 autosaves and what changelist # you're playing.");2059220593	MajorCivApproachTypes eApproachTowardsPlayer = GetMajorCivApproach(ePlayer, /*bHideTrueFeelings*/ false);20594	MajorCivOpinionTypes eOpinionTowardsPlayer = GetMajorCivOpinion(ePlayer);20595	MajorCivApproachTypes eApproachTowardsTarget = GetMajorCivApproach(eTargetPlayer, /*bHideTrueFeelings*/ false);20596	MajorCivOpinionTypes eOpinionTowardsTarget = GetMajorCivOpinion(eTargetPlayer);2059720598	// Changed our approach towards ePlayer20599	if(eApproachTowardsPlayer == MAJOR_CIV_APPROACH_HOSTILE ||20600	        GetMajorCivApproach(ePlayer, /*bHideTrueFeelings*/ true) == MAJOR_CIV_APPROACH_HOSTILE)20601		return false;2060220603	// If we're enemies or unforgivable then we're done working with this guy20604	if(eOpinionTowardsPlayer <= MAJOR_CIV_OPINION_ENEMY)20605		return false;2060620607	// If we've decided we like the guy now, we're done20608	if(eApproachTowardsTarget == MAJOR_CIV_APPROACH_FRIENDLY)20609		return false;2061020611	if(eOpinionTowardsTarget >= MAJOR_CIV_OPINION_FRIEND)20612		return false;2061320614	// If we've worked together for at least 20 turns, and are competitors, there's a chance we break things off20615	//if (GetCoopWarCounter(ePlayer) > 20)20616	//{20617	//	if (eOpinion == MAJOR_CIV_OPINION_COMPETITOR)20618	//	{20619	//		int iChance = 10 - GetWorkTargetWillingness();20620	//		int iRand = GC.getGame().getJonRandNum(100, "Diplomacy AI: Rand for whether AI wants to work Target player");2062120622	//		if (iRand < iChance)20623	//			return false;20624	//	}20625	//}2062620627	return true;20628}

Calls

Called by