• 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!

TFS 1.X+ [1.4.2] Exercise weapons - getStageRate?

OTcreator

Active Member
Joined
Feb 14, 2022
Messages
425
Solutions
1
Reaction score
44
Hi,
I used this script for exercise weapons.
EDIT: I found first problem.

How I can check skillstages (Gesior skill stages for 1.x) ?

Lua:
local skills = {
    [31208] = {id = SKILL_SWORD, voc = {4}},
    [31209] = {id = SKILL_AXE, voc = {4}},
    [31210] = {id = SKILL_CLUB, voc = {4}},
    [31211] = {id = SKILL_DISTANCE, voc = {3}, range = CONST_ANI_SIMPLEARROW},
    [31212] = {id = SKILL_MAGLEVEL, voc = {1, 2, 3, 4}, range = CONST_ANI_SMALLICE},
    [31213] = {id = SKILL_MAGLEVEL, voc = {1, 2, 3, 4}, range = CONST_ANI_FIRE},
    [37935] = {id = SKILL_SWORD, voc = {4}},
    [37936] = {id = SKILL_AXE, voc = {4}},
    [37937] = {id = SKILL_CLUB, voc = {4}},
    [37938] = {id = SKILL_DISTANCE, voc = {3}, range = CONST_ANI_SIMPLEARROW},
    [37939] = {id = SKILL_MAGLEVEL, voc = {1, 2, 3, 4}, range = CONST_ANI_SMALLICE},
    [37940] = {id = SKILL_MAGLEVEL, voc = {1, 2, 3, 4}, range = CONST_ANI_FIRE},
    [37941] = {id = SKILL_SWORD, voc = {4}},
    [37942] = {id = SKILL_AXE, voc = {4}},
    [37943] = {id = SKILL_CLUB, voc = {4}},
    [37944] = {id = SKILL_DISTANCE, voc = {3}, range = CONST_ANI_SIMPLEARROW},
    [37945] = {id = SKILL_MAGLEVEL, voc = {1, 2, 3, 4}, range = CONST_ANI_SMALLICE},
    [37946] = {id = SKILL_MAGLEVEL, voc = {1, 2, 3, 4}, range = CONST_ANI_FIRE},

    -- FREE WEAPONS --
    [31196] = {id = SKILL_SWORD, voc = {4}},
    [31197] = {id = SKILL_AXE, voc = {4}},
    [31198] = {id = SKILL_CLUB, voc = {4}},
    [31199] = {id = SKILL_DISTANCE, voc = {3}, range = CONST_ANI_SIMPLEARROW},
    [31200] = {id = SKILL_MAGLEVEL, voc = {1, 2, 3, 4}, range = CONST_ANI_SMALLICE},
    [31201] = {id = SKILL_MAGLEVEL, voc = {1, 2, 3, 4}, range = CONST_ANI_FIRE}
}


local freeDummies = {31214, 31221}
local houseDummies = {31215, 31216, 31217, 31218, 31219, 31220}
local exerciseStorage = 8702
local skillRate = 1
local magicRate = 1

local function start_train(pid,start_pos,itemid,fpos, bonusDummy, dummyId)
    local player = Player(pid)
    if player ~= nil then

    --if skills[itemid].id == SKILL_MAGLEVEL then
       --magicRate = getMagicLevelStage(player:getMagicLevel(SKILL_MAGLEVEL))
    --else
       --skillRate = getSkillStage(player:getSkillLevel(skills[itemid].id))
    --end

    if Tile(fpos):getItemById(dummyId) 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(650 * magicRate) * 1.1)
                                end
                            else
                                if not bonusDummy then
                                    player:addSkillTries(skills[itemid].id, 7 * skillRate)
                                else
                                    player:addSkillTries(skills[itemid].id, (7 * skillRate) * 1.1)
                                end
                            end
                                fpos:sendMagicEffect(CONST_ME_GROUNDSHAKER)
                            if skills[itemid].range then
                                pos_n:sendDistanceEffect(fpos, skills[itemid].range)
                            end
                          
                            local training = addEvent(start_train, voc:getAttackSpeed(), pid,start_pos,itemid,fpos,bonusDummy,dummyId)
                            player:setStorageValue(exerciseStorage,1)
                        else
                            exercise:remove(1)
                            player:sendTextMessage(MESSAGE_INFO_DESCR, "Your training weapon vanished.")
                            stopEvent(training)
                            player:setStorageValue(exerciseStorage,0)
                        end
                    end
                end
            end
        else
            player:sendTextMessage(MESSAGE_INFO_DESCR, "Your training has stopped.")
            stopEvent(training)
            player:setStorageValue(exerciseStorage,0)
        end
    else
    stopEvent(training)
            player:sendTextMessage(MESSAGE_INFO_DESCR, "Your training has stopped.")
            player:setStorageValue(exerciseStorage, 0)
            end
            else
        stopEvent(training)
        if player then
            player:sendTextMessage(MESSAGE_INFO_DESCR, "Your training has stopped.")
            player:setStorageValue(exerciseStorage,0)
        end
    end
 
    return true
end

local exerciseTraining = Action()

function exerciseTraining.onUse(player, item, fromPosition, target, toPosition, isHotkey)
  
    local start_pos = player:getPosition()
    if player:getStorageValue(exerciseStorage) == 1 then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You are already training.")
        return false
    end
    if target:isItem() then
        if isInArray(houseDummies,target:getId()) then
            if not skills[item.itemid].range and (start_pos:getDistance(target:getPosition()) > 1) then
                player:sendTextMessage(MESSAGE_INFO_DESCR, "Get closer to the dummy.")
                stopEvent(training)
                return true
            end
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You started training.")
            start_train(player:getId(),start_pos,item.itemid,target:getPosition(), true, target:getId())
      
        elseif isInArray(freeDummies, target:getId()) then
            if not skills[item.itemid].range and (start_pos:getDistance(target:getPosition()) > 1) then
                player:sendTextMessage(MESSAGE_INFO_DESCR, "Get closer to the dummy.")
                stopEvent(training)
                return true
            end
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You started training.")
            start_train(player:getId(),start_pos,item.itemid,target:getPosition(), false, target:getId())
        end
    end
    return true
end

for id = 31196, 31198 do
    exerciseTraining:id(id)
end

for id = 31199, 31201 do
    exerciseTraining:id(id)
    exerciseTraining:allowFarUse(true)
end

for id = 31208, 31210 do
    exerciseTraining:id(id)
end

for id = 31211, 31213 do
    exerciseTraining:id(id)
    exerciseTraining:allowFarUse(true)
end

for id = 37935, 37937 do
    exerciseTraining:id(id)
end

for id = 37938, 37940 do
    exerciseTraining:id(id)
    exerciseTraining:allowFarUse(true)
end

for id = 37941, 37943 do
    exerciseTraining:id(id)
end

for id = 37944, 37946 do
    exerciseTraining:id(id)
    exerciseTraining:allowFarUse(true)
end

exerciseTraining:register()
 
Last edited:
Back
Top