Quick Modding Questions Thread

Yep I did start a new game. Not certain where the pBarbarian data comes from. Is there any method for working out where data is being pulled from?
In RFC based mods, these constants are defined in the Consts.py file, you need to do the same for pBarbarian and then import it in the module you're currently writing.

I really recommend an "import * from Consts" in all your files which does not exist in base RFC because it was written in less civilised times.

Edit: If I recall correctly, the pattern was to do something like:
Code:
import Consts as con

pBarbarian = con.pBarbarian
But I advise against it because it is not idiomatic and difficult to maintain.
 
Can a tech belong to none of the eras?
I want to create one or more techs that can be acquired by some special means (events, buildings, etc.) but that sholud be the ONLY way.
And I'm not just talking about iCost -1. My problem is that if I set the era to Ancient you get the tech if starting in a later era or a civ spawned from barbarians or through revolutions. OTOH if I set the era to Future than acquiring the tech sends the civ to the Future era.
I tried <bDisable>1</bDisable> tag but that didn't do the trick I wanted.
 
Can a tech belong to none of the eras?
I want to create one or more techs that can be acquired by some special means (events, buildings, etc.) but that sholud be the ONLY way.
And I'm not just talking about iCost -1. My problem is that if I set the era to Ancient you get the tech if starting in a later era or a civ spawned from barbarians or through revolutions. OTOH if I set the era to Future than acquiring the tech sends the civ to the Future era.
I tried <bDisable>1</bDisable> tag but that didn't do the trick I wanted.
I tried <Era>NONE</Era>. It works as far as I can see. C2C doesn't complain and it uses Platyping's Tech Tree and Sevo's Pedia for BUG.

The tech does not show in the tech tree even though it has and X and Y
 
I tried <Era>NONE</Era>. It works as far as I can see. C2C doesn't complain and it uses Platyping's Tech Tree and Sevo's Pedia for BUG.

The tech does not show in the tech tree even though it has and X and Y
:eek:
I never thought that would work so I never tried.
Now I will...
THX! :goodjob:
 
Yep I did start a new game. Not certain where the pBarbarian data comes from. Is there any method for working out where data is being pulled from?

I case anyone encounters the same problem I did, the problem was:
-I added a civ but did not increase the max number of civs in the dll (stupid I know)!
This meant that the Barbarian.py did not pull the data for the civ listed last from the const.py
 
I tried <Era>NONE</Era>. It works as far as I can see. C2C doesn't complain and it uses Platyping's Tech Tree and Sevo's Pedia for BUG.

The tech does not show in the tech tree even though it has and X and Y
No, that just not "doesn't work" but even causes a CTD when clicking on the tech.
 
Which files control the game notifications? Stuff like "___ has declared war on ___" or "____ has agreed to become a vassal state of ___"? I'd like to change it from the leader names to the civ names.
 
Which files control the game notifications? Stuff like "___ has declared war on ___" or "____ has agreed to become a vassal state of ___"? I'd like to change it from the leader names to the civ names.
CvTeam.cpp (DLL) contains CvTeam::declareWar, which controls with strings to insert as arguments to the declare war text. It inserts the name from CvTeam::getName(), which in turn will use CvPlayer::getName() from the first alive team member. This function reads the leader name.

The only thing I can think of to solve this without actually modding the DLL itself is to rename the leader to be the same as the country. That's the only way to affect the text if you stick to the vanilla DLL. There aren't any python callbacks or anything like that, which can be used to affect this.
 
Can anybody think of a way to cause a city's adoption of a state religion to increase cultural output by a percentage rather than by a fixed amount? For example, right now, adoption of a state religion in a city gives the city +1 culture per turn. Can anybody think of a way to make it, say, +10% culture instead of the flat +1 culture?
 
Can anybody think of a way to cause a city's adoption of a state religion to increase cultural output by a percentage rather than by a fixed amount? For example, right now, adoption of a state religion in a city gives the city +1 culture per turn. Can anybody think of a way to make it, say, +10% culture instead of the flat +1 culture?
Tracking where culture comes from is not as trivial as I first thought, but I did manage to find it. It becomes a lot easier once you realize that there is a CommerceTypes called COMMERCE_CULTURE, meaning the code you are looking for is not called anything related to culture.

The calculation is done like this.
PHP:
iNewCommerce = (getBaseCommerceRateTimes100(eIndex) * getTotalCommerceRateModifier(eIndex)) / 100;
iNewCommerce += getYieldRate(YIELD_PRODUCTION) * getProductionToCommerceModifier(eIndex);

