Ir para conteúdo

Sistema De Pokemon No Tibia


Luga03

Posts Recomendados

Eae galera blz? hj eu tava sem nada para fazer então pensei em colocar o sistema de pokemon no tibia como ele funciona? é simples ele faz igual os sistemas de pokemons normais só que com a função de catch, go/back da pokeball,e os monstros capturados tem suas pokebolas configuradas e tem vida configuravel! agora sem mas delogas vamos ao script!

Antes de tudo vá em data/lib e crie um arquivo .lua chamado de PokeLib e coloca dentro :

 

pokein, pokeout = 2222,2223

function doRemoveTile(pos)-- Script by mock
    pos.stackpos = 0
    local sqm = getTileThingByPos(pos)
    doRemoveItem(sqm.uid,1)
end


function doCreateTile(id,pos) -- By mock
    doAreaCombatHealth(0,0,pos,0,0,0,CONST_ME_NONE)
    doCreateItem(id,1,pos)
end

function getPosDirs(p, dir) -- By MatheusMkalo
    return dir == 1 and {x=p.x-1, y=p.y, z=p.z} or dir == 2 and {x=p.x-1, y=p.y+1, z=p.z} or dir == 3 and {x=p.x, y=p.y+1, z=p.z} or dir == 4 and {x=p.x+1, y=p.y+1, z=p.z} or dir == 5 and {x=p.x+1, y=p.y, z=p.z} or dir == 6 and {x=p.x+1, y=p.y-1, z=p.z} or dir == 7 and {x=p.x, y=p.y-1, z=p.z} or dir == 8 and {x=p.x-1, y=p.y-1, z=p.z}
end

function doItem(pos,a,d)-- Script by mock
        doCreateTile(460,pos)
        pos.stackpos = 0
        local c = getTileThingByPos(pos)
        doItemSetAttribute(c.uid, "aid", a)
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

function isWalkable(pos, creature, proj, pz)-- by Nord
    if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
    if getTopCreature(pos).uid > 0 and creature then return false end
    if getTileInfo(pos).protection and pz then return false, true end
    local n = not proj and 3 or 2
    for i = 0, 255 do
        pos.stackpos = i
        local tile = getTileThingByPos(pos)
        if tile.itemid ~= 0 and not isCreature(tile.uid) then
            if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
                return false
            end
        end
    end
    return true
end

function getPosDirs(p, dir)
    return dir == 1 and {x=p.x-1, y=p.y, z=p.z} or dir == 2 and {x=p.x-1, y=p.y+1, z=p.z} or dir == 3 and {x=p.x, y=p.y+1, z=p.z} or dir == 4 and {x=p.x+1, y=p.y+1, z=p.z} or dir == 5 and {x=p.x+1, y=p.y, z=p.z} or dir == 6 and {x=p.x+1, y=p.y-1, z=p.z} or dir == 7 and {x=p.x, y=p.y-1, z=p.z} or dir == 8 and {x=p.x-1, y=p.y-1, z=p.z}
end

function canSummon(cid)
    local pos = getCreaturePosition(cid)
    local state = false
    for i = 1, 8 do
        if isWalkable(getPosDirs(getCreaturePosition(cid), i)) then
            state = true
        end
    end
return state
end

function isPlayerSummon(cid, uid)
    if getCreatureMaster(uid) == cid then
        return TRUE
    end
return FALSE
end

function getSummonLifes(cid)
    for _,x in pairs(getCreatureSummons(cid)) do
        return getCreatureHealth(x), getCreatureMaxHealth(x)
    end
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 addPokeball(cid, pokename, maxh)
    local s = doPlayerAddItem(cid, pokein)
    doItemSetAttribute(s, "poke", "This is "..pokename.."'s pokeball. HP = ["..maxh.."/"..maxh.."]")
    doItemSetAttribute(s, "description", "Contains a " .. pokename)
end

