Modmodding Q&A Thread

When I load the CMC mod with the civ I added it now loads without crashing (hooray!) albeit with a couple of error messages.
However when I go to play one of the scenarios it says I need to load the CMC mod. Any idea why the edited scenarios are not showing up after I load my mod?
Thanks,
 
When I load the CMC mod with the civ I added it now loads without crashing (hooray!) albeit with a couple of error messages.
However when I go to play one of the scenarios it says I need to load the CMC mod. Any idea why the edited scenarios are not showing up after I load my mod?
Thanks,

Try opening the scenarios with a text editor and editing the ModPath.
 
I have since found it.

When I load the CMC mod with the civ I added it now loads without crashing (hooray!) albeit with a couple of error messages.
However when I go to play one of the scenarios it says I need to load the CMC mod. Any idea why the edited scenarios are not showing up after I load my mod?
Thanks,
The edited scenarios need a specific folder name. Either change the folder name or change the mod name in the scenarios.
 
Last edited:
Does anyone know how to rig the Financial Advisor to display the Turks' Stability during autoplay?
 
Is disabling Time Victories the same as in Vanilla scenarios? (IIRC you define all victory types in the scenario file except time)
 
I don't know.
 
Does the AI take the Specialist Happiness tag into consideration when changing Civics? I can't find anything about it in PlayerAI.cpp.
 
No, considering the XML tag is unused in DoC I never implemented AI for it.
 
No, considering the XML tag is unused in DoC I never implemented AI for it.
I just drafted a rough AI for it. Thoughts?

Code:
// 1SDAN: Specialist Happiness
   if (kCivic.getSpecialistHappiness() != 0)
   {
       CvCity* pLoopCity;
       SpecialistTypes eType;
       int iLoop;
       int iSpecialists;
       int iSlots;

       for (pLoopCity = firstCity(&iLoop); NULL != pLoopCity; pLoopCity = nextCity(&iLoop))
       {
           for (int i = 0; i < GC.getNumSpecialistInfos(); i++)
           {
               eType = (SpecialistTypes)i;
               iSpecialists += pLoopCity->getSpecialistCount(eType);
               if (eType != GC.getInfoTypeForString("SPECIALIST_CITIZEN") && eType != GC.getInfoTypeForString("SPECIALIST_SLAVE"))
                   iSlots += pLoopCity->getMaxSpecialistCount(eType);
           }
       }

      iTempValue = (iSpecialists * 3) + iSlots) * kCivic.getSpecialistHappiness();
      iValue += iTempValue * AI_getHappinessWeight(iTempValue, 1) / 100;
   }

EDIT: These are the right functions right? Does MaxSpecialistCount not include Citizens? If not that's a problem. How do these two functions interact with slave specialists?

EDIT2: Are there non-AI changes I'd need to make for it to work?
 
Last edited:
Apparently Happiness from specialists who already exist at the time of converting isn't counted, so I added some code to the change method to fix this:

Code:
// Leoreth
void CvPlayer::changeSpecialistHappiness(int iChange)
{
    CvCity* pLoopCity;
    SpecialistTypes eType;
    int iSpecialists;
    int iCount;
    int iLoop;

    
    if (iChange != 0)
    {
        m_iSpecialistHappiness += iChange;
        
        // 1SDAN: Happiness from existing specialists
        for (pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))
        {
            for (int i = 0; i < GC.getNumSpecialistInfos(); i++)
            {
                eType = (SpecialistTypes)i;
                if (eType != GC.getInfoTypeForString("SPECIALIST_SLAVE"))
                {
                    iCount = pLoopCity->getSpecialistCount(eType);
                    if (iChange > 0)
                    {
                        pLoopCity->changeSpecialistGoodHappiness(iCount * iChange);
                    }
                    else
                    {
                        pLoopCity->changeSpecialistBadHappiness(iCount * iChange);
                    }
                }
            }
        }

        AI_makeAssignWorkDirty();
    }
}
 
I am finally starting to make progress with the civ I have been working on for what feels like weeks (I can actually see it when I load the scenarios!). Now comes the question, how do I upload it?
 
Okay I have finished adding the Zulus to DOC.

When I ran the scenario it immediatly said I had been defeated.

The python log showed:

Traceback (most recent call last):

File "<string>", line 1, in ?

File "<string>", line 52, in load_module

File "CvEventInterface", line 13, in ?

File "<string>", line 52, in load_module

File "CvRFCEventManager", line 11, in ?

File "<string>", line 52, in load_module

File "CvEventManager", line 12, in ?

File "<string>", line 52, in load_module

File "CvScreensInterface", line 12, in ?

File "<string>", line 52, in load_module

File "CvCivicsScreen", line 6, in ?

File "<string>", line 52, in load_module

File "Stability", line 7, in ?

File "<string>", line 52, in load_module

File "DynamicCivs", line 7, in ?

File "<string>", line 35, in load_module

File "<string>", line 13, in _get_code

File "

Victory

", line

1418




if iZuluImpi >= 10









^

SyntaxError

:

invalid syntax


Failed to load python module CvEventInterface.

ERR: Call function onEvent failed. Can't find module CvEventInterface



*Also I got an error on loading saying*
Cvglobal
Line: 1254
EleaderheadNum >1

Any thoughts on the errors would be appreciated.
Thanks
 
It says you have a syntax error, so check your syntax. Looks like you might be missing a colon at the end of that if statement.
 
I have managed to fix several error messages, but am unsure what the root of the latest one is. I am also still getting a "you have been defeated message."

Python error log:
Traceback (most recent call last):
File "CvWBInterface", line 47, in applyInitialItems
File "CvWBDesc", line 2028, in applyInitialItems
File "CvWBDesc", line 1676, in applyCity
File "CvWBDesc", line 1340, in apply
File "CvWBDesc", line 25, in getPlayer
ArgumentError: Python argument types in
CyGlobalContext.getPlayer(CyGlobalContext, NoneType)
did not match C++ signature:
getPlayer(class CyGlobalContext {lvalue}, int)
ERR: Python function applyInitialItems failed, module CvWBInterface
Traceback (most recent call last):
File "BugUtil", line 691, in <lambda>
File "BugEventManager", line 706, in preGameStart
File "CvAppInterface", line 74, in preGameStart
File "CvScreensInterface", line 106, in showMainInterface
File "CvMainInterface", line 463, in interfaceScreen
File "CvMainInterface", line 377, in initState
File "PLE", line 180, in PLE_CalcConstants
File "PLE", line 851, in getMaxRow
ZeroDivisionError: integer division or modulo by zero
ERR: Python function preGameStart failed, module CvAppInterface
Traceback (most recent call last):
File "BugEventManager", line 400, in _handleDefaultEvent
File "CvRFCEventHandler", line 101, in onGameStart
File "RiseAndFall", line 235, in setup
File "RiseAndFall", line 248, in initScenario
File "RiseAndFall", line 301, in updateStartingPlots
File "Areas", line 31, in getCapital
IndexError: tuple index out of range
 
I have managed to fix several error messages, but am unsure what the root of the latest one is. I am also still getting a "you have been defeated message."

Python error log:
Traceback (most recent call last):
File "CvWBInterface", line 47, in applyInitialItems
File "CvWBDesc", line 2028, in applyInitialItems
File "CvWBDesc", line 1676, in applyCity
File "CvWBDesc", line 1340, in apply
File "CvWBDesc", line 25, in getPlayer
ArgumentError: Python argument types in
CyGlobalContext.getPlayer(CyGlobalContext, NoneType)
did not match C++ signature:
getPlayer(class CyGlobalContext {lvalue}, int)
ERR: Python function applyInitialItems failed, module CvWBInterface

This error is likely because of an error in the scenario files. Did you change all playerID like in the tutorial?

Traceback (most recent call last):
File "BugUtil", line 691, in <lambda>
File "BugEventManager", line 706, in preGameStart
File "CvAppInterface", line 74, in preGameStart
File "CvScreensInterface", line 106, in showMainInterface
File "CvMainInterface", line 463, in interfaceScreen
File "CvMainInterface", line 377, in initState
File "PLE", line 180, in PLE_CalcConstants
File "PLE", line 851, in getMaxRow
ZeroDivisionError: integer division or modulo by zero
ERR: Python function preGameStart failed, module CvAppInterface

I don't know what is causing this. Did you reload python files during the game? I know that gives python errors, but I don't exactly which one. Restarting the game should get rid of them.

Traceback (most recent call last):
File "BugEventManager", line 400, in _handleDefaultEvent
File "CvRFCEventHandler", line 101, in onGameStart
File "RiseAndFall", line 235, in setup
File "RiseAndFall", line 248, in initScenario
File "RiseAndFall", line 301, in updateStartingPlots
File "Areas", line 31, in getCapital
IndexError: tuple index out of range

Did you add the capital location to the list of tCapitals in Areas.py?

Do you have the file on git or anywere else they can be accessed by us? Then we can help by digging in the code and see what the error is, instead of guessing by the error messages.
 
Did you add the capital location to the list of tCapitals in Areas.py?

I followed the guide for the scenario maps.

I added Ulundi to the area.py
(68, 11), # Ulundi
Do I need to defind Ulundi anywhere else?

