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

building commerce and yield by resource

Discussion in 'Civ4 - Mod Components' started by davidlallen, Nov 27, 2009.

  1. davidlallen

    davidlallen Deity

    Joined:
    Apr 28, 2008
    Messages:
    4,743
    Location:
    California
    Here is a small modcomp which allows buildings to generate commerce and yield based on the number of a resource controlled. For example, "+2 production per coal resource controlled" or "+0.75 food per rice resource controlled". You can view this as "Lightweight Corporations". The effect is similar, but there is no maintenance, no spread, and no executives. Please see this thread for additional design discussion. Here is a screenshot of the city screen:



    The attached files include:
    * Modified sdk files CvInfos.h, CvInfos.cpp, CvCity.cpp, CvGameTextMgr.cpp, CyInfoInterface1.cpp. These are copied from 3.19 vanilla with comments "davidlallen: building bonus yield, commerce" to mark the change points.
    * Modified python file CvMainInterface.py to show the building statistics in the city screen
    * Modified CIV4BuildingsSchema.xml to show the new xml syntax
    * New file assets/xml/text/bldg-cy.xml containing one format string needed in cvgametextmgr.cpp; you can put this text into any text/*.xml file you want
    * Example CIV4BuildingInfo.xml; I modified the palace to give +5 commerce and +3 culture per wheat resource.
    * Compiled cvgamecoredll.dll, in case you want to use this as your only modcomp

    The xml syntax is shown in the example xml:
    Code:
    	<BonusConsumed>BONUS_SPICE</BonusConsumed>
    	<CommerceProduced>
    		<iCommerce>200</iCommerce>
    		<iCommerce>300</iCommerce>
    		<iCommerce>400</iCommerce>
    		<iCommerce>500</iCommerce>
    	</CommerceProduced>
    	<YieldProduced>
    		<iYield>600</iYield>
    		<iYield>700</iYield>
    		<iYield>800</iYield>
    	</YieldProduced>
    
    As you can see, only a single bonus can be supplied. For my application, one is always enough. For your application, you may prefer a list; changing the BonusConsumed to a list should not be too hard for another modder to take up.
     

    Attached Files:

  2. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    Awesome! I wanted a feature like this a while ago. This seems really useful.

    One question though, does it literally consume the resource, or just provide X yeild/commerce per resource available to the city?
     
  3. davidlallen

    davidlallen Deity

    Joined:
    Apr 28, 2008
    Messages:
    4,743
    Location:
    California
    It works the same as corporations. The resource is not used up or anything; but the building provides a much larger benefit if you have multiple of the same resource.
     
  4. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    I see. Great Work. ;)
     
  5. The_J

    The_J Say No 2 Net Validations Retired Moderator Supporter

    Joined:
    Oct 22, 2008
    Messages:
    31,153
    Location:
    Germany / Netherlands
    Nice idea, good work :goodjob:.
     
  6. Arian

    Arian No more ghostbusting!!

    Joined:
    May 10, 2008
    Messages:
    2,088
    Location:
    The Netherlands
    I like this one :goodjob:
    Any chance for a release where you can use more than one resource per building like giving a forge extra :hammers: for each iron or copper resource?
     
  7. davidlallen

    davidlallen Deity

    Joined:
    Apr 28, 2008
    Messages:
    4,743
    Location:
    California
    I agree that making BonusConsumed into a list would be a good enhancement. I am not planning on doing that myself in the short term, but it should not be too hard to add.
     
  8. SaibotLieh

    SaibotLieh Emperor

    Joined:
    Sep 25, 2009
    Messages:
    1,456
    Thanks, this is really useful for me. Does this make the resources tradeable like corporations do?
     
  9. davidlallen

    davidlallen Deity

    Joined:
    Apr 28, 2008
    Messages:
    4,743
    Location:
    California
    A corporation can consume one resource and produce other resources or yields or commerces. With this modcomp, buildings can produce yields and commerces, but not other resources. So there are no new resources created.
     
  10. SaibotLieh

    SaibotLieh Emperor

    Joined:
    Sep 25, 2009
    Messages:
    1,456
    Ah, sorry, I meant if the resources are tradeable between civilisations even if both have at least one of it. For example, Sid's Sushi Co. makes Fish, Crabs, Clam and Rice tradeable again.
     
  11. Arian

    Arian No more ghostbusting!!

    Joined:
    May 10, 2008
    Messages:
    2,088
    Location:
    The Netherlands
    That's "Beyond The Skills", my skills ;)
     
  12. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    Actually, I did it, in about 10 minutes. However, one problem. The way you coded it, I can list multiple bonuses, but they will each have the same effect. I can't make an Iron give +2 hammers each, and a wheat give +2 food each, they have to give the same effect.

    You'd need to code it as two multidimensional arrays, one for commerce, the other for yields. While I'm dreaming, can I have two more multi-arrays, for modifiers as well? :mischief:
     
  13. Arian

    Arian No more ghostbusting!!

    Joined:
    May 10, 2008
    Messages:
    2,088
    Location:
    The Netherlands
    Now that's quite a big enhancement!
     
  14. Dancing Hoskuld

    Dancing Hoskuld Deity

    Joined:
    Jul 5, 2004
    Messages:
    23,329
    Gender:
    Male
    Location:
    Canberra, Australia
    Haven't you noticed "users" always want more :lol:
     
  15. Arian

    Arian No more ghostbusting!!

    Joined:
    May 10, 2008
    Messages:
    2,088
    Location:
    The Netherlands
    It's the eternal strive for perfection ;)
     
  16. keldath

    keldath LivE LonG AnD PrOsPeR

    Joined:
    Dec 20, 2005
    Messages:
    6,519
    Location:
    israel
    superb bro.

    keep it up.
     
  17. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    Eh, not really. I hate being limited, and that limitation would always bother me. Perhaps this evening, or this weekend, if I run out of time, I will code it as a multidimensional array. All 4 arrays.
     
  18. Arian

    Arian No more ghostbusting!!

    Joined:
    May 10, 2008
    Messages:
    2,088
    Location:
    The Netherlands
    As I said earlier: It's the eternal strive for perfection ;)
     
  19. davidlallen

    davidlallen Deity

    Joined:
    Apr 28, 2008
    Messages:
    4,743
    Location:
    California
    Is there a reason that has to be done in the same building? What is it, a combination forge / granary? You can use the existing code if you limit each building to one effect.
     
  20. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    No real reason... but why limit myself to only one bonus and one commerce and yield change?
     

Share This Page