• Please note: In an effort to ensure that all of our users feel welcome on our forums, we’ve updated our forum rules. You can review the updated rules here: http://forums.wolflair.com/showthread.php?t=5528.

    If a fellow Community member is not following the forum rules, please report the post by clicking the Report button (the red yield sign on the left) located on every post. This will notify the moderators directly. If you have any questions about these new rules, please contact support@wolflair.com.

    - The Lone Wolf Development Team

How to do this?

Manalishi66

Well-known member
Lost from the start. How do I script the following for a class ability.

At 3rd level the "class" in medium armor reduce’s his chance of arcane spell failure by 5% (minimum 0). This reduction increases by 5% at 6th, 12th, 15th, and 18th level, ending with a 25% reduction in spell failure while in medium
armor.


At 9th level, the "classes" arcane armor training also applies to heavy armor. It also applies to the arcane spell failure chance from a tower shield, if the character is proficient with tower shields.
 
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
 
Now for the 9th level ability that handles heavy armor and tower shields:

After the usual tests:

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)

We'll borrow the value we calculated in the other ability:

Code:
field[abValue].value += hero.childfound[The Id of your other class ability].field[abValue].value

Don't forget to replace the text "The Id of your other class ability" with the unique Id you created for that class ability.

And generate a livename:

Code:
field[livename].text = field[thingname].text & " -" & field[abValue].value & "%"
Now, we'll modify the script on the other ability so that it only looks for heavy armor:

Code:
foreach pick in hero from BaseArmor where "ArmorClass.Heavy"
  eachpick.field[arArcFail].value -= field[abValue].value
  nexteach
Now, we'll look for the presence of tower shield proficiency:

Code:
if (hero.tagis[Hero.ProfTower] <> 0) then

And then modify the arcane armor failure of tower shields (and close the if):

Code:
  foreach pick in hero from BaseArmor where "ArmorClass.Tower"
    eachpick.field[arArcFail].value -= field[abValue].value
    nexteach
 
  endif

Timing: we want to pick a timing just after the other script, at Post-Levels/3000, so we'll pick Post-Levels/3100 - that way we can borrow the value of the other ability.

Assembling everything for easier copying:

Phase: Post-Levels, priority: 3100
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)
 
field[abValue].value += hero.childfound[The Id of your other class ability].field[abValue].value
 
field[livename].text = field[thingname].text & " -" & field[abValue].value & "%"
 
foreach pick in hero from BaseArmor where "ArmorClass.Heavy"
  eachpick.field[arArcFail].value -= field[abValue].value
  nexteach
 
if (hero.tagis[Hero.ProfTower] <> 0) then
  foreach pick in hero from BaseArmor where "ArmorClass.Tower"
    eachpick.field[arArcFail].value -= field[abValue].value
    nexteach
 
  endif

DON'T FORGET to change out "The Id of your other class ability" for Id you used for that ability.
 
Back
Top