function getPokeOutLive(cid)
    dat = {}
    for slot = CONST_SLOT_FIRST, CONST_SLOT_LAST do
        local item = getPlayerSlotItem(cid, slot)
        if isContainer(item.uid) then
            local items = getItemsInContainerById(item.uid, pokeout)
            for _, ui in pairs(items) do
                if getItemAttribute(ui, "poke"):sub(#getItemAttribute(ui, "poke")) == "." then
                    table.insert(dat, ui)
                end  
            end
       end
       
       if item.itemid == pokeout then
            if getItemAttribute(item.uid, "poke"):sub(#getItemAttribute(item.uid, "poke")) == "." then
            table.insert(dat, item.uid)
            end
        end
    end
    return dat
end

 



Agora Go/back

Vá em data/actions/scripts e crie um arquivo .lua chamado goback.lua e bota dentro :

 

local pokes = {
["Dragon"] = {level = 1, go = "Vai Dragon", back = "Volte Dragon."},
["Demon"] = {level = 8, go = "Vai Demon", back = "Volte Demon."},
["Dragon Lord"] = {level = 8, go = "Vai Dragon Lord", back = "Volte Dragon Lord."},
["Rat"] = {level = 8, go = "Vai Rat", back = "Volte Rat."},
}

local msgunica = false

function onUse(cid, item, frompos, item2, topos)
    
    local maxh = tonumber(getItemAttribute(item.uid, "poke"):match("/(.+)]"))
    local health = tonumber(getItemAttribute(item.uid, "poke"):match("%[(.-)/"))
    
    if item.itemid == pokeout then
        
        if health ~= nil and health <= 0 then
            return doPlayerSendCancel(cid, "This pokemon is dead.")
        end

        if #getCreatureSummons(cid) >= 1 then
            for _,z in pairs(getCreatureSummons(cid)) do
                if getItemAttribute(item.uid, "poke"):find(getCreatureName(z)) then
                    doTransformItem(item.uid, pokein)
                    if msgunica then
                        doCreatureSay(cid, "Back, " .. getCreatureName(z), TALKTYPE_SAY)
                    else
                        doCreatureSay(cid, pokes[getCreatureName(z)].back, TALKTYPE_SAY)
                    end
                    doItemSetAttribute(item.uid, "poke", getItemAttribute(item.uid, "poke"):sub(1, findLetter(getItemAttribute(item.uid, "poke"), ".")) .. " 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 not canSummon(cid) then
            return doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTENOUGHROOM)
        end
        
        if getPlayerStorageValue(cid, 63215) >= 1 then
            return doPlayerSendCancel(cid, "You can't use pokeball while surfing.")
        end

        if getPlayerStorageValue(cid, 62314) >= 1 then
            return doPlayerSendCancel(cid, "You can't use pokeball while flying.")
        end

        if getPlayerStorageValue(cid, 59987) >= 1 then
            return doPlayerSendCancel(cid, "You can't use pokeball while riding.")
        end
    
        for i,x in pairs(pokes) do
            if #getCreatureSummons(cid) >= 1 then
                return doPlayerSendCancel(cid, "You already summoned a pokemon.")
            end
            
            if i == getItemAttribute(item.uid, "poke"):sub(9, findLetter(getItemAttribute(item.uid, "poke"), "'")-1) then
                if getPlayerLevel(cid) >= x.level then
                    pk =  doSummonCreature(i, getThingPosition(cid))
                    doConvinceCreature(cid, pk)
                    setCreatureMaxHealth(pk, tonumber(getItemAttribute(item.uid, "poke"):match("/(.+)]")))
                    doCreatureAddHealth(pk, maxh)
                    doCreatureAddHealth(pk, health-maxh)
                    doTransformItem(item.uid, pokeout)
                    if msgunica then
                        doCreatureSay(cid, "Go, " .. i, TALKTYPE_SAY)
                    else
                        doCreatureSay(cid, x.go, TALKTYPE_SAY)
                    end
                    doItemSetAttribute(item.uid, "poke", getItemAttribute(item.uid, "poke"):sub(1, findLetter(getItemAttribute(item.uid, "poke"), ".")))
                    doSendMagicEffect(getCreaturePosition(pk), 10)
                    setPlayerStorageValue(cid, 61204, 1)
                    registerCreatureEvent(pk, "DiePoke")
                    registerCreatureEvent(cid, "PlayerPokeDeath")
                    registerCreatureEvent(cid, "LogoutPoke")
                    break
                else
                    doPlayerSendCancel(cid, "Only players level "..x.level.." or higher can use this pokemon.")
                end
            end
        end
    end
return TRUE
end

 



Agora em actions.xml coloque :


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



2222 e 2223 são os ids da pokebolas

Para evitar Bug

va em data/creaturescript/script e crie um arquivo chamado goback.lua e coloque dentro :

 

function onLogout(cid)
local health,maxhealth = getSummonLifes(cid)
    if getPlayerStorageValue(cid, 61204) >= 1 and getPlayerStorageValue(cid, 63215) <= 0 and getPlayerStorageValue(cid, 62314) <= 0 and getPlayerStorageValue(cid, 59987) <= 0 then
        setPlayerStorageValue(cid, 61205, health)
        setPlayerStorageValue(cid, 61206, maxhealth)
        setPlayerStorageValue(cid, 61204, 0)
        setPlayerStorageValue(cid, 61207, 1)
    end
    
    if getPlayerStorageValue(cid, 62314) >= 1 then
        pos = getCreaturePosition(cid)
        for i = 1,8 do
            doRemoveTile(getPosDirs(getCreaturePosition(cid), i))
        end
        doRemoveTile(getCreaturePosition(cid))
        setPlayerStorageValue(cid, 61941, pos.x)
        setPlayerStorageValue(cid, 61942, pos.y)
        setPlayerStorageValue(cid, 61943, pos.z) 
    end
return TRUE
end

function onLogin(cid)
    local pokes = {
    ["Dragon"] = {lookType=267, speed = 1500},
    ["Rat"] = {lookType=267, speed = 500},
    }

    local pokesfly = {
    ["Dragon"] = {lookType = 216, speed = 500},
    }

    local pokesride = {
    ["Dragon Lord"] = {lookType=4, speed = 3000},
    ["Dragon"] = {lookType=4, speed = 500},
    }
    
    if getPlayerStorageValue(cid, 62314) >= 1 then
        doCreateTile(460, {x=getPlayerStorageValue(cid, 61941), y=getPlayerStorageValue(cid, 61942), z=getPlayerStorageValue(cid, 61943)})
        doTeleportThing(cid, {x=getPlayerStorageValue(cid, 61941), y=getPlayerStorageValue(cid, 61942), z=getPlayerStorageValue(cid, 61943)}) 
        for i = 1,8 do
            doItem(getPosDirs(getCreaturePosition(cid), i), 65119+i)
        end
        local item = getPokeOutLive(cid)[1]
        local a = getItemAttribute(item, "poke"):match("This is (.-)'s pokeball.")
        doSetCreatureOutfit(cid, pokesfly[tostring(a)], -1)
        doChangeSpeed(cid, pokesfly[tostring(a)].speed)
        registerCreatureEvent(cid, "PlayerPokeDeath")  
    end

    if getPlayerStorageValue(cid, 63215) >= 1 then
        local item = getPokeOutLive(cid)[1]
        local a = getItemAttribute(item, "poke"):match("This is (.-)'s pokeball.")
        doSetCreatureOutfit(cid, pokes[tostring(a)], -1)
        doChangeSpeed(cid, pokes[tostring(a)].speed)
        registerCreatureEvent(cid, "PlayerPokeDeath")
    end

    if getPlayerStorageValue(cid, 59987) >= 1 then
        local item = getPokeOutLive(cid)[1]
        local a = getItemAttribute(item, "poke"):match("This is (.-)'s pokeball.")
        doSetCreatureOutfit(cid, pokesride[tostring(a)], -1)
        doChangeSpeed(cid, pokesride[tostring(a)].speed)
        registerCreatureEvent(cid, "PlayerPokeDeath")
    end

    if getPlayerStorageValue(cid, 61207) >= 1 then
        local item = getPokeOutLive(cid)[1]
        doTransformItem(item, pokein)
        doRemoveCondition(cid, CONDITION_OUTFIT)
        doItemSetAttribute(item, "poke", getItemAttribute(item, "poke"):sub(#getItemAttribute(item, "poke")) ~= "]" and getItemAttribute(item, "poke") .. " HP = ["..getPlayerStorageValue(cid, 61205).."/"..getPlayerStorageValue(cid, 61206).."]" or getItemAttribute(item, "poke"))
        setPlayerStorageValue(cid, 61207, 0)
    end

return TRUE
end

function onDeath(cid, deathList)
    local owner = getCreatureMaster(cid)
    doPlayerSendTextMessage(owner, 22, "Your pokemon died.")
    
    for slot = CONST_SLOT_FIRST, CONST_SLOT_LAST do
        local item = getPlayerSlotItem(owner, slot)
        if isContainer(item.uid) then
            local items = getItemsInContainerById(item.uid, pokeout)
            for _, ui in pairs(items) do
                if getItemAttribute(ui, "poke"):sub(#getItemAttribute(ui, "poke")) == "." then
                    local maxh = tonumber(getItemAttribute(ui, "poke"):match("/(.+)]"))
                    doItemSetAttribute(ui, "poke", getItemAttribute(ui, "poke"):sub(1, findLetter(getItemAttribute(ui, "poke"), ".")) .. " HP = [0/"..getCreatureMaxHealth(cid).."]")
                end
            end
       end
       
       if item.itemid == pokeout then
            if getItemAttribute(item.uid, "poke"):sub(#getItemAttribute(item.uid, "poke")) == "." then
                local maxh = tonumber(getItemAttribute(item.uid, "poke"):match("/(.+)]"))
                doItemSetAttribute(item.uid, "poke", getItemAttribute(item.uid, "poke"):sub(1, findLetter(getItemAttribute(item.uid, "poke"), ".")) .. " HP = [0/"..getCreatureMaxHealth(cid).."]")
            end
       end
    end
    doRemoveCreature(cid)
    setPlayerStorageValue(owner, 61207, 0)
    setPlayerStorageValue(owner, 61204, 0)
return FALSE
end 

 



Agora adicione outro arquivo .lua em data/creaturescript/script com o nome de playerpdeath e coloque isto dentro :

 

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
    
    if getPlayerStorageValue(cid, 63215) >= 1 then
        setPlayerStorageValue(cid, 61205, getPlayerStorageValue(cid, 61210))
        setPlayerStorageValue(cid, 61206, getPlayerStorageValue(cid, 61209))
        setPlayerStorageValue(cid, 61204, 0)
        setPlayerStorageValue(cid, 63215, 0)
        setPlayerStorageValue(cid, 61207, 1)
    end

    if getPlayerStorageValue(cid, 62314) >= 1 then
        setPlayerStorageValue(cid, 61205, getPlayerStorageValue(cid, 61262))
        setPlayerStorageValue(cid, 61206, getPlayerStorageValue(cid, 61263))
        setPlayerStorageValue(cid, 61204, 0)
        setPlayerStorageValue(cid, 62314, 0)
        setPlayerStorageValue(cid, 61207, 1)
    end

    if getPlayerStorageValue(cid, 59987) >=1 then
        setPlayerStorageValue(cid, 61205, getPlayerStorageValue(cid, 59988))
        setPlayerStorageValue(cid, 61206, getPlayerStorageValue(cid, 59989))
        setPlayerStorageValue(cid, 61204, 0)
        setPlayerStorageValue(cid, 59987, 0)
        setPlayerStorageValue(cid, 61207, 1)
    end
return TRUE
end 

 



Agora adicione em creaturescript.xml 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"/>



Agora o catch.lua

vá em data/actions/script/ e crie um arquivo catch.lua e coloque dentro :

 

local pokes = {
["Dragon"] = {corpseid = 5973, chance = 100, health = 12200, maxhealth = 12200},
["Dragon Lord"] = {corpseid = 5984, chance = 100, health = 12200, maxhealth = 12200},
["Demon"] = {corpseid = 5995, chance = 100, health = 12200, maxhealth = 12200},
}

local time = 4 -- Tempo para mandar as mensagens e adiciona item

function onUse(cid, item, frompos, item2, topos)
    for i,x in pairs(pokes) do
        if item2.itemid == x.corpseid then
            doRemoveItem(item.uid, 1)
            doRemoveItem(item2.uid, 1)
            if math.random(1,100) <= x.chance then
                function add()
                    local s = doPlayerAddItem(cid, pokein)
                    doItemSetAttribute(s, "poke", "This is "..i.."'s pokeball. HP = ["..x.health.."/"..x.maxhealth.."]")
                    doItemSetAttribute(s, "description", "Contains a " .. i)
                end
                doSendMagicEffect(topos, 24)
                addEvent(add, time*1000)
                return addEvent(doPlayerSendTextMessage, time*1000, cid, 27, "You catch a " .. i .. ".")
            else
                addEvent(doPlayerSendTextMessage, time*1000, cid, 27, "Your pokeball broke.")
                return doSendMagicEffect(topos, 23)
            end
        end
    end
return TRUE
end 


O npc que heala!!

vá em data/npc/script e crie um script .lua chamado de pokehealer.lua e coloque isto dentro :

 

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
    
    if msgcontains(msg, 'heal') then
        if #getCreatureSummons(cid) >= 1 then
            return selfSay('Voce precisa botar seus pokemons dentro da pokebola.', cid)
        end

    for slo = CONST_SLOT_FIRST, CONST_SLOT_LAST do
        local item = getPlayerSlotItem(cid, slo)
            if isContainer(item.uid) then
                local items = getItemsInContainerById(item.uid, pokeout)
                    for i,x in pairs(items) do
                        local maxh = tonumber(getItemAttribute(x, "poke"):match("/(.+)]"))
                        doItemSetAttribute(x, "poke", getItemAttribute(x, "poke"):sub(1, findLetter(getItemAttribute(x, "poke"), ".")) .. " HP = ["..maxh.."/"..maxh.."]")
                        doTransformItem(x, pokein)
                    end
                local items2 = getItemsInContainerById(item.uid, pokein)
                    for i,x in pairs(items2) do
                        local maxh = tonumber(getItemAttribute(x, "poke"):match("/(.+)]"))
                        doItemSetAttribute(x, "poke", getItemAttribute(x, "poke"):sub(1, findLetter(getItemAttribute(x, "poke"), ".")) .. " HP = ["..maxh.."/"..maxh.."]")
                     end

                    elseif item.itemid == pokeout or item.itemid == pokein then
                         local maxh = tonumber(getItemAttribute(item.uid, "poke"):match("/(.+)]"))
                         doItemSetAttribute(item.uid, "poke", getItemAttribute(item.uid, "poke"):sub(1, findLetter(getItemAttribute(item.uid, "poke"), ".")) .. " HP = ["..maxh.."/"..maxh.."]")
                         doTransformItem(item.uid, pokein)
                    end
    end
        
        selfSay('Pronto, voce e seus pokemons estao com a life maxima.', cid)  
    end
    return true
end

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

 



Agora em Data/npc crie um arquivo .xml com o nome de Poke Healer e coloque isto dentro :

 

<?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> 

 




Pronto galera é isto!!! Não pesão suporte para min pq não sou o criador do script apenas postei e traduzi para PT

Créditos :

Xtibia (eu peguei de um fórum espanhol e la os creditos estavão este)
Zet0N0Murmurou (Por traduzir para PT)

el 2222;2223 son las id de las pokebolas

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...