Results 1 to 24 of 24

Thread: MOD: UI - Trade Opportunities

  1. #1
    Join Date
    Apr 2011
    Location
    Near Portsmouth, UK
    Posts
    1,067

    MOD: UI - Trade Opportunities

    Visualise trading opportunites from one screen

    Adds a new Trade Opportunities tab to the Diplomatic screens



    Basic usage
    * Find a resource on the top row (your resoures) with a green number - in this picture Wine.
    * Scan down the column looking for red zeros
    * Scan along that row looking for green numbers that have a corresponding red/yellow zero in the top row
    * The combination of green resources gives you a trade opportunity

    So in this picture I can trade Wine to
    * Songhai for Cotton
    * Rome for Dyes
    * Korea for Sugar

    Of those three, I already have a Research Agreement with Korea, Rome doesn't have enough cash for an RA, but Songhai does. So I'd probably do a combined deal of Wine + RA = Sugar + RA with Songhai

    Which CS to "buy"
    Well I could go for any of them, but I need Silver, Ivory or Incense to start a "We Love The King Day" in one or more cities (indicated by the yellow zeros in the top row), so it would make sense to "buy" a CS that has one of those luxuries. If I hover over the yellow zeros it will show me which cities want that resource, and as it happens, my capital and another city want Silver, so my choice is now down to three City States. I'm going for a cultural win, so one of the cultured two would be best, and if I hover over their icons I see that one is allied to Songhai (who can certainly out-bid me next turn) and the other is allied to Persia (who is locked in wars and about to exit the game anyway) so I'll go for that one. I click on the icon and go into the CS's diplomacy screen, give them a cash "donation", pick up the luxury and watch my citizens love me

    (Follow the link to Flickr, there are more notes on the image)

    Modifies the core game files DiploOverview.lua and DiploOverview.xml, so will be incompatible with any other mod that changes these

    You can find this mod on the Mod Hub under UI -> Widgets
    Last edited by whoward69; 01-25-2012 at 12:26 PM.

  2. #2
    Join Date
    Apr 2011
    Location
    Near Portsmouth, UK
    Posts
    1,067
    So your Silk for Wine trade with Rome has finished (and your happiness has just dropped by 4) but should you just immediately renew it, or is there a better option?

    You want Silver, but only Liz has it and she wants your only Whales. Can you trade your spare Spices with someone else to get Whales, so you can trade yours to Liz for her Silver?

    Six city states have Gold, but which one should you "buy" - preferably a Cultural one not already allied (as you don't want to get into a bidding war) and it would be good if they also had Coal - but which one has all those?

    You have spare cash - who can you make a Research Agreement with?

    You need cash - who's left to sell Open Borders and/or spare luxuries to?

    What luxury will send the most cities into a "We Love The King Day"? And which Civ has that luxury?

    This mod will help answer all those (and more) questions on one screen, thereby avoiding the need to click into evey civ and note what they are willing to trade (and what they want in return). And once you know which Civ to trade with or City State to "buy" you can go to their diplomacy screen with a single click.

  3. #3
    Join Date
    Sep 2010
    Posts
    876
    Dude, you're on a roll with all these great mods, very well done and thank you.

    I've been wanting something like this; I'll definitely be trying it out.

    I hope you'll still be modding when that DLL source code is released because you can probably create some amazing stuff.

  4. #4
    Join Date
    Apr 2011
    Location
    Near Portsmouth, UK
    Posts
    1,067
    Quote Originally Posted by jpbar81 View Post
    I hope you'll still be modding when that DLL source code is released because you can probably create some amazing stuff.
    Personally I think the DLL source code is going to be a huge anti-climax for the vast majority of the modding community - only being of any real use to those few (remaining) modders planning "total conversions".

    It's hard enough adding UI features at the moment, to what is effectively an un-packed class based system, I can't even begin to imagine the chaos that most casual users would experience if every mod had to make its changes to the few XML/LUA files it needed to work but then had to zip the entire UI up into a single file before it could be uploaded and used.

    Even if they take a dynamic AOP (eg Java Spring like) approach, the inability to determine load order will limit its usefulness.

    Personally I'd rather they'd used the time developing extensions to ModBuddy to create (botched) DDS files from JPEG/PNG files - with a UI to make the various sizes of icons and masks needed; making the artwork system part of the GameData system (so you don't have to unpack .fpk files and replace the entire XML file when making new units that use existing 3d artwork); writing a ModBuddy extension so you could *draw* UI dialogs and place components (rather than having to guess with co-ordinates, alignments and offsets); implementing mod load order dependancy; or a number of other generally useful tools/features.

    So far there's only been one mod that I've wanted to write that will need DLL source code access - and even that should be possible with LUA if the events were available.

  5. #5
    Join Date
    Apr 2011
    Location
    The Republic of New Zealand
    Posts
    1,034
    Just so you know ModBrowser is up and operational again.

    These mods are absolutely fantastic, great work Whoward! Would I be allowed to incorperate them into a mod pack? Full credit would be to you of course

  6. #6
    Join Date
    Apr 2011
    Location
    Near Portsmouth, UK
    Posts
    1,067
    Quote Originally Posted by Pouakai View Post
    Would I be allowed to incorperate them into a mod pack? Full credit would be to you of course
    Feel free. I've updated my main page and placed them all into the Public Domain

  7. #7
    Join Date
    Apr 2011
    Location
    Near Portsmouth, UK
    Posts
    1,067
    Now uploaded - enjoy!

  8. #8
    Join Date
    Apr 2011
    Location
    Near Portsmouth, UK
    Posts
    1,067
    Version 2 now uploaded

    • Fixes a memory leak that causes the game to hang after 10 or so "click into civ trade screen" events (note to self, CivV is NOT object-orientated, so stop treating it as if it is!)
    • AI civilization list is now ordered according to current score (so you should favour trading with the civs at the bottom of the screen!)
    • Fixes layout issue in the CS list section

  9. #9
    Join Date
    Jan 2012
    Posts
    9
    I noticed that one of the mods I have adds some notification messages. I was wondering if it would be possible to get a notification message on a new surplus. And/Or, if you want to get fancy, when a possible trade becomes available.

    Excellent mod, btw - I'm using several of yours and like them all so far Thank you.

  10. #10
    Join Date
    Apr 2011
    Location
    Near Portsmouth, UK
    Posts
    1,067
    Interesting ideas.

    The problem is that there's no single way (and hence no single event) to generate a surplus. You can end up with a surplus from several events, eg, allied CS inproves a luxury, you improve a luxury, you conquer a city that has a luxury, a trade ends, etc and there are various ways to lose them as well, eg, loss of ally, loss of city, pillaged, culture bombed, etc. You can't actually do the calculations on events anyway (as you could gain an ally - generate notification, but in the same turn be culture bombed - no surplus), so the calculations have to be done at the start of the player's turn (no good doing it at the end, as other players may affect the outcome before you have time to react).

    Doing those calculations (60 API calls, 90 calculations and 15 compares) at the start of every turn will have an impact on speed - and most of the time (at a guess 90% at the beginning of a game, 97% towards the end) they will be pointless anyway. I'll stick it on the list of things to look at, but definately with an "On/Off" switch!

    Calculating possible trades will have a significant speed impact (multiply all the calls, calculations and comparisons by the number of alive players) and anyway, working out the trades is part of the fun/skill

  11. #11
    Join Date
    Jan 2012
    Posts
    9
    Ah. I was assuming the surplus calculation was already done since it is in the table the mod displays. I can't wait to get deeper into modding so I understand how it all works better. The problem I'm having at the moment is I only just bought the game and am having too much fun playing

  12. #12
    Join Date
    Apr 2011
    Location
    Near Portsmouth, UK
    Posts
    1,067
    Code:
      local iMinors  = pPlayer:GetResourceFromMinors(iResourceID)
      local iExports = pPlayer:GetResourceExport(iResourceID)
      local iImports = pPlayer:GetResourceImport(iResourceID)
      local iLocal   = pPlayer:GetNumResourceTotal(iResourceID, false) + iExports
    
      local iTotal   = iLocal + iMinors + iImports - iExports
      local iTradeSurplus = iLocal - iExports
      local iRealSurplus = iTradeSurplus
    
      if (iMinors+iImports == 0) then
        -- If no allies or imports, reserve one local resource for our own use
        iRealSurplus = iRealSurplus - 1
      end

  13. #13
    Join Date
    Apr 2011
    Location
    Near Portsmouth, UK
    Posts
    1,067
    Quote Originally Posted by Hambil View Post
    Ah. I was assuming the surplus calculation was already done since it is in the table the mod displays.
    It's only there 'cos' I do it in the mod

    If you want a quick way to see if you have a surplus of a luxury, check out the Luxuries part of "UI - Summaries" as it provides all the information as a mouse-over tool-tip on the top panel (so no need to click buttons to get the info)

  14. #14
    Join Date
    Jan 2012
    Posts
    9
    Hmmmm. So, you are pulling the data from a player object... interesting. I need to look at where this data is stored. If it is in memory then the overhead of doing math should be minimal, I and think I can come up with some ways to make even that more efficient. If it's stored in xml (sql) then I need to check if we have the ability to run sql queries directly, because I could pull up the right result with a single query in that case.

    Anyway, as I play this is really just my musing on a larger idea that is coming to mind, about creating something that greatly enhances the trading, diplomatic and other non-war strategies in the game. Preferably with minimal core game impact.

    Again, thanks

  15. #15
    Join Date
    Apr 2011
    Location
    Near Portsmouth, UK
    Posts
    1,067
    Version 4 uploaded - have finally (touch wood) fixed the ordering issue of the Civ and City State rows as new civs are encountered. Also changed the CS list to include those with nearby (but as yet un-improved) resources, as per the CS diplo screens

  16. #16
    Join Date
    Apr 2011
    Location
    Near Portsmouth, UK
    Posts
    1,067
    Version 5 uploaded - includes the City States affairs summary tab



    Display all met City States sorted by trait, name, ally or influence(friendship)

    Make peace and/or gift gold from dedicated icons; see which militaristic states are gifting you units.

    Click the City State name to enter the (more detailed) standard diplomatic screen

    Solves the problem of having to click into multiple CS diplo screens to make peace after making peace with a major civ

    Solves the problem of gifting gold to many CSes at a time

  17. #17
    Nice work.
    Will you be making this compatible with gods and kings.

  18. #18
    Join Date
    Apr 2011
    Location
    Near Portsmouth, UK
    Posts
    1,067
    Quote Originally Posted by Snerk View Post
    Nice work.
    Thank you

    Quote Originally Posted by Snerk View Post
    Will you be making this compatible with gods and kings.
    A question that cannot possibly be answered until Gods and Kings is actually released!

  19. #19
    Join Date
    Apr 2011
    Location
    The Republic of New Zealand
    Posts
    1,034
    Awesome work whoward! Minor querie / suggestion, would it be possible to change 'Destroy Encampment' to 'Clear Encampment' or something else? I find myself missing them as I tend to find myself ignoring "Destroy...." as the CS conquering mission

  20. #20
    Join Date
    Apr 2011
    Location
    Near Portsmouth, UK
    Posts
    1,067
    Good idea for the encampments, I'll add it in the next version. For the time being you can make the change in "...\My Games\Sid Meier's Civilization 5\Mods\UI - Trade Opportunities (v 5)\XML\UITradeOpportunities.xml" by editing the TXT_KEY_DO_CS_STATUS_QUEST_KILL_CAMP entry.

    You can also "fade out" the Destroy entries by changing TXT_KEY_DO_CS_STATUS_QUEST_KILL_CITY_STATE to "[COLOR_GREY]Destroy {1_CityStateName:textkey}[ENDCOLOR]"

    I may make that change in the next version as well.

    And while I'm at it, I'll probably also change the ordering so that roads/wonders come first and the war-monger ones last for each CS

  21. #21
    Join Date
    Apr 2011
    Location
    The Republic of New Zealand
    Posts
    1,034
    Sweet, thanks Whoward!

  22. #22
    Join Date
    Apr 2011
    Location
    Near Portsmouth, UK
    Posts
    1,067
    I notice (a modified version of) this mod has now made it into Unofficial Patch and Vanilla Enhanced Mod

  23. #23
    Join Date
    Apr 2011
    Location
    Near Portsmouth, UK
    Posts
    1,067
    Version 6 uploaded - removes the necessity of having the "Refresh" button (after displaying the CS Popup) by hooking a couple of events that will detect any changes made via the popup

  24. #24
    Please GaK update this, whoward.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •