Bazaar developer reference

CvDiplomacyAI::IsDenounceFriendAcceptable(PlayerTypes)

Defined in
CvDiplomacyAI.cpp, line 21322
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_IsDenounceFriendAcceptable

Hooks

static bool BeforeCvDiplomacyAI_IsDenounceFriendAcceptable(CvDiplomacyAI* self, PlayerTypes ePlayer, bool& result);static void AfterCvDiplomacyAI_IsDenounceFriendAcceptable(CvDiplomacyAI* self, PlayerTypes ePlayer, bool& result);static bool ReplaceCvDiplomacyAI_IsDenounceFriendAcceptable(bool (*original)(CvDiplomacyAI*, PlayerTypes), CvDiplomacyAI* self, PlayerTypes ePlayer);CivRegisterBefore<CivHooks::CvDiplomacyAI_IsDenounceFriendAcceptable>(host, &BeforeCvDiplomacyAI_IsDenounceFriendAcceptable);CivRegisterAfter<CivHooks::CvDiplomacyAI_IsDenounceFriendAcceptable>(host, &AfterCvDiplomacyAI_IsDenounceFriendAcceptable);CivRegisterReplace<CivHooks::CvDiplomacyAI_IsDenounceFriendAcceptable>(host, &ReplaceCvDiplomacyAI_IsDenounceFriendAcceptable);

Code

21321/// Are we done with ePlayer, and now want to Denounce him?21322bool CvDiplomacyAI::IsDenounceFriendAcceptable(PlayerTypes ePlayer)21323{21324	CvAssertMsg(IsDoFAccepted(ePlayer), "Diplomacy AI: Testing whether we should Denounce a Friend, but we aren't right now. Please send Jon this with your last 5 autosaves and what changelist # you're playing.");2132521326	// Changed our approach towards ePlayer21327	MajorCivApproachTypes eTrueApproach = GetMajorCivApproach(ePlayer, /*bHideTrueFeelings*/ false);21328	MajorCivApproachTypes eApproach = GetMajorCivApproach(ePlayer, /*bHideTrueFeelings*/ true);21329	if(eApproach == MAJOR_CIV_APPROACH_HOSTILE || eTrueApproach == MAJOR_CIV_APPROACH_HOSTILE)21330		return true;2133121332	// If we're enemies or unforgivable then we have no need to work with this guy any more21333	MajorCivOpinionTypes eOpinion = GetMajorCivOpinion(ePlayer);21334	if(eOpinion <= MAJOR_CIV_OPINION_ENEMY)21335		return true;21336	if(eOpinion >= MAJOR_CIV_OPINION_FAVORABLE)21337		return false;2133821339	int iChance = 0;2134021341	// If we've worked together for at least 30 turns, and are competitors, there's a chance we break things off (based on Loyalty)21342	if(GetDoFCounter(ePlayer) > 30)21343	{21344		if(eOpinion == MAJOR_CIV_OPINION_COMPETITOR)21345		{21346			// 0% chance if value is 921347			// 4% chance if value is 22134821349			iChance = 10 - GetLoyalty();21350			iChance /= 2;21351		}21352	}2135321354	// Going for conquest, and they're weak and close21355	if(IsGoingForWorldConquest())21356	{21357		if(GetPlayerMilitaryStrengthComparedToUs(ePlayer) <= STRENGTH_POOR)21358		{21359			if(GetPlayer()->GetProximityToPlayer(ePlayer) >= PLAYER_PROXIMITY_CLOSE)21360				iChance += 5;21361		}21362	}2136321364	int iRand = GC.getGame().getJonRandNum(100, "Diplomacy AI: Rand for whether AI wants to Denounce a Friend");21365	if(iRand < iChance)21366		return true;2136721368	return false;21369}

Calls

Called by