- Joined
- Feb 14, 2015
- Messages
- 5,643
- Solutions
- 559
- Reaction score
- 3,955
This is a simple script that is able to support multiple upgrader itemids without having to make a script for every single id.
edit: updated for tfs 1.2
Basic layout for each upgrader id
If you need help editing it, post here. (though it's self explanatory)
11/4/16 - updated 1.2 script (shortened script and made it more readable)
11/4/16 - updated 1.2 script again (bugfixes)
edit: updated for tfs 1.2
Basic layout for each upgrader id
Code:
[UpgraderID] = {tier = x, upgraderType = 'str', chance = y,
items = {
[StartID] = NewID
}
}
If you need help editing it, post here. (though it's self explanatory)
Code:
local cfg = {
upgrade = {
message = 'Upgrade!',
color = TEXTCOLOR_YELLOW,
effect = CONST_ME_FIREWORK_RED
},
fail = {
message = 'Upgrade Failed.',
talkType = TALKTYPE_MONSTER,
effect = CONST_ME_POFF
}
}
local gear = {
[2087] = {tier = 1, upgraderType = 'key', chance = 30,
items = {
[2505] = 2492,
[2160] = 2148
}
},
[2088] = {tier = 2, upgraderType = 'key', chance = 80,
items = {
[2148] = 2160
}
}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local tmp = gear[item.itemid]
local upgradeid = tmp and tmp.items[itemEx.itemid]
local name = (itemEx.uid == 0) and 'this' or (itemEx.type > 1) and getItemPluralName(itemEx.uid) or (getItemArticle(itemEx.uid) ~= '') and (''.. getItemArticle(itemEx.uid) .. ' ' .. getItemName(itemEx.uid)) or getItemName(itemEx.uid)
if upgradeid then
if itemEx.type <= 1 then
if math.random(100) <= tmp.chance then
doSendMagicEffect(toPosition, cfg.upgrade.effect)
doSendAnimatedText(toPosition, cfg.upgrade.message, cfg.upgrade.color)
doTransformItem(itemEx.uid, upgradeid)
else
doCreatureSay(cid, cfg.fail.message, cfg.fail.talkType)
doSendMagicEffect(toPosition, cfg.fail.effect)
end
doRemoveItem(item.uid, 1)
else
doPlayerSendCancel(cid, 'You may only upgrade '.. name ..' 1 at a time.')
doSendMagicEffect(toPosition, CONST_ME_POFF)
end
else
doPlayerSendCancel(cid, 'You are unable to upgrade '.. name ..' with a tier '.. tmp.tier .. ' '.. tmp.upgraderType ..'.')
doSendMagicEffect(toPosition, CONST_ME_POFF)
end
return true
end
Code:
local cfg = {
upgrade = {
message = 'Upgrade!',
talkType = TALKTYPE_MONSTER_SAY,
effect = CONST_ME_FIREWORK_RED
},
fail = {
message = 'Upgrade Failed.',
talkType = TALKTYPE_MONSTER_SAY,
effect = CONST_ME_POFF
}
}
local gear = {
[2087] = {tier = 1, upgraderType = 'key', chance = 30,
items = {
[2505] = 2492,
[2160] = 2148
}
},
[2088] = {tier = 2, upgraderType = 'key', chance = 80,
items = {
[2148] = 2160
}
}
}
local function shit(v, cfgu, cfgf, upgid)
if v then
return cfgu.message, cfgu.talkType, cfgu.effect, upgid
else
return cfgf.message, cfgf.talkType, cfgf.effect, 0
end
end
local cfgu, cfgf = cfg.upgrade, cfg.fail
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if player == target then
return true
end
local pos = (toPosition.x == 65535) and player:getPosition() or toPosition
local tmp = gear[item.itemid]
local upgid = tmp and tmp.items[target.itemid]
local name = (target.type > 1) and target:getPluralName() or (target:getArticle() ~= '') and (string.format('%s %s', target:getArticle(), target:getName())) or target:getName()
local v = (math.random(100) <= tmp.chance)
if not upgid then
player:sendCancelMessage(string.format('You are unable to upgrade %s with a tier %d %s.', (name == '') and 'this' or name, tmp.tier, tmp.upgraderType))
pos:sendMagicEffect(CONST_ME_POFF)
return true
end
if target.type > 1 then
player:sendCancelMessage(string.format('You may only upgrade %s 1 at a time.', name))
pos:sendMagicEffect(CONST_ME_POFF)
return true
end
local message, talktype, effect, trans = shit(v, cfgu, cfgf, upgid)
pos:sendMagicEffect(effect)
player:say(message, talktype)
target:transform(trans)
item:remove(1)
return true
end
11/4/16 - updated 1.2 script (shortened script and made it more readable)
11/4/16 - updated 1.2 script again (bugfixes)
Last edited: