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

[MODCOMP] Domestic Market

Discussion in 'Civ4Col - Mods and Files' started by Androrc the Orc, Dec 13, 2011.

  1. Androrc the Orc

    Androrc the Orc Emperor

    Joined:
    Apr 19, 2004
    Messages:
    1,621
    Location:
    Vienna, Austria
    The purpose of this modcomp is providing a domestic market, so that citizens and buildings can consume a few goods, rather than goods mostly serving only for trade with Europe.

    With this modcomp, each city gets it's own set of commodity prices, which fluctuates slightly depending on the availability of goods.



    As mentioned previously, each building or citizen type can demand goods. Which goods they demand and how much is set at the XML files:

    Code:
    			<YieldDemands>
    				<YieldDemand>
    					<YieldType>YIELD_SUGAR</YieldType>
    					<iYieldDemand>20</iYieldDemand>
    				</YieldDemand>
    				<YieldDemand>
    					<YieldType>YIELD_CLOTH</YieldType>
    					<iYieldDemand>20</iYieldDemand>
    				</YieldDemand>
    				<YieldDemand>
    					<YieldType>YIELD_COATS</YieldType>
    					<iYieldDemand>20</iYieldDemand>
    				</YieldDemand>
    				<YieldDemand>
    					<YieldType>YIELD_RUM</YieldType>
    					<iYieldDemand>20</iYieldDemand>
    				</YieldDemand>
    				<YieldDemand>
    					<YieldType>YIELD_CIGARS</YieldType>
    					<iYieldDemand>20</iYieldDemand>
    				</YieldDemand>
    			</YieldDemands>
    
    Each turn, the demand values of each citizen and each building are added up and then divided by 100. If there are goods of that kind stored in the city, then they will be sold and the owner of the city will gain gold accordingly.



    By default, citizens of middle and upper class (Master Carpenters, Elder Statesmen, etc.) are set to demand 0.20 of each of Sugar, Cloth, Coats, Rum and Cigars commodities per turn; Churches demand 1 Silver per turn and Cathedrals demand 2. But of course, those that find this modcomp useful are advised to change demands to fit what they deem more appropriate.

    Download Domestic Market 1.0
     
  2. orlanth

    orlanth Storm God. Yarr!

    Joined:
    Nov 17, 2001
    Messages:
    1,776
    Wow awesome! :goodjob: I am the first to download it :p

    I really like the idea, adding complexity to the internal economy like Victoria or those kinds of games.

    If you don't mind, maybe I will give a try at adding it to the 2071 mod, though it will be my first real attempt at DLL modding. Could you explain further the formula of how prices are set?

    BTW a cool addition to the concept might be to produce a small amount of Crosses and Liberty when citizens consume goods, to represent how the citizens are satisfied at their needs being met and how the strong economy attracts more immigrants.
     
  3. KJ Jansson

    KJ Jansson Prince

    Joined:
    Oct 7, 2008
    Messages:
    509
    Very interesting MODCOMP. My congratulations, Andre!

    Couple questions.

    1. You have in CIV4UnitInfos.xml file the same values <iYieldDemand> for practically all units.

    Code:
    			<YieldDemands>
    				<YieldDemand>
    					<YieldType>YIELD_SUGAR</YieldType>
    					<iYieldDemand>20</iYieldDemand>
    				</YieldDemand>
    				<YieldDemand>
    					<YieldType>YIELD_CLOTH</YieldType>
    					<iYieldDemand>20</iYieldDemand>
    				</YieldDemand>
    				<YieldDemand>
    					<YieldType>YIELD_COATS</YieldType>
    					<iYieldDemand>20</iYieldDemand>
    				</YieldDemand>
    				<YieldDemand>
    					<YieldType>YIELD_RUM</YieldType>
    					<iYieldDemand>20</iYieldDemand>
    				</YieldDemand>
    				<YieldDemand>
    					<YieldType>YIELD_CIGARS</YieldType>
    					<iYieldDemand>20</iYieldDemand>
    				</YieldDemand>
    			</YieldDemands>
    Is it possible to make the different <iYieldDemand> between:

    - unprofessional units (COLONIST, INDENTURED_SERVANT, CRIMINAL),
    - field-professional units (MINER, LUMBERJACK, etc.),
    - high-professional units (BLACKSMITH, GUNSMITH, CARPENTER, etc.) and
    - "elite" units (STATESMAN).

    (P.S. It's very easy to test, but I have no such possibility now.)

    2. What happens if required yields are absent in the city? As I understand now a "Happiness" or "Satisfaction" parameter is absent.
     
  4. Androrc the Orc

    Androrc the Orc Emperor

    Joined:
    Apr 19, 2004
    Messages:
    1,621
    Location:
    Vienna, Austria
    Glad you liked it :)

    The formula is the same as for European prices, but with one change:

    Code:
    void CvCity::doPrices()
    {
    	for (int iYield = 0; iYield < NUM_YIELD_TYPES; ++iYield)
    	{
    		YieldTypes eYield = (YieldTypes) iYield;
    		CvYieldInfo& kYield = GC.getYieldInfo(eYield);
    
    		if (kYield.isCargo())
    		{
    			int iBaseThreshold = kYield.getPriceChangeThreshold() * GC.getHandicapInfo(getHandicapType()).getEuropePriceThresholdMultiplier() * GC.getGameSpeedInfo(GC.getGameINLINE().getGameSpeedType()).getGrowthPercent() / 10000;
    			int iNewPrice = kYield.getBuyPriceLow() + GC.getGameINLINE().getSorenRandNum(kYield.getBuyPriceHigh() - kYield.getBuyPriceLow() + 1, "Price selection");
    			iNewPrice += [COLOR="Red"]getYieldStored(eYield)[/COLOR] / std::max(1, iBaseThreshold);
    
    			if (GC.getGameINLINE().getSorenRandNum(100, "Price correction") < kYield.getPriceCorrectionPercent() * std::abs(iNewPrice - getYieldBuyPrice(eYield)))
    			{
    				iNewPrice = std::min(iNewPrice, getYieldBuyPrice(eYield) + 1);
    				iNewPrice = std::max(iNewPrice, getYieldBuyPrice(eYield) - 1);
    				setYieldBuyPrice(eYield, iNewPrice, true);
    			}
    		}
    	}
    }
    
    I replaced getYieldBoughtTotal(eYield) from the original CvPlayer::doPrices() with getYieldStored(eYield). This means that the prices will fluctuate randomly between the BuyPriceHigh and BuyPriceLow set in CIV4YieldInfos.xml, and will slightly decrease if you have a lot of that yield stored.

    I have, though, thought of making the price increase continually if there is unfulfilled demand, and continually decrease if there is a lot of that yield stored, changing slower the more distant prices got from the base price, and changing faster the closer the prices got to the base price.

    That could easily be added, but I think it wouldn't work very well... a happiness indicator would be interesting, but too much for the scope of this modcomp.

    Thanks :D

    Yes, it is fully possible. The city's demand formula cycles through each population unit (and building) and adds it's respective yield demand, before doing the final division by 100.

    Nothing happens, except that a sale is missed.
     
  5. raystuttgart

    raystuttgart Civ4Col Modder

    Joined:
    Jan 24, 2011
    Messages:
    5,357
    Gender:
    Male
    Location:
    Stuttgart, Germany
    Wow, great ! :goodjob:

    Actually that is similar to a solution I had in mind. :)

    Some differences in my concept if you are interested:
    Spoiler :

    1. I had a Specialbuilding (wiht 2 levels of building) to sell these things inside a city.

    -> Market and Trade Center

    see here, bottom row, 4th building from left (the one without a production bar, because it does not produce):


    2. I also had a Profession and a Specialist.

    -> Profession "Shopkeeper" and Specialist "Experienced Shopkeeper".

    They were needed to satisfy the demand of the citizens and were influencing the actual amounts sold.

    3. I wanted to do a mini-screen where you could set the maximum amount to be sold to "Domestic Market" for every yield.

    4. I wanted to have special pricing mechanism
    (Defined at Yields)

    Examples:
    -> Luxury Goods from Europe would sell at higher prices than in Europe
    -> Salt would sell at same price as in Europe
    -> Cloth would sell at slightly lower price than in Europe

    5. Rather than defining Yields for every Unit I wanted to do:

    A) Every unit gets a social class (upper, middle, lower)

    Examples:

    Statesman -> Upper
    Carpenter -> Middle
    Farmer -> Lower

    B) At the Yield it should be defined how much interest every Class would have

    Examples

    Yield_Spices:
    Upper -> 0.4
    Middle -> 0.2
    Lower -> 0.1

    Yield_Rum:
    Upper -> 0.1
    Middle -> 0.4
    Lower -> 0.2

    6. In "later Releases" of [Religion and Revolution] it will of course influence Satisfaction, once that is implemented.

     
  6. DARCK-PHOENIX

    DARCK-PHOENIX Chieftain

    Joined:
    Jan 23, 2011
    Messages:
    35
    from what mod is the picture ?


    this modcopm is the best
     
  7. DARCK-PHOENIX

    DARCK-PHOENIX Chieftain

    Joined:
    Jan 23, 2011
    Messages:
    35
    from what mod is the picture ?


    this modcopm is the best
     
  8. Androrc the Orc

    Androrc the Orc Emperor

    Joined:
    Apr 19, 2004
    Messages:
    1,621
    Location:
    Vienna, Austria
    :D

    :) Did you define social class by profession or by unit type?

    And what was the formula you were thinking of using for the pricing mechanism?

    Thanks :) The picture is from the modcomp itself being played with no other mods.
     
  9. raystuttgart

    raystuttgart Civ4Col Modder

    Joined:
    Jan 24, 2011
    Messages:
    5,357
    Gender:
    Male
    Location:
    Stuttgart, Germany
    By unit type.

    An "Indentured Servant" working as a "Fur Trader" is still an "Indentured Servant". :dunno:

    I simply would have "flagged" the Yield with XML attribute <Domestic_Market_Demand>:
    (actual values could have been 0 to 3)

    0 -> no interest of Domestic_Market (something like "Weapons")
    --> not sold through Domestic_Market

    1 -> low interest of Domestic_Market (something like "Cloth")
    --> price always a little lower than in Europe

    2 -> normal interest of Domestic_Market (something like "Salt")
    --> price just the same as in Europe

    3 -> high interest of Domestic_Market (something like "Luxury Goods from Europe")
    --> price always a little higher than in Europe

    Main difference in my concepts however:
    You have Specialbuilding / Buildings and a Profession for actually selling the goods.

    So you have 2 aspects:
    Demand (which goods and how much they would consume) and Supply (goods, markets and shopkeepers).
    (You have to do something to ensure "Supply".)

    But there are many more aspects to my really huge "Economy Concept" ...
    (It will probably be the largest part of Release 2 for [Religion and Revolution])

    Spoiler :

    One example:

    For most "categories" of goods there are three levels:

    Wool -> mainly lower class
    Cloth -> mainly middle class
    Coloured Cloth -> mainly upper class

    Leather -> mainly lower class
    Fur Coats -> mainly middle class
    Premium Fur Coats -> mainly upper class

    ...

    Another Example:

    Alcohol (Beer, Rum, Wine) is not sold by Market / Trade Center but by Taverns.
    Selling a lot of alcohol in Tavern will trigger certain events.
    Otherwise very similar concepts apply.

    Last Example for now:

    We will introduce Satisfaction as major feature.
    "Domestic Markets" will influence Satisfaction.
     
  10. orlanth

    orlanth Storm God. Yarr!

    Joined:
    Nov 17, 2001
    Messages:
    1,776
    Great modcomp :thumbsup:, I think I've now got it integrated into the 2071 mod.

    In 2071, Agricultural specialists will demand Biotech, Industrial ones demand Fusion Cores, and Scientific ones (Physicists, Biochemists etc) demand Progenitor Tech. And of course, the Preachers and Politicians will demand Narcotics (as you can see it's very realistic!) ;) Also everyone demands a small amount of Trade Goods, because if they're being "traded" someone must have use for them..

    In recognition of your help, I decree that you will now get one of the Alien Chieftains named in your honor. So do you have any favorites? (I know, they're all gross and wrinkly..:D)

    Yeah, that could be a cool addition. If the prices are flexible enough; it might even become worthwhile for players to do some trading at foreign ports and natives to take advantage of imbalances in local supply and demand.
     
  11. Androrc the Orc

    Androrc the Orc Emperor

    Joined:
    Apr 19, 2004
    Messages:
    1,621
    Location:
    Vienna, Austria
    :D I quite like the leader of the Felids, if that one is available.
     
  12. orlanth

    orlanth Storm God. Yarr!

    Joined:
    Nov 17, 2001
    Messages:
    1,776
    No problem lol, consider yourself the new Felid Emperor:king::p .

    I uploaded version 1.4 of the 2071 mod, and was able to merge your modcomp with the techtree modcomp. It seems to be working nicely :goodjob:. One worry is that if prices for consuming in colonies average the same as Europe (Earth) and are sometimes less, players will not be happy when things are consumed, and could be motivated by a need to constantly move goods out of colonies to avoid consumption and increase prices. So perhaps there should be some sort of reward for players for satisfying demand; or it could make sense for prices of manufactured goods and trade goods to be higher in colonies than Europe. (I think with your idea to have prices increase continually if there is unfulfilled demand, this might happen automatically as a result.) Especially I'd like Trade Goods to be more expensive in colonies (since they are supposed to be consumer goods but have no use in the vanilla game); then you can get some benefit from importing them to your colonies where they get consumed.

    In editing the DLL I tried a crude way of making higher colonial prices by simply adding 2 to iBuyPrice, but that doesn't seem to be having the desired effect.

    Spoiler :
    in void CvCity::init :
    Code:
    	//Androrc Domestic Market
    	for (int iYield = 0; iYield < NUM_YIELD_TYPES; ++iYield)
    	{
    		YieldTypes eYield = (YieldTypes) iYield;
    		CvYieldInfo& kYield = GC.getYieldInfo(eYield);
    
    		FAssert(kYield.getBuyPriceHigh() >= kYield.getBuyPriceLow());
    
    		int iBuyPrice = 2 + kYield.getBuyPriceLow() + GC.getGameINLINE().getSorenRandNum(kYield.getBuyPriceHigh() - kYield.getBuyPriceLow() + 1, "Yield Price");
    		setYieldBuyPrice(eYield, iBuyPrice, false);
    	}
    	//Androrc End

    in void CvCity::doPrices() :
    Code:
    void CvCity::doPrices()
    {
    	for (int iYield = 0; iYield < NUM_YIELD_TYPES; ++iYield)
    	{
    		YieldTypes eYield = (YieldTypes) iYield;
    		CvYieldInfo& kYield = GC.getYieldInfo(eYield);
    
    		if (kYield.isCargo())
    		{
    			int iBaseThreshold = kYield.getPriceChangeThreshold() * GC.getHandicapInfo(getHandicapType()).getEuropePriceThresholdMultiplier() * GC.getGameSpeedInfo(GC.getGameINLINE().getGameSpeedType()).getGrowthPercent() / 10000;
    			int iNewPrice = 2 + kYield.getBuyPriceLow() + GC.getGameINLINE().getSorenRandNum(kYield.getBuyPriceHigh() - kYield.getBuyPriceLow() + 1, "Price selection");
    			iNewPrice += getYieldStored(eYield) / std::max(1, iBaseThreshold);
    
    			if (GC.getGameINLINE().getSorenRandNum(100, "Price correction") < kYield.getPriceCorrectionPercent() * std::abs(iNewPrice - getYieldBuyPrice(eYield)))
    			{
    				iNewPrice = std::min(iNewPrice, getYieldBuyPrice(eYield) + 1);
    				iNewPrice = std::max(iNewPrice, getYieldBuyPrice(eYield) - 1);
    				setYieldBuyPrice(eYield, iNewPrice, true);
    			}
    		}
    	}
    }


    Let me know if you update your modcomp with your idea to have prices increase with unfulfilled demand; that seems like a better way to do it. But I also like the concept of getting a small amount of Crosses or Liberty when demand is well satisfied, to produce some reward of "happiness" from a well managed economy without needing a complicated extra system. Could you maybe suggest a code snippet that would produce 1 Cross and 1 Liberty in a colony for each 10 Gold worth of goods that are consumed?
     
  13. orlanth

    orlanth Storm God. Yarr!

    Joined:
    Nov 17, 2001
    Messages:
    1,776
    By the way I noticed this code in CvCity.cpp of the techtree modcomp with your name on it which was commented out, I wonder if you know anything about it?

    I am wondering if something in CvCity::canConstruct or some related function could be causing the issue of sometimes not having the Inventors House building. But this code would prevent constructing a building if you dont have a tech (and it's commented out) so this wouldn't be the cause.

    Code:
    	//Androrc Required Technology/Invention Building
    	//Inventor
    //	for (int iI = 0; iI < GC.getNumCivicInfos(); iI++)
    //    {
    //        if (GC.getCivicInfo((CivicTypes) iI).getNumActivateBuildings() > 0)
    //        {
    //            for (int iiI = 0; iiI < GC.getCivicInfo((CivicTypes) iI).getNumActivateBuildings(); iiI++)
    //            {
    //                if (GC.getCivicInfo((CivicTypes) iI).getActivateBuilding(iiI) == eBuilding)
    //                {
    //                    if (GET_PLAYER(getOwnerINLINE()).getIdeasResearched((CivicTypes) iI) == 0)
    //                    {
    //                        return false;
    //                    }
    //                }
    //            }
    //        }
    //	}
    	//Inventor End
     
  14. Androrc the Orc

    Androrc the Orc Emperor

    Joined:
    Apr 19, 2004
    Messages:
    1,621
    Location:
    Vienna, Austria
    There would still be many advantages to domestic consumption, such as not paying taxes to the colonial master. Also, the prices will tend to be eventually be higher than Europe's, since the way vanilla Civ4Col prices are structured, if you keep selling to Europe, European prices will continually fall down (and never recover); that has been a complaint about Colonization's economy since the original game.

    I think that it would do so automatically too, I will try some things and see how they work out.

    Trade Goods being more expensive in colonies makes perfect sense and is a good idea for gameplay as well.

    That's strange, it should be increasing the price by 2 as you said. Why do you think it isn't having an effect?

    The problem is that the domestic sales are processed after the production of yields are calculated... What would be a more practical solution is implementing something akin to what raystuttgart has talked about earlier in this thread, having a satisfaction level (similar to the revolutionary sentiment level) which would rise or drop depending on demand fulfillment, and could then affect a myriad of things, such as increasing crosses and bells produced.

    Your feedback is very appreciated :)
     
  15. Androrc the Orc

    Androrc the Orc Emperor

    Joined:
    Apr 19, 2004
    Messages:
    1,621
    Location:
    Vienna, Austria
    That code was for checking whether the technology that allowed that building had been researched or not, but that function was if I recall correctly, modified and transposed to CvPlayer.cpp. I took a look at the SDK files for your mod... but I have no idea what is causing your problem. Have you tried using a debug dll?
     
  16. orlanth

    orlanth Storm God. Yarr!

    Joined:
    Nov 17, 2001
    Messages:
    1,776
    De nada! Im glad you like the Trade Goods suggestion, it will be great for 2071 mod since there is an Orbital Trader profession that produces them from space tiles. I think this modcomp will help the game be more fair for AI civs too, since they often have trouble transporting things the right way.

    Oh, maybe I forgot to move the updated file before recompiling:blush:, I will try recompiling it again.

    Ok. Instead of actual Cross/Bell yield production, might it be simpler to just let it add some to the immigration meter or rebel sentiment directly? As you said, creating a whole new Happiness system seems complicated and probably beyond the scope of the modcomp.

    Yeah I'm really puzzled what's causing it. Thanks a lot for looking into the dll. I have tried making a debug dll, and after awhile of trying I finally did get it to compile; however after attaching it to the process it will not show variables or other information even after setting a breakpoint, maybe I have configured things the wrong way.
     
  17. Androrc the Orc

    Androrc the Orc Emperor

    Joined:
    Apr 19, 2004
    Messages:
    1,621
    Location:
    Vienna, Austria
    Yes; actually, it somehow slipped my mind that it would be possible to change the Bells and Crosses stored at CvPlayer, as well as changing culture. If you add the following changes (in red) to the modcomp's code in CvCity::doYields(), it will add 1 Cross and 1 Bell (including culture) for every 10 gold of sales of a yield:

    Code:
    				//Androrc Domestic Market
    				if (getYieldDemand(eYield) > 0 && getYieldStored(eYield) > 0)
    				{
    					int iAmount = getYieldDemand(eYield);
    					if (getYieldDemand(eYield) > getYieldStored(eYield))
    					{
    						iAmount = getYieldStored(eYield);
    					}
    					int iProfit = iAmount * getYieldBuyPrice(eYield);
    					changeYieldStored(eYield, -iAmount);
    					GET_PLAYER(getOwnerINLINE()).changeGold(iProfit);
    
    [COLOR="Red"]					changeCulture(getOwnerINLINE(), (iProfit / 10), false);
    					GET_PLAYER(getOwnerINLINE()).changeBellsStored((iProfit / 10));
    					changeCrossesStored((iProfit / 10));[/COLOR]
    
    	//					GET_PLAYER(getOwnerINLINE()).changeYieldTradedTotal(eYield, iDemand);
    
    					CvWString szBuffer = gDLL->getText("TXT_KEY_GOODS_DOMESTIC_SOLD", iAmount, GC.getYieldInfo(eYield).getChar(), getNameKey(), iProfit);
    					gDLL->getInterfaceIFace()->addMessage(getOwnerINLINE(), false, GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_BUILD_BANK", MESSAGE_TYPE_MINOR_EVENT, GC.getYieldInfo(eYield).getButton(), (ColorTypes)GC.getInfoTypeForString("COLOR_WHITE"), getX_INLINE(), getY_INLINE(), true, true);
    				}
    				//Androrc End
    
     
  18. orlanth

    orlanth Storm God. Yarr!

    Joined:
    Nov 17, 2001
    Messages:
    1,776
    Great, thanks. To get it compiled I had to change it to the below, does that look correct?

    Code:
    					changeCulture(getOwnerINLINE(), (iProfit / 10), false);
    					GET_PLAYER(getOwnerINLINE()).changeBellsStored((iProfit / 10));
    					GET_PLAYER(getOwnerINLINE()).changeCrossesStored((iProfit / 10));
    It did apply the +2 and looks like it's working to make Crosses, but I'm not sure if it's affecting Bells / Culture / Rebel Sentiment.
     
  19. Androrc the Orc

    Androrc the Orc Emperor

    Joined:
    Apr 19, 2004
    Messages:
    1,621
    Location:
    Vienna, Austria
    Yes, sorry. I forgot to put the "GET_PLAYER(getOwnerINLINE())." part before the changeCrossesStored.

    It doesn't affect rebel sentiment (because rebel sentiment is based on bell production rate, rather than a bells stored variable), but should be affecting culture.
     
  20. orlanth

    orlanth Storm God. Yarr!

    Joined:
    Nov 17, 2001
    Messages:
    1,776
    BTW if you are still looking for prehistoric mammals try this nif file: not sure what it could be but maybe a Palaeotherium? (I don't know how to create nifs, but simply squashed the Camel made by someone else :p)
     

Share This Page