int CvDiplomacyAI::GetReligionScore(PlayerTypes ePlayer)
{
if (GC.getGame().isOption(GAMEOPTION_NO_RELIGION))
return 0;
if (IsVassal(ePlayer))
return 0; // Vassals have their own function for this
int iOpinionWeight = 0;
ReligionTypes eOurOwnedReligion = GetPlayer()->GetReligions()->GetOwnedReligion();
ReligionTypes eOurStateReligion = GetPlayer()->GetReligions()->GetStateReligion(false);
ReligionTypes eTheirOwnedReligion = GET_PLAYER(ePlayer).GetReligions()->GetOwnedReligion();
ReligionTypes eTheirStateReligion = GET_PLAYER(ePlayer).GetReligions()->GetStateReligion(false);
int iFlavorReligion = m_pPlayer->GetFlavorManager()->GetPersonalityFlavorForDiplomacy((FlavorTypes)GC.getInfoTypeForString("FLAVOR_RELIGION"));
int iEraMod = GC.getEraInfo(GC.getGame().getCurrentEra())->getDiploEmphasisReligion();
// Weight increases or decreases based on flavors
if (iFlavorReligion < 5)
{
iEraMod = max(0, iEraMod - 1);
}
else if (iFlavorReligion > 7)
{
iEraMod++;
}
iEraMod += GetPlayer()->GetPlayerTraits()->IsReligious() ? 1 : 0;
// We didn't found or conquer, but have a state religion
if (eOurOwnedReligion == NO_RELIGION && eOurStateReligion != NO_RELIGION)
{
if (GetNegativeReligiousConversionPoints(ePlayer) <= 0 && !IsHolyCityCapturedBy(ePlayer))
{
if (eOurStateReligion == eTheirOwnedReligion)
{
iOpinionWeight = /*-4*/ GD_INT_GET(OPINION_WEIGHT_ADOPTING_HIS_RELIGION) * iEraMod;
// If it's the World Religion and they're its controller, support them since we get extra League votes from it
if (GC.getGame().GetGameLeagues()->GetReligionSpreadStrengthModifier(ePlayer, eTheirOwnedReligion) > 0)
{
iOpinionWeight *= /*150*/ GD_INT_GET(OPINION_WEIGHT_WORLD_RELIGION_MODIFIER);
iOpinionWeight /= 100;
}
}
// Same state religions?
else if (eOurStateReligion == eTheirStateReligion)
{
iOpinionWeight = /*-2*/ GD_INT_GET(OPINION_WEIGHT_SAME_STATE_RELIGIONS) * iEraMod;
}
}
// Different majority religions?
if (eOurStateReligion != eTheirStateReligion && eTheirStateReligion != NO_RELIGION)
{
iOpinionWeight = /*2*/ GD_INT_GET(OPINION_WEIGHT_DIFFERENT_OWNED_RELIGIONS) * iEraMod;
}
}
// We founded or conquered
else if (eOurOwnedReligion != NO_RELIGION)
{
// Did they also found or conquer? We don't like that!
if (eTheirOwnedReligion != NO_RELIGION)
{
iOpinionWeight = /*5*/ GD_INT_GET(OPINION_WEIGHT_DIFFERENT_OWNED_RELIGIONS) * iEraMod;
// If it's the World Religion and they control its Holy City, we should work against them
if (GC.getGame().GetGameLeagues()->GetReligionSpreadStrengthModifier(ePlayer, eTheirOwnedReligion) > 0)
{
iOpinionWeight *= /*150*/ GD_INT_GET(OPINION_WEIGHT_WORLD_RELIGION_MODIFIER);
iOpinionWeight /= 100;
}
}
// No? Well, do they have a state religion?
else if (eTheirStateReligion != NO_RELIGION)
{
// Ours?
if (eTheirStateReligion == eOurOwnedReligion)
{
iOpinionWeight = /*-8*/ GD_INT_GET(OPINION_WEIGHT_ADOPTING_MY_RELIGION) * iEraMod;
// If it's the World Religion and we control its Holy City, we should work together
if (GC.getGame().GetGameLeagues()->GetReligionSpreadStrengthModifier(GetID(), eOurOwnedReligion) > 0)
{
iOpinionWeight *= /*150*/ GD_INT_GET(OPINION_WEIGHT_WORLD_RELIGION_MODIFIER);
iOpinionWeight /= 100;
}
}
// Someone else's?
else
{
const CvReligion* pReligion = GC.getGame().GetGameReligions()->GetReligion(eTheirStateReligion, NO_PLAYER);
if (!pReligion)
return 0;
// If the religion's founder is our teammate, don't apply a penalty if that teammate is still alive.
if (IsTeammate((PlayerTypes)pReligion->m_eFounder) && GET_PLAYER((PlayerTypes)pReligion->m_eFounder).getNumCities() > 0)
return 0;
// If the religion's founder is THEIR teammate, treat it like a state religion.
if (GET_PLAYER(ePlayer).GetDiplomacyAI()->IsTeammate((PlayerTypes)pReligion->m_eFounder) && GET_PLAYER((PlayerTypes)pReligion->m_eFounder).getNumCities() > 0)
{
iOpinionWeight = /*5*/ GD_INT_GET(OPINION_WEIGHT_DIFFERENT_OWNED_RELIGIONS) * iEraMod;
// If it's the World Religion and their teammate controls its Holy City, we should work against them
if (GC.getGame().GetGameLeagues()->GetReligionSpreadStrengthModifier((PlayerTypes)pReligion->m_eFounder, eTheirStateReligion) > 0)
{
iOpinionWeight *= /*150*/ GD_INT_GET(OPINION_WEIGHT_WORLD_RELIGION_MODIFIER);
iOpinionWeight /= 100;
}
}
// Otherwise, apply a penalty for different majority religions.
else
{
iOpinionWeight = /*2*/ GD_INT_GET(OPINION_WEIGHT_DIFFERENT_OWNED_RELIGIONS) * iEraMod;
}
}
}
}
if (iOpinionWeight > 0 && IsIgnoreReligionDifferences(ePlayer))
return 0;
return iOpinionWeight;
}
/// Should we ignore religious differences with ePlayer?
bool CvDiplomacyAI::IsIgnoreReligionDifferences(PlayerTypes ePlayer) const
{
if (!GetPlayer()->isMajorCiv() || !GET_PLAYER(ePlayer).isMajorCiv())
return true;
if (IsTeammate(ePlayer) || IsMaster(ePlayer))
return true;
if (GetNegativeReligiousConversionPoints(ePlayer) > 0)
return false;
if (IsHolyCityCapturedBy(ePlayer))
return false;
// Capital captured? Exception if they resurrected us: only test to see if they captured it.
if (WasResurrectedBy(ePlayer))
{
vector<PlayerTypes> vTheirTeam = GET_TEAM(GET_PLAYER(ePlayer).getTeam()).getPlayers();
for (size_t i=0; i<vTheirTeam.size(); i++)
{
if (!GET_PLAYER(vTheirTeam[i]).isMajorCiv())
continue;
if (IsPlayerCapturedCapital(vTheirTeam[i]))
return false;
}
}
else
{
if (IsCapitalCapturedBy(ePlayer))
return false;
}
// Special diplomatic behavior for Celts - no natural religion spread
if (!HasEverConvertedCity(ePlayer) && !GET_PLAYER(ePlayer).GetDiplomacyAI()->HasEverConvertedCity(GetID()))
{
if (GetPlayer()->GetPlayerTraits()->IsNoNaturalReligionSpread())
return true;
if (GET_PLAYER(ePlayer).GetPlayerTraits()->IsNoNaturalReligionSpread())
return true;
}
if (IsAtWar(ePlayer) || IsUntrustworthy(ePlayer))
return false;
// Ideological buddies tolerate religious differences.
if (IsPlayerSameIdeology(ePlayer))
return true;
if (IsPlayerLiberatedCapital(ePlayer) || IsPlayerLiberatedHolyCity(ePlayer) || IsPlayerReturnedCapital(ePlayer) || IsPlayerReturnedHolyCity(ePlayer) || WasResurrectedBy(ePlayer) || GetDoFType(ePlayer) == DOF_TYPE_BATTLE_BROTHERS)
return true;
if (IsCityRecentlyLiberatedBy(ePlayer))
return true;
// If they're helping us go to war, we'll set aside our differences for now.
if (GetCoopWarScore(ePlayer) > 1 || GetGlobalCoopWarWithState(ePlayer) >= COOP_WAR_STATE_PREPARING)
return true;
return false;
}