How to disable settlers from being bought and produced?

Xiomn

Chieftain
Joined
May 6, 2020
Messages
15
I want to limit all AI Civilisations to 3 cities.

I have edited the in-game files making it so each Civ starts with three settler units.

The next step would be to make it so neither myself nor any AI can product or buy any further settlers.


In order to attempt to do this I have also edited the CIV5Units .XML file and in the settlers section I have included the new line and i have also changed the following line

(See highlighted colours below).

However, when starting a new game to test whether I can still produce another settler, it is still possible when theoretically it shouldn't be? (Ancient Era, Community Patch).

I have also tried putting the values at super high values to effectively achieve the same effect, again with no success.

Can anyone help me out?

Row>
<ID>0</ID>
<Class>UNITCLASS_SETTLER</Class>
<Type>UNIT_SETTLER</Type>
<Cost>-1</Cost>
<Moves>2</Moves>
<Capture>UNITCLASS_WORKER</Capture>
<CivilianAttackPriority>CIVILIAN_ATTACK_PRIORITY_HIGH_EARLY_GAME_ONLY</CivilianAttackPriority>
<HurryCostModifier>-1</HurryCostModifier>
<Domain>DOMAIN_LAND</Domain>
<DefaultUnitAI>UNITAI_SETTLE</DefaultUnitAI>
<Description>TXT_KEY_UNIT_SETTLER</Description>
<Civilopedia>TXT_KEY_CIV5_ANTIQUITY_SETTLER_TEXT</Civilopedia>
<Strategy>TXT_KEY_UNIT_SETTLER_STRATEGY</Strategy>
<Help>TXT_KEY_UNIT_HELP_SETTLER</Help>
<Requirements>TXT_KEY_NO_ACTION_SETTLER_SIZE_LIMIT_HARDCODED</Requirements>
<Food>true</Food>
<Found>true</Found>
<CombatLimit>0</CombatLimit>
<UnitArtInfo>ART_DEF_UNIT__SETTLER</UnitArtInfo>
<UnitArtInfoCulturalVariation>true</UnitArtInfoCulturalVariation>
<PortraitIndex>0</PortraitIndex>
<IconAtlas>UNIT_ATLAS_1</IconAtlas>
 
Since the Settler's production cost seems to be defined outside of the standard Cost row in the database, your best bet is probably to use Lua to prevent Settlers from being trained. Try creating a Lua file in your project that includes this code:

Code:
local iSettler = GameInfoTypes["UNIT_SETTLER"]

function PreventSettlerTraining(playerID, unitType)
    if unitType == iSettler then
        return false
    end
    return true
end
GameEvents.PlayerCanTrain.Add(PreventSettlerTraining)
 
Since the Settler's production cost seems to be defined outside of the standard Cost row in the database, your best bet is probably to use Lua to prevent Settlers from being trained. Try creating a Lua file in your project that includes this code:

Code:
local iSettler = GameInfoTypes["UNIT_SETTLER"]

function PreventSettlerTraining(playerID, unitType)
    if unitType == iSettler then
        return false
    end
    return true
end
GameEvents.PlayerCanTrain.Add(PreventSettlerTraining)


I don't know anything about Lua or how to go about doing this, but I'll find out how to do it somehow.. I'm in the mod buddy right now, created an empty mod and have created a new project and selected create lua script, do I just copy the above script you posted word for word?
 
Ideally I would need some super cool person to run me through it step by step.. I would very grateful as this is the last thing that would literally make me happy as ever to play Civ5. Without it, I don't really feel like playing it.

I've copy and pasted the code the other poster put into new project/mod.. but don't know what I am doing next at all.
 
Yup!

To get the Lua code to run, you'll need to set the file to InGameUIAddin in Modbuddy; whoward has a tutorial on how to do that, which phrases it more effectively then I'd be able to myself.

Got it to work. This should work for AI as well as me, the player, too right? If so thank you so much for your help.. might actually be able to enjoy playing Civ 5 scenarios as I want to play them without inundated AI city spam.. hopefully. We'll see.
 
Last edited:
Top Bottom