Ir para conteúdo
Entre para seguir isso  
MatheusMkalo

Go/back, Catch, Nurse npc systens

Recommended Posts

MatheusMkalo    0
MatheusMkalo
Nomes: Catch System, Nurse Npc, Catch System

Autor: MatheusMkalo

Versão Testada: 8.54+

Informaçoes Adicionais: Alguns sistemas de pokemon.

Preview:

[ame]

[/ame]

 

Go/Back Pokeball System

By: MatheusMkalo

Vá em data/actions/scripts e adicione um arquivo.lua com o nome de goback.lua

Depois de ter feito isso, adicione o seguinte script no arquivo goback.lua:

local pokein, pokeout = 2222,2223

local pokes = {
["Dragon"] = {level = 150, go = "Vai Dragon", back = "Volte Dragon."},
["Demon"] = {level = 500, go = "Vai Demon", back = "Volte Demon."},
["Dragon Lord"] = {level = 300, go = "Vai Dragon Lord", back = "Volte Dragon Lord."},
}

function onUse(cid, item, frompos, item2, topos)
   function getDescription(uid)
       for i,x in pairs(getItemDescriptions(uid)) do
           if i == "special" then
               return x
           end
       end
   end

   function findLetter(string, letter)
       for i = 1, #string do
           if string:sub(i, i) == letter then
               return i
           end
       end
   end

   local maxh = tonumber(getDescription(item.uid):match("/(.+)]"))
   local health = tonumber(getDescription(item.uid):match("%[(.-)/"))

   if item.itemid == pokeout then

       if #getCreatureSummons(cid) >= 1 then
           for _,z in pairs(getCreatureSummons(cid)) do
               if getDescription(item.uid):find(getCreatureName(z)) then
                   doTransformItem(item.uid, pokein)
                   doCreatureSay(cid, pokes[getCreatureName(z)].back, TALKTYPE_SAY)
                   doItemSetAttribute(item.uid, "description", getDescription(item.uid):sub(1, findLetter(getDescription(item.uid), ".")) .. " HP = ["..getCreatureHealth(z).."/"..getCreatureMaxHealth(z).."]")
                   setPlayerStorageValue(cid, 61204, 0)
                   doSendMagicEffect(getCreaturePosition(z), 10)
                   return doRemoveCreature(z)
               end
           end
       end

   elseif item.itemid == pokein then

       if getTilePzInfo(getCreaturePosition(cid)) then
           return doPlayerSendCancel(cid, "You can't use pokeball in Protection Zones.")
       end

       if health <= 0 then
           return doPlayerSendCancel(cid, "This pokemon is dead.")
       end

       for i,x in pairs(pokes) do
           if #getCreatureSummons(cid) >= 1 then
               return doPlayerSendCancel(cid, "You already summoned a pokemon.")
           end

           if i == getDescription(item.uid):sub(9, findLetter(getDescription(item.uid), "'")-1) then
               if getPlayerLevel(cid) >= x.level then
                   pk =  doSummonCreature(i, getThingPosition(cid))
                   doConvinceCreature(cid, pk)
                   setCreatureMaxHealth(pk, tonumber(getDescription(item.uid):match("/(.+)]")))
                   doCreatureAddHealth(pk, maxh)
                   doCreatureAddHealth(pk, health-maxh)
                   doTransformItem(item.uid, pokeout)
                   doCreatureSay(cid, x.go, TALKTYPE_SAY)
                   doItemSetAttribute(item.uid, "description", getDescription(item.uid):sub(1, findLetter(getDescription(item.uid), ".")))
                   doSendMagicEffect(getCreaturePosition(pk), 10)
                   setPlayerStorageValue(cid, 61204, 1)
                   registerCreatureEvent(pk, "DiePoke")
                   registerCreatureEvent(cid, "PlayerPokeDeath")
                   break
               else
                   doPlayerSendCancel(cid, "Only players level "..x.level.." or higher can use this pokemon.")
               end
           end
       end
   end
