Bazaar developer reference

CvReligionAI::ChoosePantheonBelief(PlayerTypes)

Defined in
CvReligionClasses.cpp, line 5062
Class
CvReligionAI
Hook name
CivHooks::CvReligionAI_ChoosePantheonBelief

Hooks

static bool BeforeCvReligionAI_ChoosePantheonBelief(CvReligionAI* self, PlayerTypes ePlayer, BeliefTypes& result);static void AfterCvReligionAI_ChoosePantheonBelief(CvReligionAI* self, PlayerTypes ePlayer, BeliefTypes& result);static BeliefTypes ReplaceCvReligionAI_ChoosePantheonBelief(BeliefTypes (*original)(CvReligionAI*, PlayerTypes), CvReligionAI* self, PlayerTypes ePlayer);CivRegisterBefore<CivHooks::CvReligionAI_ChoosePantheonBelief>(host, &BeforeCvReligionAI_ChoosePantheonBelief);CivRegisterAfter<CivHooks::CvReligionAI_ChoosePantheonBelief>(host, &AfterCvReligionAI_ChoosePantheonBelief);CivRegisterReplace<CivHooks::CvReligionAI_ChoosePantheonBelief>(host, &ReplaceCvReligionAI_ChoosePantheonBelief);

Code

5060/// Select the belief most helpful to this pantheon5061#if defined(MOD_EVENTS_ACQUIRE_BELIEFS)5062BeliefTypes CvReligionAI::ChoosePantheonBelief(PlayerTypes ePlayer)5063#else5064BeliefTypes CvReligionAI::ChoosePantheonBelief()5065#endif5066{5067	CvGameReligions* pGameReligions = GC.getGame().GetGameReligions();5068	CvWeightedVector<BeliefTypes, SAFE_ESTIMATE_NUM_BELIEFS, true> beliefChoices;50695070#if defined(MOD_EVENTS_ACQUIRE_BELIEFS)5071	std::vector<BeliefTypes> availableBeliefs = pGameReligions->GetAvailablePantheonBeliefs(ePlayer);5072#else5073	std::vector<BeliefTypes> availableBeliefs = pGameReligions->GetAvailablePantheonBeliefs();5074#endif50755076	for(std::vector<BeliefTypes>::iterator it = availableBeliefs.begin();5077	        it!= availableBeliefs.end(); ++it)5078	{5079		const BeliefTypes eBelief = (*it);5080		CvBeliefEntry* pEntry = m_pBeliefs->GetEntry(eBelief);5081		if(pEntry)5082		{5083			const int iScore = ScoreBelief(pEntry);5084#if !defined(MOD_BUGFIX_MINOR)5085			if(iScore > 0)5086			{5087#endif5088				beliefChoices.push_back(eBelief, iScore);5089#if !defined(MOD_BUGFIX_MINOR)5090			}5091#endif5092		}5093	}50945095	// Choose from weighted vector5096	beliefChoices.SortItems();5097	int iNumChoices = MIN(beliefChoices.size(),3);   // Throw out two-thirds of the choices -- this was way too loose as choices way down were being selected now only top 35098	RandomNumberDelegate fcn = MakeDelegate(&GC.getGame(), &CvGame::getJonRandNum);5099	BeliefTypes rtnValue = beliefChoices.ChooseFromTopChoices(iNumChoices, &fcn, "Choosing belief from Top Choices");5100	LogBeliefChoices(beliefChoices, rtnValue);51015102	return rtnValue;5103}

Calls

Called by