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

skill dmg formula (tfs 1.2)

Edroniasty

New Member
Joined
Oct 2, 2015
Messages
84
Reaction score
1
Hello! I'm trying to calculate this skill formula but don't know how..

: player lvl 150 with skill 115 and attack 115

For me it means min/max = 150 * 1 = 150 + 115 * 115 = 13225 * 0 = 0
so.. both damages should be the same - 150 but my dmg is around 131-141??? why..


Code:
function onGetFormulaValues(player, skill, attack, factor)

    local min = (player:getLevel() * 1) + (skill * attack * 0) + 0
    local max = (player:getLevel() * 1) + (skill * attack * 0) + 0
    return -min, -max
end


help

ref
 
Last edited by a moderator:
Solution
Oh, that's because you are using the wrong callback parameter. Just replace the CALLBACK_PARAM_LEVELMAGICVALUE with CALLBACK_PARAM_SKILLVALUE and your good to go.

The function parameters for the callback parameter "LEVELMAGICVALUE" are arranged this way:
Code:
function onGetFormulaValues(player, level, magicLevel)
end

The function parameters for the callback parameter "SKILLVALUE" are arranged this way:
Code:
function onGetFormulaValues(player, skill, attack, factor)
end

Which means you were using the parameter "level" as the "skill" and "magicLevel" as the "attack".
not, the armor and def is 0

here
Code:
function onGetFormulaValues0(player, skill, attack, factor)
    local min = (skill + attack * 0.09) + 0
    local max = (skill + attack * 0.09) + 0
    return -min, -max
end

my sword skill 18 atk 115 so this must be 18 + 115 =133 * 0.09 = 11.97 but my dmg is 445..

its look like skill and attack don't working
 