return TRUE
end

Depois, va em actions.xml e adicione a seguinte tag:

<action itemid="2222;2223" event="script" value="goback.lua"/>

Sendo que 2222 e 2223 são, respectivamente, o id da pokeball que ira "chamar" o pokemon, e o outro o id da pokeball que ira retirar o pokemon. (Seriam as pokebolas acesas e apagadas do PO)

 

Agora, para evitar alguns bugs, va em data/creaturescripts/scripts e crie um arquivo.lua com o nome goback.lua e bote o seguinte script dentro:

local pokein, pokeout = 2222,2223

function getDescription(uid)
   for i,x in pairs(getItemDescriptions(uid)) do
       if i == "special" then
           return x
       end
   end
end

function findLetter(string, letter)
   for i = 1, #string do
       if string:sub(i, i) == letter then
           return i
       end
   end
end

function getSummonLifes(cid)
   for _,x in pairs(getCreatureSummons(cid)) do
       return getCreatureHealth(x), getCreatureMaxHealth(x)
   end
end

function onLogout(cid)
local health,maxhealth = getSummonLifes(cid)
   if getPlayerStorageValue(cid, 61204) >= 1 then
       setPlayerStorageValue(cid, 61205, health)
       setPlayerStorageValue(cid, 61206, maxhealth)
       setPlayerStorageValue(cid, 61204, 0)
       setPlayerStorageValue(cid, 61207, 1)
   end
return TRUE
end

function onLogin(cid)
   if getPlayerStorageValue(cid, 61207) >= 1 then
       local item = getPlayerItemById(cid, TRUE, pokeout)
       doTransformItem(item.uid, pokein)
       doItemSetAttribute(item.uid, "description", getDescription(item.uid) .. " HP = ["..getPlayerStorageValue(cid, 61205).."/"..getPlayerStorageValue(cid, 61206).."]")
       setPlayerStorageValue(cid, 61207, 0)
   end
return TRUE
end

function onDeath(cid, deathList)
   local owner = getCreatureMaster(cid)
   doPlayerSendTextMessage(owner, 22, "You pokemon died.")
   local item = getPlayerItemById(owner, TRUE, pokeout)
   doTransformItem(item.uid, pokein)
   doItemSetAttribute(item.uid, "description", getDescription(item.uid):sub(1,     findLetter(getDescription(item.uid), ".")) .. " HP = [0/"..getCreatureMaxHealth(cid).."]") 
   doRemoveCreature(cid)
   setPlayerStorageValue(owner, 61207, 0)
   setPlayerStorageValue(owner, 61204, 0)
return FALSE
end

Agora faça um outro arquivo.lua na mesma pasta e bote o nome de playerpdeath e bote esse script dentro:

local pokein, pokeout = 2222,2223

function getSummonLifes(cid)
   for _,x in pairs(getCreatureSummons(cid)) do
       return getCreatureHealth(x), getCreatureMaxHealth(x)
   end
end

function onDeath(cid)
local health,maxhealth = getSummonLifes(cid)
   if #getCreatureSummons(cid) >= 1 then
       setPlayerStorageValue(cid, 61205, health)
       setPlayerStorageValue(cid, 61206, maxhealth)
       setPlayerStorageValue(cid, 61204, 0)
       setPlayerStorageValue(cid, 61207, 1)
   end
return TRUE
end

Depois va em creaturescripts.xml e adicione as seguintes TAGS:

<event type="death" name="PlayerPokeDeath" event="script" value="playerpdeath.lua"/>
<event type="death" name="DiePoke" event="script" value="goback.lua"/>
<event type="logout" name="LogoutPoke" event="script" value="goback.lua"/>
<event type="login" name="LoginPoke" event="script" value="goback.lua"/>

Npc Healler

By: MatheusMkalo

 

Vá em data/npc/scripts e adicione um arquivo.lua com o nome de pokehealer.lua

