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

Lua TFS 1.2 Item Attributes

Glovacky

New Member
Joined
Jun 22, 2013
Messages
8
Reaction score
0
Hi. I want to make item upgrade system with more options than just modifying attack, defense, range, hitchance. Is there any way to make action script that increases attack speed, adds elemental damage, health/ mana regen, particular skill, walking speed?
I dont think its possible with attributes. I know I can change max mana and health by conditions but that's it...
Any way to do that just by .lua scripts? Im not asking for solution, just a hint would be great.
 
You can do this via, Weapons/scripts.. example =

item.lua
item id = 2400
You see a magic sword. (atk: 50, def: 30)
Description =
Critical: 20% +
Fire Famage 20% +

function onUseWeapon(player, variant)
local item = player:getSlotItem(CONST_SLOT_LEFT):getId()
local roll = math.random(1,100)
local percent = 10

if item == 2400 and roll <= percent then ----------------CRITICAL + 20%

return combat2:execute(player, variant)

elseif item == 2400 and roll >= percent then ---------------- fire damage + 20%

return combat:execute(player, variant)

end

the combats =

Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)

function onGetFormulaValues(player, skill, attack, factor)
    local min = 110
    local max = 220
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_EXPLOSIONAREA)
combat2:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_WEAPONTYPE)

function onGetFormulaValues(player, skill, attack, factor)
    local min = 115 + 17
    local max = 353 + 62
    return -min, -max
end

combat2:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
 
in an action script you can add descriptions do the item, for example:
Code:
item:setAttribute('description', 'Speed: +26%')
then you can cut the numbers out and tonumber() them with tonumber(string.match(str, '(%d+)'))
that will be the value of the Speed description, you can use this inside of onEquip and use this to add speed:
Code:
player:changeSpeed(player:getSpeed() + player:getSpeed() * (tonumber(string.match(str, '(%d+)'))) * 0.1)
then with onDeEquip:
Code:
player:changeSpeed(player:getSpeed() - player:getSpeed() * (tonumber(string.match(str, '(%d+)'))) * 0.1)
 
Last edited:
Thanks Xeraphus, very good idea. I will surely use it. What about increasing mana regen or other attributes?
You can do this via, Weapons/scripts.. example =

item.lua
item id = 2400
You see a magic sword. (atk: 50, def: 30)
Description =
Critical: 20% +
Fire Famage 20% +

function onUseWeapon(player, variant)
local item = player:getSlotItem(CONST_SLOT_LEFT):getId()
local roll = math.random(1,100)
local percent = 10

if item == 2400 and roll <= percent then ----------------CRITICAL + 20%

return combat2:execute(player, variant)

elseif item == 2400 and roll >= percent then ---------------- fire damage + 20%

return combat:execute(player, variant)

end

the combats =

Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)

function onGetFormulaValues(player, skill, attack, factor)
    local min = 110
    local max = 220
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_EXPLOSIONAREA)
combat2:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_WEAPONTYPE)

function onGetFormulaValues(player, skill, attack, factor)
    local min = 115 + 17
    local max = 353 + 62
    return -min, -max
end

combat2:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

Can I somehow assign that parameters to item by action script? I would like to have a specific item (usable on target) that will make any meele weapon have for instance additional fire damage.
How can this be done?
 
Back
Top