Modmodding Q&A Thread

I've tried adding another scenario (Aka another in game date) in my modmod, and for some reason, all the countries that exist in 3000, 600, or 1700 scenarios are working perfectly fine, but the ones that are exclusive to this scenario seem to be having issues specifically on the first turn. Diplomacy doesn't initialise and there's an error with the buildings in the city screen, for example. Does anyone have a clue what the fix for this might be?

Note that the issue disappears after the first turn, so it's got to be something wrong with the initialisation.
 
The error that occurs looks like this...
Screenshot (11).png
 
Initial code checks first since I can't really look at your codebase at the moment:
  • Have you created a new Scenario####AD.py for your new scenario?
    • This should contain the civ definitions for each civ at the start of the scenario (e.g. gold, civics, state religion, techs)
  • [EDIT] Have you added the constant for the new scenario in Consts.py?
    • Look for this line:
      Python:
      (i3000BC, i600AD, i1700AD) = range(3)
  • Have you added the new scenario Python file to the defines in Scenarios.py?
You can try debugging by building a Debug DLL, attaching Visual Studio to your Civ 4 process, and trying to load the scenario. Usually when you encounter unidentifiable C++ exceptions like this, you can investigate it further by debugging the DLL.

Also, as a control, try loading starts for the culprit civs through the 3000 BC scenario.
 
Last edited:
Also, based on the stack trace, another probable culprit could be new assets (especially graphical) that you may have added. It could be for any of the civs present in this scenario, not necessarily just Celts, or probably something else like civic or unit buttons. You can try double-checking too that all new units, buildings, techs, and civics have proper icons in the Civilopedia in the main menu.
 
Initial code checks first since I can't really look at your codebase at the moment:
  • Have you created a new Scenario####AD.py for your new scenario?
    • This should contain the civ definitions for each civ at the start of the scenario (e.g. gold, civics, state religion, techs)
  • Have you added the new scenario Python file to the defines in Scenarios.py?
You can try debugging by building a Debug DLL, attaching Visual Studio to your Civ 4 process, and trying to load the scenario. Usually when you encounter unidentifiable C++ exceptions like this, you can investigate it further by debugging the DLL.

Also, as a control, try loading starts for the culprit civs through the 3000 BC scenario.
All these things are done. I’m coming to realise that the civs that aren’t working aren’t exclusively the ones new to the scenario, and some of the new ones are working. I’m beginning to suspect that the cause might just be miscellaneous things with the map script, eg. I noticed Java wasn’t working because I accidentally had Netherlands in previous civs even though they haven’t been born in this scenario.
 
Probably you need to make sure that the order of civ constants in Consts.py and in CvEnums.h are aligned with that in the XML.

As for the map script, I think if you've had a syntax error or typo in the text files, the scenario won't probably even load. But again, that's just what I think. What did you get when you tried debugging the DLL?

And what triggered the endless errors in that screenshot? Did that instantly appear upon loading or did you happen to click on a certain city?
 
Probably you need to make sure that the order of civ constants in Consts.py and in CvEnums.h are aligned with that in the XML.

As for the map script, I think if you've had a syntax error or typo in the text files, the scenario won't probably even load. But again, that's just what I think. What did you get when you tried debugging the DLL?

And what triggered the endless errors in that screenshot? Did that instantly appear upon loading or did you happen to click on a certain city?
I think I solved the problem. It was pretty stupid actually. I just forgot to give 4 of the civs a palace, and those were the ones causing a crash. Other than that, I’ve auto played the scenario for the next several hundred years, and played in it slightly. Everything seems to be working as intended :)
 
Do they look fine in civilopedia? If yes, your XML is probably correct.

Maybe there is some special code in the worldbuilder that skips a terrain/feature based on its ID so the terrain the worldbuilder thinks it is placing is one off from its actual ID.

I think it has something to do that DoC terrainXML also includes peaks and hills. They are elevation types rather than terrain types. They are also the only 2 with <bGraphicalOnly> set to 1. And the offset of the placed terrain and the resulting terrain is also 2.
I do not have access to the vanilla XML right now, so I can't compare the DoC xml with the vanilla xml.

IIRC hills and peaks are added to DoC/RFC terrains, so they can be shown in the pedia. They got the <bGraphicalOnly> tag so it does not effect any other gameplay.
The can easily be checked by looking if hills and peaks are also part of the vanilla terrainXML. If they are not, remove them from the terrainXML from your mod.

If that is not the reason, <bGraphicalOnly> could also be the culprit. IIRC this is not a vanilla XML tag, so the vanilla WB cannot deal with it properly.

Code:
        <TerrainInfo>
            <Type>TERRAIN_PEAK</Type>
            <Description>TXT_KEY_TERRAIN_PEAK</Description>
            <Civilopedia>TXT_KEY_TERRAIN_PEAK_PEDIA</Civilopedia>
            <ArtDefineTag>ART_DEF_TERRAIN_PEAK</ArtDefineTag>
...
            <bGraphicalOnly>1</bGraphicalOnly>
        </TerrainInfo>
        <TerrainInfo>
            <Type>TERRAIN_HILL</Type>
            <Description>TXT_KEY_TERRAIN_HILL</Description>
            <Civilopedia>TXT_KEY_TERRAIN_HILL_PEDIA</Civilopedia>
            <ArtDefineTag>ART_DEF_TERRAIN_HILL</ArtDefineTag>
...
            <bGraphicalOnly>1</bGraphicalOnly>
        </TerrainInfo>