Depois adicione o seguinte script dentro dele:

local pokein, pokeout = 2222,2223
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid)            npcHandler:onCreatureAppear(cid)        end
function onCreatureDisappear(cid)        npcHandler:onCreatureDisappear(cid)        end
function onCreatureSay(cid, type, msg)        npcHandler:onCreatureSay(cid, type, msg)    end
function onThink()                npcHandler:onThink()                end

function creatureSayCallback(cid, type, msg)

   if(not npcHandler:isFocused(cid)) then
       return false
   end

function getItemsInContainerById(container, itemid) -- Function By Kydrai
   local items = {}
   if isContainer(container) and getContainerSize(container) > 0 then
       for slot=0, (getContainerSize(container)-1) do
           local item = getContainerItem(container, slot)
           if isContainer(item.uid) then
               local itemsbag = getItemsInContainerById(item.uid, itemid)
               for i=0, #itemsbag do
                   table.insert(items, itemsbag[i])
               end
           else
               if itemid == item.itemid then
                   table.insert(items, item.uid)
               end
           end
       end
   end
   return items
end

function getDescription(uid)
   for i,x in pairs(getItemDescriptions(uid)) do
       if i == "special" then
           return x
       end
   end
end

function findLetter(string, letter)
   for i = 1, #string do
       if string:sub(i, i) == letter then
           return i
       end
   end
end


   if msgcontains(msg, 'heal') then
       if #getCreatureSummons(cid) >= 1 then
           return selfSay('Voce precisa botar seus pokemons dentro da pokebola.', cid)
       end

       local bp = getPlayerSlotItem(cid, CONST_SLOT_BACKPACK)
       local handr = getPlayerSlotItem(cid, CONST_SLOT_RIGHT)
       local handl = getPlayerSlotItem(cid, CONST_SLOT_LEFT)
       local arrow = getPlayerSlotItem(cid, CONST_SLOT_AMMO)

       if handr.itemid == pokein then
           local maxh = tonumber(getDescription(handr.uid):match("/(.+)]"))
           doItemSetAttribute(handr.uid, "description", getDescription(handr.uid):sub(1, findLetter(getDescription(handr.uid), "[")) .. maxh .. getDescription(handr.uid):sub(findLetter(getDescription(handr.uid), "/"))) 
       end

       if handl.itemid == pokein then
           local maxh = tonumber(getDescription(handl.uid):match("/(.+)]"))
       doItemSetAttribute(handl.uid, "description", getDescription(handl.uid):sub(1, findLetter(getDescription(handl.uid), "[")) .. maxh .. getDescription(handl.uid):sub(findLetter(getDescription(handl.uid), "/")))
       end

       if arrow.itemid == pokein then
           local maxh = tonumber(getDescription(arrow.uid):match("/(.+)]"))
       doItemSetAttribute(arrow.uid, "description", getDescription(arrow.uid):sub(1, findLetter(getDescription(arrow.uid), "[")) .. maxh .. getDescription(arrow.uid):sub(findLetter(getDescription(arrow.uid), "/"))) 
       end

       local items = getItemsInContainerById(bp.uid, pokein)
       doCreatureAddHealth(cid, getCreatureMaxHealth(cid)-getCreatureHealth(cid))
       for _, uid in pairs(items) do
           local maxh = tonumber(getDescription(uid):match("/(.+)]"))
           doItemSetAttribute(uid, "description", getDescription(uid):sub(1, findLetter(getDescription(uid), "[")) .. maxh .. getDescription(uid):sub(findLetter(getDescription(uid), "/")))     
       end
       selfSay('Pronto, voce e seus pokemons estao com a life maxima.', cid)
   end
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Depois adicione um arquivo.xml na pasta npc chamado Pokemon Healer.xml e adicione o seguinte script dentro dele:

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Pokemon Healer" script="pokehealer.lua" walkinterval="2000" floorchange="0">
   <health now="100" max="100"/>
   <look type="128" head="17" body="54" legs="114" feet="0" addons="2"/>
   <parameters>
       <parameter key="message_greet" value="Ola, diga {heal} para recuperar sua vida e a vida dos seus pokemons."/>
   </parameters>
