Modmodding Q&A Thread

There is no existing logging for this, but you could easily add it using event handlers. There have been reports about the tech pace being off in the last weeks, so I plan to implement something like this soon to investigate things like that more systematically. I often do that sort of logging on a temporary basis but maybe for tech progress it is worth keeping around.
 
How would I go on about changing unit art with Varietas Delectat on this mod? Some civilizations are missing unique art for some of their units and currently I'd like to change the French tank to something else (maybe giving them the british or american tank art, not sure yet) as I dislike the vanilla version they're using. Is this very difficult to do and how would I go on about it?
It is about as difficult as adding unit art in general. You just have to create a unit art definition and then add it to the unit art definitions of a particular civilization. If you look into the VD module you should be able to use the existing definitions as an example.
 
It is about as difficult as adding unit art in general. You just have to create a unit art definition and then add it to the unit art definitions of a particular civilization. If you look into the VD module you should be able to use the existing definitions as an example.
Thanks, this turned out to be rather easy and I succesfully did this.

I also discovered there actually was a french tank model and lots of other stuff in the VD folder that just wasn't assigned so it was a really pleasant surprise!
 
Yeah the VD module is kind of a mess because it is just a plain import of the VD mod, which has a lot of inconsistencies like this unfortunately.
 
I just added a new wonder in to the game and everything seemed to work like intended, or almost everything... As I tried to load an earlier game (from before I added the new wonder) I got an error popup saying "Failed to compress game data" or something along those lines and then a CTD. Is it impossible to add new wonders mid game or have I done something wrong here?
 
No, that is to be expected. Every building is associated with its own ID (equal to its position in the XML file) which the game uses to keep track of which city has a building etc. Now that you have added a new building the IDs of many buildings have shifted (and the overall number is different as well), which means it is impossible to correctly use the old save with the new set of buildings.
 
How can i set civs to only spawn when human plays them, like what happens with polynesia.
 
Look into the civilizations XML. There is a field named bAIPlayable or something like that.
 
Any idea how I can set the following wonder effect:

"All of your power plants in your cities yield +2 commerce each"

I've tried looking anything in the CIV4BuildingInfos that would be similar to that but I can't really find a similar enough effect to reference. The closest I can think of is the wonders that change specialist yields like the Golden Gate Bridge below:

"
<SpecialistYieldChanges>
<SpecialistYieldChange>
<SpecialistType>SPECIALIST_SCIENTIST</SpecialistType>
<YieldChanges>
<iYield>0</iYield>
<iYield>0</iYield>
<iYield>1</iYield>
</YieldChanges>
</SpecialistYieldChange>
<SpecialistYieldChange>
<SpecialistType>SPECIALIST_ENGINEER</SpecialistType>
<YieldChanges>
<iYield>0</iYield>
<iYield>0</iYield>
<iYield>1</iYield>
</YieldChanges>
</SpecialistYieldChange>
</SpecialistYieldChanges>
"

Is there someway I can tweak this line for my purposes of giving the kind of wonder effect that I described earlier? Tyvm anyone who can help me out!
 
Hey, the game supports increasing the yield/commerce of specific buildings but the XML itself does not support adding this ability. Wonders that currently have this ability do so via the DLL.
 
I am working on a large spinoff mod to DOC, so I've touched code in the DLL, XML, and Python. I'm still learning, but I have gotten okay at finding things I need, mostly. However, I'm getting a Python exception that I'm having a hard time tracking down. It says:

Code:
Traceback (most recent call last):

  File "CvScreensInterface", line 706, in forceScreenRedraw

  File "CvMainInterface", line 1308, in redraw

  File "CvMainInterface", line 5393, in updateHelpStrings

RuntimeError: unidentifiable C++ exception
ERR: Python function forceScreenRedraw failed, module CvScreensInterface

I found updateHelpStrings() in CvMainInterface.py, and the line in question reads:

Code:
screen.setHelpTextString( CyInterface().getHelpString() )

My problem is that I have not been able to find the getHelpString() defined anywhere in the code; not in the Python nor the DLL. I did a text search of the entire mod folder and there are only two references, one in CvMainInterface.py and one in CvMainInterface-PLE.py, neither of which are a definition. So I'm wondering what exactly the getHelpString() method is calling, and why it is causing an unidentifiable C++ extension. Any clues on how to debug this? I probably just don't understand the Cy Interfaces well enough.

The most consistent cause for this error is hovering over the east-most column of tiles while playing as specific civilizations in my mod that have no Core area. I don't know if this is related to the setPlotHelp() method of CvGameTextMgr.cpp or not. Just looking for tips on how I could trace this error.
 
Many UI functions are not defined in the DLL but in the exe, so you cannot find them in the source code. My best guess for the cause of the error is that whatever is in the tile you're hovering over is a null pointer when trying to create the tooltip text. The issue should still happen in DLL code, you should run a debug DLL to identify the offending line.
 
I never knew about that feature! Good to know. It didn't point me to the exact line, but it did tell me the problem was a divide by zero error.

Interestingly, it seems the root cause was a BUG bug (haha). BUG has a feature where the plot tooltip displays the Latitude and Longitude of a tile when hovering over after researching Calendar. The method it uses to calculate minutes of lat or long didn't protect against a divide by zero that occurs if the Prime Meridian is also the east-most column of tiles (which, in my map, it is. Go figure). Not that anyone but me would need this, but this is my fix for CvPlot::calculateMinutes():

