Choosing my religion

Rob (R8XFT)

Ancient Briton
Retired Moderator
Joined
Aug 11, 2002
Messages
10,866
Location
Leeds (UK)
Is there any code/component anyone has done surrounding civs having a second or even third religion to choose from if their preference has already been taken? I ask this as my mod includes about 18 religions (including modded ones from Tomatekh). All the Greek civs are aligned to Hellenism. If, for example, Epirus founds a religion first and takes Hellenism, then if Athens is next to found a religion they choose a random one out of the others. This then has a domini effect; if they choose Pesedjet, and Egypt are next, they might choose Druidism, forcing the Gauls to opt for Hinduism.

I think you get the picture ;).

So I guess what I'm looking for is either a second choice or a way to make certain religions exclusive to certain civilizations.
 
The logic used to found a religion is
1) If my preferred religion is available, found that
2) Otherwise, found the first religion that can still be founded AND is not a preferred religion by a civ in the game
3) Otherwise, found the first religion that can still be founded

(where "first" is "lowest ID value")

So you could avoid some of the domino effect by leaving one or two religions as "spares"

Any other fix is going to need a patched DLL as all the AI religion choosing code is in C++

Edit: Easiest way would be to add a new GameEvent, so all the logic can be delegated to the modder, eg

Code:
function OnGetReligionToFound(iPlayer, iPreferredReligion, bIsAlreadyFounded)
  return iPreferredReligion
end
GameEvents.GetReligionToFound.Add(OnGetReligionToFound)
 
The logic used to found a religion is
1) If my preferred religion is available, found that
2) Otherwise, found the first religion that can still be founded AND is not a preferred religion by a civ in the game
3) Otherwise, found the first religion that can still be founded

(where "first" is "lowest ID value")

So you could avoid some of the domino effect by leaving one or two religions as "spares"

Any other fix is going to need a patched DLL as all the AI religion choosing code is in C++

Edit: Easiest way would be to add a new GameEvent, so all the logic can be delegated to the modder, eg

Code:
function OnGetReligionToFound(iPlayer, iPreferredReligion, bIsAlreadyFounded)
  return iPreferredReligion
end
GameEvents.GetReligionToFound.Add(OnGetReligionToFound)

Ah-ah!! Right, I think that for my capabilities, leaving a couple of religions as "spares" would be best; I'll use Christianity as one of them as it could fit a wide range of civs in the mod. Thanks again!
 
I've added the following GameEvents to my modded DLL (should be up on my site sometime over the weekend), they should give total control over religions

Spoiler :
Code:
-- Can this player found a pantheon?
-- Return false if the player can never found a pantheon
function OnPlayerCanFoundPantheon(iPlayer)
  print(string.format("Can player %i found a pantheon", iPlayer))
  return true
end
GameEvents.PlayerCanFoundPantheon.Add(OnPlayerCanFoundPantheon)

-- Can this player found a religion with this city becomming the Holy City?
-- Returning false will permit the Great Prophet to move to another city
function OnPlayerCanFoundReligion(iPlayer, iCity)
  print(string.format("Can player %i found a religion in city %i", iPlayer, iCity))
  return true
end
GameEvents.PlayerCanFoundReligion.Add(OnPlayerCanFoundReligion)

-- Get the religion for this player to found
function OnGetReligionToFound(iPlayer, iPreferredReligion, bIsAlreadyFounded)
  print(string.format("What religion shall we give to player %i (they would like %i)", iPlayer, iPreferredReligion))
  return iPreferredReligion
end
GameEvents.GetReligionToFound.Add(OnGetReligionToFound)

-- Notification that this player has founded a pantheon
function OnPantheonFounded(iPlayer, iCapitalCity, iReligion, iBelief)
  print(string.format("Player %i founded a pantheon with belief %i", iPlayer, iBelief))
end
GameEvents.PantheonFounded.Add(OnPantheonFounded)

-- Notification that this player has founded a religion
-- iBelief1 will be the pantheon belief
-- iBelief4 and iBelief5 will usually be -1, unless the religion was founded via Lua
function OnReligionFounded(iPlayer, iHolyCity, iReligion, iBelief1, iBelief2, iBelief3, iBelief4, iBelief5)
  print(string.format("Player %i founded religion %i with beliefs %i, %i, %i", iPlayer, iReligion, iBelief1, iBelief2, iBelief3))
end
GameEvents.ReligionFounded.Add(OnReligionFounded)

-- Notification that this player has enhanced a religion
function OnReligionEnhanced(iPlayer, iReligion, iBelief1, iBelief2)
  print(string.format("Player %i enhanced religion %i with beliefs %i and %i", iPlayer, iReligion, iBelief1, iBelief2))
end
GameEvents.ReligionEnhanced.Add(OnReligionEnhanced)

-- Can this player have this (pantheon) belief
function OnPlayerCanHaveBelief(iPlayer, iBelief)
  print(string.format("Can player %i have pantheon belief %i", iPlayer, iBelief))
  return true
end
GameEvents.PlayerCanHaveBelief.Add(OnPlayerCanHaveBelief)

-- Can this religion have this belief
function OnReligionCanHaveBelief(iReligion, iBelief)
  print(string.format("Can religion %i have belief %i", iReligion, iBelief))
  return true
end
GameEvents.ReligionCanHaveBelief.Add(OnReligionCanHaveBelief)
 
That is brilliant; you're a million miles ahead of me when it comes to this type of modding.
 
Back
Top Bottom