</npc>

Catch Pokemon System (BETA)

By: MatheusMkalo

 

Vá em data/actions/scripts e adicione um arquivo.lua chamado catch.lua e coloque o seguinte script dentro dele:

local pokein, pokeout = 2222,2223

local pokes = {
["Dragon"] = {chance = 40, health = 100, maxhealth = 100},
["Demon"] = {chance = 20, health = 1000, maxhealth = 1000},
}

function onUse(cid, item, frompos, item2, topos)
   for i,x in pairs(pokes) do
       if getItemNameById(item2.itemid):find(i:lower()) then
           doRemoveItem(item.uid, 1)
           doRemoveItem(item2.uid, 1)
           if math.random(1,100) <= x.chance then
               local s = doPlayerAddItem(cid, pokein)
               doSendMagicEffect(topos, 29)
               addEvent(doSendMagicEffect, 300, topos, 30)
               doItemSetAttribute(s, "description", "This is "..i.."'s pokeball. HP = ["..x.health.."/"..x.maxhealth.."]")
               doPlayerSendTextMessage(cid, 27, "You catch a "..i..".")
           else
               doPlayerSendTextMessage(cid, 27, "Your pokeball broke.")
               doSendMagicEffect(topos, 2)
           end
       end
   end            
return TRUE
end

Depois adicione a seguinte TAG no actions.xml:

<action itemid="2147" event="script" value="catch.lua"/>

Sendo 2147, o id da sua pokebola para capturar pokemons (NAO A DE CHAMAR O POKEMON)

 

 

Configurando os scripts

 

 

Como adicionar mais pokemons no go/back:

 

No inicio do script, tem essa tabela com as informaçoes:

local pokes = {

["Dragon"] = {level = 150, msgs = {"Essa mensagem pode ser sortiada 1", "Essa mensagem pode ser sortiada 2"}},

["Demon"] = {level = 500, msgs = {"Essa mensagem pode ser sortiada 1", "Essa mensagem pode ser sortiada 2"}},

["Dragon Lord"] = {level = 300, msgs = {"Essa mensagem pode ser sortiada 1", "Essa mensagem pode ser sortiada 2"}},

}

Copie a ultima linha (vermelha) e cole logo abaixo, editando os nomes e as mensagens ficando assim:
local pokes = {

["Dragon"] = {level = 150, msgs = {"Essa mensagem pode ser sortiada 1", "Essa mensagem pode ser sortiada 2"}},

["Demon"] = {level = 500, msgs = {"Essa mensagem pode ser sortiada 1", "Essa mensagem pode ser sortiada 2"}},

["Dragon Lord"] = {level = 300, msgs = {"Essa mensagem pode ser sortiada 1", "Essa mensagem pode ser sortiada 2"}},

["Dragon Lord"] = {level = 300, msgs = {"Essa mensagem pode ser sortiada 1", "Essa mensagem pode ser sortiada 2"}},

}

Voce pode configurar o level para usar o poke mudando o valor de level.

 

 

Configurando pokemons para o catch:

 

Olhe a tabela no inicio do script:

local pokes = {

["Dragon"] = {chance = 40, health = 100, maxhealth = 100},

["Demon"] = {chance = 20, health = 1000, maxhealth = 1000},

}

Faça o mesmo processo do acima de copiar e colar embaixo e editar:
local pokes = {

["Dragon"] = {chance = 40, health = 100, maxhealth = 100},

["Demon"] = {chance = 20, health = 1000, maxhealth = 1000},

["Rat"] = {chance = 100, health = 330, maxhealth = 330},

}

