Grenefolc Posted October 2, 2018 Report Share Posted October 2, 2018 (edited) I am asking a question on here so I also need to provide a tip or two, for what they are worth... Experienced modders are no doubt already aware of this but for the people new to coding: I am always aggrieved by units that cost food to "create", but then do not consume food whilst they are "alive". So, how to make your units consume food: (1) Change the simulation/components/ResourceTrickle.js Add a new schema element that provides "Negative Trickle" amounts... ResourceTrickle.prototype.Schema = "<a:help>Controls the resource trickle ability of the unit.</a:help>" + "<element name='Rates' a:help='Positive Trickle Rates'>" + Resources.BuildSchema("nonNegativeDecimal") + "</element>" + "<element name='NegativeRates' a:help='Negative Trickle Rates'>" + Resources.BuildSchema("nonNegativeDecimal") + "</element>" + "<element name='Interval' a:help='Number of miliseconds must pass for the player to gain the next trickle.'>" + "<ref name='nonNegativeDecimal'/>" + "</element>"; (2) Update the function to take account of the "Negative Trickle": ResourceTrickle.prototype.ComputeRates = function() { this.rates = {}; for (let resource in this.template.Rates) this.rates[resource] = ApplyValueModificationsToEntity("ResourceTrickle/Rates/"+resource, +this.template.Rates[resource], this.entity); for (let resource in this.template.NegativeRates) this.rates[resource] = ApplyValueModificationsToEntity("ResourceTrickle/NegativeRates/"+resource, -this.template.NegativeRates[resource], this.entity); }; (3) Change the simulation/templates/template_unit.xml Add the newly defined element to the Xml as appropriate. The unit is the default for "everyone" and so covers the whole population that needs to feed: <ResourceTrickle> <Rates/> <NegativeRates> <food>0.1</food> </NegativeRates> <Interval>4000</Interval> </ResourceTrickle> (4) Start feeding your population before you run out of food... Hope it's useful to somebody... *NOTE: Obviously, the templates for template_structure.xml must also be updated to included the new element (e.g. <NegativeRates/>). Under most circumstances you do not want it but I use it for my blacksmith so that he burns wood to keep the forge hot, etc. You can use it for anything that consume resources by default. Edited October 2, 2018 by Grenefolc There is always something to forget... Quote Link to comment Share on other sites More sharing options...
Guest Posted October 2, 2018 Report Share Posted October 2, 2018 (edited) You are doing this way too complex. You don't need a new "NegativeRates", What you need is to modify the schema to allow the Rate to be negative. The only code changes required would be https://code.wildfiregames.com/D1323 See how it's done in this particular mod. https://github.com/0abc/0abc-a23 Edited October 2, 2018 by Guest Quote Link to comment Share on other sites More sharing options...
Grenefolc Posted October 2, 2018 Author Report Share Posted October 2, 2018 @Duplicarius - I would say "way too complex", although I admit it adds the performance overhead of the 2nd iteration through the extra element ;-) Thanks for pointing out the other example. Quote Link to comment Share on other sites More sharing options...
dmzerocold Posted October 2, 2018 Report Share Posted October 2, 2018 And what if food amount reach 0 ? starving and starting to lose health and death? if you want to apply this please also include this part as well 3 Quote Link to comment Share on other sites More sharing options...
Guest Posted October 2, 2018 Report Share Posted October 2, 2018 26 minutes ago, dmzerocold said: And what if food amount reach 0 ? I forgot to mention this earlier, but you need a check in ResourceTrickle.js before trickling if you don't want negative resource amounts. Quote Link to comment Share on other sites More sharing options...
dmzerocold Posted October 2, 2018 Report Share Posted October 2, 2018 24 minutes ago, (-_-) said: but you need a check in ResourceTrickle.js before trickling if you don't want negative resource amounts. @Grenefolc I think this one is for you @(-_-) are we going to include it in main game ? if yes , also with starving , losing health and death ? Quote Link to comment Share on other sites More sharing options...
Guest Posted October 2, 2018 Report Share Posted October 2, 2018 20 minutes ago, dmzerocold said: @(-_-) are we going to include it in main game ? if yes , also with starving , losing health and death ? I do not know. That is for the dev team to decide. Quote Link to comment Share on other sites More sharing options...
Imperator Ferrum Princeps I Posted October 2, 2018 Report Share Posted October 2, 2018 Probably not, this discussion came up before and many casual rts gamers felt it would add too much micro and such. But I am working on a delenda est/balance-mod/age-of-0ad mega fork that will focus on the tastes of more hardcore rts gamers with supply lines, more combat support units such as engineers, etc 2 Quote Link to comment Share on other sites More sharing options...
man_s_our Posted October 10, 2023 Report Share Posted October 10, 2023 (edited) I have components for that but they aren't fully finished yet. although they're enough if you want to make it for players only use it. PS: in my WIP mod food resources are devided. so, you need few customizations to use it with the public mod. edit: you also need the custom unit ai for the purpose of the units break for launch don't break the cammands' series. MeatSupplies.js VeganSupplies.js WaterSupplies.js UnitAI.js Edited October 10, 2023 by man_s_our 3 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.