Ir para conteúdo
Entre para seguir isso  
jnbrotther

Pokeball para TFS

Recommended Posts

jnbrotther    0
jnbrotther

não vi nada relacionado aqui, então quis contribuir um pouco com o grande acervo de coisas que temos aqui... :D

 

O que o action faz:

 

- Guarda monstros dentro de objetos e salva seu status, você pode colocar pra salvar em qlqr objeto.. seria ótimo para projetos pokemons..

 

Vamos começar.

Você vai precisar disso nas funções do Global (global functions)

[spoiler=spoiler]

[left]_warpzone = 2147483648 -- start storing strings here (THIS IS THE ABSOLUTE MAXIMUM VALUE FOR THIS)
_maxlength = 1024 -- multiply by 3 to get the true length.

setPlayerStorageInteger = setPlayerStorageValue
getPlayerStorageInteger = getPlayerStorageValue

function setPlayerStorageString(cid, key, value)
   if #value > (_maxlength-1) * 3 - 1 then -- Last word is reserved for 0 termination of the string.
       error("Storage string is too long")
   end
   if key > _warpzone / _maxlength then
       error("Storage string key is too large (" .. key .. ")")
   end
   key = _warpzone + key * _maxlength

   local word = 0
   local wordwrap = 0
   local wordcount = 0
   local i = 1
   while i <= #value do
       local byte = string.byte(string.sub(value, i, i))
       word = bit.bor(word, bit.lshift(byte, wordwrap))
       wordwrap = wordwrap + 8
       if wordwrap == 24 then
           --[[
               In the ideal world we would be able to store 4 characters per word,
               however, as the default return value for getPlayerStorageValue is
               -1, we cant use the last bit.
           ]]--
           setPlayerStorageInteger(cid, key + wordcount, word)
           word = 0
           wordwrap = 0
           wordcount = wordcount + 1
       end
       i = i + 1
   end
   -- store the last word
   setPlayerStorageInteger(cid, key + wordcount, word)
end

function getPlayerStorageString(cid, key)
   if key > _warpzone / _maxlength then
       error("Storage string key is too large (" .. key .. ")")
   end
   key = _warpzone + key * _maxlength

   local wordcount = 0
   local str = ""
   while true do
       if wordcount >= _maxlength then
           break
       end
       local word = getPlayerStorageInteger(cid, key + wordcount)
       if word == -1 then
           -- end of string
           break
       else 
           -- Extract the 3 characters from the value
           byte = bit.band(word, 255)
           if byte == 0 then break else str = str .. string.char(byte) end
           byte = bit.rshift(bit.band(word, 65280), 8)
           if byte == 0 then break else str = str .. string.char(byte) end
           byte = bit.rshift(bit.band(word, 16711680), 16)
           if byte == 0 then break else str = str .. string.char(byte) end
       end
       wordcount = wordcount + 1
   end
   return str
end  
   [/left]

 

 

e isso

[spoiler=spoiler]


[left]   function doConvinceSummon(cid, creature, amount, pos)
summonplayerpos = {x=pos.x, y=pos.y, z=pos.z, stackpos=253}
summonplayer = getThingfromPos(summonplayerpos)


   if(summonplayer ~= nil and summonplayer.itemid > 0) then    
       doPlayerSendCancel(cid,"There is not enough room to summon here.")
       ret = 0
   else
       convince = doSummonCreature(creature, pos)
       doConvinceCreature(cid, convince)
       ret = 1
end

       return ret
end  
   [/left]

 

 

ok, agora o script

em data/actions/scripts crie pokeball.lua

e coloque isso dentro:

[spoiler=spoiler]

[left]local notAllowed = {"Ferumbras", "Demon"}
local storage = {
   status = 25650,
   pokeName = 25651
}
local actionid_used = 7510

