Jump to content

Grenefolc

Community Newbie
  • Posts

    3
  • Joined

  • Last visited

Grenefolc's Achievements

Tiro

Tiro (1/14)

1

Reputation

  1. @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.
  2. 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.
  3. I am trying to create extended supply chains to replicate some of my favourite features of other games. As an example, I build a very simple drop site that is effectively just a pile of a specific material (metal, wood, stone) on the ground near to the collection area (trees, rocks, etc). I use the graphics from the "treasures" to represent these such as a pile of stones or wood. I then intend to have a "carter" who can pick up from that drop site and deliver it more efficiently to a storehouse over a longer distance. I have defined new material subtypes in the resource *.json files which reflect their original source location in order to control who can pick it up (e.g. wood.dropsite_wood as opposed to wood.tree). The subtypes are also specific to the material so that the "global" references to subtypes (e.g. when you see something just referring to "ruins") does not pickup a simple "dropsite" type. I can build the "piles" and drop the resource just fine. However, when I go to collect the resource from the pile the capacity of the carrier is ignored, it just collects everything in the pile in *multiples* of their maximum capacity for that resource. So, if the resource is "90" and the carrier's capacity is "10", the carrier will iterate the collection 9 times until the whole pile has gone and then walk off to dump it at the storehouse. I was under the belief that the capacity simply used the major type (e.g. wood and stone, etc.) as the key to the limitation and the ResourceGatherer.js seems to confirm this. Does anybody have an idea why the capacity limit is being ignored for my new resource type (i.e. wood.dropsite_wood or stone.dropsite_stone)? The whole point of this is that I intend to amend the "drop" side so that the "amount" attribute of the "pile" gets incremented by the drop amount each time. This then acts as a "buffer" which can be added to and collected from until it really has all gone. **Forgot to mention... the other point of this that the "piles" are not included in the available resources for building etc. They simply remain equivalent to an environment resource that anybody could start "stealing" from, adding the tactical requirement that the supply chain needs to be protected. Only once the carter has collected the resource and delivered it to the storehouse is it then added into the available resources.
×
×
  • Create New...