Jump to content

Monder87

Community Members
  • Content Count

    8
  • Joined

  • Last visited

Community Reputation

12 Good

About Monder87

  • Rank
    Tiro

Recent Profile Visitors

43 profile views
  1. Monder87

    Add Money resources and related component issue

    @stanislas69 where should i upload the Mod? Github? Or you have a dedicated place?
  2. Monder87

    Add Money resources and related component issue

    Hi everyone!! Some Update on the job done so far!! First an update on the Project: Goal: create a Economy System for 0Ad to give more realism and add strategy to the game. Brief Description : Money Of course all is about money, so the first thing i did is to create the money resource. The Player that i call State in my Economy System, perceive a fee for every transaction done in its kingdom, (20%) plus it can collect money selling resources to the producers and adding other fee after a certain amount of time. More glorious is his economy more money he can make. Economy Entities Dividing the Military Unit from the Civilian , we focus just in the latter for our Economy. Civilian Entity can upgrade from Slave to Noble, (see post above to know more), there are two kind of entity in our model: Passive: Earn Money from the resource gathering job Active: Earn Money producing and selling products We can say that Passive Entity are just Consumer, and Active are both Consumer and Producer. All the Economy Entities consume product and resources, can stock products , have own money that they can spend or earn. They can Upgrade paying fee to special structure. Components : EntityFinance, EntityConsumer, EntityProducer Products So far i created 8 products that can be sold: - Food: bread, wine, steak, sausage - Clothes - Entertainment - Jewelry - Slave Each Product has a price that change based on the Supply and Demand, they are being calculated by the ProductManager Component and broadcasted to all other components once changed after a certain amount of time What i Achieved so far As you can see on the image i took the template of Female Support i add to the template EntityFinance, EntityConsumer and EntityProducer. With EntityFinance Component they can earn money every resources gathered, they automatically pay the tax to the State, they can store all money in a Balance which has a maximum capacity , depending if are just citizen or nobles. or dealer etc.. With EntityConsumer Component i track the need of the entity, every time she work one algorithm calculate different variables to define is actual need. these variables are : - Product Daily Consuming, - Product Daily Availability, - Product Already in Stock - Product Prices Compared with his Own Balance. The need is so calculated as a value between 0 and 2 , if the value of need of a product is major of 1 , the product is inserted inside a list of FirstChoiceProduct, which define the entity needed product in every given the moment Of course this component track all the product consumed and stocked by the entity With EntityProducer Component instead define the capabilities to produce products to resell later. all Products produced are in a catalogue that other entity can see , so far i developed just to let the entity purchase what she wants, still need to be developed to producing product etc.. To make the entity moving to buy product if needed i implemented a new order in unitAI Component, i called it "Shopping", which let the entity once she working checking if she has need, if there are producer with available product around and in case if go to them, buy the product, stock them and go back to work . Also For the Visual Part and GUI, i added the 8 product category for Entity Consumer in the left panel so to have a track of what the entity has in stock(you can see the tooltip) and the balance of money of the entity is showed on top of the head of the 3d woman and also in the central panel, where there is a more specific description with tot amount ant max capacity. Money resources are instead tracked in the top together with all other resources. Also i added one new animation once the entity approach the seller, is just a start but at least she do something like paying cash.( Is the third picture, i used another woman as a producer cause i don t have now 3d model of vendor to use) As always i would be very happy to share all the code, just now is really a lots.!!...i don t think here would look nice and also are becoming really a lot of implementation , so you just tell me where would be best share and i ll post. And Please give me Ideas and Feedback
  3. Monder87

    Add Money resources and related component issue

    Hi everyone!! i m updating on the progress: Thanks @stanislas69 and @(-_-) for the valuable tips: i fix the typo error and i moved all the stuff out of guiinterface.js so to don t create problems. What i achieved is this: See Image Uploaded: A full working prototype of a female citizen who can work and earn money for the job done, the wealth is showed in the progress bar on top of her health bar Every time she work and gather some resources: metal, wood, stone or food, she earn some amount of money. depending of her <EntityFinance> template: i use <EarningRate> to specify the rate of earning and <WalletCapacities> to specify the max amount of money she can store Of course she can spend as well, i will now try to update the GUI of money resource for the unit and after i will develop a economy model where unit can earn and spend , this is my draft idea so far: Splitting the civilian from the military we can focus just on civilian as a main actors of our economy. We can split the Economy Entities in: Slave, Citizen, Food Vendor, Artist, Dealers(Shops), Trader(Market , implementing that already exists), Nobles and the State Every actor has a degree of importance in the Economy Model and from slave can evolve in all different entities: Slave work for free and consume just some food the only owner is the State which account for the food and benefits of the resources gathered Citizen the can earn and spend; they consume food and also other commodities like textile or wine, they can buy food from the State or from Food vendors, and the other commodities from the shops or in the market, the own the money earned but also the State own them: all resources gathered go to State which pay them producing money from free Shops, Market, Circus are instead Structures which spend money to buy resources from State and resell them to Citizens offering different products from clothes exotic food entreatment etc..also they need to pay a tax for each transaction to State Nobles instead they can own Slave and earn a percent for all the Lifecycles of them economy once they upgrade in the different economy entity described above. They Spend money for very expensive commodities and they influence the civ evolution like giving some very good benefits to win the game( not sure yet which one ) All the Prices of the different commodities and resources are set by a PriceManager Component, which will calculate the demand and offer every tot amount of time, to give realism of the Economy Model Also The State has the Capacity to apply Tax to all the transaction and also a Tax to all entities once passed a certain amount of Time This is a draft for the first two State: Ownership: Own Spend : Money / Technology, Weapon, Diplomacy, Super Unit, Corruption etc.. Earn : Money/ VAT Tax, Monthly Tax, Resources, Villas, Castles Consume: None Produce: Money, Slaves, Market Building Dedicated Building: Civ Center Slave: Ownership: State, Nobles Spend : NO Money Earn : NO Money Consume: 1 Food[fish,fruit,grain,meat]/Day Dedicated Building: No Produce: Labor   Citizen: Ownership: State, Own Spend : Money / Products and Resources Earn : Money/ Resource Gathered Consume: 2 Food [fish, fruit, grain, meat]/Day 2 Food [wine, sausage, bread, steak]/Day 1 Clothes/Week ( will be produced by some Shop or  1 Entertainment/Month Produce: Labor Dedicated Building: No Food Dealer: Ownership: Own Spend : Money / Resources, Products Earn : Money / Bread , Sausage Consume: 4 Food [fish, fruit, grain, meat]/Day 4 Food [wine, sausage, bread, steak]/Day 2 Clothes/Week 2 Entertainment/Month 1 Jewelry Produce: Sausages,Breads,Wines, Steak Dedicated Building: 1 Level : Street Vendor, 2 Level: Locand, Bakery, Butcher Clothes Dealer: Ownership: Own Spend : Money / Resources, Products Earn : Money / Clothes Consume: 4 Food [fish, fruit, grain, meat]/Day 4 Food [wine, sausage, bread, steak]/Day 2 Clothes/Week 2 Entertainment/Month 1 Jewelry Produce: Clothes Dedicated Building: 1 Level : Street Vendor, 2 Level: Clothes Shop Jewelry Dealer: Ownership: Own Spend : Money / Resources, Products Earn : Money / Jewelry Consume: 6 Food [fish, fruit, grain, meat]/Day 6 Food [wine, sausage, bread, steak]/Day 4 Clothes/Week 3 Entertainment/Month 2 Jewelry Produce: Jewelry Dedicated Building: 1 Level : Street Vendor, 2 Level: Jewelry Shop Trader: Ownership: Own Spend : Money / Resources, Products Earn : Money / Resources, Products Traded Consume: 6 Food [fish, fruit, grain, meat]/Day 6 Food [wine, sausage, bread, steak]/Day 4 Clothes/Week 3 Entertainment/Month 2 Jewelry Produce: Resources, Products Dedicated Building: 1 Level : Street Merchant, Artist: Ownership: Own Spend : Money / Resources, Products Earn : Money / Entreatment Consume: 6 Food [fish, fruit, grain, meat]/Day 6 Food [wine, sausage, bread, steak]/Day 4 Clothes/Week 3 Entertainment/Month 2 Jewelry Produce: Entreatment Dedicated Building: 1 Level : Street Vendor, 2 Level: Entreatment Building(Arena) Noble: Ownership: Own Spend : Money / Resources, Products, Slaves Earn : Money / Tax from his former Slaves Consume: 20 Food [fish, fruit, grain, meat]/Day 20 Food [wine, sausage, bread, steak]/Day 10 Clothes/Week 10 Entertainment/Month 10 Jewelry Produce: Technology Dedicated Building: 1 Level : Villa, 2 Level: Castle Please share your ideas and give me some feedback, always once i implemented further i will share all code to the community
  4. Monder87

    Add Money resources and related component issue

    I just write down a component to handle the Enitity Finance but even following the suggestion of @stanislas69 to create the interface, i occurred in a error that the template cannot be validated. So i still miss to understand how component work. This my component: EntityFinance.js function EntityFinance() {} EntityFinance.prototype.Schema = "<a:help>Lets the unit earn money for the job done!.</a:help>" + "<a:example>" + "<WalletCapacities>1000</WalletCapacities>" + "</a:example>" + "<a:example>" + "<EarningRate>1.0</EarningRate>" + "</a:example>" + "<element name='WalletCapacities' a:help='Max Money the Entity can earn '>" + "<ref name='positiveDecimal'/>" + "</element>" + "<element name='EarningRate' a:help='Earning Rate of the Entity'>" + "<ref name='positiveDecimal'/>" + "</element>"; EntityFinance.prototype.Init = function() { this.balance = 1; // the Actual Amount of money the entity has this.RecalculateEarningRate(); // Recalculate the Earning Rate this.RecalculateWalletCapacities(); // Recalculate the Wallet Capacity }; EntityFinance.prototype.GetFinancialStatus = function() { let fin = { balance: this.balance, walletCapacity: this.walletCapacity, earnRate: this.earningRate }; return fin; }; EntityFinance.prototype.GetWalletCapacity = function() { if (!this.template.WalletCapacities) return 0; return this.template.WalletCapacities; }; EntityFinance.prototype.RecalculateWalletCapacities = function() { this.walletCapacity = this.GetWalletCapacity; // once added financing tool in tech, right now yet }; EntityFinance.prototype.RecalculateEarningRate = function() { // if Player get some change in earning rate is being update to the entity let cmpPlayer = QueryOwnerInterface(this.entity, IID_Player); let multiplier = cmpPlayer ? cmpPlayer.GetEarningRateMultiplier() : 1; this.earningRate = this.template.EarningRate * multiplier; // once added financing tool in tech, right now yet /*this.earningRate = ApplyValueModificationsToEntity( "EntityFinance/EarningRate", +this.template.EarningRate, this.entity );*/ }; EntityFinance.prototype.Earn = function(amount) { // once the entity spend a certain amount of money this.balance += amount; Engine.PostMessage(this.entity, MT_EntityFinanceChanged, { to: this.GetFinancialStatus() }); }; EntityFinance.prototype.Spend = function(amount) { // once the entity spend a certain amount of money this.balance -= amount; Engine.PostMessage(this.entity, MT_EntityFinanceChanged, { to: this.GetFinancialStatus() }); }; Engine.RegisterComponentType( IID_EntityFinancey, "EntityFinance", EntityFinance ); I also added the Interface in simulation/components/interface : EntityFinance.js Engine.RegisterInterface("EntityFinance"); Engine.RegisterMessageType("EntityFinanceChanged"); and i try to modify the default_support_female_citizen.xml adding this code: <EntityFinance> <WalletCapacities> 1000 </WalletCapacities> <EarningRate>1.0</EarningRate> </EntityFinance> but once i test it the console log say that the template is not validated and that there is a extra EntityFinance element as a error. What i miss? thanks for the help
  5. Monder87

    Add Money resources and related component issue

    Hi everyone, i give you some update on the job done so far: I created successfully money resources and i created a mechanism to increment this value proportionally to the GDP of the civ, the GDP is calculated as a sum of each resource amount times the resource price, i calculated the price of each resource using the Actual Population as a criteria, the concept behind is the market law of demand and offer, so if the metal (for example) collected exceed by far the actual population its price go down, if instead the metal is minor , its price go higher these are the Spec for who is interested: I don t post how create money resource cause there are already a tutorial for it. i achieved the mechanism of economic gain doing this: Session.js --> add this code to onTick() .... var framCounter = 0 function onTick() { framCounter += 1; if (framCounter % 32 == 0) { // We start the money Supply calling a method of GuiInterface Engine.GuiInterfaceCall("GetStartedMoneySupply"); } ....} GuiInterface.js --> add this method GuiInterface.prototype.GetStartedMoneySupply = function() { //let cmpMoneySupplyer = Engine.QueryInterface(SYSTEM_ENTITY, IID_MoneySupply); //cmpMoneySupplyer.AddResources(); let numPlayers = Engine.QueryInterface( SYSTEM_ENTITY, IID_PlayerManager ).GetNumPlayers(); for (let i = 0; i < numPlayers; ++i) { let cmpPlayer = QueryPlayerIDInterface(i); let totres = cmpPlayer.GetResourceCounts(); let totMetal = totres["metal"]; totMetal == 0 ? (totMetal = 0.01) : totMetal; let totStone = totres["stone"]; totStone == 0 ? (totStone = 0.01) : totStone; let totWood = totres["wood"]; totWood == 0 ? (totWood = 0.01) : totWood; let totFood = totres["food"]; totFood == 0 ? (totFood = 0.01) : totFood; // --> IMPLEMENTATION // Next Step is add also all Services and products produced // Calculte Resources Prices divinding population for tot resources let totPop = cmpPlayer.GetPopulationCount(); let metalPrice = totPop / totMetal; let stonePrice = totPop / totStone; let woodPrice = totPop / totWood; let foodPrice = totPop / totFood; // --> IMPLEMENTATION // Next Step is to trade every resources with money and calculate the offer and the request to more accuratly calculate resources prices // Calculate GDP let gdp = totMetal * metalPrice + totStone * stonePrice + totWood * woodPrice + totFood * foodPrice; // Adding Money to all players if (cmpPlayer) cmpPlayer.AddMoneyResource(0.01 * gdp); } }; and finally in Player.js adding this method Player.prototype.AddMoneyResource = function(amount) { this.resourceCount["money"] += +amount; }; Done, is simple but work quite well, but now i am planning to create something more advanced, the plan is to create a UnitFinance Component, and record for each entity the money earned and spent , if this is achieved i can divide the entity is simple worker, owner of shop, trader and Goverment, each with different degree of collect, spend and earn money, from that i can also calculate the GDP of the civ in a more specific way and associate the money supply i did before as a percent of GDP or as a Tax collection, with money the Player could buy weapons, Units, Building Infrustracture etc... quite . a lot i know but i will give a try, very appreciated people want to give a help in this or want to implement the idea. Ciaooo
  6. Monder87

    Add Money resources and related component issue

    If i am succesfull with my idea i will share with the community the code :))
  7. Monder87

    Add Money resources and related component issue

    Thanks stanislas!! I saw that s great!
  8. Hi everyone!! First time i post in this forum, and compliment every developer for the great job done!!!! I am a developer and playing the game i feel i whish to create a economy structure of the game more complex, so as a first step i thought that a wise solution would be add money resource, which i did succesfully, but now i am implementing the way the money resource increase proportionally with the size of the civilization and trade relationships, as far as i understand now i should create a new component in simulation, which i did in Js and added to the Engine through : Engine.RegisterSystemComponentType(IID_MoneySupply, "MoneySupply", MoneySupply); but i run into an error: IID_MoneySupply no defined. prob i miss many concepts here, anyone can help?
×