Hail Xtibianos.
Eu estava/estou atualizando alguns scripts meus bem antigos, então resolvi compartilhar para vocês que priorizam um jogo mais ao estilo: segunda vida na idade média.
Bom... tu terás que fazer uma sala parecida como essa e com esses ids (pois já foram implementados no código).
Agora vamos implementar os códigos:
Vá em data/actions.xml e insira essas tags:
Citar
<action itemid="2422" event="script" value="tools/ferreiro.lua"/>
<action itemid="5468" event="script" value="tools/wood.lua"/>
<action itemid="8670" event="script" value="tools/bellow.lua"/>
<action itemid="8669" event="script" value="tools/bellow.lua"/>
Em data/actions/scripts/tools; insira todos esses códigos cada um com seus respectivos nomes:
ferreiro.lua
--[[> Marcryzius D'evil <]]-- lista_forja = { [2406] = { {5880,2148,2148, result = 2395, fail = 2234}, {5880,5880,5880, result = 2413, fail = 2234}, {5880,2144,5880,2144,5880, result = 7385, fail = 2234} }, [2376] = { {5880, result = 2397, fail = 2234}, }, [2412] = { {2144,2143, result = 2438, fail = 2234}, {5880, 5880, 2149,2149, result = 2419, fail = 2234}, }, [2413] = { {5880,5880,5880,2152, result = 2377, fail = 2234}, }, [2384] = { {5880,5880,7760,5880,7760,7760,7760, result = 2392, fail = 2234}, {5880,5880, 5880, result = 2385, fail = 2234}, }, [2385] = { {5880, 2144, result = 2412, fail = 2234}, }, [2395] = { {2396,2396,2396,2157,2396, result = 2407, fail = 2234}, }, [2383] = { {5880,2145,2145,2145, result = 7449, fail = 2234}, }, [2379] = { {5880, result = 2376, fail = 2234}, {1294,1294,5880, result = 2420, fail = 2234}, {2151,5880,2151,2149, result = 2411, fail = 0}, }, [2420] = { {5880, 5880, result = 2443, fail = 2234}, {5880, 2149,5880,2149, result = 2419, fail = 2234}, }, [2402] = { {5880, result = 2384, fail = 2234}, }, [2403] = { {5880, result = 2406, fail = 0}, {2151,5880,2151, result = 2402, fail = 0}, }, [2404] = { {5880, result = 2395, fail = 2234}, {5880,2143, 2143, result = 2379, fail = 0}, }, -- axes [2380] = { {5901,5901,5901, result = 2381, fail = 2559}, {5880, result = 2386, fail = 2559}, {2144, result = 2388, fail = 2559}, }, [2386] = { {5880, 1294, 5880, 1294, result = 8601, fail = 2559}, {2143, 5880, 5880, 2143, result = 2387, fail = 2559}, {2388,2144, 5880, 2144, result = 2430, fail = 2559}, }, [2416] = { {5880,5880,5901, result = 2422, fail = 2416}, }, [2225] = { -- knife {5880,2151, result = 2403, fail = 0}, {5880,2143, result = 2404, fail = 0}, {5880,2144, result = 2379, fail = 0}, -- axe {5880,5901, result = 2380, fail = 0}, -- hammer {5880,1294, result = 2416, fail = 0}, }, } function skill(cid) -- verifica o skill(ferreiro) do player usando store. return (getPlayerStorageValue(cid,getStoreString('_FERREIRO_SKILL')) < 0) and 0 or getPlayerStorageValue(cid,getStoreString('_FERREIRO_SKILL')) end function formatFerreiroLevel(valor) return math.floor(valor/20) end function getPiece(str) local obj = { itemid = str.itemid, actionid = str.actionid, uid = str.uid, time = 0, quant = 0, count = 0, max_count = getItemInfo(str.itemid) and (getItemInfo(str.itemid).attack == 0 and getItemInfo(str.itemid).defense or getItemInfo(str.itemid).attack) or 5, stack = 0, step = {}, receita = {} } if not(self)then self = setmetatable(obj,self) self.__index = self self.__call = function(self,uid,obj) if uid and not self[uid] then self[uid] = { __index = obj} setmetatable(self[uid], self[uid]) return self[uid] elseif(self[uid])then return self[uid] end end end return self.__call(self,str.actionid == 0 and str.uid or str.actionid,obj) end function onUse(cid, item, fromPosition, itemEx, toPos) local obj = nil local pos_item = {x=toPos.x,y=toPos.y,z=toPos.z,stackpos=1} local get = getThingFromPos(pos_item) local anvil = getThingFromPos({x=toPos.x,y=toPos.y,z=toPos.z,stackpos=2}) -- bigorna if(isCreature(itemEx.uid))then return true elseif not(anvil) or not(anvil.itemid == 2555)then -- bigorna return true,doPlayerSendCancel(cid,"use seu martelo em algum item em cima de uma bigorna.") elseif not(get) or not(isInArray({1,3,4},getItemWeaponType(get.uid)) or get.itemid == 2225) then return true else if(itemEx.actionid == 0)then doItemSetAttribute(itemEx.uid,"aid",itemEx.uid) end obj = getPiece(itemEx) -- pega o item para refinamento. end if(obj.type ~= 4 and obj.time+(obj.count*10) < os.time())then obj.count = 0 doPlayerSendCancel(cid,"Ponha sua arma na fornalha.") elseif((skill(cid)/20)%2 == 0 or (skill(cid)/20)%2 == 1)then doPlayerSendTextMessage(cid,20,"voce avançou para o level "..formatFerreiroLevel(skill(cid)).." na profissao de (Ferreiro).") doSendMagicEffect(toPos,3) else -- Verificações necessarias para adicionar um extraAtaque ou extraDefesa no item. local extra = getItemAttribute(itemEx.uid,'extraattack') or getItemAttribute(itemEx.uid,'extradefense') or 0 local number = math.random(1,obj.max_count+((extra == 0 and 1 or extra)*10)) if(formatFerreiroLevel(skill(cid)) > number) then if(obj.quant >= obj.max_count)then if(obj.stack > 0)then table.insert(obj.step,obj.stack) obj.stack = 1 local result = nil for _, list in pairs(lista_forja[obj.itemid]) do local parar = nil for k,passo in ipairs(obj.step)do result = not(passo == list[k]) and list.fail or nil if(#obj.step == k and not result)then if(#obj.step == #list)then result = list.result end parar = true end end if(parar)then break end end if(result)then obj.stack = 0 if(result == 0)then doRemoveItem(itemEx.uid) else doItemSetAttribute(itemEx.uid,"aid",itemEx.uid) doTransformItem(itemEx.uid, result) end doSendMagicEffect(toPos,5) return end end if(getItemWeaponType(itemEx.uid) == 1 or getItemWeaponType(itemEx.uid) == 3)then doItemSetAttribute(itemEx.uid,"extraattack",extra+1) elseif(getItemWeaponType(itemEx.uid)== 4)then doItemSetAttribute(itemEx.uid,"extradefense",extra+1) end obj.count = 0 obj.quant = 0 doSendMagicEffect(toPos,14) return end obj.quant = obj.quant+1 doSendMagicEffect(toPos,13) doSendMagicEffect(toPos,3) elseif(formatFerreiroLevel(skill(cid)) < math.random(1,20))then doCreatureAddHealth(cid,-5) doPlayerSendCancel(cid,"você se machucou com seu martelo.") doSendMagicEffect(toPos,2) else doSendMagicEffect(toPos,3) end end return true,setPlayerStorageValue(cid,getStoreString('_FERREIRO_SKILL'),skill(cid)+1) end
bellow.lua
local retardo,effe_index,add,_molde = 0, 1,0,nil local lista_forja,list_rec = { -- dicionario de receitas para forjar equipamentos. -- [id do item que será forjado] = {id e quantidade dos items requeridos para fazer tal item} [2463] = {[5880]=3,[2224]=10}, -- P armor [2647] = {[5880]=1,[2224]=7}, -- P legs [2466] = {[9971]=1,[5880]=3,[2224]=10}, -- G armor [2470] = {[9971]=1,[5880]=1,[2224]=1}, -- G legs [2465] = {[2224]=3,[5880]=10}, -- B armor [2478] = {[2224]=1,[5880]=7}, -- B legs },{} local function passEffect(pos,...) local effe = {...} doSendMagicEffect(pos,effe[effe_index] or 15) effe_index = effe_index+1 return coroutine.yield() end local crucible_bellow = function(pos,...) local a = {passEffect(pos,...)} local b = {passEffect(unpack(a))} local c = {passEffect(unpack(b))} passEffect(unpack(c)) effe_index = 1 return end function molde(crucible) local troca,dropar,tipo,verificacao = { {lava =8673, aceso = 8649, apagado = 8653}, {aceso = 8645, apagado = 8646, molde_armor = 8682, molde_legs = 8679}, {aceso = 8643, apagado = 8647, molde_armor = 8683, molde_legs = 8678}, },nil,0,{} add = 0 -- resete necessario para não interferir no sistema de refino for drop, receita in pairs(lista_forja) do -- dicionario de receitas local cc = 1 for item,quant in pairs(list_rec) do -- o que foi adicionado ao crucible if(receita[item] and receita[item] == quant)then if(cc == table.len(list_rec))then list_rec = {} dropar,tipo = drop,getItemSlotType(drop) end cc = cc+1 else break end end end for y, ta in pairs(troca) do local get = assert(getThingFromPos({x=crucible.pos.x+1, y=crucible.pos.y+(y-1),z=crucible.pos.z,stackpos=1})) local get2 = assert(getThingFromPos({x=crucible.pos.x+1, y=crucible.pos.y+(y-1),z=crucible.pos.z,stackpos=2})) if(dropar)then if(y > 1)then local pos = {x=crucible.pos.x+1, y=crucible.pos.y+(y-1),z=crucible.pos.z,stackpos=1} doTransformItem(getThingFromPos({x=crucible.pos.x, y=crucible.pos.y,z=crucible.pos.z,stackpos=1}).uid,8642) addEvent(doCreateItem, 10*1000, dropar,1, {x=crucible.pos.x+1, y=crucible.pos.y+2,z=crucible.pos.z,stackpos=1}) addEvent(molde, 10*1000, crucible) dropar = nil end end if(get)then doTransformItem(get.uid,(get.itemid == ta.apagado and ta.aceso or ta.apagado)) end if(get2 and get2.itemid == 8673)then doRemoveItem(getThingFromPos({x=crucible.pos.x+1, y=crucible.pos.y,z=crucible.pos.z,stackpos=2}).uid) elseif(ta.lava)then doCreateItem(ta.lava, 1, {x=crucible.pos.x+1, y=crucible.pos.y,z=crucible.pos.z,stackpos=1}) end end return true end function onUse(cid, item, fpos, itemEx, toPos) local crucible,mesa = nil,fpos for X = -1,1 do for Y = -1,1 do local npos = {x=X+fpos.x,y=Y+fpos.y,z=fpos.z,stackpos=1} local weapon = {x=X+fpos.x,y=Y+fpos.y,z=fpos.z,stackpos=2} local get = assert(getThingFromPos(npos)) if(get and get.itemid == 8641 or get.itemid == 8642)then crucible = getPiece(get) if(get.actionid == 0)then doItemSetAttribute(get.uid,"aid",get.uid) end if(item.itemid == 8641)then return true,molde(crucible) end if not(crucible.pos)then crucible.pos = npos end if not(crucible.co)then crucible.co = coroutine.create(crucible_bellow) end elseif(get and get.itemid == 10967)then local get = assert(getThingFromPos(weapon)) if not(isInArray({1,3,4},getItemWeaponType(get.uid)) or get.itemid == 2225)then if(get.itemid ~= 10967)then local obj = getPiece(get) if(obj.itemid > 0 and get.actionid == 0)then doItemSetAttribute(get.uid,"aid",get.uid) end if(obj.count <= 3)then obj.count = obj.count+1 else add = obj.itemid if(obj.itemid > 0 )then list_rec[obj.itemid] = (list_rec[obj.itemid] or 0) + (get.type == 0 and 1 or get.type) end doRemoveItem(get.uid) doSendMagicEffect(weapon,5) end end end mesa = weapon end end end local peg = getThingFromPos(mesa) local attack_item = 5 if(peg and getItemInfo(peg.itemid))then attack_item = getItemInfo(peg.itemid).attack < 5 and 5 or getItemInfo(peg.itemid).attack end if(crucible and retardo <= os.time())then retardo = os.time()+1 -- intervalo de uso em segundo's. if(crucible.itemid == 8642 and crucible.actionid > 0)then local co = coroutine.resume(crucible.co,crucible.pos,6,15,36) if not(co)then local item_pos = getThingFromPos(crucible.pos) crucible.co = coroutine.create(crucible_bellow) doSendMagicEffect(fpos,2) crucible.itemid = 8641 doTransformItem(item_pos.uid,8641) if(crucible.count > math.random(3,5))then doItemSetAttribute(item_pos.uid,"aid",0); crucible.actionid = 0 end addEvent(function(obj) local item_pos = getThingFromPos(obj.pos) obj.count = obj.count+1 obj.itemid = 8642 doSendMagicEffect(obj.pos,CONST_ME_POFF) doTransformItem(item_pos.uid,8642) end,60000*math.random(4,5),crucible) end elseif(crucible.itemid == 8641 and type(mesa) == 'table' and math.random(1,attack_item*3) <= skill(cid))then local get_weapon = getThingFromPos(mesa) if not(get_weapon) or get_weapon.itemid == 0 then return true end local obj = getPiece(get_weapon) if(get_weapon.actionid == 0)then doItemSetAttribute(get_weapon.uid,"aid",get_weapon.uid) end obj.time = os.time() obj.stack = obj.stack > 1 and obj.stack or add add = 0 if(obj.count > attack_item)then crucible.step[get_weapon.itemid] = get_weapon.type doRemoveItem(get_weapon.uid) doSendMagicEffect(crucible.pos,5) return else obj.count = obj.count+1 end else doSendMagicEffect(crucible.pos,2) return true end doSendMagicEffect(mesa or crucible.pos,15) doSendMagicEffect(crucible.pos,5) doSendMagicEffect(fpos,67) end return true end
wood:
--[[> Marcryzius D'evil <]]-- function onUse(cid, item, fPos, itemEx, toPos) local number = math.random(1,10) if(itemEx.itemid == 8642)then if (skill(cid)/20 >= number)then doRemoveItem(item.uid, 1) doTransformItem(itemEx.uid,8641) doItemSetAttribute(itemEx.uid,"aid",itemEx.uid) doSendMagicEffect(toPos,6) doSendMagicEffect(toPos,15) doSendMagicEffect(toPos,36) addEvent(function(pos) local item_pos = getThingFromPos(pos) doSendMagicEffect(pos,2) doTransformItem(item_pos.uid,8642) end,60000*math.random(5,6),toPos) else if(math.random(1,10) == 1)then doCreatureSay(cid,"Aaaai!",1) doCreatureAddHealth(cid,-5) doSendMagicEffect(getCreaturePosition(cid),15) doPlayerSendCancel(cid,"você se queimou.") else doSendMagicEffect(toPos,2) doSendMagicEffect(toPos,5) end end setPlayerStorageValue(cid,getStoreString('_FERREIRO_SKILL'),skill(cid)+1) -- cana de açucar elseif(itemEx.itemid == 5471)then if(math.random(1,10) == 10)then doRemoveItem(item.uid) end doTransformItem(itemEx.uid,5465) doDecayItem(itemEx.uid) else doPlayerSendTextMessage(cid,20,"use o fogo na fornalha ou no canavial.") end return true end
Pronto. Instalados os scripts; agora irei explicar como funciona o sistema.
Para acender o crucible, você precisa usar o fire bug (5468) no crucible (8642) até ele acender.
Agora você põe a arma em cima da bancada e clica no bellow para ele 'aquecer' a arma para forja.
Depois de 'esquentar' a arma, voce forja ela no anvil (bigorna de id 2555) por um tempo (tempo esse determinado pelo uso do crucible).
Se o crucible 'apagar', voce clica no bellow até ele voltar a 'acender', mas isso só pode ser feito algumas vezes.
Se você clicar muitas vezes e ele não 'acender', então tu terás que usar o fire bug de novo no crucible.
Novo sistema de forja adicionado.
Agora tu poderás adicionar materiais a forja para obter outros items.
Explicação desse novo sistema:
Primeiro tu põe a arma base para adição de novos compostos na mesa.
adicione o item em cima da arma.
Clique no bellow e o item de adição desaparecera.
Leve o item "aquecido" para a bigorna.
Use a marreta nele até sair um efeito verde.
Caso ele peça para por de volta na fornalha a arma, não adicione outro item, apenas aqueça-o.
Faça esse mesmo procedimento adicionando compostos até que o item seja criado.
aqui um manual de forja feito a parti da tabela forja no script ferreiro.lua
Manual de forja para iniciantes.
>[silver dagger + iron ore > rapier]
>[combat knife + iron ore > carlin sword]
>[combat knife + iron ore + white pearl + white pearl > dagger]
>[short sword + iron ore + gold coin + gold coin > carlin sword]
>[short sword + iron ore + iron ore + iron ore > broadsword]
>[short sword + iron ore + black pearl + iron ore + black pearl + iron ore > crimson sword]
>[dagger + iron ore > sword]
>[dagger + small stone + small stone + iron ore > machete]
>[dagger + talon + iron ore + talon + small emerald > poison dagger]
>[katana + black pearl + white pearl > epee]
>[katana + iron ore + iron ore + small emerald + small emerald > scimitar]
>[spike sword + iron ore + small diamond + small diamond + small diamond > crystal sword]
>[sabre + iron ore + black pearl > katana]
>[machete + iron ore + iron ore > ravager's axe]
>[machete + iron ore + small emerald + iron ore + small emerald > scimitar]
>[carlin sword + ice rapier + ice rapier + ice rapier + gold nugget + ice rapier > bright sword]
>[knife + iron ore > short sword]
>[knife + talon + iron ore + talon > silver dagger]
>[sword + iron ore > longsword]
>[hand axe + wood + wood + wood > halberd]
>[hand axe + iron ore > axe]
>[hand axe + black pearl > hatchet]
>[broadsword + iron ore + iron ore + iron ore + platinum coin > two handed sword]
>[rapier + iron ore + iron ore + enchanted small ruby + iron ore + enchanted small ruby + enchanted small ruby + enchanted small ruby > fire sword]
>[rapier + iron ore + iron ore + iron ore > sabre]
>[axe + iron ore + small stone + iron ore + small stone > steel axe]
>[axe + white pearl + iron ore + iron ore + white pearl > double axe]
>[axe + hatchet + black pearl + iron ore + black pearl > knight axe]
>[piece of iron + iron ore + talon > knife]
>[piece of iron + iron ore + white pearl > combat knife]
>[piece of iron + iron ore + black pearl > dagger]
>[piece of iron + iron ore + wood > hand axe]
>[piece of iron + iron ore + small stone > crowbar]
>[crowbar + iron ore + iron ore + wood > iron hammer]
Tu poderás adicionar mais compostos para obter outros items a seu critério.
Nova atualização!
Agora a sala de forja ficou assim:
Agora é possível forjar/fundir items:
Adicione os compostos necessário para forja um por um (desde que ele não seja agrupaveis) na bancada do crucible e clique no bellow até ele sumir. adicione todos os items necessários e ao final clique no crucible:
Resultado ao clicar no crucible com os compostos:
Resultado da forja com os compostos:
Onde edito ou ponho novos compostos no script?
No script bellow.lua existe a lista de compostos e suas respectivas forjas. É só copiar uma nova instrução e editar os valores para novos items que possam ser forjados.
ATENÇÃO! Todos os compostos precisam ser exatos para a receita funcionar, nem mais nem menos.
{
-- dicionario de receitas para forjar equipamentos.
-- [id do item que será forjado] = {id e quantidade dos items requeridos para fazer tal item}
[2463] = {[5880]=3,[2224]=10}, -- P armor
[2647] = {[5880]=1,[2224]=7}, -- P legs
[2466] = {[9971]=1,[5880]=3,[2224]=10}, -- G armor
[2470] = {[9971]=1,[5880]=1,[2224]=1}, -- G legs
[2465] = {[2224]=3,[5880]=10}, -- B armor
[2478] = {[2224]=1,[5880]=7}, -- B legs
},{}
Função requerida:
function getStoreString(str) --[[( Marcryzius )]]-- --Essa função converte a 'string' em numeros e devolve a soma de todos os numeros. local store = 0 if(type(str) == 'string')then for pos = 1,#str do store = store+str:sub(pos,pos):byte() end elseif(type(str) == 'number')then return str else print('function getStoreString adverte: tipo de parametro invalido. ('..type(str)..')') end return store end
É isso pessoal, depois posto mais scripts atualizados meu; espero que gostem; qualquer erro ou dúvida deixem no comentário abaixo.
Um vídeo explicando como fazer objetos de fundição: