Getting the AI to build my mod's new terrain improvement


Feb 27, 2006
Sioux Falls, SD
I've spent months perfecting my flagship mod, Soli Deo Gloria, and its kin. SDG overhauls religion such that all civs (except Kongo) can found a religion, and each civ can earn multiple great prophets. The subsequent great prophets are used to evangelize new beliefs, and, as such, a civ's religion could have dozens of beliefs. This all works just the way I want it to.

The ONLY issue I have is that the AI will not use their 2nd, 3rd, etc great prophets. These prophets just wander around their nation doing nothing. They'll obtain the prophets, but not use them.

Here's some more detail. The first great prophet uses the normal "found religion" action. Every subsequent great prophet gets 1 build charge and the ability to build a "great sermon" terrain improvement. Once the sermon is built, the prophet expires (just like a builder using its last builder-charge). The "great sermon" terrain improvement triggers "add new belief" and voila, you're prompted to add something to your religion. "Great sermons" can be built on any terrain within your borders (unless there's already a terrain improvement there... just like you can't put a farm on a mine). And the Great Prophet also comes equipped with the "remove improvement" unit action so they can tear down that farm (or, more likely, a previous great sermon) to make room for their own great sermon.

So, now here's the simple question: How do I get the AI to use the "build great sermon" unit action on their subsequent great prophets? Seems like it should be doable... like how we would tell the AI to use a military engineer to build a fort or airstrip. But after hours of searching, I can't figure this out.

Thanks for reading.

Kind regards,
Last edited:
The AI uses a prophet only to found a religion, the game doesn't know about all your other options. I see 2 options here:
1. Try to dwell into behavior trees and see if anything related to builders and improvements can be reused.
2. Write a piece of Lua code that simply activates those prohpets when there is a spot and other conditions are met.
Hi Infixo!

Thanks for sharing! Love your mods!

My time thus far has been spent on your (1.)... analyzing the AI+ mod and trying to grok how the database guides AI decisions. No luck on terrain improvements so far.

I've only briefly worked with the lua side of things, and my understanding was that lua was more for UI type mods, not AI. But if there's a possibility there, I'd love to dissect some existing mods. Can you link some mods that use lua for AI?

