Changes between Version 3 and Version 4 of ModdingResources
- Timestamp:
- Oct 28, 2017, 2:51:48 PM (7 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ModdingResources
v3 v4 3 3 = Modding Resources = 4 4 5 As of r18964, the code base of 0AD attempts to deal with gatherable/tradable/tributable resources ( ie. `food`, `wood`) in an agnostic fashion. In other words, the resources are not hardcoded inside simulation components, the GUI or the AI.5 As of r18964, the code base of 0AD attempts to deal with gatherable/tradable/tributable resources (e.g. `food`, `wood`) in an agnostic fashion. In other words, the resources are not hardcoded inside simulation components, the GUI or the AI. 6 6 7 7 This means that adding or removing resources are somewhat easier for modders to do, should they wish. The following guide attempts to show how to do just that. … … 54 54 * **`name`** - Player-friendly name of the resource. This will be localized into the player's chosen language (if localizing data exists for it) 55 55 * **`order`** - The order it appears in the in-game GUI. Resources will appear in numerical order of this attribute. 56 * **`subtypes`** - An object of Subtypes of this resource. At least one must be specified. The entries within this object follow the form `"{subtype-code}": "{subtype-name}"` where `subtype-code` is the internal reference to this subtype, and `subtype-name` is the user-friendly translatable name of the subtype. Resources can have the same subtype codes ( ie. both `wood` and `stone` both possess a `ruin` subtype).56 * **`subtypes`** - An object of Subtypes of this resource. At least one must be specified. The entries within this object follow the form `"{subtype-code}": "{subtype-name}"` where `subtype-code` is the internal reference to this subtype, and `subtype-name` is the user-friendly translatable name of the subtype. Resources can have the same subtype codes (e.g. both `wood` and `stone` both possess a `ruin` subtype). 57 57 * **`truePrice`** - This is the true worth of the resource. This is used in calculating how much should be exchanged per click in the markets' Barter dialogue compared to other resources. See the `Barter` component for further details. 58 58 * **`aiAnalysisInfluenceGroup`** - This is used by the AI to help determine where to build resource deposit sites and where to allocate workers. There are three possible values: … … 70 70 71 71 72 == To remove a resource == #removeResource72 == How to remove a resource == #removeResource 73 73 Substraction is the inverse of addition. To remove a resource, in short, follow the instructions to add a resource (below), but in reverse making sure to remove all reference to the resource. Although not really difficult, it is a lot of work. Suppose you would want to remove a certain resource, e.g. food (because your units are not children anymore, they can look after themselves, and get their own food; just because AoE includes food as a resource doens't mean 0 A.D. has to as well). A sensible, though not necessary complete approach, could be: 74 74 * remove all entries (e.g. Cost, Loot, ResourceGatherer, etc.) in all `simulation/data/` and `simulation/templates/` (e.g. using `grep food *` is very helpful) … … 135 135 136 136 137 Congratulations! You can now have, display, trade, barter, and spend “water”!137 Congratulations! You can now have, display, trade, barter, tribute, and spend “water”! You can now also “water” in technologies and templates (e.g. as costs, loot, resource trickle rate, etc.). 138 138 139 139 … … 154 154 2. Provide something to gather from. For this you will need to create or modify an xml file to define the entity that will be your gather-site. 155 155 156 The parent template you may wish to inherit from will differ depending on your resource, for instance if your resource is something mined then inheriting from `template_gaia_geo` would be a good start, or if your resource comes from a plant then inherit from `template_gaia_flora`, or if gathered from some kind of structure ( ie. a farm) `template_structure_resource`.156 The parent template you may wish to inherit from will differ depending on your resource, for instance if your resource is something mined then inheriting from `template_gaia_geo` would be a good start, or if your resource comes from a plant then inherit from `template_gaia_flora`, or if gathered from some kind of structure (e.g. a farm) `template_structure_resource`. 157 157 158 158 Either way, in order to make the gather-site provide your resource you must include the `ResourceSupply` component into the template of your gather-site: 159 159 {{{ 160 160 #!xml 161 161 <ResourceSupply> … … 165 165 <MaxGatherers>1</MaxGatherers> 166 166 </ResourceSupply> 167 167 }}} 168 168 169 169 For the specifics of what tag does what here, see the schema of the [source:/ps/trunk/binaries/data/mods/public/simulation/components/ResourceSupply.js ResourceSupply] component. 170 170 171 171 3. To the templates of the units that will be doing the gathering (or the parent templates of those units), add a gather rate and carry capacity to the `ResourceGatherer` component. For example: 172 172 {{{ 173 173 #!xml 174 174 <ResourceGatherer> … … 180 180 </Capacities> 181 181 </ResourceGatherer> 182 182 }}} 183 183 184 184 4. Your units will then need to drop the resource off somewhere. If the resource is to be dropped off at a structure (or worker elephant) that already permits resource dropping off, add your resource type to the existing `Types` list inside the `ResourceDropsite` component. Else add the component to the structure: 185 185 {{{ 186 186 #!xml 187 187 <ResourceDropsite> … … 189 189 <Sharable>true</Sharable> 190 190 </ResourceDropsite> 191 191 }}} 192 192 193 193 5. Lastly, modify the `art/actor` xml files of **all** the actors of **all** the units you wish to gather this new resource so as to tell the game which animations and props to use on units for gathering and returning with your new resource. Every civ that has that unit, every promotion level. The easiest way to do this is to use `variants` (see the contents of the `art/variants` folder for some idea of how this works), but it will still require modifying a lot of actor templates. 194 194 195 195 This step could be seen as optional, as the gathering will still take place without error, but without it units will just stand at the resource (playing the idle animation) until their resource capacity is full. 196 197 198 199 == Teaching the AI to gather the new resource == 200 For this you will have to edit some of the `simulation/ai/` files. 201 202 203 204 == Including your resource objects on maps == 205 If you have created new objects from which your new resource can be gathered (e.g. water wells), you might want to include these into the `maps/` files. 196 206 197 207 … … 210 220 * `simulation/templates/special/player_gaia.xml` 211 221 * `simulation/templates/template_structure.xml` 212 This sufficient for having, displaying, trading, bartering, and using a resource.222 This sufficient for having, displaying, trading, bartering, tributing, and using a resource. 213 223 214 224 If you also want to make your resource gatherable, you'll need more icons, create templates, and edit AI files and maps; see the relevant sections (above).