From 7359b49b5b0e0efcd24c4b91fef99921b71036a3 Mon Sep 17 00:00:00 2001 From: Sebastian Nobbelin Date: Thu, 29 Feb 2024 20:20:24 +0100 Subject: [PATCH] fix: offline training for magic level --- .../creaturescripts/others/offline_training.lua | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/data/scripts/creaturescripts/others/offline_training.lua b/data/scripts/creaturescripts/others/offline_training.lua index abfb0b94b3d..e967a7c4505 100644 --- a/data/scripts/creaturescripts/others/offline_training.lua +++ b/data/scripts/creaturescripts/others/offline_training.lua @@ -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