• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

TFS 0.X wand dealing extra damage with skills

Lurk

Active Member
Joined
Dec 4, 2017
Messages
336
Reaction score
49
Hi, I have a bow in my server that deals damage via script, the thing is I don't know how to make this bow do extra damage with skills AND up the player distance skill (since it's a wand). This is the script I'm using (this is the wand one but the bow is exactly the same)
the way it is right now it does extra damage with resets and level, but it would be nice to also have a skill scalling and for it to also increase the users skill with every attack, just like a normal bow/sword

LUA:
w3333 = {
[1] = {ef = 51, sh = 41, dmg = COMBAT_HOLYDAMAGE},
[2] = {ef = 51, sh = 41, dmg = COMBAT_HOLYDAMAGE} -- antes era 41 (bolo)
}
 
function onUseWeapon(cid, var)
local extra = 0
local extra2 = 0
local haha = 0
local target = getCreatureTarget(cid)

if getPlayerStorageValue(cid, 378378) > 0 then -- dano extra com reset
extra = (getPlayerStorageValue(cid, 378378)*23000)
else
extra = 0
end

    if getPlayerLevel(cid) > 50000 then
        extra2 = getPlayerLevel(cid)*2
    else
        extra2 = 1100
    end

haha = extra+extra2
min, max = 229000+haha, 299000+haha
target = getCreatureTarget(cid)


if target ~= 0 then
wx3333 = w3333[math.random(1, #w3333)]
doSendDistanceShoot(getThingPos(cid), getThingPos(target), wx3333.sh)
addEvent(doAreaCombatHealth, 100, cid, wx3333.dmg, getThingPos(target), 0, -min, -max, wx3333.ef)
end
return true
end
 
Solution
The script above only deals damage from min to max which won't increase by distance or sword.
I think you'll have to use this formula and calculate the same damage which the script above deals by testing in-game to make it increase with distance skills/sword skills.
here is an example
LUA:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 0)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HITBYFIRE)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, 33)

function onGetFormulaValues(cid, level, skill, attack, factor)
    local skillTotal, levelTotal = skill + attack, level / 5
    return -(skillTotal * 0.5 + levelTotal), -(skillTotal *...
try this
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 0)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_YELLOW_RINGS)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, 15)
function onGetFormulaValues(cid, level, skill, attack, factor)
    local skillTotal, levelTotal = skill + attack, level / 5
    return -(skillTotal * 5500 + levelTotal), -(skillTotal * 7000 + levelTotal)
end
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")


function onUseWeapon(cid, var)
return doCombat(cid, combat, var)
end
 
I do want to keep the original scallings from my script AND increment the skill thing, if I incorpore some aspects of your script it would be enough? like this part
LUA:
function onGetFormulaValues(cid, level, skill, attack, factor)
    local skillTotal, levelTotal = skill + attack, level / 5
    return -(skillTotal * 5500 + levelTotal), -(skillTotal * 7000 + levelTotal)
end
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
 
aight, so I'm doing this
LUA:
w3333 = {
[1] = {ef = 51, sh = 41, dmg = COMBAT_HOLYDAMAGE},
[2] = {ef = 51, sh = 41, dmg = COMBAT_HOLYDAMAGE} -- antes era 41 (bolo)
}
 
function onUseWeapon(cid, var)
local extra = 0
local extra2 = 0
local extra3 = 0
local haha = 0
local target = getCreatureTarget(cid)

if getPlayerStorageValue(cid, 378378) > 0 then -- dano extra com reset
extra = (getPlayerStorageValue(cid, 378378)*23000)
else
extra = 0
end

    if getPlayerLevel(cid) > 50000 then
        extra2 = getPlayerLevel(cid)*2
    else
        extra2 = 1100
    end

function onGetFormulaValues(cid, level, skill, attack, factor)
    local skillTotal, levelTotal = skill + attack, level / 5
    return -(skillTotal * 500 + (levelTotal/2)), -(skillTotal * 600 + (levelTotal/2))
end

extra3 = onGetFormulaValues()
haha = extra+extra2+extra3
min, max = 229000+haha, 299000+haha
target = getCreatureTarget(cid)


