Immobile Settlers

Orbicus

Chieftain
Joined
Feb 23, 2018
Messages
5
Location
Ohio
Hello All,

I'm working on a mod where I intend to have somewhat historically accurate city foundation places and dates. I've disabled being able to build settlers and can get them to spawn automatically for each civ when and where I want them to, but sometimes the AI makes them stray from where they've spawned and found a city elsewhere. To fix this, I made settlers immobile, but then the AI sometimes doesn't use them, I think because they'd rather have them somewhere else but can't move them. I thought I got close to fixing this when I saw that I could change the Domain from Land to Immobile (which I would have thought would make the AI realize that the settler can't move and might as well found a city where it is) but it didn't really help.

One way I've thought to fix this is to make all tile types unsettlable, and make a settlable copy of each, carefully placing them where I want them underneath the settler spawns. Seems like a lot of work editing my world map for a fix that I can't even guarantee will work. I'm afraid the AI will still not use the settlers because they'd rather found a city on one of the new settlable tiles elsewhere.

Does anyone have any ideas for how to force a settler to found a city right away where it is? Or how to bypass the settler spawning and just spawn a city when a civ reaches a certain tech? Thanks for any input.
 
Yeah, they start right where I want them. Sometimes the AI will found a city with them right away. Sometimes they get moved around by the AI to another location or (after I rendered them immobile) sometimes just sit there unused if the AI isn't satisfied with where they are.
 
You're crediting the AI with far more "intelligence" than the programmers gave it, by wanting it to deal with edge cases that are not in the base game.

There are billions of possibilities that the programmers could have coded for but they were constrained by time, so naturally they choose to constrain the game logic to some of the possibilities that could actually occur in the game they were making.

Base game settlers can move, so the AI scans the known world for the best place to build a city, and tries to move them there. Distance was no consideration (although if you're using a modded DLL it is), this is why settlers will walk half way around the map to try and build a city. Making a settler immobile was never a consideration, so the AI will just keep stacking up "move to" orders to get the unit there, and as the settler never arrives, it will never found a city.

What's worse, the base DLL picks units that can found cities by the unit (class) type, and not by the "can found" flag - which is why combat units with secondary founding abilities are never used by the AI to build cities (again, unless you're using a modded DLL).

To achieve what you want to do, you'll need to push the "found city" event onto the AI's settler unit manually (which may or may not work, as I can't remember how the AI picks units to perform certain tasks at the start of each turn), or use a modded DLL that allows you to place cities directly via Lua (pretty sure my DLL has that ability)
 
To achieve what you want to do, you'll need to push the "found city" event onto the AI's settler unit manually (which may or may not work, as I can't remember how the AI picks units to perform certain tasks at the start of each turn), or use a modded DLL that allows you to place cities directly via Lua (pretty sure my DLL has that ability)

It's actually possible to spawn a city directly within the base DLL already: pPlayer:InitCity(iX, iY)
The guy in this post confirmed that that method was working.

EDIT: It also seems to be used in the Medieval Scenario
 
Wow, thanks for your help, everyone. Looks like I've got some fiddling around to do this evening.
 
You can also use
Code:
Player:Found(iPlotX, iPlotY, -1)
I know this to work because I used it in my Scipio mod. The third argument with the "-1" is not as I recall standard DLL but gives as I recall compatibility with William's VMC DLL and by inheritance I would assume the CP DLL.

But it's been literally years since I wrote the code for the Scipio mod, so :dunno: re whether I am remembering properly what that "-1" argument does.
 
The third parameter is the starting religion for the city, -1 for none
 
Thanks again, guys. Actually Player:Found(iPlotX, iPlotY, -1) works a little better for me than pPlayer:InitCity(iX, iY). I think I'll have better luck getting Found() to work with the Dynamic City Names I got from FramedArchitect. InitCity() just grabbed the names from the Civ's city list. I haven't messed around with its Religion functionality, but that sounds promising too.
 
Back
Top Bottom