Skip to content

Commit

Permalink
Fix baseline skill progress award
Browse files Browse the repository at this point in the history
Looks like this script forgot to carry over the baseline skill progress
award that the game gave the player. Only "extra" progress was awarded!
Pretty big bug. This was caused by confusion over variable names and
debug messages. It was especially noticeable for new players who cast
low-cost spells, i.e. ones that would not award any extra progress.
These players would be unable to progress using those spells.
  • Loading branch information
IllyaMoskvin committed Dec 15, 2019
1 parent 6a862a7 commit 8d5b088
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -388,15 +388,20 @@ end

local runAwardProgress = function(pid, spellCost, skillId, skillName, skillProgress, skillProgressDelta)
local extraProgress = math.ceil(spellCost / config['spellCostDivisor'] * skillProgressDelta) - skillProgressDelta
local newProgess = skillProgress + extraProgress

dbg('PID #' .. pid .. ' is owed ' .. extraProgress .. ' more progress for spell cost ' .. spellCost)

tes3mp.SetSkillProgress(pid, skillId, newProgess) -- save to memory
Players[pid].data.skills[skillName].progress = newProgess -- save to disk
tes3mp.SendSkills(pid) -- send to all clients
if extraProgress > 0 then
local newProgess = skillProgress + skillProgressDelta + extraProgress

dbg('PID #' .. pid .. ' progress bumped from ' .. skillProgress .. ' to ' .. tes3mp.GetSkillProgress(pid, skillId))
tes3mp.SetSkillProgress(pid, skillId, newProgess) -- save to memory
Players[pid].data.skills[skillName].progress = newProgess -- save to disk
tes3mp.SendSkills(pid) -- send to all clients

dbg('PID #' .. pid .. ' progress bumped from ' .. skillProgress .. ' to ' .. tes3mp.GetSkillProgress(pid, skillId))
else
dbg('PID #' .. pid .. ' progress naturally rose to from ' .. skillProgress .. ' to ' .. tes3mp.GetSkillProgress(pid, skillId))
end
end

customEventHooks.registerValidator('OnPlayerSkill', function(eventStatus, pid)
Expand Down

0 comments on commit 8d5b088

Please sign in to comment.