Aonde as informaçoes chance, health, maxhealth serao, respectivamente: Chance de capturar em %, health que o pokemon iria ir pro player, e health maxima que o poke iria ir para o player.

 

 

Como trocar os ids das pokebolas, acesas e apagadas.

Em todos os scripts.lua tem no inicio "local pokein, pokeout = 2222,2223", sendo que o 2222 seria o id da pokebola acesa com o poke dentro e a 2223 com o poke fora da pokebola.

 

Mude-os em todos os scripts e tambem na tag do action.xml que seu script ira funcionar perfeitamente.

 

 

Informaçoes Importantes!!!

 

Para poder summonar os pokemons com o go/back, voce precisa ir no arquivo.xml do monstro e editar essa linha:

<flag convinceable="0"/>
Se estiver convinceable="0", mude para convinceable="1" ficando:
<flag convinceable="1"/>
Creditos:

Kydrai pela funçao "getItemsInContainerById"

MarcelloMkez

 

Agradecimentos:

D3rs00n (Me ajudou a fazer sumir o corpo do pokemon)

 

 

Bugs, erros, duvidas, elogios no topico

Compartilhar este post


Link para o post
Antharaz    4
Antharaz

Desculpe a demora...

 

Achei que se usava a pokeball no pokemon ainda vivo e por isto achei que estava errado. (não jogo pokemon '-')

 

Testado e aprovado.

 

Como envolve mais de um tipo de script, movi para Sistemas e Bibliotecas

Editado por Antharaz

Compartilhar este post


Link para o post
AkillesW    6
AkillesW

Testei e funcionou

vlw por trazer vai ajudar muita gente

Só é ruim configurar todos os pokes neh.

Compartilhar este post


Link para o post
bananakkk    0
bananakkk

Eu testei aqui e funcionou certinho! =D

Agora eu to com uma dúvida:

Eu tenho um script para evoluir e eu arrumei e funcionou com o seu script! Mas quando eu evoluo o meu pokemon, ex: Charmander > Charmeleon, a pokeball continua sendo do charmander dai n da pra da back...

Teria como vicê me ajuda?

Script evolução:

local evo = {

["Charmander"] = "Charmeleon",

["Charmeleon"] = "Charizard",

}

 

function onUse(cid, item, fromPosition, itemEx, toPosition)

if isMonster(itemEx.uid) and getCreatureMaster(itemEx.uid) == cid then

local monster = getCreatureName(itemEx.uid)

if evo[monster] then

local health, maxHealth = getCreatureHealth(itemEx.uid), getCreatureMaxHealth(itemEx.uid)

doRemoveCreature(itemEx.uid)

local summon = doCreateMonster(evo[monster], toPosition)

doConvinceCreature(cid, summon)

doCreatureAddHealth(summon, health-maxHealth)

doSendMagicEffect(getThingPos(summon), CONST_ME_FIREWORK_RED)

return TRUE

end

end

return FALSE

end

Compartilhar este post


Link para o post
vyctor17    35
vyctor17

ake nao funciono nao o bixo nao volta

Compartilhar este post


Link para o post
bacteria    1
bacteria

cara seguinte aki deu certo mas qnd eu desco uma rampa com o pokemon fora da ball ele nao vai junto cmg

cmo arruma isso?

pra o pokemon ir junto cmg?

Compartilhar este post


Link para o post
ADM MaX DE    0
ADM MaX DE

Isso ae manin, bom script como ja havia dito! ^^"

Apesar de você ter postado, você poderia ter vendido neh pra lucrar oskaosaks'

Mas anyway, gz ae, e façam bom uso --'

E se possivel agradeça, n tira pedaço de ninguem.

 

Att~ MaX

 

cara seguinte aki deu certo mas qnd eu desco uma rampa com o pokemon fora da ball ele nao vai junto cmg

cmo arruma isso?

pra o pokemon ir junto cmg?

 

Vai no config.lua e poe em 'teleportsummons' o valor true --'

