--Item Upgrading released by granaria.hopto.org for TFS 0.3.6
--Another guy made this script(TFS 0.3.5), I don't know who it was. I'll not take credit for this script whatsoever.
local config = {
brokeChance = 5,
upgradePercent = 8,
maxUpgrade = 50,
notAllowed = {}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local getUpgraded = itemEx.actionid - 10000
if getUpgraded < 0 then
getUpgraded = 0
end
if getUpgraded < config.maxUpgrade then
if itemEx.itemid > 100 then
if isItemMoveable(itemEx.itemid) and not isItemRune(itemEx.itemid) and not isCorpse(itemEx.uid) and not isContainer(itemEx.uid)and not isItemStackable(itemEx.itemid) and not isItemFluidContainer(itemEx.itemid) and not isInArray(config.notAllowed, itemEx.itemid) then
if config.brokeChance <= math.random(100) then
doItemSetAttribute(itemEx.uid, "name", getItemNameById(itemEx.itemid) .. "+" .. (getUpgraded+1))
doItemSetAttribute(itemEx.uid, "actionid", 10000+(getUpgraded+1))
doSendMagicEffect(toPosition, 30)
doPlayerSendTextMessage(cid, 22, "You successfuly upgraded " .. getItemNameById(itemEx.itemid) .. " to " .. (getUpgraded+1) .. " level.")
if getItemAttribute(itemEx.uid, "attack") and getItemAttribute(itemEx.uid, "attack") > 0 then
doItemSetAttribute(itemEx.uid, "attack", (getItemAttribute(itemEx.uid, "attack")+((getItemAttribute(itemEx.uid, "attack")/100)*config.upgradePercent))+1)
end
if getItemAttribute(itemEx.uid, "extraattack") and getItemAttribute(itemEx.uid, "extraattack") > 0 then
doItemSetAttribute(itemEx.uid, "extraattack", (getExtraItemAttack(itemEx.uid)+((getExtraItemAttack(itemEx.uid)/100)*config.upgradePercent))+1)
end
if getItemAttribute(itemEx.uid, "defense") and getItemAttribute(itemEx.uid, "defense") > 0 then
doItemSetAttribute(itemEx.uid, "defense", (itemEx.uid), (getItemAttribute(itemEx.uid, "defense")+((getItemAttribute(itemEx.uid, "defense")/100)*config.upgradePercent))+1)
end
if getItemAttribute(itemEx.uid, "extradefense") and getItemAttribute(itemEx.uid, "extradefense") > 0 then
doItemSetAttribute(itemEx.uid, "extradefense", (itemEx.uid), (getItemAttribute(itemEx.uid, "extradefense")+((getItemAttribute(itemEx.uid, "extradefense")/100)*config.upgradePercent))+1)
end
if getItemAttribute(itemEx.uid, "armor") and getItemAttribute(itemEx.uid, "armor") > 0 then
doItemSetAttribute(itemEx.uid, "armor", (itemEx.uid), (getItemAttribute(itemEx.uid, "armor")+((getItemAttribute(itemEx.uid, "armor")/100)*config.upgradePercent))+1)
end
if getItemAttribute(itemEx.uid, "attackspeed") and getItemAttribute(itemEx.uid, "attackspeed") > 0 then
doItemSetAttribute(itemEx.uid, "attackspeed", (itemEx.uid), (getItemAttribute(itemEx.uid, "attackspeed")+((getItemAttribute(itemEx.uid, "attackspeed")/100)*config.upgradePercent))+1)
end
if getItemAttribute(itemEx.uid, "hitchance") and getItemAttribute(itemEx.uid, "hitchance") > 0 then
doItemSetAttribute(itemEx.uid, "hitchance", (itemEx.uid), (getItemAttribute(itemEx.uid, "hitchance")+((getItemAttribute(itemEx.uid, "hitchance")/100)*config.upgradePercent))+1)
end
else
doPlayerSendTextMessage(cid, 22, getItemNameById(itemEx.itemid).." upgrading to level " .. (getUpgraded+1) .. " fail! You lose item!")
doRemoveItem(itemEx.uid, 1)
doSendMagicEffect(toPosition, 34)
end
doRemoveItem(item.uid, 1)
else
doPlayerSendCancel(cid, "You cannot upgrade this item!")
end
end
else
doPlayerSendCancel(cid, "This item is already upgraded to maximum item level.")
end
return true
end