Most modders have probably noticed that by using Champion:trainSkill(), you can set skill levels to any value between -inf and 5, but not above 5.
We can do slightly better. EquipmentItemComponent has a "skillModifiers" field that nobody else seems to have noticed, probably because it doesn't have a getter and setter in the scripting interface. It's pretty self-explanatory:
Code: Select all
{
class = "EquipmentItem",
protection = 5,
skillModifiers={
light_weapons=5,
armors=3,
critical=5000,
},
},
Do, however, be careful of the following:
- Champion:trainSkill() will fail to change the skill level altogether if the new skill level it would reach is over 5, so you can't train a skill down from 500 to 499 without going through the intermediate steps of removing the item(s) and re-equipping them etc.
- the skills tab only displays the integer part of skill level between 0 and 5, so skills under 0 display as 0 and skills over 5 display as 5 and a skill of 2.8 displays as 2.
- skill modifiers do not give the traits for the new skill level. Skill traits are only checked when trainSkill() is called. So you should call Champion:trainSkill(skill,0) after equipping the item. (If you want the skill modifier to not give traits at all, you're SOL because the traits will be given if the champion just puts a single point into that skill while the item is equipped. If you want the skill modifier to remove the traits when removed, you have to implement that manually).
The only reasons this could ever be useful are the builtin light_weapons, heavy_weapons, missile_weapons, throwing, firearms, and magic skills since you can't cleanly recreate their effects using the scripting interface. Other than that it would be better to use your own skill system.
P.S. Races and classes can also have a "skills" table in their definition that works similarly, like this:
Code: Select all
defineRace{
name = "human",
uiName = "Human",
inventoryBackground = "assets/textures/gui/inventory_backgrounds/human_$sex.tga",
skills = {alchemy=3,dodge=2}
}