I’m guessing the fact that it says I am instantly defeated means that there is a problem with the ryhs and fall py.
I the guide for creating a civ says “In the beginning, you should make a copy of the constant from Consts.py and get the PyPlayer and PyTeam objects for your player.”

I don’t understand what this mean.

I am wondering if part of the problem is that I haven’t defined some of the things I use in the victory and unique powers py.

Unqiue power:
#------------------ZULU U.P.-------------------


def zuluUP(self, argsList): #Real Slavery by Sevo

if not pZzulu.isAlive(): return

if utils.isReborn(iZulu): return



pWinningUnit, pLosingUnit = argsList



iWinningPlayer = pWinningUnit.getOwner()

pWinningPlayer = gc.getPlayer(iWinningPlayer)



iLosingPlayer = pLosingUnit.getOwner()

iLosingUnit = pLosingUnit.getUnitType()



if iWinningPlayer != iZulu:

return



# Only enslave land units!!

if pLosingUnit.isAnimal() or not (pLosingUnit.getDomainType() == DomainTypes.DOMAIN_LAND and gc.getUnitInfo(iLosingUnit).getCombat() > 0):

return



iRandom = gc.getGame().getSorenRandNum(100, 'capture chance')

if iRandom < 20:

pNewUnit = pWinningPlayer.initUnit(iZuluRifleman, pWinningUnit.getX(), pWinningUnit.getY(), UnitAITypes.UNITAI_ZuluRifleman, DirectionTypes.DIRECTION_SOUTH)

CyInterface().addMessage(iWinningPlayer, True, 15, CyTranslator().getText("TXT_KEY_UP_ZULU_WIN", ()), 'SND_REVOLTEND', 1, 'Art/Units/kongolese_pombos/button_pombospombos/button_pombos.dds', ColorTypes(8), pWinningUnit.getX(), pWinningUnit.getY(), True, True)

CyInterface().addMessage(iLosingPlayer, True, 15, CyTranslator().getText("TXT_KEY_UP_ZULU_LOSE", ()), 'SND_REVOLTEND', 1, 'Art/Units/kongolese_pombos/button_pombos.dds', ColorTypes(7), pWinningUnit.getX(), pWinningUnit.getY(), True, True)

if pLosingUnit.getOwner() not in lCivGroups[5] and pLosingUnit.getOwner() < iNumPlayers: # old world civs now

data.iZuluRifleman += 1

Do I need to define Zulu rifleman, and if so where?


# Control all South Africa in 1900 AD

if iGameTurn == getTurnForYear(1900):

if isControlled(iZulu, utils.getPlotList(tSAfricaTL, tSAfricaBR)):

win(iZulu, 2)

else:

lose(iZulu, 2
Do I need to define South Africa, and if so where?


# second goal: have 10 Impi in 1875 AD

if isPossible(iEngland, 1):

iZuluImpi = 0

iZuluImpi += pZulu.getUnitClassCount(gc.getUnitInfo(iImpi).getUnitClassType())



if iZuluImpi >= 10:

win(iZulu, 1)



if iGameTurn == getTurnForYear(1875):

expire(iZulu, 1)

Do I need to define Zulu Impi, and if so where?


elif iPlayer == iZulu:

if iGoal == 0:

iNumIkhanda = getNumBuildings(iZulu, iIkhanda)

aHelp.append(getIcon(iNumIkhanda >= 2) + localText.getText("TXT_KEY_VICTORY_NUM_IKHANDA", (iNumIkhanda, 2)))
Do I need to define Ikhanda, and if so where?


On the scenario menu screen under the Zulu’s it says they have no unqiue building. Which file should it be pulling that from?


Finally the last time I tried to play the scenario I got the following error messages:


Cvglobal

Line: 1254

EleaderheadNum >1


Assert Failed

File: .\.\CvPlot.cpp

Line: 7325

Expression: eIndex >= 0

Message: iIndex is expected to be non-negative (invalid Index)

FAssertMsg(eIndex >= 0, "iIndex is expected to be non-negative (invalid Index)");


Assert Failed

File: .\.\CvPlot.cpp

Line: 7193

Expression: eIndex >= 0

Message: iIndex is expected to be non-negative (invalid Index)

FAssertMsg(eIndex >= 0, "iIndex is expected to be non-negative (invalid Index)");


Assert Failed

File: .\.\CvPlot.cpp

Line: 7340

Expression: getCulture(eIndex) >= 0

Message:

FAssert(getCulture(eIndex) >= 0);


Thanks to anyone who can help with all these problems!

I’m determined to manage to create a functioning civilization!
 
Top Bottom