1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Quick Modding Questions Thread

Discussion in 'Civ4 - Creation & Customization' started by kiwitt, Jan 27, 2010.

  1. Dancing Hoskuld

    Dancing Hoskuld Warlord

    Joined:
    Jul 5, 2004
    Messages:
    23,289
    Gender:
    Male
    Location:
    Canberra, Australia
    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.
     
    Imp. Knoedel likes this.
  2. Imp. Knoedel

    Imp. Knoedel Knoedel Imperator Satani Filius Augustus Nooborum

    Joined:
    Nov 11, 2011
    Messages:
    8,542
    Location:
    Land der Mörder, Land der Hetzer
    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.
     
  3. Dancing Hoskuld

    Dancing Hoskuld Warlord

    Joined:
    Jul 5, 2004
    Messages:
    23,289
    Gender:
    Male
    Location:
    Canberra, Australia
    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.
     
    Imp. Knoedel likes this.
  4. kay dub

    kay dub Chieftain

    Joined:
    May 12, 2018
    Messages:
    2
    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.
     
    Imp. Knoedel likes this.
  5. Imp. Knoedel

    Imp. Knoedel Knoedel Imperator Satani Filius Augustus Nooborum

    Joined:
    Nov 11, 2011
    Messages:
    8,542
    Location:
    Land der Mörder, Land der Hetzer
    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.
     
  6. kay dub

    kay dub Chieftain

    Joined:
    May 12, 2018
    Messages:
    2
    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>
     
  7. Zeta Nexus

    Zeta Nexus Chieftain

    Joined:
    Jan 23, 2014
    Messages:
    3,299
    Location:
    In a constant brainstorm...
    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?
     
  8. Dancing Hoskuld

    Dancing Hoskuld Warlord

    Joined:
    Jul 5, 2004
    Messages:
    23,289
    Gender:
    Male
    Location:
    Canberra, Australia
    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.
     
  9. Zeta Nexus

    Zeta Nexus Chieftain

    Joined:
    Jan 23, 2014
    Messages:
    3,299
    Location:
    In a constant brainstorm...
    You can add free techs to HandicapInfo.xml too.
     
  10. Zeta Nexus

    Zeta Nexus Chieftain

    Joined:
    Jan 23, 2014
    Messages:
    3,299
    Location:
    In a constant brainstorm...
    Here's the screenshot:
    Civ4ScreenShot0217.JPG
    Anyone any idea?
     
  11. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    33,052
    Gender:
    Male
    Location:
    Leblanc
    If you have logging enabled, a more detailed stack trace will be in your PythonErr.log.
     
  12. Yoda Power

    Yoda Power ✫✫✫✫✫✫✫

    Joined:
    Sep 24, 2002
    Messages:
    13,866
    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?
     
  13. Zeta Nexus

    Zeta Nexus Chieftain

    Joined:
    Jan 23, 2014
    Messages:
    3,299
    Location:
    In a constant brainstorm...
    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:
     
  14. rtt4a

    rtt4a Chieftain

    Joined:
    Mar 3, 2009
    Messages:
    437
    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.
     

    Attached Files:

  15. skycorvair

    skycorvair Chieftain

    Joined:
    May 14, 2013
    Messages:
    9
    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!
     
  16. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    33,052
    Gender:
    Male
    Location:
    Leblanc
    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.
     
  17. Zeta Nexus

    Zeta Nexus Chieftain

    Joined:
    Jan 23, 2014
    Messages:
    3,299
    Location:
    In a constant brainstorm...
    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?
     
  18. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    33,052
    Gender:
    Male
    Location:
    Leblanc
    Not right now, but a quick Ctrl+F should find them.
     
  19. Zeta Nexus

    Zeta Nexus Chieftain

    Joined:
    Jan 23, 2014
    Messages:
    3,299
    Location:
    In a constant brainstorm...
    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'.
     
  20. devolution

    devolution Chieftain

    Joined:
    Oct 7, 2016
    Messages:
    255
    Gender:
    Male
    Location:
    Stavanger, Norway
    @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: Jun 12, 2018

Share This Page