Bazaar developer reference

CvDiplomacyAI::IsWantsOpenBordersWithPlayer(PlayerTypes)

Defined in
CvDiplomacyAI.cpp, line 5081
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_IsWantsOpenBordersWithPlayer

Hooks

static bool BeforeCvDiplomacyAI_IsWantsOpenBordersWithPlayer(CvDiplomacyAI* self, PlayerTypes ePlayer, bool& result);static void AfterCvDiplomacyAI_IsWantsOpenBordersWithPlayer(CvDiplomacyAI* self, PlayerTypes ePlayer, bool& result);static bool ReplaceCvDiplomacyAI_IsWantsOpenBordersWithPlayer(bool (*original)(CvDiplomacyAI*, PlayerTypes), CvDiplomacyAI* self, PlayerTypes ePlayer);CivRegisterBefore<CivHooks::CvDiplomacyAI_IsWantsOpenBordersWithPlayer>(host, &BeforeCvDiplomacyAI_IsWantsOpenBordersWithPlayer);CivRegisterAfter<CivHooks::CvDiplomacyAI_IsWantsOpenBordersWithPlayer>(host, &AfterCvDiplomacyAI_IsWantsOpenBordersWithPlayer);CivRegisterReplace<CivHooks::CvDiplomacyAI_IsWantsOpenBordersWithPlayer>(host, &ReplaceCvDiplomacyAI_IsWantsOpenBordersWithPlayer);

Code

5080/// Do we want Open Borders with eOtherPlayer? - this is only used for when to trigger an AI request, not whether or not the AI will accept a deal period5081bool CvDiplomacyAI::IsWantsOpenBordersWithPlayer(PlayerTypes ePlayer)5082{5083	CvAssertMsg(ePlayer >= 0, "DIPLOMACY_AI: Invalid Player Index.  Please send Jon this with your last 5 autosaves and what changelist # you're playing.");5084	CvAssertMsg(ePlayer < MAX_MAJOR_CIVS, "DIPLOMACY_AI: Invalid Player Index.  Please send Jon this with your last 5 autosaves and what changelist # you're playing.");50855086	// If going for culture win always want open borders against civs we need influence on5087	AIGrandStrategyTypes eCultureStrategy = (AIGrandStrategyTypes) GC.getInfoTypeForString("AIGRANDSTRATEGY_CULTURE");5088	if (eCultureStrategy != NO_AIGRANDSTRATEGY && m_pPlayer->GetGrandStrategyAI()->GetActiveGrandStrategy() == eCultureStrategy && m_pPlayer->GetCulture()->GetTourism() > 0 )5089	{5090		// The civ we need influence on the most should ALWAYS be included5091		if (m_pPlayer->GetCulture()->GetCivLowestInfluence(false /*bCheckOpenBorders*/) == ePlayer)5092		{5093			return true;5094		}50955096		// If have influence over half the civs, want OB with the other half5097		if (m_pPlayer->GetCulture()->GetNumCivsToBeInfluentialOn() <= m_pPlayer->GetCulture()->GetNumCivsInfluentialOn())5098		{5099			if (m_pPlayer->GetCulture()->GetInfluenceLevel(ePlayer) < INFLUENCE_LEVEL_INFLUENTIAL)5100			{5101				return true;5102			}5103		}5104	}51055106	if(GetPlayer()->GetProximityToPlayer(ePlayer) != PLAYER_PROXIMITY_NEIGHBORS)5107	{5108		return false;5109	}51105111	MajorCivApproachTypes eApproach = GetMajorCivApproach(ePlayer, /*bHideTrueFeelings*/ true);5112	if(eApproach == MAJOR_CIV_APPROACH_HOSTILE || eApproach == MAJOR_CIV_APPROACH_GUARDED || eApproach == MAJOR_CIV_APPROACH_AFRAID)5113	{5114		return false;5115	}51165117	switch(GetPlayerMilitaryStrengthComparedToUs(ePlayer))5118	{5119	case STRENGTH_IMMENSE:5120	case STRENGTH_POWERFUL:5121	case STRENGTH_STRONG:5122		return false;5123	}51245125	return true;5126}

Calls

Called by