xienwolf
Deity
Well, the math is wrong anyway. Those calculations are a diminishing 20% of 20%. The actual odds would be a diminishing 20% of 80%, thus the chain would be 20%, 16%, 12.8%, 10.24%, 8.192%, 6.5536%, 5.24288%. Thus total odds of getting any religion at all in a city with all religions present would be 79.02848%.
EDIT: Also noticed while re-writting the function that I was incorrect when I evaluated it before. It is not the FIRST religion listed in the XML which is most likely, it is the LAST listed religion. And the above numbers are not accurate either, slightly.
The reason is that the function does not break when a religion is given to the unit. Thus the unit can actually gain EVERY religion in the city, but each one overwrites the previous one. Thus the 20% isn't applied to a diminishing 80%, it is applied repeatedly to the full 100%. If you win on the final "roll" then you adopt the final listed religion. So for that one it is really a flat 20% chance. For the religion just before that one it is a 20% chance, but then you have to subtract the intersecting set which also wins on the next roll (so 20% of the 20% won't make it, so your result will be 16%... Hrm... Sounds like the above numbers might be valid then, just not for the stated reasoning. Not enough time to run through the rest of the numbers right not, and it no longer applies to me anyway )
If any other Modders (or Kael) would like my new function here it is:
EDIT: Also noticed while re-writting the function that I was incorrect when I evaluated it before. It is not the FIRST religion listed in the XML which is most likely, it is the LAST listed religion. And the above numbers are not accurate either, slightly.
The reason is that the function does not break when a religion is given to the unit. Thus the unit can actually gain EVERY religion in the city, but each one overwrites the previous one. Thus the 20% isn't applied to a diminishing 80%, it is applied repeatedly to the full 100%. If you win on the final "roll" then you adopt the final listed religion. So for that one it is really a flat 20% chance. For the religion just before that one it is a 20% chance, but then you have to subtract the intersecting set which also wins on the next roll (so 20% of the 20% won't make it, so your result will be 16%... Hrm... Sounds like the above numbers might be valid then, just not for the stated reasoning. Not enough time to run through the rest of the numbers right not, and it no longer applies to me anyway )
If any other Modders (or Kael) would like my new function here it is:
Spoiler Code Revision :
To break it down in English first: If you are Agnostic, none of your units will gain a religion. Otherwise, each unit has the Global Define "RELIGION_ADOPTION_CHANCE" (currently 20%, I am wondering if it ought to be increased however to 40%) to gain your state religion. If this check fails, then they have the same chance to gain any religion present in the city (which quite likely includes your state religion). If they succeed on the check for a religion from those present in the city, one is selected at random from the lists).
Code:
/*************************************************************************************************/
/** Xienwolf Tweak 09/06/08 Xienwolf **/
/** **/
/** Grants a level playing field for adoption of religions **/
/*************************************************************************************************/
/** ---- Start Original Code ---- **
for (int iI = 0; iI < GC.getNumReligionInfos(); iI++)
{
if (isHasReligion((ReligionTypes)iI))
{
if (pUnit->getReligion() == NO_RELIGION)
{
if (GC.getGameINLINE().getSorenRandNum(100, "Religion Adoption") <= GC.getDefineINT("RELIGION_ADOPTION_CHANCE"))
{
pUnit->setReligion(iI);
}
}
}
}
/** ---- End Original Code ---- **/
if (pUnit->getReligion() == NO_RELIGION && !GET_PLAYER(getOwnerINLINE()).isAgnostic())
{
if ((GET_PLAYER(getOwnerINLINE()).getStateReligion() != NO_RELIGION) && (GC.getGameINLINE().getSorenRandNum(100, "Religion Adoption") <= GC.getDefineINT("RELIGION_ADOPTION_CHANCE")))
pUnit->setReligion(GET_PLAYER(getOwnerINLINE()).getStateReligion());
if (pUnit->getReligion() == NO_RELIGION)
{
if (GC.getGameINLINE().getSorenRandNum(100, "Religion Adoption") <= GC.getDefineINT("RELIGION_ADOPTION_CHANCE"))
{
int iRel = GC.getGameINLINE().getSorenRandNum(getReligionCount(), "Religion Adoption");
iCount = 0;
for (int iI = 0; iI < GC.getNumReligionInfos(); iI++)
{
if (isHasReligion((ReligionTypes)iI))
{
if (iCount == iRel)
pUnit->setReligion(iI);
iCount++;
}
}
}
}
}
/*************************************************************************************************/
/** Xienwolf Tweak END **/
/*************************************************************************************************/