In the context of Click_LaunchSpellFromBook, the two unknown bytes in the champion data structure are used this way:
Byte 13 (hex) is the number of the spell that the player attempts to cast.
Byte 14 (hex) is the spell power boost gained by spending additional mana.
Well, what I meant about practicing a spell will be clear in a moment.. ("spoiler": each spell is practiced individually by counting the number of times it has succeeded (all champions contribute to the same count). A high number of successes increase the chances of further successes for that particular spell.)
In the following I will say that champions, wands, rings and spells matches if their colour matches.Mana Cost(Attempting to cast a spell always reduces vitality (Byte 07) by 4 to a minimum of 0, and sets the attack cooldown timer (Byte 1B) to 15, but neither of these two stats have any effect on the spell success chance.)
Each spell has a base mana cost that is derived from the first row of this table:
+----------------------------------------------------------------------------------------------------------------------------------------------+
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
| ------------------------------------------------------------------------------------------------------------------------------ |
| Spellcost 1 2 2 1 1 2 2 3 1 3 2 5 2 2 4 5 3 3 7 3 4 4 2 5 8 3 7 4 5 6 6 4 |
| Difficulty 14 15 14 14 13 14 14 15 14 15 14 18 15 15 17 16 15 16 36 16 17 19 14 18 24 16 22 16 17 19 18 16 |
+----------------------------------------------------------------------------------------------------------------------------------------------+
Table 1: Spells
The base mana cost is
2 * (Spellcost + 1)
e.g. spell 10 has base cost 8.
If an attack bonus/penalty is applied to the spell (Byte 14), the base value is adjusted according to the next table.
+--------------------------------------------------------------------------------------------------+
| Attack modifier .. -3 -2 -1 0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 |
| ------------------------------------------------------------------------------ |
| Additional mana .. -3 -2 -1 0 3 6 10 15 21 28 36 45 55 66 78 91 |
+--------------------------------------------------------------------------------------------------+
Table 2: Attack modifiers
Mana used on a single spell can't exceed 99.
If the champion wears a ring matching the spell, a charge from that will be spent instead of using mana.
Such spells are always cast unmodified (no attack bonus/penalty).
Casting successIf a champion matches the spell or is wielding a wand matching the spell, the base attack is given in Table 3A.
Otherwise the base attack is given in Table 3B.
+---------------------------------------+ +---------------------------------------+
| #Successes Base attack | | #Successes Base attack |
| ---------- ---------------- | | ---------- ---------------- |
| 0 - 4 0 + (X - 0)/1 | | 0 - 9 0 + (X - 0)/2 |
| 5 - 14 5 + (X - 5)/2 | | 10 - 29 5 + (X - 10)/4 |
| 15 - 34 10 + (X - 15)/4 | | 30 - 69 10 + (X - 30)/8 |
| 35 - 74 15 + (X - 35)/8 | | 70 - 127 15 + (X - 70)/16 |
| 75 - 127 20 + (X - 75)/16 | +---------------------------------------+
+---------------------------------------+ Table 3B: Non-matching spell
Table 3A: Matching spell
Here #Successes is the accumulated number of times the spell has succeeded. (The count stops increasing after 127 successes)
The base attack is adjusted by caster class:
+---------------------------------------------------+
| Class: Matching bonus Level bonus |
| ------- -------------- ------------- |
| Warrior +3 +2 / 4 levels |
| Wizard +5 +2 / 1 level |
| Adventurer +4 +2 / 2 levels |
| Cutpurse +4 +2 / 4 levels |
+---------------------------------------------------+
Table 4: Class bonuses
The matching bonus of Table 4 applies when the champion matches the spell. If the champion does not match but is wielding a wand that matches the spell, a matching bonus of +3 is used instead.
The level bonus is based on the level of the champion (Byte 0).
Next the attack bonus/penalty from mana adjustment (Byte 14) is added to the result.
A further +5 is added if a PowerStaff is equipped.
Now subtract the spell difficulty found in Table 1.
Finally the Spell Cool Down Timer (Byte 15), is subtracted from the result. Only half the Spell Cool Down Timer is subtracted if spell, equipped wand and champion are all matching.
Spell Cool Down Timer then increases by Spellcost+5 (ref. Table 1) to a maximum of 100.
If the final attack value plus 3D6 is less than 0 the spell fails, otherwise the spell succeeds.
EDIT:
The roll was of course the more natural 3D6 (three dice of value 0-5 plus 3)