Well actually, since it is something you get from a class, "class special" would probably be the more appropriate tag. Oftentimes you can see how to do things by looking at eval scripts already programmed things in HL, for example, the ranger's Evasion requires being in light armor for it to work. You can access the SRD classes through the editor through Open File -> Source folder -> appropriate class or you can just New (Copy) the appropriate special and look at the evals there.
From the ranger's class special evasion I see:
~ If we're wearing medium or worse armor, get out
if (hero.tagis[Hero.MedArmor] + hero.tagis[Hero.HeavyArmor] <> 0) then
var result as number
result = delete[Helper.ShowSpec]
done
endif
Barbarian's Fast movement requires you not be heavily encumbered. I would use Monk's fast movement, but it seems to have dissappeared from the program mysteriously.... Anyway from that eval script I pull:
var result as number
~ If we fail the test for being speedy, get out
if (hero.tagis[Encumbered.Light] + hero.tagis[Encumbered.Medium] = 0) then
result = assign[Helper.SpcDisable]
done
elseif (hero.tagis[Hero.HeavyArmor] <> 0) then
result = assign[Helper.SpcDisable]
done
endif
And finally, adding a bonus based on level requires you to first get your level, and determine the bonus based on that. There are many abilities you can copy to see how to program a variable bonus, and to see how to add to reflex saves, look at the Lightning Reflexes feat. Here is some code I pulled:
~ Get the bonus based on our level
var bonus as number
var level as number
level = field[xTotalLev].value
if (level < 5) then
bonus = -2
elseif (level < 9) then
bonus = -1
else
bonus = 0
endif
container.child[vRef].field[Bonus].value = container.child[vRef].field[Bonus].value + 2
Now you just have to combine the pieces you have gathered and test the code. It may take a little bit of fiddling. I have found that the hardest thing is often getting the right timing for it to work. Here is the final code I would try testing.
var result as number
~ If we fail the test for being speedy, get out
~ Note that I switched this around a little, due to personal preference
if (hero.tagis[Encumbered.Medium] + hero.tagis[Encumbered.Heavy] <> 0) then
result = assign[Helper.SpcDisable]
done
elseif (hero.tagis[Hero.MedArmor] + hero.tagis[Hero.HeavyArmor] <> 0) then
result = assign[Helper.SpcDisable]
done
endif
~ Get the bonus based on our level
var bonus as number
var level as number
level = field[xTotalLev].value
if (level >= 20) then
bonus = 3
elseif (level >= 11) then
bonus = 2
else
bonus = 1
endif
~ Note that the bonus is a Competence bonus, so I have changed what was previously .field[Bonus] to .field[BonComp]
container.child[vRef].field[BonComp].value = container.child[vRef].field[BonComp].value + bonus
Feel free to ask any questions about other class specials and whatnot. You may also want to talk to chiefweasel about posting your finished file for the community to share, he is setting up a website where I am planning to post mine at least.
|