Hooks
static bool BeforeCvReligionAI_ChooseBonusBelief(CvReligionAI* self, PlayerTypes ePlayer, ReligionTypes eReligion, int iExcludeBelief1, int iExcludeBelief2, int iExcludeBelief3, BeliefTypes& result);static void AfterCvReligionAI_ChooseBonusBelief(CvReligionAI* self, PlayerTypes ePlayer, ReligionTypes eReligion, int iExcludeBelief1, int iExcludeBelief2, int iExcludeBelief3, BeliefTypes& result);static BeliefTypes ReplaceCvReligionAI_ChooseBonusBelief(BeliefTypes (*original)(CvReligionAI*, PlayerTypes, ReligionTypes, int, int, int), CvReligionAI* self, PlayerTypes ePlayer, ReligionTypes eReligion, int iExcludeBelief1, int iExcludeBelief2, int iExcludeBelief3);CivRegisterBefore<CivHooks::CvReligionAI_ChooseBonusBelief>(host, &BeforeCvReligionAI_ChooseBonusBelief);CivRegisterAfter<CivHooks::CvReligionAI_ChooseBonusBelief>(host, &AfterCvReligionAI_ChooseBonusBelief);CivRegisterReplace<CivHooks::CvReligionAI_ChooseBonusBelief>(host, &ReplaceCvReligionAI_ChooseBonusBelief);
Code
5240/// Select the belief most helpful to enhance this religion5241#if defined(MOD_EVENTS_ACQUIRE_BELIEFS)5242BeliefTypes CvReligionAI::ChooseBonusBelief(PlayerTypes ePlayer, ReligionTypes eReligion, int iExcludeBelief1, int iExcludeBelief2, int iExcludeBelief3)5243#else5244BeliefTypes CvReligionAI::ChooseBonusBelief(int iExcludeBelief1, int iExcludeBelief2, int iExcludeBelief3)5245#endif5246{5247 CvGameReligions* pGameReligions = GC.getGame().GetGameReligions();5248 CvWeightedVector<BeliefTypes, SAFE_ESTIMATE_NUM_BELIEFS, true> beliefChoices;52495250#if defined(MOD_EVENTS_ACQUIRE_BELIEFS)5251 std::vector<BeliefTypes> availableBeliefs = pGameReligions->GetAvailableBonusBeliefs(ePlayer, eReligion);5252#else5253 std::vector<BeliefTypes> availableBeliefs = pGameReligions->GetAvailableBonusBeliefs();5254#endif52555256 for(std::vector<BeliefTypes>::iterator it = availableBeliefs.begin();5257 it!= availableBeliefs.end(); ++it)5258 {5259 const BeliefTypes eBelief = (*it);5260 CvBeliefEntry* pEntry = m_pBeliefs->GetEntry(eBelief);5261 if(pEntry)5262 {5263 if (pEntry->GetID() != iExcludeBelief1 && pEntry->GetID() != iExcludeBelief2 && pEntry->GetID() != iExcludeBelief3)5264 {5265 const int iScore = ScoreBelief(pEntry);5266#if !defined(MOD_BUGFIX_MINOR)5267 if(iScore > 0)5268 {5269#endif5270 beliefChoices.push_back(eBelief, iScore);5271#if !defined(MOD_BUGFIX_MINOR)5272 }5273#endif5274 }5275 }5276 }52775278 // Choose from weighted vector5279 beliefChoices.SortItems();5280 int iNumChoices = MIN(beliefChoices.size(),3); // this was way too loose as choices way down were being selected now only top 35281 RandomNumberDelegate fcn = MakeDelegate(&GC.getGame(), &CvGame::getJonRandNum);5282 BeliefTypes rtnValue = beliefChoices.ChooseFromTopChoices(iNumChoices, &fcn, "Choosing belief from Top Choices");5283 LogBeliefChoices(beliefChoices, rtnValue);52845285 return rtnValue;5286}