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. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    34,408
    Gender:
    Male
    Location:
    Leblanc
    Is there a Python event to be handled when the Python code is read again?
     
  2. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    34,408
    Gender:
    Male
    Location:
    Leblanc
    In case anyone else is wondering about that, if you use BUG, there is a "PythonReloaded" event you can hook up to that is fired every time the game refreshes and reinitialises the Python code.
     
  3. Merkava120

    Merkava120 Oberleutnant

    Joined:
    Feb 2, 2013
    Messages:
    387
    Gender:
    Male
    Location:
    Socially distant
    How do you get a graphical effect to continually loop?? (I feel like it should be obvious...)
     
  4. Merkava120

    Merkava120 Oberleutnant

    Joined:
    Feb 2, 2013
    Messages:
    387
    Gender:
    Male
    Location:
    Socially distant
    No, wait, I know how to do it. In CvEventManager there is a function called "update" that you can put looping/constant things in. So a looping graphical effect could be done by putting triggerEffect in update().

    Edit: it seems that the function you should use is onGameUpdate()
     
    Last edited: Jul 15, 2020
  5. ProjectMaximus

    ProjectMaximus Chieftain

    Joined:
    Aug 7, 2014
    Messages:
    21
    Hi Zeta,

    In my modding of ROM AND2 I would like to do exactly the same thing what you've mentioned in this post. I have done the TechIcon size, TechName position and TechPanel button positions so far.

    Have you found the way of widening TechPanels in this mode? I would like to do roughly 1.5x wide on each (same size on all).
    By the way, I would increase the text font size as well a bit.
    Can you (or anyone) help me?
     
  6. rtt4a

    rtt4a Prince

    Joined:
    Mar 3, 2009
    Messages:
    512
    Hi all, can somebody tell me what this python error log means..? I

    Traceback (most recent call last):
    File "CvScreensInterface", line 442, in pediaMain
    File "SevoPediaMain", line 263, in pediaJump
    File "SevoPediaMain", line 322, in showContents
    File "SevoPediaMain", line 552, in placeNationalWonders
    File "SevoPediaMain", line 834, in placeItems
    RuntimeError: unidentifiable C++ exception
    ERR: Python function pediaMain failed, module CvScreensInterface
     
    Last edited: Jul 29, 2020
  7. Zeta Nexus

    Zeta Nexus Deity

    Joined:
    Jan 23, 2014
    Messages:
    3,969
    Gender:
    Male
    Location:
    In a constant brainstorm...
    Where can I find and edit the text marked with yellow?
    upload_2020-7-30_9-56-42.png
     
  8. Zeta Nexus

    Zeta Nexus Deity

    Joined:
    Jan 23, 2014
    Messages:
    3,969
    Gender:
    Male
    Location:
    In a constant brainstorm...
    Actually I have totally forgot about it. :lol:
    I tried it this morning but with only partial success (increased the tech icon size but it covers tech name and unblockable content).
    Can you share your file, your changes?
     
  9. Dancing Hoskuld

    Dancing Hoskuld Deity

    Joined:
    Jul 5, 2004
    Messages:
    23,539
    Gender:
    Male
    Location:
    Canberra, Australia
    I looked at my versions of SevoPedia but the line numbers don't line up. It usually means there is something wrong with what is being displayed. It is probably not a wrong sized icon or two items with the same name, as those cause other problems:lol:. I would need to see that python module (SevoPediaMain.py) to be able to help more.
     
  10. rtt4a

    rtt4a Prince

    Joined:
    Mar 3, 2009
    Messages:
    512
    Hi, heres main.py if you really have time to check:) this error cause pedia not working (building and techs) and trying to use it will crash game.. also if try to star game it will open without UI.
     

    Attached Files:

  11. ProjectMaximus

    ProjectMaximus Chieftain

    Joined:
    Aug 7, 2014
    Messages:
    21
    Hi Zeta,

    There is a good news, I finished completely my TechTree (see uploaded CvTechChooser.py file and some pics). :)

    I used Note++.

    1. TechName
    Line 417: (szTechID, szTechRecord, szTechString, CvUtil.FONT_LEFT_JUSTIFY, iX + 6 + X_INCREMENT*2, iY + 6, -0.1, FontTypes.SMALL_FONT, WidgetTypes.WIDGET_TECH_TREE, i, -1)
    Line 1146: (szTechID, sPanel, szTechString, CvUtil.FONT_LEFT_JUSTIFY, iX + 6 + X_INCREMENT*2, iY + 6, -0.1, FontTypes.SMALL_FONT, WidgetTypes.WIDGET_TECH_TREE, i, -1)

    2. TechIcon size & TechName positioning
    Line 422: (szTechButtonID, szTechRecord, gc.getTechInfo(i).getButton(), iX + 6, iY + 6, TEXTURE_SIZE*2, TEXTURE_SIZE*2, WidgetTypes.WIDGET_TECH_TREE, i, -1, False)
    Line 1146: (szTechID, sPanel, szTechString, CvUtil.FONT_LEFT_JUSTIFY, iX + 6 + X_INCREMENT*2, iY + 6, -0.1, FontTypes.SMALL_FONT, WidgetTypes.WIDGET_TECH_TREE, i, -1)

    3. TechPanel button positions
    Line 425: (screen, i, X_START+ X_INCREMENT*2, iX, iY - 3, szTechRecord)

    4. TechPanel lenghtening
    Line 107, 256, 263, 267, 1079, 1084: BOX_INCREMENT_WIDTH = 30

    5. I changed the colours of all era and the colour of selecting requested tech.
    If you don't like my style, just ignore this part or you can adjust the numbers in RGB system:

    Line 373: (szTechRecord, 255, 255, 0) - yellow for current research
    Line 376: (szTechRecord, 255, 0, 0) - red for researching tech

    Line 383: (szTechRecord, 96, 42, 30) - Ancient
    Line 386: (szTechRecord, 50, 55, 2) - Classical
    Line 389: (szTechRecord, 0, 96, 18) - Medieval
    Line 392: (szTechRecord, 0, 74, 74) - Renaissance
    Line 395: (szTechRecord, 0, 55, 85) - Industrial
    Line 398: (szTechRecord, 0, 0, 122) - Modern
    Line 401: (szTechRecord, 124, 0, 130) - Future

    then the same in

    Line 1152: (szTechRecord, 255, 255, 0) - yellow for current research
    Line 1154: (szTechRecord, 255, 0, 0) - red for researching tech

    Line 1160: (szTechRecord, 96, 42, 30) - Ancient
    Line 1163: (szTechRecord, 50, 55, 2) - Classical
    Line 1166: (szTechRecord, 0, 96, 18) - Medieval
    Line 1169: (szTechRecord, 0, 74, 74) - Renaissance
    Line 1172: (szTechRecord, 0, 55, 85) - Industrial
    Line 98: (szTechRecord, 0, 0, 122) - Modern
    Line 401: (szTechRecord, 124, 0, 130) - Future
     

    Attached Files:

    Merkava120, lfgr and Zeta Nexus like this.
  12. LPlate2

    LPlate2 Warlord

    Joined:
    Dec 27, 2018
    Messages:
    134
    Hi,

    I’m trying to cycle through the yields and get the yield value on some plots.
    I’m currently trying,
    Code:
    for i in range(YieldTypes.NUM_YIELD_TYPES):
       plotYield = pPlot.getYield(i)
    This is now giving me a, “ this constructor takes no arguments” error.
    In CyPlot.h, the function is
    int getYield(YieldTypes eIndex).

    How do I get this to work?
     
  13. bluepotato

    bluepotato Warlord

    Joined:
    Dec 11, 2018
    Messages:
    240
    Looks like getYield expects a YieldTypes enum type. So I think you could use something like
    Code:
    pPlot.getYield(YieldTypes(i))
    (but I haven't tested that so I might be wrong.)
     
  14. LPlate2

    LPlate2 Warlord

    Joined:
    Dec 27, 2018
    Messages:
    134
    Thanks, worked
     
  15. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    34,408
    Gender:
    Male
    Location:
    Leblanc
    Is there an existing, XML-only way to make multiple buildings mutually exclusive? I am thinking about a bunch of early buildings that require a Palace and an give early specialist slots, but each civ should only be allowed to have one of them.

    If not, what is the most elegant way to solve this? I am thinking of giving SpecialBuildings a "max player instances" attribute and make all those buildings instances of the same special building.
     
  16. Merkava120

    Merkava120 Oberleutnant

    Joined:
    Feb 2, 2013
    Messages:
    387
    Gender:
    Male
    Location:
    Socially distant
    Here's the line in question -

    Code:
    screen.setTableText(self.ITEM_LIST_ID, 0, i, u"<font=3>" + item[0] + u"</font>", info(item[1]).getButton(), widget, data1, data2, CvUtil.FONT_LEFT_JUSTIFY)
    
    For reference, here's the same sort of line in the normal CvPediaMain.py:

    Code:
    screen.setTableText(tableName, iColumn, iRow, u"<font=3>" + item[0] + u"</font>", gc.getTechInfo(item[1]).getButton(), WidgetTypes.WIDGET_PEDIA_JUMP_TO_TECH, item[1], 1, CvUtil.FONT_LEFT_JUSTIFY)
    
    I don't see anything obviously wrong, but the info(item[1]).getButton() seems fishy for some reason. Usually when I get a C++ exception it's because I am referring to something that I think exists, but doesn't actually; for example, using gc.getInfoTypeForString("TECH_RADAR") when I haven't actually added TECH_RADAR to the xml. In this case, I'm betting that whatever that "info(item[1])" is, it's been messed up somewhere so that it no longer refers to what it should be referring to.

    It could be something else in that line doing the same thing...but nothing jumps out at me.
     
    rtt4a likes this.
  17. Merkava120

    Merkava120 Oberleutnant

    Joined:
    Feb 2, 2013
    Messages:
    387
    Gender:
    Male
    Location:
    Socially distant
    All of the text in the victory screen seems to be set up in roughly lines 500-600 of CvVictoryScreen.py. But if you want to just find the text and edit it directly, you can search around in your mod's XML/Text files for whichever one says "ascension" and change it there.

    It's possible that whatever mod builds that part of the victory screen using the name of the building rather than any specific text - for example, "Build" followed by TXT_KEY_BUILDING_GATEOFASCENSION (or even pBuilding.getDescription()) in which case you'd have to edit the lines in CvVictoryScreen if you want to change it beyond that.

    That's the place Platyping adds text for new victory mods.
     
  18. Merkava120

    Merkava120 Oberleutnant

    Joined:
    Feb 2, 2013
    Messages:
    387
    Gender:
    Male
    Location:
    Socially distant
    First, I'm not sure, but buildings aren't able to require other buildings, are they? There are mods that do that but I'm pretty sure vanilla doesn't let you require buildings to build buildings. (Although you can get around it by having the building be required for a unit, which then builds its own building, like a military academy for great generals.)

    Edit: I just found BuildingClassNeededs in the XML and it changed my life.

    Second, I don't know about "elegant"...but I can think of some ways I'd tackle this:
    1. The max player instances for specialbuildings would work but requires SDK (though not that much SDK)
    2. Using purely XML, you could have an event with a trigger of iWeight = -1, whose only condition is building a certain building. Then use this building ("BUILDING_DUMMY" or something) to trigger a set of events where the player can choose between different buildings to build in the city. The event trigger can be set to trigger only once. Problem with this is that the AI might not know to build the dummy building unless you give it some benefit, and removing the dummy building would require python (but would be really easy). Or, you could just set the event to trigger when the first city is founded and shortcut all the dummy building stuff.
    3. Using python, you could mess around in canConstruct in CvGameUtils and whip out the mutual exclusion pretty easily. Probably not very elegant but very easy. (Although you would have to check to make sure the building isn't built in any of the player's cities, which could become a big loop - though I suppose you could just check whatever city the palace is in, because the buildings will require the palace)
    4. With SDK you could add a list tag to the BuildingInfos tile, like <CannotBuildBuildings>, that lists buildings that, if built in the city, will make this building unable to be built. But that seems like just a slightly more complicated way to do the SpecialBuilding thing you were saying.
    5. Or with XML you could just make the buildings National Wonders and limit each city to 1 national wonder. But that would also exclude other national wonders, and wouldn't keep the whole civ from building the other buildings, just that one city.
    6. Combining python with XML you could do some fancy tech trigger thing where once one of the buildings is built, something is triggered that removes the tech necessary to build all the other buildings. Might work a little better than the dummy building thing or the canConstruct but it's a little more complicated.
     
    Last edited: Aug 12, 2020
  19. Zeta Nexus

    Zeta Nexus Deity

    Joined:
    Jan 23, 2014
    Messages:
    3,969
    Gender:
    Male
    Location:
    In a constant brainstorm...
    Afforess has added some code for AND that does just the thing you want:
    Code:
                <PrereqNotBuildingClasses>
                    <PrereqNotBuildingClass>
                        <BuildingClassMustNotHave>BUILDINGCLASS_NEWTONS_UNIVERSITY</BuildingClassMustNotHave>
                        <bPrereqNot>1</bPrereqNot>
                    </PrereqNotBuildingClass>
                    <PrereqNotBuildingClass>
                        <BuildingClassMustNotHave>BUILDINGCLASS_LEONARDO</BuildingClassMustNotHave>
                        <bPrereqNot>1</bPrereqNot>
                    </PrereqNotBuildingClass>
                </PrereqNotBuildingClasses>
    
    With the code above a city cannot build the Copernicus Observatory if it already has Newton's University or Leonardo's Workshop.
     
  20. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    34,408
    Gender:
    Male
    Location:
    Leblanc
    Great, thanks! I am not opposed to editing the DLL, I just want to do it the least invasive way. And make sure I am not missing an already existing way to do this.
     

Share This Page