Quick Modding Questions Thread

If a random event grants an instant culture boost to a city or several, where exactly in the code does that actually happen?
The amount is defined in the Event Infos XML file. I don't know where in the code that is used. Just in case you were actually asking where you could change it.
 
The amount is defined in the Event Infos XML file. I don't know where in the code that is used. Just in case you were actually asking where you could change it.
Well yes, I knew that already. What I am asking is indeed where in the actual code (that is Pyhton or the DLL) the game then takes this value and applies it.
 
Well yes, I knew that already. What I am asking is indeed where in the actual code (that is Pyhton or the DLL) the game then takes this value and applies it.
Sorry. Much is done in the Python\EntryPoints\CvRandomEventInterface.py usually there is a "canApply<Event name>" and an "apply<Event name>" function associated with the event, ie they have a similar name.
 
I'm trying to do something really simple: Set up my default civ so that it starts with a certain set of techs (Pottery, Hunting, Iron working, plus all pre-reqs). Is this something I can do in the CivilizationIV.ini file, or within a mod, or ... ???

If it matters, I'm playing Civ4 Beyond the Sword on a Mac using Steam. Thanks for any help / pointers.
 
I'm trying to do something really simple: Set up my default civ so that it starts with a certain set of techs (Pottery, Hunting, Iron working, plus all pre-reqs). Is this something I can do in the CivilizationIV.ini file, or within a mod, or ... ???

If it matters, I'm playing Civ4 Beyond the Sword on a Mac using Steam. Thanks for any help / pointers.

Starting techs are set for each civ individually in:

C:\Games\Sid Meier's Civilization 4 Complete\Beyond the Sword\Assets\XML\Civilizations\CIV4CivilizationInfos.xml

I recommend following Kael's tutorial on how to create a mod, shortcut and all, though I'm not sure how much of it is applicable to Mac:

https://forums.civfanatics.com/threads/msmd-how-to-create-a-mod-video-demo.262402/

At any rate, CIV4CivilizationInfos.xml has an entry for each civ in the game, its city names, unique units and buildings, starting civs, leaders, starting techs etc. The entry for America's starting techs for example looks like this:

Code:
            <FreeTechs>
                <FreeTech>
                    <TechType>TECH_FISHING</TechType>
                    <bFreeTech>1</bFreeTech>
                </FreeTech>
                <FreeTech>
                    <TechType>TECH_AGRICULTURE</TechType>
                    <bFreeTech>1</bFreeTech>
                </FreeTech>
            </FreeTechs>

If you want to give America also Iron Working and Pottery as starting techs then you would change it like so:


Code:
          <FreeTechs>
                <FreeTech>
                    <TechType>TECH_FISHING</TechType>
                    <bFreeTech>1</bFreeTech>
                </FreeTech>
                <FreeTech>
                    <TechType>TECH_AGRICULTURE</TechType>
                    <bFreeTech>1</bFreeTech>
                </FreeTech>
                <FreeTech>
                    <TechType>TECH_POTTERY</TechType>
                    <bFreeTech>1</bFreeTech>
                </FreeTech>
                <FreeTech>
                    <TechType>TECH_IRON_WORKING</TechType>
                    <bFreeTech>1</bFreeTech>
                </FreeTech>
            </FreeTechs>

The names for all techs can be found in:

C:\Games\Sid Meier's Civilization 4 Complete\Beyond the Sword\Assets\XML\Technologies\CIV4TechInfos.xml

Most are pretty straightforward, only Communism is named TECH_UTOPIA for whatever reason.

Edit: Ugh, I swear, this forum sometimes... I want to emphasize the lines I added by making them bold and/or changing their text color, but the code feature doesn't allow this kind of formatting and if I put it in a quote instead it ruins the indentation.
 
Many thanks for the pointers!

It worked ... sort of. I added 21 techs to the list in the mod file Canada_CIV4CivilizationInfos.xml, but only the first 13 "worked" (up to MASONRY, but not HORSEBACK_RIDING).