I actually have found a semi-workaround, by copypasting into my mod's folder the terrain art and xml from RFCE instead. The only new terrains that are showing up are semidesert and salt lake, which is still better than only vanilla terrains, but I'm still trying to figure out how to get all the DoC terrains (and eventually resources) into my mod. Still, semidesert was the DoC terrain I wanted the most for my map because I really like its graphics. Here are some screenshots.
 

Attachments

  • Civ4ScreenShot1901.JPG
    Civ4ScreenShot1901.JPG
    297.8 KB · Views: 35
  • Civ4ScreenShot1900.JPG
    Civ4ScreenShot1900.JPG
    321.6 KB · Views: 24
  • Civ4ScreenShot1899.JPG
    Civ4ScreenShot1899.JPG
    290 KB · Views: 29
  • Civ4ScreenShot1898.JPG
    Civ4ScreenShot1898.JPG
    280.6 KB · Views: 25
  • Civ4ScreenShot1897.JPG
    Civ4ScreenShot1897.JPG
    337.7 KB · Views: 26
  • Civ4ScreenShot1896.JPG
    Civ4ScreenShot1896.JPG
    354.7 KB · Views: 27
  • Civ4ScreenShot1895.JPG
    Civ4ScreenShot1895.JPG
    420.2 KB · Views: 24
  • Civ4ScreenShot1894.JPG
    Civ4ScreenShot1894.JPG
    402.7 KB · Views: 21
  • Civ4ScreenShot1893.JPG
    Civ4ScreenShot1893.JPG
    429.2 KB · Views: 23
  • Civ4ScreenShot1892.JPG
    Civ4ScreenShot1892.JPG
    389.7 KB · Views: 21
  • Civ4ScreenShot1891.JPG
    Civ4ScreenShot1891.JPG
    334.8 KB · Views: 21
  • Civ4ScreenShot1890.JPG
    Civ4ScreenShot1890.JPG
    320.6 KB · Views: 22
  • Civ4ScreenShot1889.JPG
    Civ4ScreenShot1889.JPG
    352.4 KB · Views: 21
  • Civ4ScreenShot1888.JPG
    Civ4ScreenShot1888.JPG
    399.1 KB · Views: 26
  • Civ4ScreenShot1887.JPG
    Civ4ScreenShot1887.JPG
    385.2 KB · Views: 23
  • Civ4ScreenShot1902.JPG
    Civ4ScreenShot1902.JPG
    292.6 KB · Views: 23
  • Civ4ScreenShot1903.JPG
    Civ4ScreenShot1903.JPG
    238.4 KB · Views: 22
  • Civ4ScreenShot1904.JPG
    Civ4ScreenShot1904.JPG
    257.6 KB · Views: 37
Screenshot (15).png

My Modmod has surpass the 100 unit count which has resulted in a minor problem. Essentially the 101st and 102nd civs are place after the 10th civ in the intro screen, likely due to alphabetical ordering that doesn't account for the third digit. Does anyone know where in the files this occurs, so I can fix it?
 
Do they look fine in civilopedia? If yes, your XML is probably correct.

Maybe there is some special code in the worldbuilder that skips a terrain/feature based on its ID so the terrain the worldbuilder thinks it is placing is one off from its actual ID.
I finally got the new terrains, but when I try to add new features, I get this error message even though I've triple checked the line it refers to.
xml.png

Here is the XML file in question
 

Attachments

The error message really says it all. You have opened a <FeatureArtInfo> tag but the next closing tag found is </FeatureArtInfos> (note the s). Either you have a misplaced </FeatureArtInfos> or missing </FeatureArtInfo>. The line mentioned in the error message is the best place to start looking.
 
I want to experiment with diplomacy acting differently (trying out higher/lower bonuses for religion, trade, etc.). Where would I make those changes? Usually, that would be in the LeaderheadInfos-XML, but changing things there didn't seem to have an effect?
 
The error message really says it all. You have opened a <FeatureArtInfo> tag but the next closing tag found is </FeatureArtInfos> (note the s). Either you have a misplaced </FeatureArtInfos> or missing </FeatureArtInfo>. The line mentioned in the error message is the best place to start looking.
Thank you. I was missing a FeatureArtInfo in the Savanna entry. I've now fixed it, and although for some reason islands and cape are not showing up in worldbuilder, at least I can now place marsh and savanna overlays.

Is it possible to convert the black boxes with city names written in them into a CityNameManager, or would I have to recreate it manually?
 

Attachments

  • Civ4ScreenShot1924.JPG
    Civ4ScreenShot1924.JPG
    366.5 KB · Views: 23
There are a bunch of utility functions in Maps.py to help with converting between the ingame editor and the CSV files used to manage city names, settler maps etc.

In particular, there is exportCityNames(), which takes the existing city name map, replaces the names of all tiles with a landmark on them with the landmark content, and then saves it to the Cities.csv file. It requires that there is a Cities.csv file in place, even if it's an empty one. If you branched off DoC 1.18, that should be the case. You need to call that function from the ingame Python console.
 
There are a bunch of utility functions in Maps.py to help with converting between the ingame editor and the CSV files used to manage city names, settler maps etc.

In particular, there is exportCityNames(), which takes the existing city name map, replaces the names of all tiles with a landmark on them with the landmark content, and then saves it to the Cities.csv file. It requires that there is a Cities.csv file in place, even if it's an empty one. If you branched off DoC 1.18, that should be the case. You need to call that function from the ingame Python console.
Thanks. My mod isn't branched from DoC. Would it be beneficial for me to branch from DoC? What would I need to do to make my mod (which has a new map with DoC terrains and features but no other alterations to base BTS) a branch of DoC?
 
Oh I assumed because you are asking here. I don't know. It depends on which DoC features and functionality you want to use.
 
Back
Top Bottom