Looking to adjust the "Barbarian World" option...

JacenSaracen

Chieftain
Joined
Mar 26, 2011
Messages
36
Can anybody point me to where to mod the behavior of the Barbarian World option? As written, the option will create one city per player at the beginning of the game. I would like to mod it to create more (or fewer) cities...

Thanks!
 
You can search for GAMEOPTION_BARBARIAN_WORLD in the CvGameCoreDLL files. I am not sure if it changes on each mod, but in my own the code is in the CvGame.cpp file.

Code:
if (isOption(GAMEOPTION_BARBARIAN_WORLD))
{
    logBBAI("IS BARBARIAN WORLD");
    for (int iI = 0; iI < MAX_CIV_PLAYERS; iI++)
    {
        if (GET_PLAYER((PlayerTypes)iI).isAlive())// && iI != BARBARIAN_PLAYER)
        {
            logBBAI("   Looking for city site %d", iI);
            foundBarbarianCity();
        }
    }
}
 
Alright.... I vaguely understand the code above.... but not enough as to know what to change to suit my purposes.

Example 1, let's assume I want two barb cities for every player.... what needs to change?

Example 2, 10 barb cities for every player.... same question?

Thanks!
 
Let's check the code step by step. I am going to add a comment at the end of each file explaining what each line does. Comments start with //

Code:
if (isOption(GAMEOPTION_BARBARIAN_WORLD)) // This code is only executed if the game option Barbarian World is enabled.
{
    logBBAI("IS BARBARIAN WORLD"); // Add a line to the BBAI log file.
    for (int iI = 0; iI < MAX_CIV_PLAYERS; iI++) // For each player...
    {
        if (GET_PLAYER((PlayerTypes)iI).isAlive()) // If that player is alive...
        {
            logBBAI("   Looking for city site %d", iI); // Add another line to the BBAI log file.
            foundBarbarianCity(); // Found a barbarian city.
        }
    }
}

So, if you want to found two cities, you would need to do this:

Code:
if (isOption(GAMEOPTION_BARBARIAN_WORLD)) // This code is only executed if the game option Barbarian World is enabled.
{
    logBBAI("IS BARBARIAN WORLD"); // Add a line to the BBAI log file.
    for (int iI = 0; iI < MAX_CIV_PLAYERS; iI++) // For each player...
    {
        if (GET_PLAYER((PlayerTypes)iI).isAlive()) // If that player is alive...
        {
            logBBAI("   Looking for city site %d", iI); // Add another line to the BBAI log file.
            foundBarbarianCity(); // Found the first barbarian city.
            foundBarbarianCity(); // Found the second barbarian city.
        }
    }
}

If you want to found more barbarian cities for each player, it is simpler if you place foundBarbarianCity in a for loop instead of duplicating foundBarbarianCity calls. The following example adds 42 barbarian cities for each player.

Code:
if (isOption(GAMEOPTION_BARBARIAN_WORLD)) // This code is only executed if the game option Barbarian World is enabled.
{
    logBBAI("IS BARBARIAN WORLD"); // Add a line to the BBAI log file.
    for (int iI = 0; iI < MAX_CIV_PLAYERS; iI++) // For each player...
    {
        if (GET_PLAYER((PlayerTypes)iI).isAlive()) // If that player is alive...
        {
           for (int iCityNum = 0; iCityNum < 42; iCityNum++) // Run 42 times...
           {
               logBBAI("   Looking for city site %d", iI); // Add another line to the BBAI log file.
               foundBarbarianCity(); // Found barbarian city number iCityNum.
           }
        }
    }
}
 
Top Bottom