function onUse(cid, item, fromPos, item2, toPos)
   local pokeballStatus = getPlayerStorageValue(cid, storage.status)
   local pokeName = getPlayerStorageString(cid, storage.pokeName)
   pos = getPlayerPosition(cid) pos.stackpos = 0
       if pokeballStatus == -1 then
           toPos.stackpos = 253
           local pokeThing = getThingfromPos(toPos)
           if isCreature(pokeThing.uid) == TRUE then
               if isPlayer(pokeThing.uid) == FALSE then
                   local pokename_ = getCreatureName(pokeThing.uid)
                   if item.actionid ~= actionid_used then
                   --    local maxHealth = 400
                   --    local creatureHealth = getCreatureHealth(pokeThing.uid)
                   --    local divNum = (string.len(maxHealth)-1)^2
                   --    local result = math.floor((creatureHealth/divNum)/10)
                   --    local chance = math.random(1, math.random(4, math.random(7, math.max(result, 7))))
                   --    if chance == result then
                           if isInTable(notAllowed, pokename_) == TRUE then
                               doPlayerSendCancel(cid, "You cannot catch this creature")
                           else
                               setPlayerStorageString(cid, storage.pokeName, pokename_)
                               doRemoveCreature(pokeThing.uid)
                               doSendDistanceShoot(fromPos, toPos, 37)
                               setPlayerStorageValue(cid, storage.status, 1)
                               doSetItemSpecialDescription(item.uid, "it contains a " .. pokename_ .. ".")
                               doSetItemActionId(item.uid, actionid_used)
                           end
                   --    else
                   --        doSendMagicEffect(fromPos, 2)
                   --        doPlayerSendCancel(cid, "The Pokemom Escaped")
                   --    end
                   elseif item.actionid == actionid_used and pokename_  == pokeName then
                       doPlayerSay(cid, pokeName .. " Back!!", TALKTYPE_SAY)
                       doRemoveCreature(pokeThing.uid)
                       doSetItemSpecialDescription(item.uid, "it contains a " .. pokename_ .. ".")
                       setPlayerStorageValue(cid, storage.status, 1)
                       doSendDistanceShoot(fromPos, toPos, 37)
                   else
                       doSendMagicEffect(fromPos, 2)
                       doPlayerSendCancel(cid, "This pokeball is already used")
                   end
               else
                   doPlayerSendCancel(cid, "You cannot catch this creature")
               end
           else
               doPlayerSendCancel(cid, "Creature not found")
           end
       elseif pokeballStatus == 1 then
           summons = getCreatureSummons(cid)
       --    if #summons >= 2 then
       --        doPlayerSendCancel(cid, "You cannot call more pokemons")
       --    else
               doConvinceSummon(cid, pokeName, 0, toPos)
               doSendDistanceShoot(fromPos, toPos, 37)
               doPlayerSay(cid, pokeName .. " Go!!", TALKTYPE_SAY)
               setPlayerStorageValue(cid, storage.status, -1)
               doSetItemSpecialDescription(item.uid, "it is empty.")
       --    end
       end
   else

   return 1
end 

function isInTable(t, val)
   for _, v in pairs(t) do
       if v == val then
           return TRUE
       end
   end
   return LUA_ERROR
end  
   [/left]

 

 

para TFS

[spoiler=spoiler]

[left]local notAllowed = {"Ferumbras", "Demon"}
local storage = {
   status = 15244,
   pokeName = 15212
}
local actionid_used = 7510

