Skip to content

Commit

Permalink
fix: offline training for magic level
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Nobbelin authored and elsongabriel committed Feb 29, 2024
1 parent 80a731f commit 7359b49
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions data/scripts/creaturescripts/others/offline_training.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,22 @@ function offlineTraining.onLogin(player)
local promotion = vocation:getPromotion()
local topVocation = not promotion and vocation or promotion

local updateSkills = false
local tries = nil
if table.contains({ SKILL_CLUB, SKILL_SWORD, SKILL_AXE, SKILL_DISTANCE }, offlineTrainingSkill) then
local modifier = topVocation:getBaseAttackSpeed() / 1000
updateSkills = player:addOfflineTrainingTries(offlineTrainingSkill, (trainingTime / modifier) / (offlineTrainingSkill == SKILL_DISTANCE and 4 or 2))
tries = (trainingTime / modifier) / (offlineTrainingSkill == SKILL_DISTANCE and 4 or 2)
elseif offlineTrainingSkill == SKILL_MAGLEVEL then
local gainTicks = topVocation:getManaGainTicks() * 2
local gainTicks = topVocation:getManaGainTicks() / 1000
if gainTicks == 0 then
gainTicks = 1
end

updateSkills = player:addOfflineTrainingTries(SKILL_MAGLEVEL, trainingTime * (vocation:getManaGainAmount() / gainTicks))
tries = trainingTime * (vocation:getManaGainAmount() / gainTicks)
end

local updateSkills = false
if tries then
updateSkills = player:addOfflineTrainingTries(offlineTrainingSkill, tries)
end

if updateSkills then
Expand Down

0 comments on commit 7359b49

Please sign in to comment.