Kind regards,
Lua is a programming language. Civ has a native support for it because its UI is written in it, but not only. Scenarios use it for gameplay.
I don’t know any specific mods.
The idea here is that you need to simulate the UI action that the game does when you press a specific button e.g., for building a sermon. This is done in UI script and you can do the same in yours in a different situation. You need to get the parameters right however, this part is a bit complex.
Then you need to write a Lua script that does some thinking, basically deciding where to activate those functions.
All in all, it is not easy :(
I don’t know the details of your mod, but this option surely looks easier plus it feels more like the in-game mechanic. I mean, in the game you can evangelize a belief just by doing single action, practically anytime and anywhere. No dummy improvements, etc.
Here's where I am at the end of a full day working on this...

The promotion method can add a belief, but there's no clean way to get rid of the prophet. So my solution is to use both methods. I'll use the promotion method ONLY for the AI, where human players will still use the Great Sermon improvement.

So the prophet promotion adds a belief, and then I give the AI civs (that founded a religion) a modifier like Mont St Michel... gives their prophets the belief-promotion automatically. Human players' prophets never get the promotion.

Now here's the rub. AI gets their first prophet and founds a religion. They take the Warrior Monks belief. AI gets their second prophet and (according to Firetuner) that prophet has the promotion. But they don't take a second belief. Same for the 3rd, 4th, etc. prophets.

When I give my prophet the promotion (via Firetuner) I get a belief. But for whatever reason, the AI doesn't. It's like it skips the choose-belief screen.

Kind regards,
Ok, the reason why it only added one belief was because I had put all the beliefs in the BELIEF_CLASS_FOLLOWER. Once I moved a couple into a different class, then the AI would take one of those. The AI stops taking beliefs once it has a belief from each class... so I decided to make 10 classes, so that an AI player could take up to 10 beliefs.

Also learned that the number of Follower beliefs create a cap for the number of prophets the game will use. I have 25 prophets in my mod, but if there are only 10 Follower beliefs, it stops after 10. When I moved all my beliefs out of Follower, there were no prophets at all. (The game does the same thing for Pantheon beliefs, too... I learned that a few weeks ago. When I had only 19 pantheon options, only 19 great prophets were dispensed.)

And I learned that even when AdoptionOrder is set to 2 for all your belief classes... it will only let you choose from the Follower beliefs first. On the second choice you see the remaining 100+ options.

Tomorrow I'll see if AdoptionOrder affects the order that the AI grabs beliefs. If so, then I can arrange my belief classes such that the AI takes the more generally useful beliefs first and the more niche ones later.

Also, I wonder what would happen in the extreme case of making 85 belief classes, one each for the 85 beliefs that aren't Followers. Maybe the AI would just keep grabbing beliefs... and I could potentially assign the order in which the AI takes them.

Kind regards,
Just to add to the record: as per @dbergan request I've tinkered a little bit with this problem (ie Prophet with Builder ability). I've took Roman Legionaire as an example (rem Legionare has exclusive ability to build RomanFort). Unfortunately Prophets still stand idle and don't build an improvement (Pasture in my test). Then I've started autoplay just to see if Rome AI uses Legionares to build RomanForts. I have seen zero RomanForts in my test game. Now I am suspicious that something is broken (what a surprise) in game code and AI just don't use Prophets as builders for the same reason why AI don't build RomanForts with Legionares.
Q: Have anyone ever seen Rome AI build RomanForts?
Also adding below my test code with Prophet-Builder_Pasture for the record (as explained not functional):
UPDATE GreatPersonClasses SET MaxPlayerInstances=null WHERE GreatPersonClassType="GREAT_PERSON_CLASS_PROPHET";
UPDATE Map_GreatPersonClasses SET MaxWorldInstances=99 WHERE GreatPersonClassType="GREAT_PERSON_CLASS_PROPHET";
UPDATE Improvement_ValidBuildUnits SET UnitType="UNIT_GREAT_PROPHET" WHERE ImprovementType="IMPROVEMENT_PASTURE";
UPDATE Improvement_YieldChanges SET YieldChange=YieldChange*2 WHERE ImprovementType="IMPROVEMENT_PASTURE";
Last edited:
Success! Just published my update to Soli Deo Gloria where the AI civs successfully acquire all their beliefs. Here are the patch notes, explaining how I handled the items discussed in this thread.

Kind regards,

- AI now selects beliefs. To get this to work, a couple quirks needed to be worked-around.
1) The AI won't build Great Sermons, so instead the AI's subsequent Great Prophets are born with a promotion, and that promotion instantly gives them a belief. However, their Great Prophets don't disappear, so you'll see them wandering around their territory. However, I did set it so that Great Prophets can be killed outright... just go to war and walk over them with a scout.
2) The AI only takes one belief per "belief class". Originally I had all the SDG beliefs in the "Follower" category... so the AI would choose one belief and then never take a second one. The fix to this was to make 116 belief classes, one for each and every belief. The downside to this solution is that the beliefs no longer group nicely and alphabetize in the Civilopedia page. I haven't found a solution for that.
3) It turns out that Civ 6 only spawns as many Great Prophets as there are Follower Beliefs. (Just like the Pantheon limit I discovered a few updates ago.) So to support the 25 Great Prophets in SDG, 25 Follower Beliefs needed to be created. Since the AI only ever takes one belief from a category, I didn't want the AI to be locked out of 24 decent beliefs. So my solution here was to create 25 do-nothing Follower Beliefs, and force all players (human and AI) to choose one (and only one) when they found a religion. So now when you found a religion, you technically get 2 beliefs... a do-nothing Follower Belief and then a normal one.
4) For the sake of flavor I'm using the do-nothing Follower Beliefs to carry the best religious quotes I've come across. Thus, you choose the quote that best fits your personality and it's forever headlining your belief list.
5) I have not found a way to control the order in which the AI takes beliefs. They really like Warrior Monks and things that generate faith. I wish I could steer them toward the combat beliefs, because that would make them more challenging...
Top Bottom