Spell success is the rate at which casting a spell can be expected to succeed. As of 0.16.0 spell success rate is determined by a complex combination of:
- Spell-related skills
- Spell level
- Armour and Shield penalty, mitigated by Armour skill and Shields skill
- Mutation Penalty (Wild Magic)
- Piety with Vehumet for Conjurations spells
- Any equipped wizardry items
Spell success calculations
It is debatable whether the following formulae are of real use during a game. However, inflection points such when the extra armour EV penalty disappears are fairly easy to discern. Calculating this stuff on the fly is only for savants!
The source code talks in terms of chance of failure, not success. Therefore, we want the spellFailure chance to be as low as possible - in fact, to reach a Perfect success rate, your chance to fail has to be negative. More on that below.
To begin with, there's a 60% chance of failure. From this, two things are subtracted - twice the caster's Intelligence, and a value calculated from the user's relevant skills. This value is similar to (but simpler than) the spell power. Note that these two factors are the only ones that directly improve spell success, while other factors described below only serve to mitigate spellcasting penalties. Therefore, focus on these areas if you want to maximize your spellcasting chances, particularly spell skills.
Here's an overview of the basic formula, before stepdown and miscellaneous penalties and enhancers.
spellFailure = 60 - [6 * spell skills] - [2 * Intelligence] + Spell difficulty + Armour/shield penalty
Now they use very familiar equation with spellcasting equation. The main difference is, spell skill boost effect of potion of brilliance is not counted here.
S_0 = [Spellcasting / 2] + [Average(SpellSkills) * 2]
spell skills = 50 * log_2 (1 + S_0 / 50)
This value is naturally capped at 370, assuming 27 lv on spell skills and spellcasting.
A number is added, making spellcasting more difficult, dependent on the spell's level.
spellDifficulty = 3 (level 1) 15 (level 2) (+12) 35 (level 3) (+20) 70 (level 4) (+35) 100 (level 5) (+30) 150 (level 6) (+50) 200 (level 7) (+50) 260 (level 8) (+60) 330 (level 9) (+70)
Armour and shield penalties (Under Construction)
Armour/Shield Penalty = 19 * (armour penalty) + 19 * (shield penalty)
armour penalty = 0.4 * (Encumbrance Rating)^2 * (45 - Armour skill Lv) / 45 / (Str + 3)
shield penalty = (EV Penalty) - (Shield Skill Lv) / (Player species factor)
Player species factor is 5 for normal species, 3 for large species, and 7 for small species, respectively. Spriggans have 9, though they only can use bucklers.
At this point, the spell failure is put through a step down curve. If it's over 45 (just into the 'Fair' range), it's unaffected, otherwise it needs to be progressively lower to improve the overall result. This is a stepwise curve, and complex to describe. In the table is the listed native chance to reach certain points (i.e., spell success bands), although note that there are a couple of further steps performed after this.
|Description||Success rate||Needed fail chance|
From −60 to −180 it's linear, with each difference of 20 giving 2% in the final spell success chance. So penalties affect bad wizards more than good ones. Penalty mitigation (for armour) applies before this, so the stepping function doesn't change that.
From now on, we work with STEPPED DOWN failure rates.
Placid magic: Failure Rate - 7 % Wild magic: Failure Rate + 7 % Anti-Wizadry: Failure Rate + 4 %
The unrandart Hat of the High Council offers +7 %, not +4 %. It is noted as separate line in source spl-cast.cc file.
Failure Rate + Sap duration(in terms of turns) / 10 (%)
Wizardry, Vehumet, and other factors
Finally (phew!) spellcasting success boosts from items and other sources are applied. Note that these are actually calculated as a reduction in the fail chance, so in the table below, a low number is better.
- Vehumet knocks 1/3 off the fail chance for Conjurations for disciples in good standing (piety over 70).
- Rings of wizardry and staves of wizardry give some assistance, given by their "Wizardry" bonus in that column, but they suffer from decreasing cumulative effects. Other spell enhancers, such as rings of fire/ice or staves of various kinds, do not affect spell success chances, only their power. Wizardry effect is determined using this formula:
Reduced Failure rate = Failure rate * 6 / (7 + # of Wizardry Items)
- Potion of brilliance: Failure rate / 2 (Directly to max level of reduction)
Note that there is an hard cap of 50% for the effect of all enhancers.
The final step
The number we have obtained isn't the final chance of failure. The game doesn't compare that number with a random number between 0 and 99, but with the sum of three numbers divided by three.
(1d101 + 1d101 + 1d100 - 3)/3 < fail chance
This is equivalent to applying this transformation to the chance of failure:
This sigmoid function makes it more difficult to decrease your failure rate when it is high or low, but it will go down very quickly when it is in the middle. Up to raw failure rate of 33%, one can use this formula:
N = (raw_failure_rate) * 3 Real Failure Rate = N * (N+1) * (N+2) / 6 / 101 / 101 (in unit of %)