Capping the Number of Cities Civs Can Build

Vilyathar

Chieftain
Joined
Mar 2, 2022
Messages
19
I thought it would be fun to play a game where all civs could only grow so far (say 5 cities) and anything else had to be acquired from other civs. So I was trying to find a simple solution to this question, and I found a few threads with other people asking similar questions. I tried some simple python edits, as recommended in a few other threads, but no matter what I did to troubleshoot the small piece of code I was adding (double checking indentation, etc.) it unfailingly broke the UI for the game. So, as someone with only a passing familiarity with python and not wanting to waste hours more doing more indepth troubleshooting, I gave up on that and decided to try to just use the XML to achieve what I wanted. Someone in another thread noted that you can turn off the ability to build settlers and change the amount of settlers each Civ begins the game with to the desired number, but I wasn't a fan of that solution since it meant everyone would be rapidly expanding to maximum size immediately at the onset of the game, and I wanted to preserve some amount of gradual expansion as in the base game, just halting it after a certain number of cities is reached. Since there seem to be others interested in limiting city number, I thought I would share my own solution here to add it to the options people find when they are looking for an answer to this problem. The solution I came up with was to tie settlers to the tech tree, so that you "unlock" a new settler periodically as you advance through the earlier techs. You can't do this with the techinfos.xml, since that only has the option to give a unit to the FIRST civilization to research it, which could be fun, but wasn't what we wanted in this case. Instead we are going to use the game's event system to reward a settler to each civilization as they reach the required techs.

The first step is to edit the unitinfos.xml file. For the settler, change the cost (icost) from 0 to -1. This will make it so civs cannot build settlers.

Next is an edit to the civ4eventinfos.xml. Create a new event like this:
Code:
    <EventInfo>
            <Type>EVENT_SETTLER</Type>
            <Description>Go forth and make an empire!</Description>
            <LocalInfoText>Settler Event</LocalInfoText>
            <WorldNewsTexts/>
            <OtherPlayerPopup/>
            <QuestFailText/>
            <bQuest>0</bQuest>
            <bGlobal>0</bGlobal>
            <bTeam>0</bTeam>
            <bPickCity>0</bPickCity>
            <bPickOtherPlayerCity>0</bPickOtherPlayerCity>
            <bDeclareWar>0</bDeclareWar>
            <iGold>0</iGold>
            <bGoldToPlayer>0</bGoldToPlayer>
            <iRandomGold>0</iRandomGold>
            <iCulture>0</iCulture>
            <iEspionagePoints>0</iEspionagePoints>
            <bGoldenAge>0</bGoldenAge>
            <iFreeUnitSupport>0</iFreeUnitSupport>
            <iInflationMod>0</iInflationMod>
            <iSpaceProductionMod>0</iSpaceProductionMod>
            <Tech>NONE</Tech>
            <TechFlavors/>
            <iTechPercent>0</iTechPercent>
            <iTechCostPercent>0</iTechCostPercent>
            <iTechMinTurnsLeft>0</iTechMinTurnsLeft>
            <PrereqTech>NONE</PrereqTech>
            <UnitClass>UNITCLASS_SETTLER</UnitClass>
            <iNumFreeUnits>1</iNumFreeUnits>
            <bDisbandUnit>0</bDisbandUnit>
            <iUnitExperience>0</iUnitExperience>
            <iUnitImmobileTurns>0</iUnitImmobileTurns>
            <UnitPromotion/>
            <UnitName/>
            <UnitCombatPromotions/>
            <UnitClassPromotions/>
            <BuildingClass>NONE</BuildingClass>
            <iBuildingChange>0</iBuildingChange>
            <BuildingExtraYields/>
            <BuildingExtraCommerces/>
            <BuildingExtraHappies/>
            <BuildingExtraHealths/>
            <iHappy>0</iHappy>
            <iHealth>0</iHealth>
            <iHurryAnger>0</iHurryAnger>
            <iHappyTurns>0</iHappyTurns>
            <iRevoltTurns>0</iRevoltTurns>
            <iMinPillage>0</iMinPillage>
            <iMaxPillage>0</iMaxPillage>
            <iFood>0</iFood>
            <iFoodPercent>0</iFoodPercent>
            <FreeSpecialistCounts/>
            <FeatureType>NONE</FeatureType>
            <iFeatureChange>0</iFeatureChange>
            <ImprovementType>NONE</ImprovementType>
            <iImprovementChange>0</iImprovementChange>
            <BonusType>NONE</BonusType>
            <iBonusChange>0</iBonusChange>
            <RouteType>NONE</RouteType>
            <iRouteChange>0</iRouteChange>
            <BonusRevealed>NONE</BonusRevealed>
            <BonusGift>NONE</BonusGift>
            <PlotExtraYields/>
            <iConvertOwnCities>0</iConvertOwnCities>
            <iConvertOtherCities>0</iConvertOtherCities>
            <iMaxNumReligions>-1</iMaxNumReligions>
            <iOurAttitudeModifier>0</iOurAttitudeModifier>
            <iAttitudeModifier>0</iAttitudeModifier>
            <iTheirEnemyAttitudeModifier>0</iTheirEnemyAttitudeModifier>
            <iPopulationChange>0</iPopulationChange>
            <AdditionalEvents/>
            <EventTimes/>
            <ClearEvents/>
            <PythonCallback/>
            <PythonExpireCheck/>
            <PythonCanDo/>
            <PythonHelp/>
            <Button>,Art/Interface/Buttons/Process/Blank.dds,Art/Interface/Buttons/Beyond_the_Sword_Atlas.dds,8,5</Button>
            <iAIValue>1000</iAIValue>
    </EventInfo>