Compartilhar este post


Link para o post
ByJeanxD    0
ByJeanxD

Melhor script de pokemon gratis.

 

 

Parabéns MatheusMkalo.

Ja tinha visto esse script mas foi em outro forum.

 

OBS.: Poe o fly,o surf e o ride tb :D...

Editado por ByJeanxD

Compartilhar este post


Link para o post
josejunior23    2
josejunior23

parabéns pelo script.

 

mas você sabe que isso pode reduzir em 80%?

abraço!

Compartilhar este post


Link para o post
MaXwEllDeN    13
MaXwEllDeN

Fiu Fiu, Ótimo!!

Parabéns Mkalo pelo trabalho!

~~MaX Aproves(não é muita coisa né)

Compartilhar este post


Link para o post
xhaos    0
xhaos
[18/10/2010 21:04:11] [Error - Action Interface]

[18/10/2010 21:04:11] data/actions/scripts/goback.lua:onUse

[18/10/2010 21:04:11] Description:

[18/10/2010 21:04:11] data/actions/scripts/goback.lua:48: attempt to compare nil with number

[18/10/2010 21:04:11] stack traceback:

[18/10/2010 21:04:11] data/actions/scripts/goback.lua:48: in function <data/actions/scripts/goback.lua:7>

comofas

Compartilhar este post


Link para o post
ViniciusLelis    0
ViniciusLelis

UIa, a turma tudo vendendo estes scripts por Dinheiro real (RS) e você veio e postou, parabens ae, voce postou com o intuitivo de ajudar as pessoas, gosto de pessoas assim, que gostam de ajudar as pessoas, e não esses que vendem esses scripts por dinheiro , as vezes caro pra caramba.

Vinicius Lelis The Chinchilla Aproves

Compartilhar este post


Link para o post
ViniciusLelis    0
ViniciusLelis

Uma Duvida:

parece o seguinte erro:

[19/10/2010 16:40:39] [Error - LuaScriptInterface::loadFile] data/actions/scripts/goback.lua:1: unexpected symbol near '{'

[19/10/2010 16:40:39] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/goback.lua)

[19/10/2010 16:40:39] data/actions/scripts/goback.lua:1: unexpected symbol near '{'

 

Se possivel me ajudar eu agradeço.

tchau^^

Compartilhar este post


Link para o post
lenon00    0
lenon00

Aqui funcionou perfeitamente :D,

a versão tem que ser 8.54+~

Boa @Mat

Compartilhar este post


Link para o post
MatheusMkalo    0
MatheusMkalo

Jaja posto o resto dos scripts que eu fiz, to meio sem tempo '-'

Vinicius, se der posta o script goback.lua la da pasta actions pra eu ver se voce fez algo errado ao configurar os scripts

Compartilhar este post


Link para o post
bruno954    0
bruno954
> ERROR: Unable to load Actionsl
o meu da esse erro quando coloco o go/back catch e quando eu tiro aparece uma pokebola mais ela não da pra fazer nada =/ ajuda se for possivel ou me add no msn para conversar mais para poder me ajudar

[email protected]

Editado por bruno954

Compartilhar este post


Link para o post
topmaster    0
topmaster

Muito bom lek parabens script de qualidade e ainda free

Compartilhar este post


Link para o post
GOD TY    0
GOD TY

Ou otservs 8.1x nao tem a pasta creaturescripts como faço agora??

Compartilhar este post


Link para o post
Blakk    26
Blakk

Ta funfando certin aqui, eu keria sabe como eu faõ pra troca o efeito, quando eu pegar e quando falhar tbm!

Compartilhar este post


Link para o post
marvis    0
marvis

ava script lixo

["Dragon Lord"] = {level = 300, go = "Vai Dragon Lord", back = "Volte Dragon Lord."},

quanto tempo se acha q vo perder fazendo isso enquanto tem uns 10 vezees melhores e automatico nessas mensagens

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.

×