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

The Modding Q&A Thread

Discussion in 'Rhye's and Fall Modmods' started by Leoreth, Apr 2, 2011.

  1. embryodead

    embryodead Caliph

    Joined:
    Jan 1, 2003
    Messages:
    5,179
    Location:
    basement
    Find and open your Civilization4.INI by
    opening My Documents/My Games/Beyond the Sword/CivilizationIV.ini,
    or opening _Civ4Config in your main Beyond the Sword folder (the same that contains Mods)

    Inside the file, using Notepad:
    - Find "LoggingEnabled" and change it from 0 to 1
    - Find "ShowPythonDebugMsgs" and it from 0 to 1

    if you can't find one of these, then add it at the end of file i.e. type:
    ShowPythonDebugMsgs = 1

    It's also useful to enable cheat/debug mode in the same file, as it provides you console and more useful in-game information:
    Spoiler :
    CheatCode = chipotle


    Remember that enabling logs/exceptions slows the game down, but provides you with logs and in-game information about Python errors.
     
  2. J. pride

    J. pride Chieftain

    Joined:
    Feb 23, 2011
    Messages:
    788
    I feel like a noob but I cant find _Civ4Config anywhere
     
  3. embryodead

    embryodead Caliph

    Joined:
    Jan 1, 2003
    Messages:
    5,179
    Location:
    basement
    Alternatively try:
    My Documents/My Games/Beyond the Sword/CivilizationIV.ini
     
  4. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    33,042
    Gender:
    Male
    Location:
    Leblanc
    And how! Some days ago I found myself typing "if (bool1 and bool2){}" in C++ ... while in Python I always get exceptions thrown at me for using && and || as junctors.
     
  5. LuKo

    LuKo The Royal Guard

    Joined:
    Aug 28, 2006
    Messages:
    1,501
    Location:
    Poland
    @embryodead: There is no setPower- should I make setStability? Does pStream read Python information? Because I have no idea how it can work with just changing name of variable (I like to know what I'm doing :p). If I compile successfully how can I check if it's working?
     
  6. embryodead

    embryodead Caliph

    Joined:
    Jan 1, 2003
    Messages:
    5,179
    Location:
    basement
    Yes, make setStability - of course you can use changeStability, but it will be more convenient considering RFC uses setStability. I assume you know how to do it, looking at changeStability?

    pStream is for reading/writing savegames, i.e. the line makes sure your variable is loaded/saved properly.

    Python part is in CyPlayer.cpp/h and CyPlayerInterface1/2. Those files are nothing but DLL->Python interfaces. i.e. in CyPlayer you declare get/setStability, and these functions only call get/setStability from CvPlayer. Whatever is properly added to CyPlayer/CyPlayerInterface should work in Python. To test if it's working, simply start the game, open Python console and try something like this:

    pPlayer=gc.getPlayer(0)
    print pPlayer.getStability()
    pPlayer.setStability(10)
    print pPlayer.getStabiltiy()

    It should say 0, then 10.

    Save the game, reload and type
    print gc.getPlayer(0).getStability()

    It should say 10 - which means pStream is working.

    If it's working, modify get/setStability in StoredData.py so that it uses pPlayer.get/setStability instead of scriptData, and you're done.
     
  7. LuKo

    LuKo The Royal Guard

    Joined:
    Aug 28, 2006
    Messages:
    1,501
    Location:
    Poland
    Thanks! But how do I change StoredData.py if there is no get/set Stability?
     
  8. civ-addicted

    civ-addicted Chieftain

    Joined:
    Aug 8, 2009
    Messages:
    852
    Location:
    The City of the Lion
    The classic
    Code:
    print("hello world")
    where exactly is it printed to? Is there a console or something?
     
  9. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    33,042
    Gender:
    Male
    Location:
    Leblanc
    You have to enable logging in the Civ4Config file first, it's printed into the PythonDbg text file then. You can find it in "My Games\Beyond the Sword\Logs\".
     
  10. civ-addicted

    civ-addicted Chieftain

    Joined:
    Aug 8, 2009
    Messages:
    852
    Location:
    The City of the Lion
    Okay, thanks.
     
  11. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    civ-addicted: Yeah, there is actually a console. How to open it without a standard US keyboard is another issue altogether... :p
     
  12. embryodead

    embryodead Caliph

    Joined:
    Jan 1, 2003
    Messages:
    5,179
    Location:
    basement
    Sorry I forgot that in RFCMarathon, set/getStability is in RFCUtils.py and Stability.py
    In both files change:
    Code:
            def getStability( self, iCiv ):
                    return sd.scriptDict['lStability'][iCiv]
    
            def setStability( self, iCiv, iNewValue ):
                    sd.scriptDict['lStability'][iCiv] = iNewValue
    to:

    Code:
            def getStability( self, iCiv ):
                    return gc.getPlayer(iCiv).getStability()
    
            def setStability( self, iCiv, iNewValue ):
                    gc.getPlayer(iCiv).setStability(iNewValue)
     
  13. J. pride

    J. pride Chieftain

    Joined:
    Feb 23, 2011
    Messages:
    788
    Im still not having any luck changing the culture of the independent city. Just for the record, I only have to make the change Riseandfall.py right

    On a completely different note: do i have to recompile the dll if i use winmerge to import changes
     
  14. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    33,042
    Gender:
    Male
    Location:
    Leblanc
    The change is definitely right where you've put it. Don't you get a Python exception when loading RFC or at lest at the date the code is supposed to trigger?

    And you need to recompile the DLL every time you change the C++ source code, yes.
     
  15. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    J. Pride, do you know what a Python exception is? Are you sure that you're not getting any either at startup or at run-time?
     
  16. J. pride

    J. pride Chieftain

    Joined:
    Feb 23, 2011
    Messages:
    788
    I cannot enable Python exceptions because I dont have the "ShowPythonDebugMsgs" in the Civ4.ini file but even when i add it, i dont get the exceptions ( i had already changed Enabled Logging). I really cant tell what im doing wrong since pasted everything exactly as it was posted here.

    BTW: With my latest modification, i get defeat on spawn but before that the game would continue just fine but the change would just not take place. I have a feeling that its not the indentations that are wrong but the command is not being recognized becuase ive been able to make unit spawns just fine.
    Its actually funny how hard it is to explain even little changes. Im sorry for wasting ur time :(
     
  17. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    Create a intentional syntax error by garbling up some line of code. If it doesn't show anywhere, then you've not been able to enable exceptions.

    Also note that you need to enable exceptions in the \Documents\Games\BtS\CivilizationIV.ini file - not the .ini file of RFC.
     
  18. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    33,042
    Gender:
    Male
    Location:
    Leblanc
    You also have to find HidePythonExceptions and set it to 0 - otherwise the exceptions will only be displayed in the logs, not during runtime.
     
  19. LuKo

    LuKo The Royal Guard

    Joined:
    Aug 28, 2006
    Messages:
    1,501
    Location:
    Poland
    Thanks, edead!

    OK, I've got tools now so I can keep asking questions how to complete my evil plan. Where is number of soldiers count (the one from statistics page)? And how can I change power of unit in combat, depending on stability of owner?
     
  20. narvego

    narvego Chieftain

    Joined:
    Jan 10, 2010
    Messages:
    80
    Hello,

    I want to do a some experiment, and start play with Americans in ~2750 BC (the 10 turn). I changed the tBirth date in Consts.py, ant it works! They were born and I can play with them. Also, I modified the Americans startEra/startingEra from 3 (renaissance) to 0 (ancient) in CvPlayer.cpp and CvCity.cpp, but I have the problem -

    Even if I delete the modern American technologies at start from RiseAndFall.py, so they are starting with stone age discoveries, our Americans still are living in the renaissance era. If I will build the first city, then it have 4 population and some buildings at start. Also all of technologies I can get with 1 turn (every technology needs only 1 ressearch point to discover). And, I cannot build the pyramids, stonehenge, the oracle, and the rest of the ancient-classical world wonders.

    What I need to do else, to start with the Americans in 3000BC in ancient era?
     

Share This Page