• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Exercise Weapon

IgoR lYCAN

New Member
Joined
Dec 1, 2018
Messages
169
Reaction score
4
How to make it:

LUA:
local skillRate = configManager.getNumber(configKeys.RATE_SKILL)
local magicRate = configManager.getNumber(configKeys.RATE_MAGIC)

local function start_train(pid,start_pos,itemid,fpos, bonusDummy)
    local player = Player(pid)
    if player ~= nil then
        local pos_n = player:getPosition()
        if start_pos:getDistance(pos_n) == 0 and getTilePzInfo(pos_n) then
            if player:getItemCount(itemid) >= 1 then
                local exercise = player:getItemById(itemid,true)
                if exercise:isItem() then
                    if exercise:hasAttribute(ITEM_ATTRIBUTE_CHARGES) then
                        local charges_n = exercise:getAttribute(ITEM_ATTRIBUTE_CHARGES)
                        if charges_n >= 1 then
                            exercise:setAttribute(ITEM_ATTRIBUTE_CHARGES,(charges_n-1))

                            local voc = player:getVocation()

                            if skills[itemid].id == SKILL_MAGLEVEL then
                                if not bonusDummy then
                                    player:addManaSpent(math.ceil(500*magicRate))
                                else
                                    player:addManaSpent(math.ceil(500*magicRate)*1.1) -- 10%
                                end
                            else
                                if not bonusDummy then
                                    player:addSkillTries(skills[itemid].id, 1*skillRate)
                                else
                                    player:addSkillTries(skills[itemid].id, (1*skillRate)*1.1) -- 10%
                                end
                            end

works with this table :

LUA:
skillStages = {}
skillStages[SKILL_FIST] = {{0,47},{60,14},{80,2}}
skillStages[SKILL_CLUB] = {{0,47},{65,34},{80,8},{100,6},{110,4},{121,2}}
skillStages[SKILL_SWORD] = {{0,47},{65,34},{80,8},{100,6},{110,4},{121,2}}
skillStages[SKILL_AXE] = {{0,47},{65,34},{80,8},{100,6},{110,4},{121,2}}
skillStages[SKILL_DISTANCE] = {{0,47},{65,34},{80,8},{100,6},{110,4},{121,2}}
skillStages[SKILL_SHIELD] = {{0,89},{65,38},{80,10},{100,8},{110,6},{121,3}}
skillStages[SKILL_FISHING] = {{0,12},{40,8},{80,5},{100,2},{110,1}}
skillStages[SKILL_MAGLEVEL] = {{0,10},{6,10},{12,7},{13,4},{16,15},{60,10},{98,4},{110,2}}
  
function Player:onGainSkillTries(skill, tries)
    if APPLY_SKILL_MULTIPLIER == false then
        return tries
    end
  
local skillName
local skillRate
    if(skill==0)then
        skillName=SKILL_FIST
    elseif(skill==1)then
        skillName=SKILL_CLUB
    elseif(skill==2)then
        skillName=SKILL_SWORD
    elseif(skill==3)then
        skillName=SKILL_AXE
    elseif(skill==4)then
        skillName=SKILL_DISTANCE
    elseif(skill==5)then
        skillName=SKILL_SHIELD
    elseif(skill==6)then
        skillName=FISHING
    end
     if(skillStages[skill] ~= nil) then
        skillRate = 1
        for i, skillRateInfo in pairs(skillStages[skill]) do
            if(getPlayerSkill(self, skillName) >= skillRateInfo[1]) then
                skillRate = skillRateInfo[2]
            else
                break
            end
        end
    end
  
    if skill == SKILL_MAGLEVEL then
        return tries * configManager.getNumber(configKeys.RATE_MAGIC) * skillRate
    end
    return tries * configManager.getNumber(configKeys.RATE_SKILL) * skillRate
end
 

Similar threads

Back
Top