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

about skills doubts tfs 1.4.3

Mateus Robeerto

Excellent OT User
Joined
Jun 5, 2016
Messages
1,337
Solutions
71
Reaction score
697
Location
ლ(ಠ益ಠლ)
I would like to know if it's possible, for example, when using a sword, the script reads it correctly. This weapon belongs to class A. I've created a unique script for each sword, axe, club, and fist, even though they are all classified as class A weapons. However, when I use an axe, it's recognized as a sword. I aim for it to automatically recognize the axe and execute the correct skill for attacking. I've attempted to add more functions, but without success. Could someone assist me in resolving this issue?

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)

function onGetFormulaValues(cid, level, maglevel)
    local player = Player(cid)
    if not player then
        return 0, 0
    end
    
    local skill = player:getSkillLevel(SKILL_SWORD)
    local playerLevel = player:getLevel()
    
    local min = -((skill * 18) + playerLevel * 9)
    local max = -((skill * 27) + playerLevel * 9)
    
    return min, max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onUseWeapon(cid, var)
    combat:execute(cid, var)
end

I made alterations and added a regular player with 100 axe skill, yet the damage dealt was significantly less than expected compared to using a sword. Despite the sword having only 10 skill, it inflicts more damage than the axe. I intended for it to recognize the specific skill when equipped with an axe, ensuring it deals the appropriate damage. However, it consistently recognizes only the sword. I'm having difficulty making it function properly; any assistance would be appreciated.

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)

function onGetFormulaValues(cid, level, maglevel)
    local player = Player(cid)
    if not player then
        return 0, 0
    end
    
    local swordSkill = player:getSkillLevel(SKILL_SWORD)
    local axeSkill = player:getSkillLevel(SKILL_AXE)
    local fistSkill = player:getSkillLevel(SKILL_FIST)
    local clubSkill = player:getSkillLevel(SKILL_CLUB)
    
    local playerLevel = player:getLevel()
    
    local min = -(((swordSkill + axeSkill + fistSkill + clubSkill) * 18) + playerLevel * 9)
    local max = -(((swordSkill + axeSkill + fistSkill + clubSkill) * 27) + playerLevel * 9)
    
    return min, max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onUseWeapon(cid, var)
    combat:execute(cid, var)
end
 
Solution
Try This, not testing ;p

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)

local function getWeaponSkill(player)
    local weapon = player:getSlotItem(CONST_SLOT_LEFT)
    if not weapon then
        return SKILL_FIST
    end

    local weaponType = weapon:getType()
    if weaponType:getWeaponType() == WEAPON_SWORD then
        return SKILL_SWORD
    elseif weaponType:getWeaponType() == WEAPON_AXE then
        return SKILL_AXE
    elseif weaponType:getWeaponType() == WEAPON_CLUB then
        return SKILL_CLUB
    else
        return SKILL_FIST
    end
end

function onGetFormulaValues(player, level, maglevel)
    local skillType = getWeaponSkill(player)
    local skill =...
Try This, not testing ;p

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)

local function getWeaponSkill(player)
    local weapon = player:getSlotItem(CONST_SLOT_LEFT)
    if not weapon then
        return SKILL_FIST
    end

    local weaponType = weapon:getType()
    if weaponType:getWeaponType() == WEAPON_SWORD then
        return SKILL_SWORD
    elseif weaponType:getWeaponType() == WEAPON_AXE then
        return SKILL_AXE
    elseif weaponType:getWeaponType() == WEAPON_CLUB then
        return SKILL_CLUB
    else
        return SKILL_FIST
    end
end

function onGetFormulaValues(player, level, maglevel)
    local skillType = getWeaponSkill(player)
    local skill = player:getSkillLevel(skillType)
    local min = -((skill * 18) + level * 9)
    local max = -((skill * 27) + level * 9)

    return min, max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onUseWeapon(player, var)
    combat:execute(player, var)
end
 
Solution
Try This, not testing ;p

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)

local function getWeaponSkill(player)
    local weapon = player:getSlotItem(CONST_SLOT_LEFT)
    if not weapon then
        return SKILL_FIST
    end

    local weaponType = weapon:getType()
    if weaponType:getWeaponType() == WEAPON_SWORD then
        return SKILL_SWORD
    elseif weaponType:getWeaponType() == WEAPON_AXE then
        return SKILL_AXE
    elseif weaponType:getWeaponType() == WEAPON_CLUB then
        return SKILL_CLUB
    else
        return SKILL_FIST
    end
end

function onGetFormulaValues(player, level, maglevel)
    local skillType = getWeaponSkill(player)
    local skill = player:getSkillLevel(skillType)
    local min = -((skill * 18) + level * 9)
    local max = -((skill * 27) + level * 9)

    return min, max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onUseWeapon(player, var)
    combat:execute(player, var)
end
Now it's perfect, okay. Thank you very much.
 
Back
Top