Tweaking Barbarian Variables

ATPoseidon

Chieftain
Joined
Jun 1, 2021
Messages
10
Hello everyone. My Civ V playstyle can be considered more "Sandbox" rather than competitive or w/e so I use a bunch of mods to tweak the game to my liking. One of the mods I use for that is a simple change to Barbarian spawn behaviour and have beefed it up to what would normally be considered stupid amounts. However, any clarifications and additional help would be welcome. Right now, the following covers the map in Encampments at the beginning of the game and keeps it that way until the map is explored. Once you clear that initial superspawn however, the remainder of the game is back to spawning a single camp a turn at best and I'm looking to maintain barbarian population as extreme and as frequent as possible:


XML:
<GameData> --I'm guessing this is how many fog tiles there has to be between barbarian camps. I suspect setting it to 0 will be game breaking, or it might be exactly what I need. Clarifications are welcome.
    <Worlds>
        <Update>
            <Where Type="WORLDSIZE_DUEL" />
            <Set FogTilesPerBarbarianCamp="7" />
        </Update>
        <Update>
            <Where Type="WORLDSIZE_TINY" />
            <Set FogTilesPerBarbarianCamp="7" />
        </Update>
        <Update>
            <Where Type="WORLDSIZE_SMALL" />
            <Set FogTilesPerBarbarianCamp="7" />
        </Update>
        <Update>
            <Where Type="WORLDSIZE_STANDARD" />
            <Set FogTilesPerBarbarianCamp="7" />
        </Update>
        <Update>
            <Where Type="WORLDSIZE_LARGE" />
            <Set FogTilesPerBarbarianCamp="7" />
        </Update>
        <Update>
            <Where Type="WORLDSIZE_HUGE" />
            <Set FogTilesPerBarbarianCamp="1" />
        </Update>
    </Worlds>

    <GameSpeeds> --This seems obvious, however a clarification on the actual possible Values of BarbPercent would be welcome.
        <Update>
            <Where Type="GAMESPEED_MARATHON" />
            <Set BarbPercent="1000" />
        </Update>
        <Update>
            <Where Type="GAMESPEED_EPIC" />
            <Set BarbPercent="300" />
        </Update>
        <Update>
            <Where Type="GAMESPEED_STANDARD" />
            <Set BarbPercent="200" />
        </Update>
        <Update>
            <Where Type="GAMESPEED_QUICK" />
            <Set BarbPercent="100" />
        </Update>
        <Update>
            <Where Type="GAMESPEED_HISTORIC" />
            <Set BarbPercent="50" />
        </Update>
    </GameSpeeds>

    <Defines>
        <Update>
            <Set Value="400"/> --Same as before, clarification of the value would be good. Is anything above 100 as I've set here even possible?
            <Where Name="BARBARIAN_CAMP_ODDS_OF_NEW_CAMP_SPAWNING"/>
        </Update>
        <Update>
            <Set Value="4"/> --Obvious enough.
            <Where Name="BARBARIAN_CAMP_MINIMUM_DISTANCE_CAPITAL"/>
        </Update>
        <Update>
            <Set Value="1"/> --Obvious enough as well. Setting it to 0 might again be game breaking.
            <Where Name="BARBARIAN_CAMP_MINIMUM_DISTANCE_ANOTHER_CAMP"/>
        </Update>
        <Update>
            <Set Value="10"/> --Chance of barbarians spawning on coastal tiles?
            <Where Name="BARBARIAN_CAMP_COASTAL_SPAWN_ROLL"/>
        </Update>
        <Update>
            <Set Value="100"/> --Not quite sure about this one. They don't seem to spawn that much more extra units.
            <Where Name="BARBARIAN_EXTRA_RAGING_UNIT_SPAWN_CHANCE"/>
        </Update>
        <Update>
            <Set Value="500"/> --Landlock the bastards, they don't need to go places.
            <Where Name="BARBARIAN_NAVAL_UNIT_START_TURN_SPAWN"/>
        </Update>
        <Update>
            <Set Value="20"/> --Clarificaiton please.
            <Where Name="MAX_BARBARIANS_FROM_CAMP_NEARBY"/>
        </Update>
        <Update>
            <Set Value="2"/> --Clarificaiton please.
            <Where Name="MAX_BARBARIANS_FROM_CAMP_NEARBY_RANGE"/>
        </Update>
       
        <Update>
            <Set Value="50"/> --What percent of total barbarians to spawn on first turn I guess. But why is there a total amount? And where is it set?
            <Where Name="BARBARIAN_CAMP_FIRST_TURN_PERCENT_OF_TARGET_TO_ADD"/>
        </Update>
    </Defines>
</GameData>
 
If you understand C++, the answers to your questions can be found in CvBarbarians.cpp
 
If you understand C++, the answers to your questions can be found in CvBarbarians.cpp
Thank for having the resources linked in your signature, made this a lot easier.

Now, if I understand all of this correctly:

C++:
int iCampTargetNum = (iFogTilesPerBarbarianCamp != 0)? iNumValidCampPlots / iFogTilesPerBarbarianCamp : 0;//getHandicapInfo().getFogTilesPerBarbarianCamp();
So max number of Camps per map is based on map size, divided by FogTiles variable, which can't be 0, so for highest possible number of camps, set it to 1, adjusted for difficulty handicap, where I imagine the higher the difficulty, the better for number of camps.

and then

C++:
    if(iNumCampsToAdd > 0 && GC.getBARBARIAN_CAMP_ODDS_OF_NEW_CAMP_SPAWNING() > 0) // slewis - added the barbarian chance for the FoR scenario
        {
            // First turn of the game add 1/3 of the Target number of Camps
            if(kGame.getElapsedGameTurns() == 0)
            {
                iNumCampsToAdd *= /*33*/ GC.getBARBARIAN_CAMP_FIRST_TURN_PERCENT_OF_TARGET_TO_ADD();
                iNumCampsToAdd /= 100;
            }
            // Every other turn of the game there's a 1 in 2 chance of adding a new camp if we're still below the target
            else
            {
                if(kGame.getJonRandNum(/*2*/ GC.getBARBARIAN_CAMP_ODDS_OF_NEW_CAMP_SPAWNING(), "Random roll to see if Barb Camp spawns this turn") > 0)
                {
                    iNumCampsToAdd = 1;
                }
                else
                {
                    iNumCampsToAdd = 0;
                }
            }

This is the code for adding new camps every other turn? As far as I understand, that's "hard-coded" to add a single camp every time it finds it necessary? i.e. there's no way for me to increase that or is there, cause this would be the limit of my abilities?
 
For anyone that might ever have the same questions/interests as me, the Community Patch Project has done a lot of work on the main game DLL containing said variables, including "un-hardcoding" most of them and improving conditions and behaviours of Barbarians, offering plenty of options!

Big thanks to Chrisy15 from the Civ V Modding Helpline Discord!
 
Top Bottom