Is there some sort of limit on the number of free techs I can specify?

Code:
<FreeTechs>
<FreeTech><TechType>TECH_FISHING</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_THE_WHEEL</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_AGRICULTURE</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_HUNTING</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_MYSTICISM</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_MINING</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_SAILING</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_POTTERY</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_ANIMAL_HUSBANDRY</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_ARCHERY</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_MEDITATION</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_POLYTHEISM</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_MASONRY</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_HORSEBACK_RIDING</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_PRIESTHOOD</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_MONOTHEISM</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_BRONZE_WORKING</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_WRITING</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_IRON_WORKING</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_MATHEMATICS</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_CURRENCY</TechType><bFreeTech>1</bFreeTech></FreeTech>
</FreeTechs>
 
I tried to change how Palace works: You don't start with one but has a tech requirement and you have to build it.
But once I (or the AI) settle the first city there is an error appearing on screen. Its not fatal but annoying.
(Grrr... I forgot the screenshot :mad: )
It said something like: "Error onCitySet (something) 0C5687x1" (or something similiar)
Anyone knows what's causing it and how to solve it?
 
Many thanks for the pointers!

It worked ... sort of. I added 21 techs to the list in the mod file Canada_CIV4CivilizationInfos.xml, but only the first 13 "worked" (up to MASONRY, but not HORSEBACK_RIDING).

Is there some sort of limit on the number of free techs I can specify?

Code:
<FreeTechs>
<FreeTech><TechType>TECH_FISHING</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_THE_WHEEL</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_AGRICULTURE</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_HUNTING</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_MYSTICISM</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_MINING</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_SAILING</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_POTTERY</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_ANIMAL_HUSBANDRY</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_ARCHERY</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_MEDITATION</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_POLYTHEISM</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_MASONRY</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_HORSEBACK_RIDING</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_PRIESTHOOD</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_MONOTHEISM</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_BRONZE_WORKING</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_WRITING</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_IRON_WORKING</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_MATHEMATICS</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_CURRENCY</TechType><bFreeTech>1</bFreeTech></FreeTech>
</FreeTechs>
They have limits to help the code go faster. Usually the actual value of the limit is set in the GlobalDefines.XML file but I can't see one for FreeTech.
 
Many thanks for the pointers!

It worked ... sort of. I added 21 techs to the list in the mod file Canada_CIV4CivilizationInfos.xml, but only the first 13 "worked" (up to MASONRY, but not HORSEBACK_RIDING).

Is there some sort of limit on the number of free techs I can specify?

Code:
<FreeTechs>
<FreeTech><TechType>TECH_FISHING</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_THE_WHEEL</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_AGRICULTURE</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_HUNTING</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_MYSTICISM</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_MINING</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_SAILING</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_POTTERY</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_ANIMAL_HUSBANDRY</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_ARCHERY</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_MEDITATION</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_POLYTHEISM</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_MASONRY</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_HORSEBACK_RIDING</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_PRIESTHOOD</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_MONOTHEISM</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_BRONZE_WORKING</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_WRITING</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_IRON_WORKING</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_MATHEMATICS</TechType><bFreeTech>1</bFreeTech></FreeTech>
<FreeTech><TechType>TECH_CURRENCY</TechType><bFreeTech>1</bFreeTech></FreeTech>
</FreeTechs>
You can add free techs to HandicapInfo.xml too.
 
I tried to change how Palace works: You don't start with one but has a tech requirement and you have to build it.
But once I (or the AI) settle the first city there is an error appearing on screen. Its not fatal but annoying.
(Grrr... I forgot the screenshot :mad: )
It said something like: "Error onCitySet (something) 0C5687x1" (or something similiar)
Anyone knows what's causing it and how to solve it?
Here's the screenshot:
Civ4ScreenShot0217.JPG
Anyone any idea?
 
If you have logging enabled, a more detailed stack trace will be in your PythonErr.log.
 
