Bazaar developer reference

CvDiplomacyAI::IsDoFAcceptable(PlayerTypes)

Defined in
CvDiplomacyAI.cpp, line 21103
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_IsDoFAcceptable

Hooks

static bool BeforeCvDiplomacyAI_IsDoFAcceptable(CvDiplomacyAI* self, PlayerTypes ePlayer, bool& result);static void AfterCvDiplomacyAI_IsDoFAcceptable(CvDiplomacyAI* self, PlayerTypes ePlayer, bool& result);static bool ReplaceCvDiplomacyAI_IsDoFAcceptable(bool (*original)(CvDiplomacyAI*, PlayerTypes), CvDiplomacyAI* self, PlayerTypes ePlayer);CivRegisterBefore<CivHooks::CvDiplomacyAI_IsDoFAcceptable>(host, &BeforeCvDiplomacyAI_IsDoFAcceptable);CivRegisterAfter<CivHooks::CvDiplomacyAI_IsDoFAcceptable>(host, &AfterCvDiplomacyAI_IsDoFAcceptable);CivRegisterReplace<CivHooks::CvDiplomacyAI_IsDoFAcceptable>(host, &ReplaceCvDiplomacyAI_IsDoFAcceptable);

Code

21102/// Is this AI willing to work with ePlayer?21103bool CvDiplomacyAI::IsDoFAcceptable(PlayerTypes ePlayer)21104{21105	// Can't declare friendship with a civ you're at war with21106	if(GET_TEAM(GetTeam()).isAtWar(GET_PLAYER(ePlayer).getTeam()) || GC.getGame().isOption(GAMEOPTION_ALWAYS_WAR))21107	{21108		return false;21109	}2111021111	// Haven't known this guy for long enough21112	if(IsTooEarlyForDoF(ePlayer))21113		return false;2111421115	MajorCivApproachTypes eApproach = GetMajorCivApproach(ePlayer, /*bHideTrueFeelings*/ false);2111621117	// If player is planning War, always say no21118	if(eApproach == MAJOR_CIV_APPROACH_WAR)21119		return false;21120	// If player is Hostile, always say no21121	else if(eApproach == MAJOR_CIV_APPROACH_HOSTILE)21122		return false;21123	// If player is afraid, always say yes21124	else if(eApproach == MAJOR_CIV_APPROACH_AFRAID)21125		return true;2112621127	MajorCivOpinionTypes eOpinion = GetMajorCivOpinion(ePlayer);2112821129	// If player is unforgivable, always say no21130	if(eOpinion == MAJOR_CIV_OPINION_UNFORGIVABLE)21131		return false;21132	// If player is an enemy, always say no21133	else if(eOpinion == MAJOR_CIV_OPINION_ENEMY)21134		return false;2113521136	// Has there been a denouncement either direction?21137	if(IsDenouncedPlayer(ePlayer))21138		return false;21139	if(GET_PLAYER(ePlayer).GetDiplomacyAI()->IsDenouncedPlayer(GetPlayer()->GetID()))21140		return false;2114121142	// Are we working AGAINST ePlayer with someone else?21143	//if (IsWorkingAgainstPlayer(ePlayer))21144	//	return false;2114521146	int iWeight = 0;2114721148	// Base Personality value; ranges from 0 to 10 (ish)21149	iWeight += GetDoFWillingness();2115021151	// Weight for Approach21152	if(eApproach == MAJOR_CIV_APPROACH_DECEPTIVE)21153		iWeight += 3;21154	else if(eApproach == MAJOR_CIV_APPROACH_GUARDED)21155		iWeight += -1;21156	else if(eApproach == MAJOR_CIV_APPROACH_FRIENDLY)21157		iWeight += 3;2115821159	// Weight for Opinion21160	if(eOpinion == MAJOR_CIV_OPINION_COMPETITOR)21161		iWeight += -3;21162	else if(eOpinion == MAJOR_CIV_OPINION_FAVORABLE)21163		iWeight += 2;21164	else if(eOpinion == MAJOR_CIV_OPINION_FRIEND)21165		iWeight += 5;21166	else if(eOpinion == MAJOR_CIV_OPINION_ALLY)21167		iWeight += 10;2116821169	// Rand21170	iWeight += GC.getGame().getJonRandNum(5, "Diplomacy AI: Rand for whether AI wants to work with player");2117121172	if(iWeight >= /*12*/ GC.getDOF_THRESHOLD())21173		return true;2117421175	return false;21176}

Calls

Called by