r_rolo1
King of myself
The function is in the dll and it is called doReligion IIRC.
Edit: it is CvGame::doHolyCity ....
Edit: it is CvGame::doHolyCity ....
Code:
void CvGame::doHolyCity()
{
PlayerTypes eBestPlayer;
TeamTypes eBestTeam;
long lResult;
int iValue;
int iBestValue;
int iI, iJ, iK;
lResult = 0;
gDLL->getPythonIFace()->callFunction(PYGameModule, "doHolyCity", NULL, &lResult);
if (lResult == 1)
{
return;
}
if (getElapsedGameTurns() < 5 && !isOption(GAMEOPTION_ADVANCED_START))
{
return;
}
int iRandOffset = getSorenRandNum(GC.getNumReligionInfos(), "Holy City religion offset");
for (int iLoop = 0; iLoop < GC.getNumReligionInfos(); ++iLoop)
{
iI = ((iLoop + iRandOffset) % GC.getNumReligionInfos());
if (!isReligionSlotTaken((ReligionTypes)iI))
{
iBestValue = MAX_INT;
eBestTeam = NO_TEAM;
for (iJ = 0; iJ < MAX_TEAMS; iJ++)
{
if (GET_TEAM((TeamTypes)iJ).isAlive())
{
if (GET_TEAM((TeamTypes)iJ).isHasTech((TechTypes)(GC.getReligionInfo((ReligionTypes)iI).getTechPrereq())))
{
if (GET_TEAM((TeamTypes)iJ).getNumCities() > 0)
{
iValue = getSorenRandNum(10, "Found Religion (Team)");
for (iK = 0; iK < GC.getNumReligionInfos(); iK++)
{
int iReligionCount = GET_TEAM((TeamTypes)iJ).getHasReligionCount((ReligionTypes)iK);
if (iReligionCount > 0)
{
iValue += iReligionCount * 20;
}
}
if (iValue < iBestValue)
{
iBestValue = iValue;
eBestTeam = ((TeamTypes)iJ);
}
}
}
}
}
if (eBestTeam != NO_TEAM)
{
iBestValue = MAX_INT;
eBestPlayer = NO_PLAYER;
for (iJ = 0; iJ < MAX_PLAYERS; iJ++)
{
if (GET_PLAYER((PlayerTypes)iJ).isAlive())
{
if (GET_PLAYER((PlayerTypes)iJ).getTeam() == eBestTeam)
{
if (GET_PLAYER((PlayerTypes)iJ).getNumCities() > 0)
{
iValue = getSorenRandNum(10, "Found Religion (Player)");
if (!(GET_PLAYER((PlayerTypes)iJ).isHuman()))
{
iValue += 10;
}
for (iK = 0; iK < GC.getNumReligionInfos(); iK++)
{
int iReligionCount = GET_PLAYER((PlayerTypes)iJ).getHasReligionCount((ReligionTypes)iK);
if (iReligionCount > 0)
{
iValue += iReligionCount * 20;
}
}
if (iValue < iBestValue)
{
iBestValue = iValue;
eBestPlayer = ((PlayerTypes)iJ);
}
}
}
}
}
if (eBestPlayer != NO_PLAYER)
{
ReligionTypes eReligion = (ReligionTypes)iI;
if (isOption(GAMEOPTION_PICK_RELIGION))
{
eReligion = GET_PLAYER(eBestPlayer).AI_chooseReligion();
}
if (NO_RELIGION != eReligion)
{
GET_PLAYER(eBestPlayer).foundReligion(eReligion, (ReligionTypes)iI, false);
}
}
}
}
}
}





