/// How much in V-POINTS (aka value) is Open Borders worth? You gotta admit that V-POINTS sound pretty cool though
int CvDealAI::GetOpenBordersValue(bool bFromMe, PlayerTypes eOtherPlayer, bool bUseEvenValue)
{
CvAssertMsg(GetPlayer()->GetID() != eOtherPlayer, "DEAL_AI: Trying to check value of Open Borders with oneself. Please send Jon this with your last 5 autosaves and what changelist # you're playing.");
MajorCivApproachTypes eApproach = GetPlayer()->GetDiplomacyAI()->GetMajorCivApproach(eOtherPlayer, /*bHideTrueFeelings*/ false);
// If we're friends, then OB is always equally valuable to both parties
#if !defined(MOD_BALANCE_CORE)
if(eApproach == MAJOR_CIV_APPROACH_FRIENDLY)
return 50;
#else
int iItemValue = 100;
#endif
#if defined(MOD_DIPLOMACY_CIV4_FEATURES)
if (MOD_DIPLOMACY_CIV4_FEATURES) {
if (bFromMe)
{
// If it's my item and I'm the vassal of the other player, accept it.
if (GET_TEAM(GET_PLAYER(eOtherPlayer).getTeam()).GetMaster() == GET_PLAYER(GetPlayer()->GetID()).getTeam())
{
return iItemValue;
}
}
else
{
// If it's their item and they're my vassal, accept it.
if (GET_TEAM(GetPlayer()->getTeam()).GetMaster() == GET_PLAYER(eOtherPlayer).getTeam())
{
return iItemValue;
}
}
}
#endif
// Me giving Open Borders to the other guy
if(bFromMe)
{
if (!GetPlayer()->GetDiplomacyAI()->IsWillingToGiveOpenBordersToPlayer(eOtherPlayer))
{
return INT_MAX;
}
// Approach is important
switch(eApproach)
{
case MAJOR_CIV_APPROACH_HOSTILE:
case MAJOR_CIV_APPROACH_GUARDED:
case MAJOR_CIV_APPROACH_WAR:
return INT_MAX;
break;
case MAJOR_CIV_APPROACH_DECEPTIVE:
iItemValue += 400;
break;
case MAJOR_CIV_APPROACH_AFRAID:
iItemValue += 300;
break;
case MAJOR_CIV_APPROACH_FRIENDLY:
iItemValue += 50;
break;
case MAJOR_CIV_APPROACH_NEUTRAL:
iItemValue += 200;
break;
default:
CvAssertMsg(false, "DEAL_AI: AI player has no valid Approach for Open Borders valuation. Please send Jon this with your last 5 autosaves and what changelist # you're playing.")
iItemValue += 100;
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 defined(MOD_BALANCE_CORE_DEALS)
if(iNumEnemiesAtWarWith > 0)
#else
if(iNumEnemiesAtWarWith >= 2)
#endif
{
#if defined(MOD_BALANCE_CORE_DEALS)
iItemValue *= (100 - (iNumEnemiesAtWarWith * 5));
#else
iItemValue *= 10;
#endif
iItemValue /= 100;
}
#if !defined(MOD_BALANCE_CORE_DEALS)
else if(iNumEnemiesAtWarWith == 1)
{
iItemValue *= 50;
iItemValue /= 100;
}
#endif
#if defined(MOD_BALANCE_FLIPPED_TOURISM_MODIFIER_OPEN_BORDERS)
if (GetPlayer()->GetCulture()->GetTourism() / 100 > 0)
{
// The civ we need influence on the most should ALWAYS be included
if (GetPlayer()->GetCulture()->GetCivLowestInfluence(false /*bCheckOpenBorders*/) == eOtherPlayer)
{
iItemValue *= 50;
iItemValue /= 100;
}
// If have influence over half the civs, want OB with the other half
if (GetPlayer()->GetCulture()->GetNumCivsToBeInfluentialOn() <= GetPlayer()->GetCulture()->GetNumCivsInfluentialOn())
{
if (GetPlayer()->GetCulture()->GetInfluenceLevel(eOtherPlayer) < INFLUENCE_LEVEL_INFLUENTIAL)
{
iItemValue *= 50;
iItemValue /= 100;
}
}
}
#endif
#if !defined(MOD_BALANCE_FLIPPED_TOURISM_MODIFIER_OPEN_BORDERS)
// 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() / 100 > 0 && kOtherPlayer.GetCulture()->GetInfluenceOn(GetPlayer()->GetID()) < INFLUENCE_LEVEL_INFLUENTIAL)
{
iItemValue *= 500;
iItemValue /= 100;
}
}
#if defined(MOD_BALANCE_CORE_DEALS)
if(MOD_BALANCE_CORE_DEALS)
{
CvPlayer &kOtherPlayer = GET_PLAYER(eOtherPlayer);
if (kOtherPlayer.GetCulture()->GetTourism() / 100 > 0 && (kOtherPlayer.GetCulture()->GetInfluenceOn(GetPlayer()->GetID()) > INFLUENCE_LEVEL_FAMILIAR) && (kOtherPlayer.GetCulture()->GetInfluenceOn(GetPlayer()->GetID()) < INFLUENCE_LEVEL_INFLUENTIAL))
{
if(GetPlayer()->GetDiplomacyAI()->GetMajorCivOpinion(eOtherPlayer) <= MAJOR_CIV_OPINION_NEUTRAL)
{
if(GetPlayer()->GetDiplomacyAI()->GetVictoryBlockLevel(eOtherPlayer) >= BLOCK_LEVEL_STRONG || GetPlayer()->GetDiplomacyAI()->GetVictoryDisputeLevel(eOtherPlayer) >= DISPUTE_LEVEL_STRONG)
{
iItemValue = 100000;
}
}
}
}
#endif
#endif
}
// Other guy giving me Open Borders
else
{
#if defined(MOD_BALANCE_CORE)
if (!GetPlayer()->GetDiplomacyAI()->IsWantsOpenBordersWithPlayer(eOtherPlayer))
{
return INT_MAX;
}
// Approach is important
switch(eApproach)
{
//If we don't like him, don't take his borders. It's a trap!
case MAJOR_CIV_APPROACH_WAR:
case MAJOR_CIV_APPROACH_HOSTILE:
case MAJOR_CIV_APPROACH_DECEPTIVE:
case MAJOR_CIV_APPROACH_GUARDED:
return INT_MAX;
break;
case MAJOR_CIV_APPROACH_AFRAID:
iItemValue += 200;
break;
case MAJOR_CIV_APPROACH_FRIENDLY:
iItemValue += 100;
break;
case MAJOR_CIV_APPROACH_NEUTRAL:
iItemValue += 50;
break;
default:
CvAssertMsg(false, "DEAL_AI: AI player has no valid Approach for Open Borders valuation. Please send Jon this with your last 5 autosaves and what changelist # you're playing.")
iItemValue += 100;
break;
}
// Proximity is very important
switch(GetPlayer()->GetProximityToPlayer(eOtherPlayer))
{
case PLAYER_PROXIMITY_DISTANT:
iItemValue *= 70;
iItemValue /= 100;
break;
case PLAYER_PROXIMITY_FAR:
iItemValue *= 80;
iItemValue /= 100;
break;
case PLAYER_PROXIMITY_CLOSE:
iItemValue *= 90;
iItemValue /= 100;
break;
case PLAYER_PROXIMITY_NEIGHBORS:
iItemValue *= 110;
iItemValue /= 100;
break;
default:
CvAssertMsg(false, "DEAL_AI: AI player has no valid Proximity for Open Borders valuation. Please send Jon this with your last 5 autosaves and what changelist # you're playing.")
iItemValue = 0;
break;
}
#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;
default:
CvAssertMsg(false, "DEAL_AI: AI player has no valid Proximity for Open Borders valuation. Please send Jon this with your last 5 autosaves and what changelist # you're playing.")
iItemValue = 0;
break;
}
#endif
// Reduce value by half if the other guy only has a single City
if(GET_PLAYER(eOtherPlayer).getNumCities() == 1)
{
iItemValue *= 50;
iItemValue /= 100;
}
#if defined(MOD_BALANCE_CORE_DIPLOMACY)
if(GetPlayer()->IsCramped() && GET_PLAYER(eOtherPlayer).getNumCities() > GetPlayer()->getNumCities())
{
iItemValue *= 125;
iItemValue /= 100;
}
if(GetPlayer()->GetDiplomacyAI()->GetNeighborOpinion(eOtherPlayer) == MAJOR_CIV_OPINION_ENEMY)
{
iItemValue *= 125;
iItemValue /= 100;
}
if(GetPlayer()->GetDiplomacyAI()->MusteringForNeighborAttack(eOtherPlayer))
{
iItemValue *= 150;
iItemValue /= 100;
}
//We need to explore?
EconomicAIStrategyTypes eNeedRecon = (EconomicAIStrategyTypes) GC.getInfoTypeForString("ECONOMICAISTRATEGY_NEED_RECON");
EconomicAIStrategyTypes eNavalRecon = (EconomicAIStrategyTypes) GC.getInfoTypeForString("ECONOMICAISTRATEGY_NEED_RECON_SEA");
if(eNeedRecon != NO_ECONOMICAISTRATEGY && GetPlayer()->GetEconomicAI()->IsUsingStrategy(eNeedRecon))
{
iItemValue *= 115;
iItemValue /= 100;
}
if(eNavalRecon != NO_ECONOMICAISTRATEGY && GetPlayer()->GetEconomicAI()->IsUsingStrategy(eNavalRecon))
{
iItemValue *= 115;
iItemValue /= 100;
}
#endif
// 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
#if !defined(MOD_BALANCE_FLIPPED_TOURISM_MODIFIER_OPEN_BORDERS)
AIGrandStrategyTypes eCultureStrategy = (AIGrandStrategyTypes) GC.getInfoTypeForString("AIGRANDSTRATEGY_CULTURE");
if (eCultureStrategy != NO_AIGRANDSTRATEGY && GetPlayer()->GetGrandStrategyAI()->GetActiveGrandStrategy() == eCultureStrategy && GetPlayer()->GetCulture()->GetTourism() / 100 > 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;
}
}
}
#endif
#if defined(MOD_BALANCE_FLIPPED_TOURISM_MODIFIER_OPEN_BORDERS)
// Do we think he's going for culture victory? If we're contesting this, don't take his open borders!
CvPlayer &kOtherPlayer = GET_PLAYER(eOtherPlayer);
// Opinion also matters
if(GetPlayer()->GetDiplomacyAI()->GetMajorCivApproach(eOtherPlayer, /*bHideTrueFeelings*/ false) < MAJOR_CIV_APPROACH_FRIENDLY)
{
if (kOtherPlayer.GetCulture()->GetTourism() / 100 > 0 && (kOtherPlayer.GetCulture()->GetInfluenceOn(GetPlayer()->GetID()) < INFLUENCE_LEVEL_INFLUENTIAL))
{
if(GetPlayer()->GetDiplomacyAI()->GetVictoryBlockLevel(eOtherPlayer) >= BLOCK_LEVEL_STRONG || GetPlayer()->GetDiplomacyAI()->GetVictoryDisputeLevel(eOtherPlayer) >= DISPUTE_LEVEL_STRONG)
{
return INT_MAX;
}
// If he has influence over half the civs, want to block OB with the other half
if (kOtherPlayer.GetCulture()->GetNumCivsToBeInfluentialOn() <= kOtherPlayer.GetCulture()->GetNumCivsInfluentialOn())
{
return INT_MAX;
}
}
}
#endif
}
// 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)
{
int iReverseValue = GET_PLAYER(eOtherPlayer).GetDealAI()->GetOpenBordersValue(!bFromMe, GetPlayer()->GetID(), /*bUseEvenValue*/ false);
if (iReverseValue == INT_MAX)
//no deal, can't agree on a value
iItemValue = INT_MAX;
else
iItemValue = (iItemValue + iReverseValue)/2;
}
return iItemValue;
}