In Marathon mode I’d like to increase the cost of techs and the length of the game with 50 %. How should I go about doing this?
 
I think I have found the source of my error. I am modding AND2 and in RevEvents.py I've found this code:

Code:
def onCityBuilt( argsList ):
        'City Built'
        city = argsList[0]

        RevData.initCity( city )

        pPlayer = gc.getPlayer( city.getOwner() )

        if( pPlayer.isBarbarian() ) :
            city.setRevolutionIndex( int(.4*RevOpt.getAlwaysViolentThreshold()) )
            city.setRevIndexAverage(city.getRevolutionIndex())
            return

        if( not city.area().getID() == pPlayer.getCapitalCity().area().getID() ) :
            city.setRevolutionIndex( int(.35*RevOpt.getInstigateRevolutionThreshold()) )
        else :
            city.setRevolutionIndex( int(.25*RevOpt.getInstigateRevolutionThreshold()) )
        city.setRevIndexAverage(city.getRevolutionIndex())
       
        revTurn = RevData.revObjectGetVal( pPlayer, 'RevolutionTurn' )
        if( not revTurn == None ) :
            if( pPlayer.getNumCities() < 4 and game.getGameTurn() - revTurn < 25 ) :
                relID = pPlayer.getStateReligion()
                if( relID >= 0 ) :
                    if( LOG_DEBUG ) : CvUtil.pyPrint("Rev - New rebel city %s given rebel religion"%(city.getName()))
                    city.setHasReligion( relID, True, False, False )

When I tagged out this part of the code no error occurred when settling the first city.

I am a noob for python but I understand that this code is checking for the civ's capital which does not exist (I changed Palace so that you don't start with it but have to build it later).

So how could it be changed without breaking the original purpose of the code but give no error message for settling first city? :confused:
 
Does some one know what can cause this when trying to start game?
I have seen same happens on different mods few times and now its happening on my personal Rom-AND mod mod. Its not always repeatable but happens maybe 50-70% on starting new game.
 

Attachments

  • Civ4ScreenShot0002.JPG
    Civ4ScreenShot0002.JPG
    130 KB · Views: 152
Hi guys, returning to Civ IV and am a python newb, but was wondering - a while ago someone mentioned an event mod whereby taking a holy city would trigger declaration of war by all civs with that state religion: is there a script for this about, or a simple way someone could tell me how to type it into the XML? Thanks!
 
(I changed Palace so that you don't start with it but have to build it later).
That's dangerous, it is hardcoded in the DLL in many places that the capital city is set by building BUILDINGCLASS_PALACE. If this does not exist, a capital city is never set, and then other code fails because it expects there to be a capital city.
 
That's dangerous, it is hardcoded in the DLL in many places that the capital city is set by building BUILDINGCLASS_PALACE. If this does not exist, a capital city is never set, and then other code fails because it expects there to be a capital city.
Well, I received help from Vokarya and it seems to be solved. You can read it here:
https://forums.civfanatics.com/threads/modders-guide-to-a-new-dawn.344522/page-16

But can you point me to instances where the dll checks for BUILDINGCLASS_PALACE?
 
Not right now, but a quick Ctrl+F should find them.
 
I did that with for CvGameCoreDLL.dll of AND2 but found nothing.
Checking for PALACE only gave these only: TXT_KEY_MISC_NO_PALACE_PENALTY and TXT_KEY_MISC_DISTANCE_FROM_PALACE. So I don't see what could possibly go wrong ? :dunno:
In this very instance the problem was 'not having a capital' and not 'not having a palace'.
 
@Zeta Nexus
The DLL does not check for specific buildings being present, instead it looks for their properties. In the case of the capital, you would need to track down how the DLL uses the XML <bCapital>1</bCapital> property from CIV4BuildingInfos.xml where BUILDING_PALACE is the only building with this flag set to 1.
 
Last edited:
Back
Top Bottom