Go to the develop menu, and make sure that the first item, "Enable Data File Debugging" is checked.
Now, add a piece of armor from each category (light, medium, heavy, shields, tower shield) to your test character.
Right-click on each of those armors and shields, and select "Show Selection tags for XXX".
Look through those lists, comparing between them, and figure out how to distinguish a suit of light armor from medium armor from heavy armor, and distinguish shields from armor and distinguish normal shields from tower shields.
ArmorClass.Light
ArmorClass.Medium
ArmorClass.Heavy
ArmorClass.Shield
ArmorClass.Tower
Now, how is the arcane failure chance stored on the armor?
Right-click on each of those armors again, this time selecting "Show Debug Fields for XXX", and look at the lists of fields for each thing. You'll find the "Arcane % Fail" field - arArcFail.
Now, on to the script.
Okay, we'll start by creating the name of this ability as seen on the class tab for this class.
Code:
var bonus as number
bonus -= field[xIndex].value * 5
field[listname].text = field[thingname].text & " " & bonus & "%"
xIndex is the position (lowest level to highest level) that this ability will end up in when viewed in the list of class abilities. So, the level 1 copy has xIndex = 1, the level 18 copy has xIndex = 5. The listname is the name as displayed on the class tab, and the thingname is the name you gave the class ability in the editor.
Next, the usual checks that go in all class specials, so that the script only runs once, and doesn't run if you haven't reached the right level for that ability (it also keeps the script from running if an archetype replaces this ability):
Code:
~The remaining calculations should only happen for the first copy
doneif (tagis[Helper.FirstCopy] = 0)
~ If we're not shown, just get out now
doneif (tagis[Helper.ShowSpec] = 0)
Next, we calculate the amount of arcane armor failure we'll remove, and store it in the abValue field, and generate a name for our special:
Code:
field[abValue].value += field[xCount].value * 5
field[livename].text = field[thingname].text & " -" & field[abValue].value & "%"
xCount is the number of copies of this ability that have reached the correct level.
Now, we'll search through the armor on the hero, looking for everything that's light or medium armor or a shield:
Code:
foreach pick in hero from BaseArmor where "ArmorClass.Light | ArmorClass.Medium | ArmorClass.Shield"
For every one we find, we'll subtract the abValue we calculated from the armor's arcane failure chance (and then close the foreach):
Code:
eachpick.field[arArcFail].value -= field[abValue].value
nexteach
Timing: this is a class special, so it needs to know its level, which means that the script has to be at least in the Post-Levels phase or later. In this case, 3000 should work for the priority (but that timing is actually a question you'd probably need to ask me - there's not an easy way to figure that out without looking at the structural code).
Assembling all of that for easy copying:
Phase: Post-Levels, Priority: 3000
Code:
var bonus as number
bonus -= field[xIndex].value * 5
field[listname].text = field[thingname].text & " " & bonus & "%"
~The remaining calculations should only happen for the first copy
doneif (tagis[Helper.FirstCopy] = 0)
~ If we're not shown, just get out now
doneif (tagis[Helper.ShowSpec] = 0)
field[abValue].value += field[xCount].value * 5
field[livename].text = field[thingname].text & " -" & field[abValue].value & "%"
foreach pick in hero from BaseArmor where "ArmorClass.Light | ArmorClass.Medium | ArmorClass.Shield"
eachpick.field[arArcFail].value -= field[abValue].value
nexteach