Modmodding Q&A Thread

Great. And yeah I remember from when I actually got the DLL compiled for the first time and my changes affected the game. Never got anything to run I didn't develop myself from ground up before.

But I encourage you to build with Release as target instead, the mod will perform much better.
 
But I encourage you to build with Release as target instead, the mod will perform much better.

Isn't the idea that Debug is for developing and Release for the finished product?
 
Isn't the idea that Debug is for developing and Release for the finished product?
If you're using debug then yes (break marks, asserts). But practically RFC modding often consists of running autoplay and you want that to be fast.
 
If it makes you feel better, I just had to spend two hours to reassemble my project settings after I thoughtlessly deleted some local files during the release process.
 
Hm, curious: I just noticed that neither CvRhyes.h nor CvRhyes.cpp is listed among the files in the Solution Explorer in Visual Studio unless I click on Show All Files, which also shows stuff like the makefile in addition to some more .cpp and .h files that weren't there before, mostly ones from the BUG mod judging by the names. These files have a different symbol next to them, and if I right click on them I have the option to "Include in Project". What's that about? Are these files currently just being ignored and not part of the DLL even though they are in the same folder? Is that working as intended?

I attached a screenshot to help visualize what I am trying to convey.

Oh and I am also searching for the file where the DLL determines how the civics are named in the code.
 

Attachments

  • theplotthickens.png
    theplotthickens.png
    114.4 KB · Views: 54
It wasn't like this before I reimported the project. I'm trying to figure out what the configuration is.
 
It wasn't like this before I reimported the project. I'm trying to figure out what the configuration is.
As an FYI, I think I managed to clean this up in the source configs, importing the DoC source into VS (at least if it's the same version as mine) should be easier now.

If I want to add Sikhism into my SoI: Expanded mod, and have it found as an event around 1500 AD in the Punjab province, how would I go about scripting that?
Something like: when 1500 AD, select a city in the Punjab province and found Sikhism there? I assume Sikhism has already been added to the game and you can defined iSikhism in Consts.py correctly.

The place to put the trigger is the checkTurn() (or maybe onBeginGameTurn()) method in either CvRFCEventHandler.py or maybe Religions.py (if something like that exists). You should have an iGameTurn variable in those methods, and be able to check the years as
Code:
iGameTurn == getTurnForYear(1500)
There should be examples of that.

I'm pretty sure SoI has a utility method (in RFCUtils) that selects a random city in a province, but I don't know what it's called. Let's say it's utils.getRandomCityByProvince, but you have to look it up and make sure what arguments it requires and what values it returns (it might return a city directly, or the coordinates of a city).

Then you can do:
Code:
punjabiCity = utils.getRandomCityByProvince(rPunjab)
if (punjabiCity):
    gc.getGame().setHolyCity(iSikhism, punjabiCity)

This also checks if there is a city in Punjab at all. Depending on what you want to happen in case no city exists there you need to change how this works.
 
As an FYI, I think I managed to clean this up in the source configs, importing the DoC source into VS (at least if it's the same version as mine) should be easier now.


Something like: when 1500 AD, select a city in the Punjab province and found Sikhism there? I assume Sikhism has already been added to the game and you can defined iSikhism in Consts.py correctly.

The place to put the trigger is the checkTurn() (or maybe onBeginGameTurn()) method in either CvRFCEventHandler.py or maybe Religions.py (if something like that exists). You should have an iGameTurn variable in those methods, and be able to check the years as
Code:
iGameTurn == getTurnForYear(1500)
There should be examples of that.

I'm pretty sure SoI has a utility method (in RFCUtils) that selects a random city in a province, but I don't know what it's called. Let's say it's utils.getRandomCityByProvince, but you have to look it up and make sure what arguments it requires and what values it returns (it might return a city directly, or the coordinates of a city).

Then you can do:
Code:
punjabiCity = utils.getRandomCityByProvince(rPunjab)
if (punjabiCity):
    gc.getGame().setHolyCity(iSikhism, punjabiCity)

This also checks if there is a city in Punjab at all. Depending on what you want to happen in case no city exists there you need to change how this works.

Thank you!
2 more questions:
1: Sikhism is not in the mod yet, do you know which files I would have to change to add it in (as a minor religion)?
2. How can I make at happen within +/- 30 years of 1500, instead of exactly at 1500?
 
1. Add it to the XML (CIV4ReligionInfos.xml) and add the icons into the GameFont.tga files according to its position, then add it to Consts.py according to its position. What does minor religion mean exactly?

2. The typical way to do something like that is using utils.getSeed(). This returns a number that is constant at all times during the same game but different between games. To make sure you get something between 0-30 you use the modulo operator %:
Code:
utils.getSeed() % 30
If you want -30 to +30 you can do 0-60 minus 30, i.e.:
Code:
utils.getSeed() % 60 - 30
Or as the complete check:
Code:
if iGameTurn == getTurnForYear(1500 + utils.getSeed() % 60 - 30)
Do the addition outside of the brackets if you mean turns instead of years. In any case this will be a random turn in the chosen range that is different from year to year.
 
I want to create an UP similar to the Spanish and Korean UP. I created a new promotion for that and added it to the list of enums in CvEnum.h, but when I build the DLL I got an "undeclared identifier" error. Do I also have to add the new promotion to another file I missed? I don't see that other promotions in any other file.
 
Did you do a clean build (rebuild)? Not sure if VS automatically does that if you modify a header file. Otherwise your linker would use the old compiled object where you have not yet defined the new constant.
 
Is it intentional that your makefile is apparently unable to compile debug DLLs and only seems to work with release?

My Enhanced Culture modcomp seems to break city flips of other civs for some reason. Independent cities flip just fine (unless cities of other civs are supposed to flip too), but when Arabia in the 600AD scenario for instance tries to flip Byzantine cities I get "RuntimeError: unidentifiable C++ Exception" followed by a dozen or so of other Python Exceptions, and all cities and units that were supposed to flip remain in the original owner's possession and the flipper (Arabia in this case) gets squat.

Is there something I would have had to change in Python or is this entirely a DLL issue?

This happens both with my modmod as well as regular DoC. I attached the source files I edited, every change I made is commented with //KNOEDEL if it's one line, and surrounded by //KNOEDELbegin and //KNOEDELend if it's several.
 

Attachments

C++ exception indicates the issue is ultimately triggered by DLL code, but the cause can still be a state or input coded in Python. I'm aware of this bug too and would like to get rid of it, but no success so far.

I'll look into Debug and the other targets. Apparently I never checked if they worked when I reconfigured the source setup.
 
Is it intentional that your makefile is apparently unable to compile debug DLLs and only seems to work with release?
I just pushed a fix for this, Debug and Profile should work again.
 
Suppose I wanted to change the Chinese version of the bank building to something else. How would I do this? I'm seeing things like "asia_bank" and "crescent_bank" in the FPK files but I don't see how those options are tied to Civ4ArtDefines_Building, which asserts that "bank" is the NIF file being used.
 
You mean when using VD? There should be another XML file somewhere with all the civs specific art definitions, but I can't look it up right now.
 
What would I have to do to add a new scripted city like Samarkand or Jerusalem in addition to just adding a line in Barbs.py? I mean it seems to work by itself, but for some reason it throws a bunch of Python exceptions in 1200AD, coinciding with the spawn of Kazan, and I suspect it might be related to the total number of minor cities.
 
Back
Top Bottom