Modding/ToolsAndWeapons

## Introduction

Before you try to mod, it is good to have an understanding that multiple JSON files are used to contain the configuration/stats for tools and weapons. For those who have yet to encounter JSON, it is a method of pairing names and values together, and having a working understanding is important. At the simplest level, we can create data that contains a name "MyName", which holds the corresponding value of "MyValue". We'll examine the format a bit further along

```
"MyName": "MyValue"

```

So far, the important information appears to be contained in:

* Tools.json
* Weapons.json
* UISprites.json
* ToolStatsjson
* WeaponStats.json
* EquipableAudio.json

## Tools and Weapons

In some ways, tools and weapons are related, in as much as most tools can be used as weapons. This means that tools will have entries in the JSON files that deal with weapons as well as tools. At a high level, the Tools.json file appears to contain the top level definitions for tools, and effectively points to entries in other JSON files. In the same way the Weapons.json file contains the top level definitions for weapons, and points to entries in other JSON files.

## Tools

In order to try to make things a little simpler, the diagram below can help to show how the different files appear to link together. Click to enlarge it.

Not yet documented:

* EquipableHandOffsets.json

### Tools.json entries

Looking into the Tools.json file, entries are defined similar to:

```
  "Hand": {
    "Type": "Tool",
    "Data": {
      "Name": "strHandName",
      "Sprite": "HandSprite",
      "ToolStats": "HandStats",
      "WeaponStats": "HandWStats",
      "EquipableAudio": "HandAudio",
      "AudioEventSwing": "Hand_Woosh",
      "AudioEventSwingTiming": 0.0,
      "AudioEventMaterialTouch": "Material_Touch",
      "AudioEventMaterialTouchTiming": 0.0,
      "EquipableResource": "Hand"
    }
  }

```

Looking at an entry in the Tools.json file, we can see the first part is the name - in this example it is "Hand". As there are curly braces as the value part, the value of this name is actually an object that contains a "Type" name/value and a "Data" object. The Data object contains the details for this name. If you are still with this so far, well done!

For the Tools.json file, most of the values in the data object are simply references to other names in other files.

 Sprite
 ToolStats
 WeaponStats
 EquipableAudio
 AudioEventSwing
 AudioEventSwingTiming
 AudioEventMaterialTouch
 AudioEventMaterialTouchTiming
 EquipableResource

### ToolStats entries

For the ToolStats.json file, there is a significant amount of data stored. The fields are:

#### Tool multipliers and ages

When a tool operates, a number of calculations are done in order to work out how long the tool will take to operate on the material is is being deployed on. These are based around:

* The baseTime of the tool
* The toughness of the material being mined or dug.
* If the tool is optimal for the material being worked upon
* The age of material
* The age of the tool

The optimum/non-optimum multipliers are selected by if the tool type is optimal for digging the material or not. If it is optimal, then the optimumToolMultilier is selected, otherwise the nonOptimumToolMultiplier is used.

The age of the tool is also examined and subtracted from the age of the material. If this results in a positive number, then the age multiplier is selected according to this table:

 1
 2
 3

Once these values are selected, the length of time for the tool to operate is determined by the calculation:

```
Tool baseTime * Material Toughness * ToolMultiplier * AgeMultiplier

```

## Weapons

Weapons follow a similar pattern to tools. In order to show the interrelations between files, the following diagram should help.

### Weapons.json entries

Looking into the Weapons.json file, the entries will look somewhat like the following example:

```
"WoodenShortsword": {
    "Type": "Weapon",
    "Data": {
      "Name": "strWoodenShortswordName",
      "Sprite": "WoodenShortswordSprite",
      "WeaponStats": "WoodenShortswordWStats",
      "EquipableAudio": "SwordAudio",
      "EquipableResource": "Shortsword"
    }
  },

```

Examining this entry, we can see that the first part is the name - in this example it is "WoodenShortsword". Just like the Tools.json example, this name contains an object that is defined by a Type name and Data object.

For the Weapons.json file, most of the values in the data object are simply references to other names in other files.

 Sprite
 WeaponStats
 EquipableAudio
 EquipableResource

### WeaponStats.json

The WeaponStats.json file is where various details about the weapons are stored.

An example WeaponStats entry might look like the following:

```
 "HandWStats": {
    "Type": "WeaponStats",
    "Data": {
      "categoryName": "Unarmed",
      "durability": -1,
      "typeName": "Melee",
      "atkRange": 1.0,
      "hitTime": 0.375,
      "minDamage": 1,
      "maxDamage": 2,
      "attackSpeed": 1.5
    }
  },

```

There's less information in the WeaponStats entry than ToolStats. The fields are:

* *Unarmed* - Your fists
* *1-Hand* - A one handed weapon
 durability
 typeName
* *Melee* - A hand to hand weapon
* *Bow* - A ranged weapon
* *Single* - A single shot weapon
 atkRange
 hitTime
 minDamage
 maxDamage
 attackSpeed