function onUse(cid, item, fromPos, item2, toPos)
   local pokeballStatus = getPlayerStorageValue(cid, storage.status)
   local pokeName = getPlayerStorageString(cid, storage.pokeName)
   pos = getPlayerPosition(cid) pos.stackpos = 0
       if pokeballStatus <= 0 then
           toPos.stackpos = 253
           local pokeThing = getThingfromPos(toPos)
           if isCreature(pokeThing.uid) == TRUE then
               if isPlayer(pokeThing.uid) == FALSE then
                   local pokename_ = getCreatureName(pokeThing.uid)
                   if item.actionid ~= actionid_used then
                   --    local maxHealth = 400
                   --    local creatureHealth = getCreatureHealth(pokeThing.uid)
                   --    local divNum = (string.len(maxHealth)-1)^2
                   --    local result = math.floor((creatureHealth/divNum)/10)
                   --    local chance = math.random(1, math.random(4, math.random(7, math.max(result, 7))))
                   --    if chance == result then
                           if isInTable(notAllowed, pokename_) == TRUE then
                               doPlayerSendCancel(cid, "You cannot catch this creature")
                           else
                               setPlayerStorageString(cid, storage.pokeName, pokename_)
                               doRemoveCreature(pokeThing.uid)
                               doSendDistanceShoot(fromPos, toPos, 37)
                               setPlayerStorageValue(cid, storage.status, 1)
                               doSetItemSpecialDescription(item.uid, "it contains a " .. pokename_ .. ".")
                               doSetItemActionId(item.uid, actionid_used)
                           end
                   --    else
                   --        doSendMagicEffect(fromPos, 2)
                   --        doPlayerSendCancel(cid, "The Pokemom Escaped")
                   --    end
                   elseif item.actionid == actionid_used and pokename_  == pokeName then
                       doCreatureSay(cid, pokeName .. " Back!!", TALKTYPE_SAY)
                       doRemoveCreature(pokeThing.uid)
                       doSetItemSpecialDescription(item.uid, "it contains a " .. pokename_ .. ".")
                       setPlayerStorageValue(cid, storage.status, 1)
                       doSendDistanceShoot(fromPos, toPos, 37)
                   else
                       doSendMagicEffect(fromPos, 2)
                       doPlayerSendCancel(cid, "This pokeball is already used")
                   end
               else
                   doPlayerSendCancel(cid, "You cannot catch this creature")
               end
           else
               doPlayerSendCancel(cid, "Creature not found")
           end
       elseif pokeballStatus == 1 then
       --    summons = doCreatureSummons(cid)
       --    if #summons >= 2 then
       --        doPlayerSendCancel(cid, "You cannot call more pokemons")
       --    else
               doConvinceSummon(cid, pokeName, 0, toPos)
               doSendDistanceShoot(fromPos, toPos, 37)
               doCreatureSay(cid, pokeName .. " Go!!", TALKTYPE_SAY)
               setPlayerStorageValue(cid, storage.status, 0)
               doSetItemSpecialDescription(item.uid, "it is empty.")
       --    end
       end

   return 1
end 

function isInTable(t, val)
   for _, v in pairs(t) do
       if v == val then
           return TRUE
       end
   end
   return LUA_ERROR
end
   [/left]

 

 

Em data/actions/actions.xml adicione:

[spoiler=spoiler]

<action itemid="xxxx" script="pokeball.lua" allowfaruse="1" blockwalls="1" /> 

 

 

Bem, agora troque o "xxxx" pelo ID do item que você deseja como pokebola e tentem usar um item "usável" não uma "Soul Stone". :)

 

 

Créditos Maker: Nahruto

Créditos Post: Jnbrotther

Salva moscatável

Editado por jnbrotther
alguns ajustes

Compartilhar este post


Link para o post
Flatronez    1
Flatronez

Movido.

aprovadog.png

Compartilhar este post


Link para o post
Biozard    0
Biozard

Aqui Não Funciono...Deu Erro Na Hora De Dar Use Na Soul Orb ( Item Que Colokei No Lugar DO xxxx )...

Compartilhar este post


Link para o post
arthurmaffeis    0
arthurmaffeis

Eu testei aki e não deu serto .

;/

Editado por arthurmaffeis

Compartilhar este post


Link para o post
dragonlorde    0
dragonlorde

Ninguem nunca vai postar um script de pokebola certo porque todo mundo anda atras....

Esse script do Nahruto ja tem aki ele não funciona ¬¬ moderação devia tira os topicos de pokebola aqui da otnet nenhum funfa :palm:

Compartilhar este post


Link para o post
Apokalypse    0
Apokalypse

esse script ja tem aki...

Pokebola - OTServ Networks

ele não funfa, só dá pra levar 1 monstro/pokemon de uma vez...

Compartilhar este post


Link para o post
jnbrotther    0
jnbrotther

bem pessoal, eu andei dando uns ajustes pequenos e isso foi o que consegui por enquanto..

ja foi modificado no tópico lá...

mas ó..

 

