if(eApproach == MAJOR_CIV_APPROACH_FRIENDLY)
return 50;
if(bFromMe) // Me giving Open Borders to the other guy
{
// Approach is important
switch(eApproach)
{
case MAJOR_CIV_APPROACH_HOSTILE:
iItemValue = 1000;
break;
case MAJOR_CIV_APPROACH_GUARDED:
iItemValue = 100;
break;
case MAJOR_CIV_APPROACH_AFRAID:
iItemValue = 20;
break;
case MAJOR_CIV_APPROACH_FRIENDLY:
iItemValue = 50;
break;
case MAJOR_CIV_APPROACH_NEUTRAL:
iItemValue = 75;
break;
// Opinion also matters
switch(GetPlayer()->GetDiplomacyAI()->GetMajorCivOpinion(eOtherPlayer))
{
case MAJOR_CIV_OPINION_ALLY:
iItemValue = 0;
break;
case MAJOR_CIV_OPINION_FRIEND:
iItemValue *= 35;
iItemValue /= 100;
break;
case MAJOR_CIV_OPINION_FAVORABLE:
iItemValue *= 70;
iItemValue /= 100;
break;
case MAJOR_CIV_OPINION_NEUTRAL:
break;
case MAJOR_CIV_OPINION_COMPETITOR:
iItemValue *= 150;
iItemValue /= 100;
break;
case MAJOR_CIV_OPINION_ENEMY:
iItemValue *= 400;
iItemValue /= 100;
break;
case MAJOR_CIV_OPINION_UNFORGIVABLE:
iItemValue = 10000;
break;
// If they're at war with our enemies then we're more likely to give them OB
int iNumEnemiesAtWarWith = GetPlayer()->GetDiplomacyAI()->GetNumOurEnemiesPlayerAtWarWith(eOtherPlayer);
if(iNumEnemiesAtWarWith >= 2)
{
iItemValue *= 10;
iItemValue /= 100;
}
else if(iNumEnemiesAtWarWith == 1)
{
iItemValue *= 25;
iItemValue /= 100;
}
// Do we think he's going for culture victory?
AIGrandStrategyTypes eCultureStrategy = (AIGrandStrategyTypes) GC.getInfoTypeForString("AIGRANDSTRATEGY_CULTURE");
if (eCultureStrategy != NO_AIGRANDSTRATEGY && GetPlayer()->GetGrandStrategyAI()->GetGuessOtherPlayerActiveGrandStrategy(eOtherPlayer) == eCultureStrategy)
{
CvPlayer &kOtherPlayer = GET_PLAYER(eOtherPlayer);
// If he has tourism and he's not influential on us yet, resist!
if (kOtherPlayer.GetCulture()->GetTourism() > 0 && kOtherPlayer.GetCulture()->GetInfluenceOn(GetPlayer()->GetID()) < INFLUENCE_LEVEL_INFLUENTIAL)
{
iItemValue *= 500;
iItemValue /= 100;
}
}
// Other guy giving me Open Borders
else
{
// Proximity is very important
switch(GetPlayer()->GetProximityToPlayer(eOtherPlayer))
{
case PLAYER_PROXIMITY_DISTANT:
iItemValue = 5;
break;
case PLAYER_PROXIMITY_FAR:
iItemValue = 10;
break;
case PLAYER_PROXIMITY_CLOSE:
iItemValue = 15;
break;
case PLAYER_PROXIMITY_NEIGHBORS:
iItemValue = 30;
break;
// Reduce value by half if the other guy only has a single City
if(GET_PLAYER(eOtherPlayer).getNumCities() == 1)
{
iItemValue *= 50;
iItemValue /= 100;
}
// Boost value greatly if we are going for a culture win
// If going for culture win always want open borders against civs we need influence on
AIGrandStrategyTypes eCultureStrategy = (AIGrandStrategyTypes) GC.getInfoTypeForString("AIGRANDSTRATEGY_CULTURE");
if (eCultureStrategy != NO_AIGRANDSTRATEGY && GetPlayer()->GetGrandStrategyAI()->GetActiveGrandStrategy() == eCultureStrategy && GetPlayer()->GetCulture()->GetTourism() > 0 )
{
// The civ we need influence on the most should ALWAYS be included
if (GetPlayer()->GetCulture()->GetCivLowestInfluence(false /*bCheckOpenBorders*/) == eOtherPlayer)
{
iItemValue *= 1000;
iItemValue /= 100;
}
// If have influence over half the civs, want OB with the other half
else if (GetPlayer()->GetCulture()->GetNumCivsToBeInfluentialOn() <= GetPlayer()->GetCulture()->GetNumCivsInfluentialOn())
{
if (GetPlayer()->GetCulture()->GetInfluenceLevel(eOtherPlayer) < INFLUENCE_LEVEL_INFLUENTIAL)
{
iItemValue *= 500;
iItemValue /= 100;
}
}
else if (GetPlayer()->GetProximityToPlayer(eOtherPlayer) == PLAYER_PROXIMITY_NEIGHBORS)
{
// If we're cramped then we want OB more with our neighbors
if(GetPlayer()->IsCramped())
{
iItemValue *= 300;
iItemValue /= 100;
}
}
}
}
// Are we trying to find the middle point between what we think this item is worth and what another player thinks it's worth?
if(bUseEvenValue)
{
iItemValue += GET_PLAYER(eOtherPlayer).GetDealAI()->GetOpenBordersValue(!bFromMe, GetPlayer()->GetID(), /*bUseEvenValue*/ false);
iItemValue /= 2;
}
return iItemValue;