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

Platy World Builder

Discussion in 'Civ4 - Mod Components' started by platyping, Mar 27, 2013.

  1. platyping

    platyping Sleeping Dragon

    Joined:
    Oct 22, 2010
    Messages:
    4,626
    Location:
    Emerald Dreams
    Version 4.05

    1) Adds a "Hide Inactive" option
    Hides UU/UB irrelevant to the current player.
    Babylon will only see Bowmen but not Archer, Tank but not Panzer.

    Applied to Main Screen, Units, Buildings

    2) Unit Screen rearranged to add in Map and the above feature.
     
  2. MagisterCultuum

    MagisterCultuum Great Sage

    Joined:
    Feb 14, 2007
    Messages:
    16,341
    Location:
    Kael's head
    Thanks for the update.

    I already released the MNAI merge and will probably release the MagisterModmod merge tonight.

    You aren't planning on releasing another update in the next couple days are you?

    If so, I'd rather not upload MagisterModmod again before incorporating its changes.



    Do you intend to extend the Hide Inactive button to other screens? You may notice if you look at WorldBuilder 4.05 for MNAI that I went ahead and applied it to Player Data, where it toggles between showing or not showing technologies, civics, and state religions that are not currently available. (Previously I had shown all of them, while showed all the religions and civics but only the available technologies.) You are welcome to borrow that code if you wish.

    Come to think of it, it might be a good idea to make Hide Inactive also hide the ability to adjust culture and espionage when the prerequisites for adjusting them are not met. I think I'll include that in MagisterModmod now, even i it is too minor to warrant changing MNAI.

    I'm not sure if it would occur when only the currently available technologies are shown, but I've often gotten minor python exceptions when I tried adding too much research through the Player Data screen too quickly. It also looked odd when you could see that a player had 5000/80 towards some tech, when the +/- number was higher than the tech cost. I fixed both issues like this:
    Code:
    		elif inputClass.getFunctionName().find("CurrentResearch") > -1:
    			iTech = pPlayer.getCurrentResearch()
    			[COLOR="Red"]if iTech > -1:[/COLOR]
    				if inputClass.getData1() == 1030:
    					pTeam.changeResearchProgress(pPlayer.getCurrentResearch(), [COLOR="Red"]min(iChange, pTeam.getResearchCost(iTech) - pTeam.getResearchProgress(iTech))[/COLOR], iPlayer)
    				elif inputClass.getData1() == 1031:
    					pTeam.changeResearchProgress(pPlayer.getCurrentResearch(), - min(iChange, pTeam.getResearchProgress(iTech)), iPlayer)
    				self.placeResearch()
     
  3. platyping

    platyping Sleeping Dragon

    Joined:
    Oct 22, 2010
    Messages:
    4,626
    Location:
    Emerald Dreams
    Version 4.05b

    Actually, I didn't plan to do any update recently, but since you made suggestions... (You didn't give me chance to respond :D)

    1) Added Hide Inactive to Player Screen to hide Civics and Religions not currently available. Actually, these 2 are already color coded, which is why I didn't bother to do it initially. As for techs, all along, it only displayed techs which you can currently research.

    2) Added Hide Inactive to Promotion Screen.

    3) Commerce Adjustment buttons in Player Screen are no longer displayed if player can not adjust them yet.
    This is true regardless of whether Hide Inactive is active or not.

    4) Player Screen, Current Tech Progress limited to research cost.
    The iTech > -1 check wasn't really necessary, since the buttons are hidden if no tech selected, but I added it anyway.

    5) Player Screen, Combat XP limited to threshold.

    6) Player Screen, Coastal Trade Routes limited to MAX TRADE ROUTES

    7) City Data Screen, Extra Trade Routes limited to MAX TRADE ROUTES

    8) City Data Screen, Food limited to Food Threshold.

    9) City Data II Screen, Great People Progress limited to GP Threshold.

    10) Team Data Screen, Nuke Interception limited to 100.

    P.S.
    Actually I saw your Unit Screen format long ago, so since I needed to add the new feature, I might as well change the format closer to yours to make merging easier for you :D
     
  4. derflensburger

    derflensburger Chieftain

    Joined:
    Sep 12, 2006
    Messages:
    73
    Great work, I have seen it in the Mod "History Rewritten".

    A guide about how to install this WB into the original game would be nice (thread page 1)!
     
  5. platyping

    platyping Sleeping Dragon

    Joined:
    Oct 22, 2010
    Messages:
    4,626
    Location:
    Emerald Dreams
    Just place the whole download into the mods folder and load it as a mod?
     
  6. platyping

    platyping Sleeping Dragon

    Joined:
    Oct 22, 2010
    Messages:
    4,626
    Location:
    Emerald Dreams
    Version 4.06

    New Function:
    As most of you know, certain functions in WB will trigger functions in CvEventManager, such as onUnitCreated and onPlotRevealed, while others do not trigger, such as new cities will not trigger onCityBuilt, or new buildings will not trigger onBuildingBuilt.

    If you think about it, it makes perfect sense, since they are not "Built", but created from nowhere.

    Thus, an option is added which can trigger those effects as if they were built.
    Didn't bother for onUnitBuilt though, since onUnitCreated is already triggered.



    P.S.
    Hide Inactive is now modified in main screen and applied across all respective screens.
     
  7. MagisterCultuum

    MagisterCultuum Great Sage

    Joined:
    Feb 14, 2007
    Messages:
    16,341
    Location:
    Kael's head
    Thanks for the update!

    Controlling when python stuff gets triggered will be very useful in FfH2 based modmods.

    I think it would be a good idea to make the toggle also control the triggering of these functions:

    onTechAcquired
    onReligionFounded
    onReligionSpread
    onPlayerChangeStateReligion
    onCityRazed
    onCityAcquired
    onImprovementBuilt
    onImprovementDestroyed
    onUnitKilled
    onUnitLost


    I'm about to try to implement it like that in my Worldbuilder 4.06 for MNAI, so you could copy that code if you wish. Or maybe you could hurry up with another update and I could copy you? Actually, now that I think of it, the mods' respective CvEventManager files are very different so copying code between versions might be harder than just implementing it on our own.

    Edit: Hmm...It is harder than I was expecting to make the toggle apply to things which would be triggered in worldbuilder normally if not for a conditional added in CvEventManager.py. I can add a condition to check and see if we are in worldbuilder, but don't think I can use anything like self.top.bPython while in CvEventManager.py. I think I'll release Worldbuilder 4.06 for MNAI without such new features, and then see what if anything you do about them.


    Since you went ahead and added new buttons for Hide Inactive and Trigger Python Effects, could you add some more new buttons to access some of the screens that currently require going to other screens first and using a menu?



    p.s. This doesn't really matter, but I prefer to have the boolean variable written as True rather than true, so that my editor recognizes the keyword and puts it in blue. You used the lower case a lot in your latest changes. Could you change that just to make future merges go more smoothly.
     
  8. Xyth

    Xyth History Rewritten

    Joined:
    Jul 14, 2004
    Messages:
    4,054
    Location:
    Aotearoa
    Awesome, thanks for this Platy!
     
  9. platyping

    platyping Sleeping Dragon

    Joined:
    Oct 22, 2010
    Messages:
    4,626
    Location:
    Emerald Dreams
    Version 4.06b

    1) Added many buttons in main page for direct access to all pages.

    2) Fix bug in accessing Diplomacy Page in 4.06. CvScreensInterface

    @Magister
    As mentioned, there are functions in WB (Even BTS WB) which do trigger functions in CvEventManager by default. onTechAcquired, onReligionSpread, onUnitCreated, onUnitLost, onImprovementBuilt, onGreatPeopleBorn etc are all triggered automatically by those python functions.

    What I can do is add extra codes to trigger those which are NOT triggered automatically, but there is no way I can code it to NOT trigger those which are triggered automatically.

    As such, there is nothing I can do to tell it to trigger/not trigger onTechAcquired for instance, because it definitely will.

    onUnitKilled, onUnitBuilt, onCityRazed and onPlotFeatureRemoved are not triggered automatically but I have not added those yet.

    onCityRazed and onUnitKilled are problematic, because if -1 is used as the attacking player, it will cause a C++ exception error. But using another player ID doesn't make sense, since he/she is quite innocent...

    onUnitBuilt I still thinking whether to code it, since onUnitCreated is triggered automatically.

    As for onPlotFeatureRemoved, well... removing is more troublesome than addition, because there are many ways to remove, so codes are needed in too many areas.

    P.S.
    As for true vs True and false vs False, if you happen to see this, it means I did not type that code from scratch. C&P somewhere from BTS codes.
    Blame it on Firaxis :mischief:
     
  10. MagisterCultuum

    MagisterCultuum Great Sage

    Joined:
    Feb 14, 2007
    Messages:
    16,341
    Location:
    Kael's head
    Thanks again!

    That was quick work. 4.06b seems like a bigger change than 4.06 was.

    Its too bad neither of us could think of a way to prevent those functions which are triggered even in WB by default from triggering when the bPython toggle was set to false.

    The ones I most wanted to be able to control (excluding those you already implimented) were onUnitLost, onTechAcquired, and onReligionSpread.

    I certainly understand the desire to avoid C++ exceptions.

    FfH2 mods (or at least mine and Tholal's) don't use onPlotFeatureRemoved anyway, so don't worry about it.



    Is "2) Fix bug in accessing Diplomacy Page in 4.06. CvScreensInterface" in red because you have yet to do it?
    I'm definitely getting such a bug with version 4.06b.
    Code:
    Traceback (most recent call last):
    
      File "CvScreensInterface", line 310, in WorldBuilderDiplomacyModeCB
    
    TypeError: interfaceScreen() takes exactly 3 arguments (2 given)
    ERR: Python function WorldBuilderDiplomacyModeCB failed, module CvScreensInterface
    
    Code:
    def WorldBuilderDiplomacyModeCB():
    	WBDiplomacyScreen.WBDiplomacyScreen(worldBuilderScreen).interfaceScreen(CyGame().getActivePlayer())
    
    Hopefully this can be sorted through before my next release.

    It looks like this is all that is needed:
    CvScreensInterface.py:
    Code:
    def WorldBuilderDiplomacyModeCB():
    	WBDiplomacyScreen.WBDiplomacyScreen(worldBuilderScreen).interfaceScreen(CyGame().getActivePlayer()[COLOR="Red"], False[/COLOR])
    
    CvPlatyBuilderScreen.py:
    Code:
    		elif inputClass.getFunctionName() == "EditCorporations":
    			WBCorporationScreen.WBCorporationScreen(self).interfaceScreen(self.m_iCurrentPlayer)
    [COLOR="Red"]
    		elif inputClass.getFunctionName() == "EditDiplomacy":
    			WBDiplomacyScreen.WBDiplomacyScreen(self).interfaceScreen(self.m_iCurrentPlayer, False)[/COLOR]
    
    		elif inputClass.getFunctionName() == "EditEspionage":
    			WBDiplomacyScreen.WBDiplomacyScreen(self).interfaceScreen(self.m_iCurrentPlayer, True)
    
    Anyway, I should probably try to get some sleep now. I'll check back in here before releasing anything.
     
  11. platyping

    platyping Sleeping Dragon

    Joined:
    Oct 22, 2010
    Messages:
    4,626
    Location:
    Emerald Dreams
    Version 4.06c

    1) Fix missing Plot Data Header Text

    2) Expanded Python Effects to more functions.



    At the moment, they are ALL or NONE. Too troublesome to make choices which to activate/deactivate.

    Anything in red, is a bug fix.
    The one mentioned in CvScreensInterface should have been fixed in 4.06b
     
  12. MagisterCultuum

    MagisterCultuum Great Sage

    Joined:
    Feb 14, 2007
    Messages:
    16,341
    Location:
    Kael's head
    The current download seems to be 4.06b + the Diplomacy fix. It does not include the Plot Data Header Text fix or any of the Python effects changes you say are in 4.06c.

    (I'm also a bit confused at how the CvScreensInterface.py fix alone solved the diplomacy issue. It seems to works fine without the CvPlatyBuilderScreen.py change I assumed was also needed, but I'm not sure why.)
     
  13. platyping

    platyping Sleeping Dragon

    Joined:
    Oct 22, 2010
    Messages:
    4,626
    Location:
    Emerald Dreams
    Uploaded Ultrapack, but forgot to upload WB standalone :D
    Reuploaded.

    Anyway, the easiest way to check WB version is to check the version stated in CvWBDesc.
     
  14. Xyth

    Xyth History Rewritten

    Joined:
    Jul 14, 2004
    Messages:
    4,054
    Location:
    Aotearoa
    Editing Player Script Data is causing an error in 4.06c:

    Code:
    Traceback (most recent call last):
    
      File "CvEventInterface", line 27, in applyEvent
    
      File "CvEventManager", line 207, in applyEvent
    
      File "CvEventManager", line 1089, in __eventWBPlayerScriptPopupApply
    
    TypeError: __init__() takes exactly 1 argument (2 given)
    ERR: Python function applyEvent failed, module CvEventInterface

    As does City Script Data:

    Code:
    Traceback (most recent call last):
    
      File "CvEventInterface", line 27, in applyEvent
    
      File "CvEventManager", line 207, in applyEvent
    
      File "CvEventManager", line 1096, in __eventWBCityScriptPopupApply
    
    TypeError: __init__() takes exactly 1 argument (2 given)
    ERR: Python function applyEvent failed, module CvEventInterface

    And Plot Script Data:

    Code:
    Traceback (most recent call last):
    
      File "CvEventInterface", line 27, in applyEvent
    
      File "CvEventManager", line 207, in applyEvent
    
      File "CvEventManager", line 1119, in __eventWBPlotScriptPopupApply
    
    TypeError: __init__() takes exactly 1 argument (2 given)
    ERR: Python function applyEvent failed, module CvEventInterface
    Game and Unit Script Data appear to work fine though, as does Landmark naming. These errors occur in the standalone Platy Builder without any merging.
     
  15. platyping

    platyping Sleeping Dragon

    Joined:
    Oct 22, 2010
    Messages:
    4,626
    Location:
    Emerald Dreams
    Version 4.06d

    1) Fix the above (CvEventManager)

    2) Enlarges Script Data space in Unit Screen
     
  16. MagisterCultuum

    MagisterCultuum Great Sage

    Joined:
    Feb 14, 2007
    Messages:
    16,341
    Location:
    Kael's head
    I was just playing around with a change in my modmod which I thought would be easiest to test using one of the FfH2 scenarios, and came across a problem which prevented that scenario from loading correctly.
    Spoiler :
    Code:
    Traceback (most recent call last):
    
      File "CvWBInterface", line 271, in applyInitialItems
    
      File "CvWBDesc", line 2612, in applyInitialItems
    
    AttributeError: 'CyMap' object has no attribute 'setRevealed'
    ERR: Python function applyInitialItems failed, module CvWBInterface
    Traceback (most recent call last):
    
      File "BugUtil", line 692, in <lambda>
    
      File "BugEventManager", line 570, in preGameStart
    
      File "CvAppInterface", line 70, in preGameStart
    
      File "CvScreensInterface", line 117, in showTechChooser
    
      File "CvTechChooser", line 231, in interfaceScreen
    
      File "CvTechChooser", line 243, in ConstructTabs
    
      File "CvTechChooser", line 280, in DrawTechChooser
    
      File "CvTechChooser", line 324, in placeTechs
    
    AttributeError: type object 'CvPythonExtensions.WidgetTypes' has no attribute 'WIDGET_TECH_CHOOSER_ERA'
    ERR: Python function preGameStart failed, module CvAppInterface
    
    Note that line 2612 in my version would be equivalent to 2026 in yours, as mine has some FfH2 specific stuff added.

    I think this is is the first WorldBuilder save file I have tried to open where one of the teams has RevealMap=1 instead of RevealMap=0.

    This means that pWBTeam.bRevealMap is True, and that under def applyInitialItems(self): the line CyMap().setRevealed(iTeamLoop, True, False) gets called.

    From looking at the API, it appears that the function you mean to use there is
    VOID setRevealedPlots (TeamType eTeam, BOOL bNewValue, BOOL bTerrainOnly)


    Everything seems to work fine after making that minor change.
     
  17. platyping

    platyping Sleeping Dragon

    Joined:
    Oct 22, 2010
    Messages:
    4,626
    Location:
    Emerald Dreams
    Version 4.06e

    1) Fix the above
    One of the minor functions which I can't be bothered to test :mischief:
     
  18. platyping

    platyping Sleeping Dragon

    Joined:
    Oct 22, 2010
    Messages:
    4,626
    Location:
    Emerald Dreams
    Version 4.07

    1) Starting Plot
    Added ability to edit starting plot for individual players.
    Mainly for scenario making purposes.

    2) Existing Trades/Deals
    Added a page where you can cancel existing deals, such as Peace Treaty, Resource Trades, Gold Per Turn. Naturally, you will also find Open Borders, Defensive Pact, Vassals here too, although you can change them in original Diplomacy Screen too.



    3) Info Screen

    As the name states, nothing useful.
    Just a screen to locate whatever you like.
    If you are not sure how many Aluminium there are already on the map, this is your FAQ section.
    Can't find it? Click on the plot number and it will blink on the map. Click on Plot Data and it brings you to the plot.

    P.S.
    Actually, there was supposed to be a 4th new item in 4.07, but I decided to put it on hold. As we all know, if you manually edit the WB Save file, any error = instant defeat, sometimes without a helpful error message to identify where the error is.
    4th function was meant to rewrite the WB load system to ignore all errors, load everything else, and inform you where the errors are at the end of it.
    But I decided it is too much trouble, since nobody really edits manually except for leader details.
     
  19. isenchine

    isenchine Empress

    Joined:
    Oct 18, 2010
    Messages:
    1,774
    Location:
    Brussels, Belgium
    Wow! Info screen is interesting. Thank you! :)

    I still do edit scenarios manually a lot despite the lack of visualisation (but of course I don't make mistakes! :D)

    Both methods are complementary, not exclusive.
     
  20. MagisterCultuum

    MagisterCultuum Great Sage

    Joined:
    Feb 14, 2007
    Messages:
    16,341
    Location:
    Kael's head
    Very nice!

    The info screen should be particularly useful in FfH2, to find equipment and whatnot.


    Would it be possible for the trade screen to let you force new deals too, in addition to cancelling old ones?


    Edit: I just merged this with my modmod, and during my first test I found this bug whenever I try to use the new Info screen to look at Religions.
    Code:
    Traceback (most recent call last):
    
      File "CvScreensInterface", line 741, in handleInput
    
      File "WBInfoScreen", line 363, in handleInput
    
      File "WBInfoScreen", line 68, in interfaceScreen
    
      File "WBInfoScreen", line 316, in placeItems
    
    IndexError: list index out of range
    ERR: Python function handleInput failed, module CvScreensInterface
    Edit: I just tracked this down, and found this bug also occurs in a version of the mod I hadn't touched. (The CvScreensInterface part of the error traceback is in line 420 instead of 741 in the base version, but the rest is the same.)

    There is a very similar bug for viewing Corporations, but that did not happen in MNAI of MagisterModmod as there are no corporations there.

    Edit: I noticed that for bonuses, improvements, routes, features, terrains, units, promotions, and buildings, things are appended to a list in a format like lItems.append([Info.getDescription(), 0, 0, i, Info.getButton(), []]) whereas for religions and corporations it is like lItems.append([Info.getDescription(), pPlayer.getHasReligionCount(i), CyGame().countReligionLevels(i), i, Info.getButton()]) instead.

    When I changed that to lItems.append([Info.getDescription(), pPlayer.getHasReligionCount(i), CyGame().countReligionLevels(i), i, Info.getButton(), []]) then everything seemed to work fine.


    When using the Info screen to track down the location of promotions, I think it would be more useful to link to the unit with the promotion rather than just the plot. There could be many units with the promotion on the plot as well as many without it.

    I think that the Plot Data screen, and quite possibly the unit, promotions, city, building, etc, screens should have links back to new Info screen.
     

Share This Page