Code:
int CvPlot::calculateMinutes(int iPlotIndex, int iPlotCount, bool bWrap, int iDegreeMin, int iDegreeMax, int iZero) const
{
    if (!bWrap)
    {
        iPlotCount--;

        if (iZero > 0)
        {
            // MacAurther: Protect against divide by zero (i.e. the Prime Meridian is the eastmost column of plots)
            bool bUseZeroAsDenominator = (iPlotIndex < iZero) || (iPlotCount == iZero);
            return (iPlotIndex - iZero) * (iPlotIndex < iZero ? abs(iDegreeMin) : abs(iDegreeMax)) * MINUTES_PER_DEGREE / (bUseZeroAsDenominator ? iZero : iPlotCount - iZero);
        }
    }

    int iOffset = iPlotCount / 2 - iZero;
    int iAdjustedIndex = (iPlotIndex + iOffset) % iPlotCount;

    return iAdjustedIndex * (iDegreeMax - iDegreeMin) * MINUTES_PER_DEGREE / iPlotCount + iDegreeMin * MINUTES_PER_DEGREE;
}
 
Assets/Python/Resources.py
 
When using Public Welfare to hurry production, is the gold cost of a specific building tied to it's hammer requirement? I've checked BuildingInfos.xml and saw that Wonders have a specific modifier that makes hurrying them more costly. And so I have a couple of questions:

1) Does the hurry cost modifier in the .xml file affect both, the gold cost of using Public Welfare's hurry building function and a Great Engineer's hurry production function?
2) What's the easiest way of making Public Welfare's hurry function cost less gold outside of decreasing the hammer cost of buildings? Can I for example put a negative hurry modifier on late game buildings in the BuildingInfos.xml? Can I add an effect that decreases hurry cost for some building? Quickly glancing through the file it seems there are no (non wonder) buildings that have a hurry cost modifier, so I wasn't convinced it's even possible to apply one. Alternatively, is there some other file from which I can decrease hurry cost when using Public Welfare?
 
1) No, it only affects the hurry options in the city screen, i.e. from Despotism and Public Welfare. Great Engineers always grant the same amount of hammers regardless of the building.
2) Buildings for which no building cost modifier is applied use the default modifier (100), you can simply add a tag to give them a different value. I don't know what a negative modifier would do but probably nothing great. 100 means you pay 100% of the price, 0% would make hurrying free (probably capped at 1 gold and 1 pop) etc. You are always affecting pop hurry and gold hurry equally. It seems you want to buff Public Welfare, for which I recommend looking into Assets/XML/GameInfo/CIV4HurryInfos.xml, e.g.:
Code:
        <HurryInfo>
            <Type>HURRY_GOLD_BUILDINGS</Type>
            <Description>TXT_KEY_HURRY_GOLD_BUILDINGS</Description>
            <iGoldPerProduction>3</iGoldPerProduction>
            <iProductionPerPopulation>0</iProductionPerPopulation>
            <bAnger>0</bAnger>
            <bUnits>0</bUnits>
            <bBuildings>1</bBuildings>
            <Button>Art/Interface/MainScreen/CityScreen/hurry_commerce.dds</Button>
        </HurryInfo>
You can set the gold cost for each hammer for each different method of hurrying here.
 
1) No, it only affects the hurry options in the city screen, i.e. from Despotism and Public Welfare. Great Engineers always grant the same amount of hammers regardless of the building.
2) Buildings for which no building cost modifier is applied use the default modifier (100), you can simply add a tag to give them a different value. I don't know what a negative modifier would do but probably nothing great. 100 means you pay 100% of the price, 0% would make hurrying free (probably capped at 1 gold and 1 pop) etc. You are always affecting pop hurry and gold hurry equally. It seems you want to buff Public Welfare, for which I recommend looking into Assets/XML/GameInfo/CIV4HurryInfos.xml, e.g.:
Code:
        <HurryInfo>
            <Type>HURRY_GOLD_BUILDINGS</Type>
            <Description>TXT_KEY_HURRY_GOLD_BUILDINGS</Description>
            <iGoldPerProduction>3</iGoldPerProduction>
            <iProductionPerPopulation>0</iProductionPerPopulation>
            <bAnger>0</bAnger>
            <bUnits>0</bUnits>
            <bBuildings>1</bBuildings>
            <Button>Art/Interface/MainScreen/CityScreen/hurry_commerce.dds</Button>
        </HurryInfo>
You can set the gold cost for each hammer for each different method of hurrying here.
Okay this all makes sense and looks like I was just overthinking it. I assumed modifier of 100 would mean that the cost is double, that's why I asked if negative modifier would do the job. But yeah, thanks, this worked!
 
I looked into Civilization.py in Python folder and wondered about dBuildingPreferences section. I saw that civilizations on that list have values assigned for some wonders, I assume this is to make them more likely to build historical wonders when controlled by AI. Some even had negative values set which I guess is to deter them from building some specific wonders. I wanted to ask what exactly do those numbers stand for? For example Greece has a "-100" value for the Pyramids, does that mean Greece will never try to build the Pyramids or what does the number exactly signify? I have some wonders in mind that I'd like to see more consistently built on their historical locations so I wondered if I can do anything with this file to make that happen.
 
Back
Top Bottom