Esse script é um simples sistema de alquimia, porém é diferente dos outros. Alquimia era uma prática antiga que combinava alguns elementos a fim de formar outros. Esse meu sistema, faz com que os itens sejam "misturados" em um caldeirão e se pareça mais como era antigamente. Abaixo, um vídeo de demonstração e de como instalar. Deixei as mesmas posições no script pra que vocês possam se basear ao instalar no seu. Bom, vamos ao script:
-- Como funciona: O player deve colocar os itens da receita emcima do counter (balcão de pedra) e puxar a alavanca. Feito isso, os itens serão "misturados" no caldeirão e com a colher (wooden spoon) o player poderá pegar o seu item.
Crie um arquivo.xml em data/mods chamado Alchemist.xml e cole isto dentro:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Alchemist System" version="1.0" author="Leoxtibia" contact="none" enabled="yes">
<config name="alch_sys"><![CDATA[
counter = {x = 17, y = 56, z = 7}
efeitos = {x=17, y=53, z=7}
receitas = {
{items = {{2160,1}, {2157,2}} , itemgain = {{5878,100}}, storage = 56000},
{items = {{2148,5}, {2155,1}} , itemgain = {{2113,1}}, storage = 56001},
{items = {{2498,1}, {2113,1}} , itemgain = {{2472,1}}, storage = 56002}
}
function Caldeiron()
local B = {
{3693,{x=17, y=53, z=7, stackpos = 1}},
{3694,{x=18, y=53, z=7, stackpos = 1}}
}
for i = 1, #B do
doTransformItem(getThingfromPos(B[i][2]).uid,getTileItemById(B[i][2], B[i][1]).uid == 0 and B[i][1] or (B[i][1]-4))
end
end
function getItemsInPos(items, pos)
for i = 1,#items do
local stack = getTileItemById(pos, items[i][1])
if stack.uid > 0 and math.max(1, stack.type) >= items[i][2] and i == #items then
return true
end
end
return false
end
function doRemoveItensInPos(items, pos)
local items = type(items) == "table" and items or {items}
for i = 1, table.maxn(items) do
doRemoveItem(getThingFromPos({x=pos.x,y=pos.y,z=pos.z,stackpos=2}).uid)
end
return nil
end
function effets(position,delay)
local text = {"Ishhh!", "Kaboom", "Tic Tac", "BUM!", "Blop Blop!", "Cronch!"}
local effects = {2, 6, 25, 31, 36,40, 54, 51, 65, 66, 67, 68}
if delay ~= 0 then
doSendAnimatedText(position, text[math.random(1, #text)], math.random(1, 255))
doSendMagicEffect(position, effects[math.random(1, #effects)])
addEvent(effets, 1000, position, delay -1)
end
end]]></config>
<action actionid="4780" event="script"><![CDATA[
domodlib('alch_sys')
function onUse(cid, item, fromPosition, itemEx, toPosition)
doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
for _, t in ipairs(receitas) do
if getItemsInPos(t.items, counter) then
doRemoveItensInPos(t.items, counter)
effets(efeitos,6)
Caldeiron()
return setPlayerStorageValue(cid, t.storage, 1)
end
end
return doPlayerSendCancel(cid, "You must put the correct items in the counter.")
end]]></action>
<action itemid="2567" event="script"><![CDATA[
domodlib('alch_sys')
function onUse(cid, item, fromPosition, itemEx, toPosition)
if itemEx.actionid == 4781 then
for _, x in ipairs(receitas) do
if getPlayerStorageValue(cid, x.storage) >= 0 then
for i=1,#x.itemgain do
doPlayerAddItem(cid, x.itemgain[i][1], x.itemgain[i][2])
doPlayerPopupFYI(cid, "You have prepared ".. x.itemgain[i][2] .." ".. getItemNameById(x.itemgain[i][1]) ..".")
end
Caldeiron()
setPlayerStorageValue(cid, x.storage, -1)
end
end
end
return true
end]]></action>
</mod>
Configuração:
Para adicionar mais receitas, é só adicionar mais uma linha, mudando o storage para +1. Lembrando que a última linha não tem vírgula no final.
{items = {{2666,1}, {2671,1}} , itemgain = {{2672,1}}, storage = 56003}
Ainda pretendo incrementar o sistema com novas funções. Mas, por hoje é isso. Espero que tenham gostado.