CvReligionAI::ScoreCityForMissionary(CvCity *, UnitHandle)
- Defined in
- CvReligionClasses.cpp, line 6722
- Class
- CvReligionAI
- Hook name
CivHooks::CvReligionAI_ScoreCityForMissionary
Hooks
static bool BeforeCvReligionAI_ScoreCityForMissionary(CvReligionAI* self, CvCity* pCity, UnitHandle pUnit, int& result);static void AfterCvReligionAI_ScoreCityForMissionary(CvReligionAI* self, CvCity* pCity, UnitHandle pUnit, int& result);static int ReplaceCvReligionAI_ScoreCityForMissionary(int (*original)(CvReligionAI*, CvCity*, UnitHandle), CvReligionAI* self, CvCity* pCity, UnitHandle pUnit);CivRegisterBefore<CivHooks::CvReligionAI_ScoreCityForMissionary>(host, &BeforeCvReligionAI_ScoreCityForMissionary);CivRegisterAfter<CivHooks::CvReligionAI_ScoreCityForMissionary>(host, &AfterCvReligionAI_ScoreCityForMissionary);CivRegisterReplace<CivHooks::CvReligionAI_ScoreCityForMissionary>(host, &ReplaceCvReligionAI_ScoreCityForMissionary);
Code
6721/// AI's evaluation of this city as a target for a missionary6722int CvReligionAI::ScoreCityForMissionary(CvCity* pCity, UnitHandle pUnit)6723{6724 int iScore = 0;6725 ReligionTypes eMyReligion = GetReligionToSpread();6726 6727#if defined(MOD_RELIGION_LOCAL_RELIGIONS)6728 if (MOD_RELIGION_LOCAL_RELIGIONS && GC.getReligionInfo(eMyReligion)->IsLocalReligion()) {6729 if (pCity->getOwner() != pUnit->getOwner()) {6730 return iScore;6731 }67326733 if (pCity->IsOccupied() || pCity->IsPuppet()) {6734 return iScore;6735 }6736 }6737#endif67386739 // Skip if not revealed6740 if(!pCity->plot()->isRevealed(m_pPlayer->getTeam()))6741 {6742 return iScore;6743 }67446745 // Skip if already our religion6746 if(pCity->GetCityReligions()->GetReligiousMajority() == eMyReligion)6747 {6748 return iScore;6749 }67506751 // Base score based on if we are establishing majority6752 iScore = 100;6753 if(ShouldBecomeNewMajority(pCity, eMyReligion, pUnit->GetReligionData()->GetReligiousStrength() * GC.getRELIGION_MISSIONARY_PRESSURE_MULTIPLIER()))6754 {6755 iScore *= 2;6756 }67576758 if (!GET_PLAYER(pCity->getOwner()).isMinorCiv())6759 {6760 if (m_pPlayer->GetDiplomacyAI()->IsPlayerAgreeNotToConvert(pCity->getOwner()))6761 {6762 return 0;6763 }6764 }67656766 CvPlayer& kCityPlayer = GET_PLAYER(pCity->getOwner());6767 // Much better score if our own city or if this city owner isn't starting a religion6768 if(pCity->getOwner() == m_pPlayer->GetID())6769 {6770 iScore *= 5;6771 }6772 else if(!kCityPlayer.GetReligions()->HasCreatedReligion())6773 {6774 iScore *= 3;6775 }67766777 // Then subtract distance6778 iScore -= plotDistance(pUnit->getX(), pUnit->getY(), pCity->getX(), pCity->getY());67796780 // Multiplier by how safe it is6781 if(!atWar(m_pPlayer->getTeam(), kCityPlayer.getTeam()))6782 {6783 iScore *= 2;6784 }67856786 // Holy city will anger folks, let's not do that one right away6787 ReligionTypes eCityOwnersReligion = kCityPlayer.GetReligions()->GetReligionCreatedByPlayer();6788 if (eCityOwnersReligion > RELIGION_PANTHEON && pCity->GetCityReligions()->IsHolyCityForReligion(eCityOwnersReligion))6789 {6790 iScore /= 2;6791 }67926793 return iScore;6794}
Calls
- atWar(TeamTypes, TeamTypes)
- CustomMods::isRELIGION_LOCAL_RELIGIONS()
- CvCity::GetCityReligions() const
- CvCity::getOwner() const
- CvCity::getX() const
- CvCity::getY() const
- CvCity::IsOccupied() const
- CvCity::IsPuppet() const
- CvCity::plot() const
- CvCityReligions::GetReligiousMajority()
- CvCityReligions::IsHolyCityForReligion(ReligionTypes)
- CvDiplomacyAI::IsPlayerAgreeNotToConvert(PlayerTypes)
- CvGlobals::getRELIGION_MISSIONARY_PRESSURE_MULTIPLIER()
- CvGlobals::getReligionInfo(ReligionTypes)
- CvPlayer::GetDiplomacyAI() const
- CvPlayer::GetID() const
- CvPlayer::GetReligions() const
- CvPlayer::getTeam() const
- CvPlayer::isMinorCiv() const
- CvPlayerAI::getPlayer(PlayerTypes)
- CvPlayerReligions::GetReligionCreatedByPlayer(bool) const
- CvPlayerReligions::HasCreatedReligion(bool) const
- CvPlot::isRevealed(TeamTypes) const
- CvReligionAI::GetReligionToSpread() const
- CvReligionAI::ShouldBecomeNewMajority(CvCity *, ReligionTypes, int) const
- CvReligionEntry::IsLocalReligion() const
- CvUnit::getOwner() const
- CvUnit::GetReligionData() const
- CvUnit::getX() const
- CvUnit::getY() const
- CvUnitReligion::GetReligiousStrength() const
FObjectHandle::operator->- plotDistance(int, int, int, int)