CvReligionAI::GetDesiredFaithGreatPerson() const
- Defined in
- CvReligionClasses.cpp, line 7060
- Class
- CvReligionAI
- Hook name
CivHooks::CvReligionAI_GetDesiredFaithGreatPerson
Hooks
static bool BeforeCvReligionAI_GetDesiredFaithGreatPerson(const CvReligionAI* self, UnitTypes& result);static void AfterCvReligionAI_GetDesiredFaithGreatPerson(const CvReligionAI* self, UnitTypes& result);static UnitTypes ReplaceCvReligionAI_GetDesiredFaithGreatPerson(UnitTypes (*original)(const CvReligionAI*), const CvReligionAI* self);CivRegisterBefore<CivHooks::CvReligionAI_GetDesiredFaithGreatPerson>(host, &BeforeCvReligionAI_GetDesiredFaithGreatPerson);CivRegisterAfter<CivHooks::CvReligionAI_GetDesiredFaithGreatPerson>(host, &AfterCvReligionAI_GetDesiredFaithGreatPerson);CivRegisterReplace<CivHooks::CvReligionAI_GetDesiredFaithGreatPerson>(host, &ReplaceCvReligionAI_GetDesiredFaithGreatPerson);
Code
7059/// Which Great Person should we buy with Faith?7060UnitTypes CvReligionAI::GetDesiredFaithGreatPerson() const7061{7062 SpecialUnitTypes eSpecialUnitGreatPerson = (SpecialUnitTypes) GC.getInfoTypeForString("SPECIALUNIT_PEOPLE");7063 UnitTypes eRtnValue = NO_UNIT;7064 int iBestScore = 0;7065 ReligionTypes eReligion = GetReligionToSpread();70667067 // Loop through all Units and see if they're possible7068 for(int iUnitLoop = 0; iUnitLoop < GC.getNumUnitInfos(); iUnitLoop++)7069 {7070 const UnitTypes eUnit = static_cast<UnitTypes>(iUnitLoop);7071 CvUnitEntry* pkUnitInfo = GC.getUnitInfo(eUnit);70727073 if(pkUnitInfo == NULL)7074 continue;70757076 UnitClassTypes eUnitClass = (UnitClassTypes)pkUnitInfo->GetUnitClassType();70777078 // Can't be able to train it7079 if(pkUnitInfo->GetProductionCost() != -1)7080 {7081 continue;7082 }70837084 // Must be a Great Person (defined in SpecialUnitType in Unit XML)7085 if(pkUnitInfo->GetSpecialUnitType() != eSpecialUnitGreatPerson)7086 {7087 continue;7088 }70897090 // Must be a Great Person for this player's civ7091 if(!m_pPlayer->canTrain(eUnit, false /*bContinue*/, false /*bTestVisible*/, true /*bIgnoreCost*/))7092 {7093 continue;7094 }70957096 // Can we purchase this one in the capital?7097 CvCity *pCapital = m_pPlayer->getCapitalCity();7098 if (pCapital)7099 {7100 if (pCapital->IsCanPurchase(false/*bTestPurchaseCost*/, false/*bTestTrainable*/, eUnit, NO_BUILDING, NO_PROJECT, YIELD_FAITH))7101 {7102 int iScore = 0;7103 AIGrandStrategyTypes eVictoryStrategy = m_pPlayer->GetGrandStrategyAI()->GetActiveGrandStrategy();71047105 // Score it7106 if (eUnitClass == GC.getInfoTypeForString("UNITCLASS_PROPHET"))7107 {7108 if (GetReligionToSpread() > RELIGION_PANTHEON)7109 {7110 if (ChooseProphetConversionCity(true/*bOnlyBetterThanEnhancingReligion*/))7111 {7112 iScore = 1500;7113 }7114 else if (ChooseProphetConversionCity(false/*bOnlyBetterThanEnhancingReligion*/))7115 {7116 iScore = 750;7117 }7118#if defined(MOD_GLOBAL_TRULY_FREE_GP)7119 iScore /= (1+ m_pPlayer->GetReligions()->GetNumProphetsSpawned(false));7120#else7121 iScore /= (1+ m_pPlayer->GetReligions()->GetNumProphetsSpawned());7122#endif7123 }7124 }7125 else if (eUnitClass == GC.getInfoTypeForString("UNITCLASS_WRITER"))7126 {7127 if (eVictoryStrategy == (AIGrandStrategyTypes) GC.getInfoTypeForString("AIGRANDSTRATEGY_CULTURE"))7128 {7129 iScore = 1000;7130 }7131 else7132 {7133 iScore = 400;7134 }7135 iScore /= (1+ m_pPlayer->getWritersFromFaith());7136 }7137 else if (eUnitClass == GC.getInfoTypeForString("UNITCLASS_ARTIST"))7138 {7139 if (eVictoryStrategy == (AIGrandStrategyTypes) GC.getInfoTypeForString("AIGRANDSTRATEGY_CULTURE"))7140 {7141 iScore = 1000;7142 }7143 else7144 {7145 iScore = 400;7146 }7147 iScore /= (1+ m_pPlayer->getArtistsFromFaith());7148 }7149 else if (eUnitClass == GC.getInfoTypeForString("UNITCLASS_MUSICIAN"))7150 {7151 if (eVictoryStrategy == (AIGrandStrategyTypes) GC.getInfoTypeForString("AIGRANDSTRATEGY_CULTURE"))7152 {7153 iScore = 1000;7154 }7155 else7156 {7157 iScore = 400;7158 }7159 iScore /= (1+ m_pPlayer->getMusiciansFromFaith());7160 }7161 else if (eUnitClass == GC.getInfoTypeForString("UNITCLASS_SCIENTIST"))7162 {7163 if (eVictoryStrategy == (AIGrandStrategyTypes) GC.getInfoTypeForString("AIGRANDSTRATEGY_SPACESHIP"))7164 {7165 iScore = 1000;7166 }7167 else7168 {7169 iScore = 400;7170 }7171 iScore = 1000;7172 iScore /= (1+ m_pPlayer->getScientistsFromFaith());7173 }7174 else if (eUnitClass == GC.getInfoTypeForString("UNITCLASS_MERCHANT"))7175 {7176 if (eVictoryStrategy == (AIGrandStrategyTypes) GC.getInfoTypeForString("AIGRANDSTRATEGY_UNITED_NATIONS"))7177 {7178 iScore = 1000;7179 }7180 else7181 {7182 iScore = 400;7183 }7184 iScore /= (1+ m_pPlayer->getMerchantsFromFaith());7185 }7186 else if (eUnitClass == GC.getInfoTypeForString("UNITCLASS_ENGINEER"))7187 {7188 EconomicAIStrategyTypes eStrategy = (EconomicAIStrategyTypes) GC.getInfoTypeForString("ECONOMICAISTRATEGY_GS_SPACESHIP_HOMESTRETCH");7189 if (eStrategy != NO_ECONOMICAISTRATEGY && m_pPlayer->GetEconomicAI()->IsUsingStrategy(eStrategy))7190 {7191 iScore = 2000;7192 }7193 else7194 {7195 iScore = 500;7196 }7197 iScore /= (1+ m_pPlayer->getEngineersFromFaith());7198 }7199 else if (eUnitClass == GC.getInfoTypeForString("UNITCLASS_GREAT_GENERAL"))7200 {7201 if (eVictoryStrategy == (AIGrandStrategyTypes) GC.getInfoTypeForString("AIGRANDSTRATEGY_CONQUEST")&& !(GC.getMap().GetAIMapHint() & 1))7202 {7203 iScore = 1000;7204 }7205 else7206 {7207 iScore = 400;7208 }7209 iScore /= (1+ m_pPlayer->getGeneralsFromFaith() + m_pPlayer->GetNumUnitsWithUnitAI(UNITAI_GENERAL));7210 }7211 else if (eUnitClass == GC.getInfoTypeForString("UNITCLASS_GREAT_ADMIRAL"))7212 {7213 if (eVictoryStrategy == (AIGrandStrategyTypes) GC.getInfoTypeForString("AIGRANDSTRATEGY_CONQUEST") && GC.getMap().GetAIMapHint() & 1)7214 {7215 iScore = 1000;7216 }7217 else7218 {7219 iScore = 400;7220 }7221 iScore /= (1+ m_pPlayer->getAdmiralsFromFaith() + m_pPlayer->GetNumUnitsWithUnitAI(UNITAI_ADMIRAL));7222 }7223 else if (eUnitClass == GC.getInfoTypeForString("UNITCLASS_MISSIONARY"))7224 {7225 if (HaveNearbyConversionTarget(eReligion, false /*bCanIncludeReligionStarter*/))7226 {7227 iScore = 1000 / (m_pPlayer->GetNumUnitsWithUnitAI(UNITAI_MISSIONARY) + 1); 7228 }7229 }7230 else if (eUnitClass == GC.getInfoTypeForString("UNITCLASS_INQUISITOR"))7231 {7232 if (HaveEnoughInquisitors(eReligion))7233 {7234 iScore = 1000 / (m_pPlayer->GetNumUnitsWithUnitAI(UNITAI_INQUISITOR) + 1);7235 }7236 }72377238 if (iScore > iBestScore)7239 {7240 iBestScore = iScore;7241 eRtnValue = eUnit;7242 }7243 }7244 }7245 }72467247 return eRtnValue;7248}
Calls
- CvCity::IsCanPurchase(bool, bool, UnitTypes, BuildingTypes, ProjectTypes, YieldTypes)
- CvEconomicAI::IsUsingStrategy(EconomicAIStrategyTypes)
- CvGlobals::getInfoTypeForString(const char *, bool) const
- CvGlobals::getMap()
- CvGlobals::getNumUnitInfos()
- CvGlobals::getUnitInfo(UnitTypes)
- CvGrandStrategyAI::GetActiveGrandStrategy() const
- CvMap::GetAIMapHint()
- CvPlayer::canTrain(UnitTypes, bool, bool, bool, bool, CvString *) const
- CvPlayer::getAdmiralsFromFaith() const
- CvPlayer::getArtistsFromFaith() const
- CvPlayer::getCapitalCity()
- CvPlayer::GetEconomicAI() const
- CvPlayer::getEngineersFromFaith() const
- CvPlayer::getGeneralsFromFaith() const
- CvPlayer::GetGrandStrategyAI() const
- CvPlayer::getMerchantsFromFaith() const
- CvPlayer::getMusiciansFromFaith() const
- CvPlayer::GetNumUnitsWithUnitAI(UnitAITypes, bool, bool)
- CvPlayer::GetReligions() const
- CvPlayer::getScientistsFromFaith() const
- CvPlayer::getWritersFromFaith() const
- CvPlayerReligions::GetNumProphetsSpawned(bool) const
- CvReligionAI::ChooseProphetConversionCity(bool) const
- CvReligionAI::GetReligionToSpread() const
- CvReligionAI::HaveEnoughInquisitors(ReligionTypes) const
- CvReligionAI::HaveNearbyConversionTarget(ReligionTypes, bool) const
- CvUnitEntry::GetProductionCost() const
- CvUnitEntry::GetSpecialUnitType() const
- CvUnitEntry::GetUnitClassType() const