PHP:
int CvCity::getTotalCommerceRateModifier(CommerceTypes eIndex) const
{
   return std::max(0, (getCommerceRateModifier(eIndex) + GET_PLAYER(getOwnerINLINE()).getCommerceRateModifier(eIndex) + ((isCapital()) ? GET_PLAYER(getOwnerINLINE()).getCapitalCommerceRateModifier(eIndex) : 0) + 100));
}

The interesting part here is getCommerceRateModifier because it reads what is stored with CvCity::changeCommerceRateModifier(CommerceTypes eIndex, int iChange).

This means you should call changeCommerceRateModifier at some point to update the modifier. This means you have to modify the DLL, if nothing else, then it's to add python access to this function. I can't see any reason why it shouldn't work just fine when called from python, but vanilla just didn't add it to the python interface.

As a result without modifying the DLL, the only way to change this modifier is through CvBuildingInfo::getCommerceModifier(). You could in theory add an invisible building to provide the modifier. That might be doable from python/xml only.
 
Can I override caching options in [modname].ini file?

Changing these entries in vanilla Civilization4.ini works, but is that possible with [modname].ini so cache is always forced on or off for everyone?
Code:
; Disable caching of file system (may slow initialization)
DisableFileCaching = 1

; Disable caching of xml and file system (may slow initialization)
DisableCaching = 1

Is it possible to ensure, that cache is always erased when exiting game in mod?
Or at least if some file in mod would be changed, then cache would be discarded before loading it.
 
Last edited:
Where do I find the era clock images defined?
Spoiler :
hqdefault.jpg

Can those static pictures be replaced with movies?
 
Last edited:
Another question about the XML cache, to anyone playing with caching enabled: When you launch a mod, does the splash screen generally say "Init XML (cached)"? Because all I ever see, with any mod, is "Init XML (uncached)," and now I wonder if there's something slightly wrong with my installation. (Some other players have inquired about this before, but the answers were inconclusive.)
 
I encountered this weird bug while changing some XML files. While starting up a Byzantime game, I saw that the tech advisor opened up on start. The interface is gone too.

Spoiler :
2brO4go.jpg


Spoiler :
N3IdsIC.jpg


There's also this XML error which might not be related...

Spoiler :
qYhAVDC.png


I'm not sure what's causing it; I only changed some UU stats and civ colors. I thought it was the BUG mod at first, but I tried loading a game without it and the interface is still missing.

It only happens with the Byzantines. I tried it with other civs and they work just fine.
 
Last edited:
My guess is there's a typo or such in however you modded the UU. The wonky interface is from the game trying to reference a code block it can't find, so everything gets bumped a level. (I ran into the same problem with my own mod recently, but I was changing different files—I forgot comment tags only work for a single line, not whole blocks.)

Double-check what you've changed for any errors in the tags; if you did a hard edit and replaced the original UU code, make sure it's being called correctly in CIV4CivilizationInfos.xml, as this is what controls what uniques are used by which civs.
 
Open Civilization4.ini (in my documents) and disable hiding python errors (set hiding to 0). That will tell you what goes wrong with the interface.

Secondly fix the xml reading issue before fixing the interface. When you fail to load an xml file, it will fail to provide some data to the game and it can at times create a snowball effect where it affects a lot of other stuff, which affects other stuff and you end up with errors ingame, which seems unrelated to the xml file in question.
 
Thanks for the help guys! The problem was because I replaced Carthage's UU with something else. I followed Thorvald's advice and double-checked all the edits I made. Everything looks fine now, but the interface is still missing. Are there other files that I need to change? I've edited Civ4CivilizationInfos.xml, Civ4UnitInfos.xml, Civ4ArtDefines_Unit, and the strategy+description xml file.

Also the interface only disappears when I start a new game as Byzantium. When I load an existing save as them, the interface is there... how odd...
 
Is there a way to have an effect like "killoutcomes" to buildings. I want to create a wonder that is destroyed upon city capture and creates a captured wonder similar to captured animals. That new captured wonder unit would allow the owner to create that wonder in any city of their choosing. I can make the unit, no problem, not sure how to go about the killoutcomes part.
 
Is there a way to have an effect like "killoutcomes" to buildings. I want to create a wonder that is destroyed upon city capture and creates a captured wonder similar to captured animals. That new captured wonder unit would allow the owner to create that wonder in any city of their choosing. I can make the unit, no problem, not sure how to go about the killoutcomes part.
If you want a simple python only implementation, then it's likely onCityAcquiredAndKept in CvEventManager.py. Test if the wonder is there and if it is, destroy it.
 
Back
Top Bottom