Lua: addSkillLevelUpHandler does not work properly with skills that reached maximum level
Related code:
local function skillUsedHandler(skillid, params)
if NPC.isWerewolf(self) then
return false
end
local skillStat = NPC.stats.skills[skillid](self)
skillStat.progress = skillStat.progress + params.skillGain / I.SkillProgression.getSkillProgressRequirement(skillid)
if skillStat.progress >= 1 then
I.SkillProgression.skillLevelUp(skillid, I.SkillProgression.SKILL_INCREASE_SOURCES.Usage)
end
end
This code assumes that if progress is 1, it is a 100%, so there is a skill levelup.
The problem is that once skill reaches maximum level (100), progress continues to grow, but we do not reset it. As a result, at some point an every usage of this skill triggers a skill levelup event (because progress becomes > 1 and stays at this level forever).
I'd say that we should early out from skillUsedHandler if skill level reaches 100, but I am not sure if we support different skill caps at the moment.
Edited by Andrei Kortunov