Can you post the full script here (in code tags, if you don't mind). Aso, which TFS version are you using (1.0, 1.1, 1.2, 1.3 "master branch")?
 
Last edited:
not, the armor and def is 0

here
Code:
function onGetFormulaValues0(player, skill, attack, factor)
    local min = (skill + attack * 0.09) + 0
    local max = (skill + attack * 0.09) + 0
    return -min, -max
end

my sword skill 18 atk 115 so this must be 18 + 115 =133 * 0.09 = 11.97 but my dmg is 445..

its look like skill and attack don't working
Who thought you math dude? Multiplication comes before addition XD But either way, the result wouldn't be 445. Post full script.
If the problem goes deeper, it's best to investigate sources for combat and spells and check if something is altering the values there.

Also make sure the enemy has 0 armor, 0 defense and 0 resistances.
 
Last edited:
mhm... spell for knight - Used on player with sword attack 115 and sword fighting 50 so its mean 50 * 115 * 0.01 = 57.5dmg but my dmg is 26??? (I send player getlevel * 0 so my char with 455 lvl * 0 = 0 but I see when I lvl up dmg going up too.. I use tfs 1.2+ (target have 0 def and armor, no elemental protection)




Code:
local combatConfig = {
    [0] = {type = COMBAT_PHYSICALDAMAGE, effect = CONST_ME_HITAREA , distanceEffect = CONST_ANI_WHIRLWINDSWORD},
    [1] = {type = COMBAT_PHYSICALDAMAGE, effect = CONST_ME_HITAREA , distanceEffect = CONST_ANI_WHIRLWINDAXE},
    [2] = {type = COMBAT_PHYSICALDAMAGE, effect = CONST_ME_HITAREA , distanceEffect = CONST_ANI_WHIRLWINDCLUB},
    [3] = {type = COMBAT_PHYSICALDAMAGE, effect = CONST_ME_THUNDER , distanceEffect = CONST_ANI_LARGEROCK},
}

function onGetFormulaValues0(player, skill, attack, factor)
    local min = (player:getLevel() * 0) + (skill * attack * 0.01) + 0
    local max = (player:getLevel() * 0) + (skill * attack * 0.01) + 0
    return -min, -max
end

function onGetFormulaValues1(player, skill, attack, factor)
    local min = (player:getLevel() * 0) + (skill * attack * 0.01) + 0
    local max = (player:getLevel() * 0) + (skill * attack * 0.01) + 0
    return -min, -max
end

function onGetFormulaValues2(player, skill, attack, factor)
    local min = (player:getLevel() * 0) + (skill * attack * 0.01) + 0
    local max = (player:getLevel() * 0) + (skill * attack * 0.01) + 0
    return -min, -max
end

function onGetFormulaValues3(player, skill, attack, factor)
    local min = (player:getLevel() * 0) + (skill * attack * 0.01) + 0
    local max = (player:getLevel() * 0) + (skill * attack * 0.01) + 0
    return -min, -max
end

function onTargetTile0(creature, position)
    creature:getPosition():sendDistanceEffect(position, combatConfig[0].distanceEffect)
end

function onTargetTile1(creature, position)
    creature:getPosition():sendDistanceEffect(position, combatConfig[1].distanceEffect)
end

function onTargetTile2(creature, position)
    creature:getPosition():sendDistanceEffect(position, combatConfig[2].distanceEffect)
end

function onTargetTile3(creature, position)
    creature:getPosition():sendDistanceEffect(position, combatConfig[3].distanceEffect)
end

function onTargetCreature0(creature, target)
    return doChallengeCreature(creature, target)
end

function onTargetCreature1(creature, target)
    return doChallengeCreature(creature, target)
end

function onTargetCreature2(creature, target)
    return doChallengeCreature(creature, target)
end

function onTargetCreature3(creature, target)
    return doChallengeCreature(creature, target)
end

local combat = {}
for i = 0, 3 do
    combat[i] = Combat()
    combat[i]:setParameter(COMBAT_PARAM_TYPE, combatConfig[i].type)
    combat[i]:setParameter(COMBAT_PARAM_EFFECT, combatConfig[i].effect)
    combat[i]:setArea(createCombatArea(AREA_CROSS1X1))
    combat[i]:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues"..i)
    combat[i]:setCallback(CALLBACK_PARAM_TARGETTILE, "onTargetTile"..i)
    combat[i]:setCallback(CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature"..i)
end

local function combatCallBack(cid, id, variant)
    local player = Player(cid)
    if not player then
        return false
    end

    return combat[id]:execute(player, variant)
end

function onCastSpell(creature, variant)
    local cid = creature:getId()
    for i = 0, 3 do
        addEvent(combatCallBack, i * 250, cid, i, variant)
    end

    return true
end

+ trying this one
Code:
function onGetFormulaValues0(player, skill, attack, factor)
    local min = (player:getLevel() * 0) + (skill * attack) + 0
    local max = (player:getLevel() * 0) + (skill * attack) + 0
    return -min, -max
end

50 * 115 = 5750 / my dmg is 2670.. damn

++

changing to
Code:
function onGetFormulaValues0(player, skill, attack, factor)
    local min = (skill * attack) + 0
    local max = (skill * attack) + 0
    return -min, -max
end
So there's no calculable lvl gain but I changed my lvl from 445 to 545 and..
Code:
A monk loses 3270 hitpoints due to your attack.
wtf..
 
Last edited:
The values you return in onGetFormulaValues are the maximum damage you deal to monsters... but if the target is a player, the values are decreased by half.
 
update! Now I know where is problem.. + up my target is a monster :D

Code:
function onGetFormulaValues0(player, skill, attack, factor)
    local min = (skill * attack * 1) + 0
    local max = (skill * attack * 1) + 0
    return -min, -max
end
Code:
08:15 A monk loses 2670 hitpoints due to your attack.

my magic lvl is 6 and my lvl is 445 / 6*445 = 2670..

So the skill mean magic level and script don't see my 'attack as a weapon attack only lvl - how to make this working properly?
 
Oh, that's because you are using the wrong callback parameter. Just replace the CALLBACK_PARAM_LEVELMAGICVALUE with CALLBACK_PARAM_SKILLVALUE and your good to go.

The function parameters for the callback parameter "LEVELMAGICVALUE" are arranged this way:
Code:
function onGetFormulaValues(player, level, magicLevel)
end

The function parameters for the callback parameter "SKILLVALUE" are arranged this way:
Code:
function onGetFormulaValues(player, skill, attack, factor)
end

Which means you were using the parameter "level" as the "skill" and "magicLevel" as the "attack".
 
Solution
Oh, that's because you are using the wrong callback parameter. Just replace the CALLBACK_PARAM_LEVELMAGICVALUE with CALLBACK_PARAM_SKILLVALUE and your good to go.

The function parameters for the callback parameter "LEVELMAGICVALUE" are arranged this way:
Code:
function onGetFormulaValues(player, level, magicLevel)
end

The function parameters for the callback parameter "SKILLVALUE" are arranged this way:
Code:
function onGetFormulaValues(player, skill, attack, factor)
end

Which means you were using the parameter "level" as the "skill" and "magicLevel" as the "attack".
Thanks! All working ;)
 
Back
Top