if target ~= 0 then
wx3333 = w3333[math.random(1, #w3333)]
doSendDistanceShoot(getThingPos(cid), getThingPos(target), wx3333.sh)
addEvent(doAreaCombatHealth, 100, cid, wx3333.dmg, getThingPos(target), 0, -min, -max, wx3333.ef)
end
return true
end

and receiving this error in the console when trying to attack
Code:
[17:51:18.720] [Error - Weapon Interface]
[17:51:18.725] data/weapons/scripts/cakewand3.lua:onUseWeapon
[17:51:18.728] Description:
[17:51:18.731] data/weapons/scripts/cakewand3.lua:54: attempt to perform arithmetic on local 'skill' (a nil value)
[17:51:18.736] stack traceback:
[17:51:18.739]  data/weapons/scripts/cakewand3.lua:54: in function 'onGetFormulaValues'
[17:51:18.742]  data/weapons/scripts/cakewand3.lua:59: in function <data/weapons/scripts/cakewand3.lua:6>
 
Your first script above, Post how did you add it to weapons.xml
 
XML:
<wand id="7754" range="6" lvl="1" mana="0" enabled="1" exhaustion="0" event="script" value="cakewand3.lua">
        <vocation id="9"/>
        <vocation id="1"/>
        <vocation id="2"/>
        <vocation id="13"/>
        <vocation id="14"/> <vocation id="15"/> <vocation id="16"/> <vocation id="17"/>
        <vocation id="5"/>
        <vocation id="6"/>
        <vocation id="10"/>
        <vocation id="11"/>
        <vocation id="12"/>
    </wand>
 
Add it like this
XML:
    <distance id="7754" lvl="1" mana="0" event="script" value="cakewand3.lua">
        <vocation id="9"/>
        <vocation id="1"/>
        <vocation id="2"/>
        <vocation id="13"/>
        <vocation id="14"/>
        <vocation id="15"/>
        <vocation id="16"/>
        <vocation id="17"/>
        <vocation id="5"/>
        <vocation id="6"/>
        <vocation id="10"/>
        <vocation id="11"/>
        <vocation id="12"/>
    </distance>
and in items.xml add
XML:
<attribute key="range" value="6" />
 
Last edited:
whoa it worked! could the same be done with a sword?
XML:
<sword id="7754" lvl="1" mana="0" event="script" value="cakewand3.lua">
        <vocation id="9"/>
        <vocation id="1"/>
        <vocation id="2"/>
        <vocation id="13"/>
        <vocation id="14"/>
        <vocation id="15"/>
        <vocation id="16"/>
        <vocation id="17"/>
        <vocation id="5"/>
        <vocation id="6"/>
        <vocation id="10"/>
        <vocation id="11"/>
        <vocation id="12"/>
    <sword>

edit: the only part that worked was getting distance skill, the part of dealing extra damage with skills is still not working
Code:
[19:1:45.527] [Error - Weapon Interface]
[19:1:45.529] data/weapons/scripts/bow3.lua:onUseWeapon
[19:1:45.532] Description:
[19:1:45.535] data/weapons/scripts/bow3.lua:53: attempt to perform arithmetic on local 'skill' (a nil value)
[19:1:45.542] stack traceback:
[19:1:45.543]   data/weapons/scripts/bow3.lua:53: in function 'onGetFormulaValues'
[19:1:45.547]   data/weapons/scripts/bow3.lua:56: in function <data/weapons/scripts/bow3.lua:6>

code:
LUA:
w = {
[1] = {ef = 42, sh = 34, dmg = COMBAT_DROWNDAMAGE},
[2] = {ef = 42, sh = 34, dmg = COMBAT_DROWNDAMAGE} -- 43
}
 -- AUMENTANDO DANO COM RESET
function onUseWeapon(cid, var)
local extra = 0
local extra2 = 0
local extra3 = 0
local target = getCreatureTarget(cid)

if getPlayerStorageValue(cid, 378378) > 0 then -- dano extra com reset
extra = (getPlayerStorageValue(cid, 378378)*23000)
else
extra = 0
end

    if getPlayerLevel(cid) > 50000 then
        extra2 = getPlayerLevel(cid)*2
    else
        extra2 = 1100
    end

function onGetFormulaValues(cid, level, skill, attack, factor)
    local skillTotal, levelTotal = skill + attack, level / 5
    return -(skillTotal * 500 + (levelTotal/2)), -(skillTotal * 600 + (levelTotal/2))
end
extra3 = onGetFormulaValues()
min, max = 229000+(extra+extra2+extra3), 299000+(extra+extra2+extra3)
target = getCreatureTarget(cid)

if target ~= 0 then
wx = w[math.random(1, #w)]
doSendDistanceShoot(getThingPos(cid), getThingPos(target), 34)
addEvent(doAreaCombatHealth, 100, cid, COMBAT_DROWNDAMAGE, getThingPos(target), 0, -min, -max, 42)
end
return true
end
 
For melee weapons it should look like this
XML:
    <melee id="7754" lvl="1" mana="0" event="script" value="cakewand3.lua">
        <vocation id="9"/>
        <vocation id="1"/>
        <vocation id="2"/>
        <vocation id="13"/>
        <vocation id="14"/>
        <vocation id="15"/>
        <vocation id="16"/>
        <vocation id="17"/>
        <vocation id="5"/>
        <vocation id="6"/>
        <vocation id="10"/>
        <vocation id="11"/>
        <vocation id="12"/>
    </melee>
But you'll have to add in items.xml
XML:
<attribute key="weaponType" value="sword" />
 
aight will try that with the sword! any idea about the skill thing tho? I edited my previous comment

edit: also, the melee didn't worked, the sword skill isn't going up

edit2: ops nvm, melee did work and the skill is raising, the only problem now is the skill scalling
 
Last edited:
The script above only deals damage from min to max which won't increase by distance or sword.
I think you'll have to use this formula and calculate the same damage which the script above deals by testing in-game to make it increase with distance skills/sword skills.
here is an example
LUA:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 0)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HITBYFIRE)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, 33)

function onGetFormulaValues(cid, level, skill, attack, factor)
    local skillTotal, levelTotal = skill + attack, level / 5
    return -(skillTotal * 0.5 + levelTotal), -(skillTotal * 1.5 + levelTotal)
end
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")


function onUseWeapon(cid, var)
return doCombat(cid, combat, var)
end
 
Solution
if I wanted it to scale with magic level, would use the same
LUA:
function onGetFormulaValues(cid, level, skill, attack, factor)
    local skillTotal, levelTotal = skill + attack, level / 5
    return -(skillTotal * 0.5 + levelTotal), -(skillTotal * 1.5 + levelTotal)
end
os is there a magicSkill or something?
 
You'll have to use this one
LUA:
function onGetFormulaValues(player, level, maglevel)
     min = -((level / 5) + (maglevel * 1.4) + 8)
     max = -((level / 5) + (maglevel * 2.2) + 14)
     return min, max
end
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
 
Back
Top