# Talent mechanics

## Formulas

Documenting the effects of the talents is quite difficult because the code is not only complicated, but also changing. Many of the wiki pages have incorrect or incomplete numbers, or are just plain missing whole sections. This is all a work in progress.

Here are some notes on reading the source code, which is the only way we can get this documentation back into shape.

### Talent Damage

Many talents use one of the functions combatTalentPhysicalDamage(t, base, max) or combatTalentMindDamage(t, base, max) or combatTalentSpellDamage(t, base, max). (These aren't just used to calculate damages, either -- they are used for all kinds of numeric outputs.) Explaining these functions requires several steps.

The first thing to understand is that each of these functions has another hidden input. For combatTalentPhysicalDamage, your Physical Power is also used. For combatTalentMindDamage your Mindpower is used, and for combatTalentSpellDamage your Spellpower is used.

Next, max is used to fix a sort of upper bound on the function's output. max is the value that the function should produce (before the final rescaling step) if your Power (physical, mind or spell) level is 100 and your effective talent level is 5. A modifier is calculated using this formula:

```mod = max / [(base + 100) * ((sqrt - 1) * 0.8 + 1)]
```

Then the formula is reused, only this time with your Power level instead of 100, and your effective talent level instead of 5, and is scaled using the modifier:

```raw_dmg = [(base + power) * ((sqrt[talent] - 1) * 0.8 + 1)] * mod
```

Finally, the damage is rescaled:

```dmg = raw_dmg ^ 1.04
```

Let's try an example: Resolve (Wild-gift/Antimagic) gives, among other things, an effect which confers combatTalentMindDamage(t, 10, 40) percent elemental resistance. What does this mean for us?

Well, we know that if we had 100 Mindpower and an effective talent level of 5 in Resolve, it would give (40 ^ 1.04)% resistance (or 46.36%), because the third argument (max) is 40. From max, we can calculate the internal mod variable:

```mod = 40 / [(10 + 100) * ((sqrt - 1) * 0.8 + 1)]
= 0.1828
```

Now, given a talent level and a Mindpower level, we can calculate how much "damage" (resistance) it gives. With two inputs and one output, we'd need a three-dimensional plot to show the results graphically, and it would be hard to read. It might be more helpful (and it's certainly easier) to take a few arbitrary input pairs and calculate the result:

```Talent  Mindpower  Resistance
1.00      20         5.87%
2.00      30        10.66%
4.00      45        20.32%
5.00     100        46.35%

```

### mindDamage

Someone made up the shorthand notation mindDamage(x, y). This is equivalent to combatTalentMindDamage(t, x, y) from the previous section.

### Talent Modifier

Talent Modifier (which is used in the Talent Damage calculation, above) is calculated as:

```(sqrt[talent] -1) * 0.8 + 1
```

Here's a table of values for common talent levels.

effective talent level talent modifier
0.0 0.20
0.7 0.87
1.0 1.00
1.3 1.11
2.0 1.33
2.6 1.49
3.0 1.58
3.9 1.78
4.0 1.80
5.0 1.99
5.2 2.02
6.5 2.24