Sistema de Slots [Tibia 9.10 - Pedido/Ajuda]
Existe um script de slotar equipamento (que não foi feito por mim) através do uso de um item, é uma action, e é este:
---Config
local conf = {
maxSlotCount=2,
ignoredIds={}
}
--End
function choose(...) --- Function by mock.
local arg = {...}
return arg[math.random(1,#arg)]
end
if not getItemAttack then
function getItemAttack(uid)
return getItemAttribute(uid,'attack')
end
function getItemDefense(uid)
return getItemAttribute(uid,'defense')
end
end
local function isArmor(uid) -- Function by Mock the bear.
if (getItemInfo(uid.itemid).armor ~= 0) and (getItemWeaponType(uid.uid) == 0) then
return true
end
return false
end
local function isWeapon(uid) -- Function by Mock the bear.
uid = uid or 0
local f = getItemWeaponType(uid)
if f == 1 or f == 2 or f == 3 then
return true
end
return false
end
local function isShield(uid) -- Function by Mock the bear.
uid = uid or 0
if getItemWeaponType(uid) == 4 then
return true
end
return false
end
local function isBow(uid) -- Function by Mock the bear.
uid = uid or 0
if getItemWeaponType(uid) == 5 and not isItemStackable(uid) then
return true
end
return false
end
function onUse(cid, item, fromPosition, itemEx, toPosition) -- Script by mock the bear (MTB)
if item.uid == 0 or item.itemid == 0 then return false end
toPosition.stackpos = 255
if item.uid == 0 or item.itemid == 0 then return false end
toPosition.stackpos = 255
if isInArray(conf.ignoredIds, itemEx.itemid)
or (not getItemWeaponType(itemEx.uid) or getItemWeaponType(itemEx.uid) > 5)
or (getItemWeaponType(itemEx.uid) == 0 and not isArmor(itemEx))
or itemEx.itemid == 0 or itemEx.type > 1 or isItemStackable(itemEx.uid) then
doPlayerSendCancel(cid, "You cant open a slot on this item.")
return TRUE
end
if isCreature(itemEx.uid) then
return FALSE
end
local nam = getItemName(itemEx.uid)
function getper()
local n = 1
for i=1,10 do
n = n+math.random(0,10)
if n < 8*i then
break
end
end
return n
end
function getSlotCount(nam)
local c = 0
for _ in nam:gmatch('%[(.-)%]') do
c = c+1
end
return c
end
if getSlotCount(nam) < conf.maxSlotCount then
local l = choose('hp','mp','ml','cas','shield','dist')
local p = getper()
doSendMagicEffect(toPosition,30)
nam = nam..' ['..l..'.+'..p..'%]'
doItemSetAttribute(itemEx.uid,'name',nam)
doRemoveItem(item.uid,1)
else
doPlayerSendCancel(cid, "You cant open a slot on this item.")
end
return true
end
Ele funciona assim, quando vc usar o "item de slot" em um equipamento qualquer ele ira ganhar 1 slot, esse slot pode ser de vários tipos, que aumenta hp, mp, ml, cas, shield e dist, aleatóriamente quando você usar o item, e o valor que ira aumentar em % também será aleatório.
Agora o que eu quero é o seguinte:
-Que esse valor que ira aumenta em % seja um aleatório, mas que de para configurar o minímo e o máximo desse valor.
-As chances de o slot vir com hp, mp, ml e os outros seja configurado facilmente, por exemplo:
25% de chance para vir HP / 20% para MP / 15% para ML / 15% para Shield / 15% para Dist / 10% para Cas
-Além de hp, mp, ml, cas, shield e dist, terem outros tipos de slot, como: Fist, Club, Sword, Axe, Resistência de elementos (fire, holy, ...) e EXP.
Acho que isso seria mais como um desafio para alguns, mas sei que pelo menos algo que eu pedi deve dar para fazer né?
O ID do Item é 8300. Há outro item e action também, mas em vez de colocar o slot, tira todos os slots do item, cujo o ID é 8305, talvez precise mudar algo neste script também, então para qualquer coisa estou postando ele também:
---Config
local conf = {
maxSlotCount=2,
ignoredIds={}
}
--End
function choose(...)
local arg = {...}
return arg[math.random(1,#arg)]
end
if not getItemAttack then
function getItemAttack(uid)
return getItemAttribute(uid,'attack')
end
function getItemDefense(uid)
return getItemAttribute(uid,'defense')
end
end
local function isArmor(uid) -- Function by Mock the bear.
if (getItemInfo(uid.itemid).armor ~= 0) and (getItemWeaponType(uid.uid) == 0) then
return true
end
return false
end
local function isWeapon(uid) -- Function by Mock the bear.
uid = uid or 0
local f = getItemWeaponType(uid)
if f == 1 or f == 2 or f == 3 then
return true
end
return false
end
local function isShield(uid) -- Function by Mock the bear.
uid = uid or 0
if getItemWeaponType(uid) == 4 then
return true
end
return false
end
local function isBow(uid) -- Function by Mock the bear.
uid = uid or 0
if getItemWeaponType(uid) == 5 and not isItemStackable(uid) then
return true
end
return false
end
local function getWeaponLevel(uid) -- Function by Mock the bear.
uid = uid or 0
local name = getItemName(uid.uid) or getItemInfo(uid.itemid).name or ''
local lvl = string.match(name,'%s%+(%d+)%s*')
return tonumber(lvl) or 0
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.uid == 0 or item.itemid == 0 then return false end
toPosition.stackpos = 255
if item.uid == 0 or item.itemid == 0 then return false end
toPosition.stackpos = 255
if isInArray(conf.ignoredIds, itemEx.itemid)
or (not getItemWeaponType(itemEx.uid) or getItemWeaponType(itemEx.uid) > 5)
or (getItemWeaponType(itemEx.uid) == 0 and not isArmor(itemEx))
or itemEx.itemid == 0 or itemEx.type > 1 or isItemStackable(itemEx.uid) then
doPlayerSendCancel(cid, "You cant reset this item.")
return TRUE
end
if isCreature(itemEx.uid) then
return FALSE
end
local level = getWeaponLevel(itemEx)
if level > 0 then
upgrade = refine
doSendMagicEffect(toPosition,30)
setItemName(itemEx.uid, getItemNameById(itemEx.itemid)..' +'..(level))
doPlayerSendCancel(cid, "All slots were removed.")
doRemoveItem(item.uid,1)
else
doSendMagicEffect(toPosition,30)
setItemName(itemEx.uid, getItemNameById(itemEx.itemid))
doPlayerSendCancel(cid, "All slots were removed.")
doRemoveItem(item.uid,1)
end
return true
end
Estarei esperando por respostas, se alguém conseguir fazer isso para mim eu agradeço, sou muito novo em scripts, por isso peço ajuda, obrigado! Qualquer dúvida quanto ao que pedi ou falei é só falar!