realmente é preciso usar um ID para cada pokebola (vou tentar achar um jeito de colocar um sistema parecido ao do PO - n igual - que possa usar a pokebola sem precisar de vários ID's )

 

Versão que funcionou perfeitamente:

TFS 0.2.12 - Tibia 8.11

(podem existir outras versões)

 

 

 

@Apokalypse

@dragonlorde

Vou trabalhar nisso

 

 

@arthurmaffeis

olha a versão do seu OT, e "global functions" não é uma pasta, é um arquivo .lua

o nome do arquivo é Global.lua e quando falei global functions, era pra adicionar as

linhas que eu sitei nos CODES la em cima. No caso, isso aí que colokei foram as

Funções Globais que devem ser adicionados ao Global.lua dentro da pasta DATA

do seu OT.

 

@LUCASF

Tenta usar só pra testar qlqr coisa q não seja uma soul stone... até mesmo uma arma pode ser usada... tente usar qlqr item q tenha a opção "use with".

Compartilhar este post


Link para o post
kenamen    0
kenamen

gostei... só q tem arrumar ! boa lek.

Compartilhar este post


Link para o post
Mickfern    32
Mickfern

Aqui deu erro. Para qual versão seria?

Compartilhar este post


Link para o post
Biozard    0
Biozard

8.11..ele Disse...

Compartilhar este post


Link para o post
kilergui    0
kilergui

se voce for arrumar e melhor começar do zero ai lhe daria menos trabalho ;s

Compartilhar este post


Link para o post
GOD TY    0
GOD TY

Cara, nao e criticando os seus trabalhos em fazer system de pokeball (sei que e dificil), mas todos que testei ate agora, nenhum pega perfeitamente, é aquela coisa se quer... procure ... copie... não pegou? Faça voce mesmo. :/ Talvez combinando com outros scripts ou dando uma reeformulada melhore, enquanto isso nao acontece nao axo necessario a criação de novos tópicos para pokeball system. Mas vlw mesmo assim vou tentar editar seu script*.

Editado por GOD TY

Compartilhar este post


Link para o post
jnbrotther    0
jnbrotther

uma dica...

n tenta por ele...

como vc mesmo disse e pelo q vcs mesmos viram...

não é meu o script e é completo e cheio de falhas..

n é examtanete o que vcs estão procurando

se querem um script de "go/Back" q é como chamam,

terão de fazer vcs mesmo do 0, como nosso amigo ali em cima

falou...

 

desculpa n poder ajudar mais nessa área... parei um pouco de mexer nisso

por motivos pessoais...

 

abraços

Compartilhar este post


Link para o post
CumPaDe    0
CumPaDe

[21/06/2010 21:24:41] Lua Script Error: [Action Interface]

[21/06/2010 21:24:41] data/actions/scripts/pokeball.lua:onUse

 

[21/06/2010 21:24:41] data/actions/scripts/pokeball.lua:10: attempt to call global 'getPlayerStorageString' (a nil value)

[21/06/2010 21:24:41] stack traceback:

[21/06/2010 21:24:41] data/actions/scripts/pokeball.lua:10: in function <data/actions/scripts/pokeball.lua:8>

 

 

como arrumo isso ? D:

Compartilhar este post


Link para o post
celular    0
celular

tentei na versao 8.10 e deu erro mais n consigo arrumar

Compartilhar este post


Link para o post
VittinhoO    0
VittinhoO

o Meu OT não existe a global functions ;/

funfa tambem no 8.1?

Compartilhar este post


Link para o post
chukyville    0
chukyville

dont funfou. ;/

Compartilhar este post


Link para o post
ingoguilherme    0
ingoguilherme

funcionou cara, parabens, esta mt bom

so faltou funcionar 1 pokeball pra varios monstros ao inves de varias com ids deferentes para cada monstro q nem vc falou, se vc conseguir coloca pra gente ae ^^

vlw cara, teh

Compartilhar este post


Link para o post
notle.com    2
notle.com

Aqui Pego Mais Pokemon Tem Que Ta Vivo Vcs Não Tem Um Que Joga No Corpo?

Editado por notle.com

Compartilhar este post


Link para o post
Lozorio    0
Lozorio

não funcionou =X

Compartilhar este post


Link para o post
Visitante
Este tópico está impedido de receber novos posts.
Entre para seguir isso  
  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×