This will reward a settler when it is triggered.

Finally, edit the civ4eventtriggerinfos.xml and add a trigger like this:
Code:
<EventTriggerInfo>
            <Type>EVENTTRIGGER_SETTLER1</Type>
            <WorldNewsTexts/>
            <TriggerTexts>
                <TriggerText>
                    <Text>We have gathered a band of citizens prepared to venture to new lands.</Text>
                    <Era>NONE</Era>
                </TriggerText>
            </TriggerTexts>
            <bSinglePlayer>0</bSinglePlayer>
            <iPercentGamesActive>100</iPercentGamesActive>
            <iWeight>-1</iWeight>
            <bProbabilityUnitMultiply>0</bProbabilityUnitMultiply>
            <bProbabilityBuildingMultiply>0</bProbabilityBuildingMultiply>
            <Civic>NONE</Civic>
            <iMinTreasury>0</iMinTreasury>
            <iMinPopulation>0</iMinPopulation>
            <iMaxPopulation>0</iMaxPopulation>
            <iMinMapLandmass>0</iMinMapLandmass>
            <iMinOurLandmass>0</iMinOurLandmass>
            <iMaxOurLandmass>-1</iMaxOurLandmass>
            <MinDifficulty>NONE</MinDifficulty>
            <iAngry>0</iAngry>
            <iUnhealthy>0</iUnhealthy>
            <UnitsRequired/>
            <iNumUnits>0</iNumUnits>
            <iNumUnitsGlobal>0</iNumUnitsGlobal>
            <iUnitDamagedWeight>0</iUnitDamagedWeight>
            <iUnitDistanceWeight>0</iUnitDistanceWeight>
            <iUnitExperienceWeight>0</iUnitExperienceWeight>
            <bUnitsOnPlot>0</bUnitsOnPlot>
            <BuildingsRequired/>
            <iNumBuildings>0</iNumBuildings>
            <iNumBuildingsGlobal>0</iNumBuildingsGlobal>
            <iNumPlotsRequired>0</iNumPlotsRequired>
            <bOwnPlot>0</bOwnPlot>
            <iPlotType>-1</iPlotType>
            <FeaturesRequired/>
            <TerrainsRequired/>
            <ImprovementsRequired/>
            <BonusesRequired/>
            <RoutesRequired/>
            <ReligionsRequired/>
            <iNumReligions>0</iNumReligions>
            <CorporationsRequired/>
            <iNumCorporations>0</iNumCorporations>
            <bPickReligion>0</bPickReligion>
            <bStateReligion>0</bStateReligion>
            <bHolyCity>0</bHolyCity>
            <bPickCorporation>0</bPickCorporation>
            <bHeadquarters>0</bHeadquarters>
            <Events>
                <Event>EVENT_SETTLER</Event>
            </Events>
            <PrereqEvents/>
            <bPrereqEventPlot>0</bPrereqEventPlot>
            <OrPreReqs>
                <PrereqTech>TECH_POTTERY</PrereqTech>
            </OrPreReqs>
            <AndPreReqs/>
            <ObsoleteTechs/>
            <bRecurring>0</bRecurring>
            <bTeam>0</bTeam>
            <bGlobal>0</bGlobal>
            <bPickPlayer>0</bPickPlayer>
            <bOtherPlayerWar>0</bOtherPlayerWar>
            <bOtherPlayerHasReligion>0</bOtherPlayerHasReligion>
            <bOtherPlayerHasOtherReligion>0</bOtherPlayerHasOtherReligion>
            <bOtherPlayerAI>0</bOtherPlayerAI>
            <iOtherPlayerShareBorders>0</iOtherPlayerShareBorders>
            <OtherPlayerHasTech>NONE</OtherPlayerHasTech>
            <bPickCity>0</bPickCity>
            <bPickOtherPlayerCity>0</bPickOtherPlayerCity>
            <bShowPlot>0</bShowPlot>
            <iCityFoodWeight>0</iCityFoodWeight>
            <PythonCanDo/>
            <PythonCanDoCity/>
            <PythonCanDoUnit/>
            <PythonCallback/>
</EventTriggerInfo>
This will trigger the event giving a settler when the tech "Pottery" is researched. You can change the tech to whatever you like. Copy and paste this entry until you have as many as you need for the number of settlers you want (rename EVENTTRIGGER_SETTLER2, SETTLER3, etc.), and use a different tech for each one.
 
Last edited:
Top Bottom