building commerce and yield by resource

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.
 

Attachments

  • building-help.gif
    building-help.gif
    14.7 KB · Views: 1,065
  • bldg-cy.zip
    1.7 MB · Views: 166
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?
 
One question though, does it literally consume the resource, or just provide X yield/commerce per resource available to the city?

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.
 
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.
 
Thanks, this is really useful for me. Does this make the resources tradeable like corporations do?
 
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.
 
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.
 
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.

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

Now that's quite a big enhancement!
 
Now that's quite a big enhancement!

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.
 
I can't make an Iron give +2 hammers each, and a wheat give +2 food each, they have to give the same effect.

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

No real reason... but why limit myself to only one bonus and one commerce and yield change?
 
Top Bottom