Visitante Postado Janeiro 5, 2013 Share Postado Janeiro 5, 2013 Vou postar alguns scripts meus que estiveram engavetados. Faz algum tempo que fiz estes scripts, então não vou postar screenshots ou como configurar, mas as configurações são fáceis de entender, então divirtam-se. Esse é o remake de um dos meus melhores scripts, muito melhor que a primeira versão. Foi meu segundo script pra open tibia feito usando orientação a objetos (ao menos ao jeito OO de Lua). Quem já jogou Diablo 2 vai entender do que se trata. Esse sistema consiste em vários "teleports", chamados de "warps", espalhados no seu mapa, aonde você quiser. Cada warp tem uma identificação, por exemplo "dark cave" ou "venore". Todos os warps são interligados, o que significa que o player pode ir de um warp à outro, desde que esteja pisando em cima de um warp. Porém, ele só pode ir para outro lugar caso tenha ativado o warp desse lugar antes: Se um player nunca esteve na "dark cave" ou não ativou o warp de lá, ele não pode usar um outro warp para ir para lá. Para ativar um warp, o player deve dar "use" no warp ou pisar em cima dele. Para ver a lista de warps ativados e as restrições de cada warp, o player deve dar "use" no warp. Para ir de um warp para outro, o player deve satisfazer as condições de level ou mana do warp de destino e ter ativado o warp de destino antes. Além disso, deve saber a identificação do outro warp (que pode descobrir dando "use" em algum warp) e estar pisando em cima de algum warp, e então dizer "warp identificação do destino". Por exemplo, se eu estou em venore e quero ir para a dark cave, e já ativei o warp de lá antes, basta pisar em cima do warp de venore e dizer "warp dark cave". Você pode usar o item que quiser como sendo um warp. Eu usava o item de ID 9742, mas parece que ele é moveable. Apenas tenha certeza de alterar o ID do item no actions.xml e no movements.xml. Para criar um novo warp, coloque o item no mapa e abra o arquivo /data/lib/warpgate.lua, e vá até o final dele. Existem três warps de exemplo já adicionados. Apague-os e, para criar um novo, use o seguinte comando: warp:new(1000, "Gate 1", {x=1, y=1, z=7}, 10, 20) Onde o 1000 é a StorageID do warp, "Gate 1" é a identificação do warp, {x=1, y=1, z=7} é a posição do warp, 10 é a mana necessária e 20 é o level necessário. A mana e o level podem ser omitidos. Por exemplo, para configurar a dark cave com StorageID 5000: warp:new(5000, "Dark Cave", {x=100, y=120, z=8}) Agora, ao script: /data/lib/warpgate.lua -- This script is part of Warp Gate System -- Copyright (C) 2011 Skyen Hasus -- -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. warp = { config = { statusInactive = -1, statusActive = 1, talkType = TALKTYPE_ORANGE_1, warpEffect = CONST_ME_MAGIC_GREEN, stepIn = CONST_ME_MAGIC_BLUE, stepOut = CONST_ME_POFF, listPrefix = " ", listHeadline = "You can warp to:", noWarp = "You must stand above a warp gate.", noDestiny = "The gate you want to warp doesn't exist.", noMana = "You can't support the mana consumed by the gate you want to warp.", noLevel = "You can't support the level required by the gate you want to warp.", inDestiny = "You can't warp the gate that you are standing.", notActive = "You must find and activate your destiny's gate before warp it.", inFight = "You cannot warp a gate while you are in battle.", }, name = "", pos = { x = nil, y = nil, z = nil, }, mana = 0, level = 0, gates = {}, } function warp:new(id, name, pos, mana, level) if self:getWarpById(id) then return self:getWarpById(id) end local object = {id=id or #warp.gates+1, name=name, pos=pos, mana=mana, level=level} local index = {} setmetatable(object, {__index = self}) warp.gates[id] = {} setmetatable(warp.gates[id], {__index = object}) return object end function warp:getList() return self.gates end function warp:getWarpById(id) return self.gates[id] end function warp:getWarpByName(name) for index, warp in pairs(self.gates) do if warp.name:lower() == name:lower() then return warp end end return false end function warp:getWarpByPosition(pos) for index, warp in pairs(self.gates) do if warp.pos.x == pos.x and warp.pos.y == pos.y and warp.pos.z == pos.z then return warp end end return false end function warp:isActive(cid) if getPlayerStorageValue(cid, self.id) == self.config.statusActive then return true end return false end function warp:activate(cid) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "The Warp Gate is now active!") doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE) return setPlayerStorageValue(cid, self.id, self.config.statusActive) end function warp:deactivate(cid) return setPlayerStorageValue(cid, self.id, self.config.statusInactive) end warp:new(1000, "Gate 1", {x=1, y=1, z=7}) warp:new(2000, "Gate 2", {x=2, y=2, z=7}) warp:new(3000, "Gate 3", {x=3, y=3, z=7}) /data/actions/scripts/warpgate.lua -- This script is part of Warp Gate System -- Copyright (C) 2011 Skyen Hasus -- -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. function onUse(cid, item, frompos, itemEx, pos) local usedwarp = warp:getWarpByPosition(pos) if not usedwarp then return false end if not usedwarp:isActive(cid) then usedwarp:activate(cid) return true end local text, names = warp.config.listHeadline .. "\n", {} for index, gate in pairs(warp:getList()) do if gate:isActive(cid) then table.insert(names, gate.name) end end table.sort(names) for index, value in pairs(names) do text = text .. "\n" .. warp.config.listPrefix .. value if warp:getWarpByName(value).mana > 0 then text = text .. " [MP: " .. warp:getWarpByName(value).mana .. "]" end if warp:getWarpByName(value).level > 0 then text = text .. " [Lv: " .. warp:getWarpByName(value).level .. "]" end end doShowTextDialog(cid, item.itemid, text) return true end /data/actions/actions.xml <!-- Warp Gate System --> <action itemid="9742" script="warpgate.lua"/> /data/movements/scripts/warpgate.lua -- This script is part of Warp Gate System -- Copyright (C) 2011 Skyen Hasus -- -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. function onStepIn(cid, item, pos) local usedwarp = warp:getWarpByPosition(pos) if usedwarp then if not usedwarp:isActive(cid) then usedwarp:activate(cid) return true end doSendMagicEffect(pos, warp.config.stepIn) end return true end function onStepOut(cid, item, pos) if warp:getWarpByPosition(pos) then doSendMagicEffect(pos, warp.config.stepOut) end return true end /data/movements/movements.xml <!-- Warp Gate System --> <movevent type="StepIn" itemid="9742" script="warpgate.lua"/> <movevent type="StepOut" itemid="9742" script="warpgate.lua"/> /data/talkactions/scripts/warpgate.lua -- This script is part of Warp Gate System -- Copyright (C) 2011 Skyen Hasus -- -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. function onSay(cid, words, param) local pos = getCreaturePosition(cid) local usedwarp = warp:getWarpByPosition(pos) local destwarp = warp:getWarpByName(param) if not usedwarp then doPlayerSendCancel(cid, warp.config.noWarp) doSendMagicEffect(pos, CONST_ME_POFF) return true end if not destwarp then doPlayerSendCancel(cid, warp.config.noDestiny) doSendMagicEffect(pos, CONST_ME_POFF) return true end if not destwarp:isActive(cid) then doPlayerSendCancel(cid, warp.config.notActive) doSendMagicEffect(pos, CONST_ME_POFF) return true end if getCreatureCondition(cid, CONDITION_INFIGHT) then doPlayerSendCancel(cid, warp.config.inFight) doSendMagicEffect(pos, CONST_ME_POFF) return true end if pos.x == destwarp.pos.x and pos.y == destwarp.pos.y and pos.z == destwarp.pos.z then doPlayerSendCancel(cid, warp.config.inDestiny) doSendMagicEffect(pos, CONST_ME_POFF) return true end if getCreatureMana(cid) < destwarp.mana then doPlayerSendCancel(cid, warp.config.noMana) doSendMagicEffect(pos, CONST_ME_POFF) return true end if getPlayerLevel(cid) < destwarp.level then doPlayerSendCancel(cid, warp.config.noLevel) doSendMagicEffect(pos, CONST_ME_POFF) return true end doSendMagicEffect(destwarp.pos, warp.config.warpEffect) doCreatureSay(cid, words .. " " .. param, warp.config.talkType) doCreatureAddMana(cid, -destwarp.mana) doTeleportThing(cid, destwarp.pos) return true end /data/talkactions/talkactions.xml <!-- Warp Gate System --> <talkaction words="warp" sensitive="false" event="script" value="warpgate.lua"/> Link para o comentário https://xtibia.com/forum/topic/203481-warp-gate/ Compartilhar em outros sites More sharing options...
Gabrielkss 10 Postado Janeiro 5, 2013 Share Postado Janeiro 5, 2013 Incrivel o sistema muito interessate ele adorei, rep++ Irei implantar no meu serve ;D Link para o comentário https://xtibia.com/forum/topic/203481-warp-gate/#findComment-1431690 Compartilhar em outros sites More sharing options...
Slicer 1070 Postado Janeiro 6, 2013 Share Postado Janeiro 6, 2013 kk queria aprender a usar POO em .lua '--' fico muito bom ms... to usando muito esse sistema no diablo 3 kk ty Link para o comentário https://xtibia.com/forum/topic/203481-warp-gate/#findComment-1431857 Compartilhar em outros sites More sharing options...
MaXwEllDeN 89 Postado Janeiro 9, 2013 Share Postado Janeiro 9, 2013 Skyen, você não sabe o quanto eu procurei esse script quando eu não sabia programar e ele não estava mais no outro fórum. Belo sistema parabéns por fazer códigos tão bons de ser lidos e muito funcionais, é ótimo ver você um pouco ativo no mundo dos OTS novamente. Olha uma versão que eu fiz do teu sistema: Link para o comentário https://xtibia.com/forum/topic/203481-warp-gate/#findComment-1434623 Compartilhar em outros sites More sharing options...
Visitante Postado Janeiro 10, 2013 Share Postado Janeiro 10, 2013 (editado) Skyen, você não sabe o quanto eu procurei esse script quando eu não sabia programar e ele não estava mais no outro fórum. Belo sistema parabéns por fazer códigos tão bons de ser lidos e muito funcionais, é ótimo ver você um pouco ativo no mundo dos OTS novamente. Olha uma versão que eu fiz do teu sistema: Wow! Gostei bem mais do seu! Como fez essa janelinha de seleção? Editado Janeiro 10, 2013 por Visitante Link para o comentário https://xtibia.com/forum/topic/203481-warp-gate/#findComment-1436171 Compartilhar em outros sites More sharing options...
MaXwEllDeN 89 Postado Janeiro 10, 2013 Share Postado Janeiro 10, 2013 (editado) Skyen, você não sabe o quanto eu procurei esse script quando eu não sabia programar e ele não estava mais no outro fórum. Belo sistema parabéns por fazer códigos tão bons de ser lidos e muito funcionais, é ótimo ver você um pouco ativo no mundo dos OTS novamente. Olha uma versão que eu fiz do teu sistema: Wow! Gostei bem mais do seu! Como fez essa janelinha de seleção? Se não me engano o TFS do cliente 9.70 tem a função addPlayerDialog, algo assim. Eu tava jogando LOL ai tô no Janelas, quando eu for pro Linux eu posto o código aqui. @Edit Lib Movement Editado Janeiro 30, 2013 por MaXwEllDeN Link para o comentário https://xtibia.com/forum/topic/203481-warp-gate/#findComment-1436173 Compartilhar em outros sites More sharing options...
Posts Recomendados