Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getPokemonByName(cid, pokemon)
- local arraypoke = {}
- local container = getPlayerSlotItem(cid, 3).uid
- local pokeballs = getPokeballsInContainer(container)
- for i =1, #pokeballs do
- name = getItemAttribute(pokeballs[i], "poke")
- if pokemon == name then
- table.insert(arraypoke, pokeballs[i])
- return arraypoke[1]
- end
- end
- return false
- end
- function tranfBallInShiny(pokeball)
- doItemSetAttribute(pokeball, "shiny", "shiny")
- return true
- end
- function getShinyByPokeball(pokeball)
- local shiny = getItemAttribute(pokeball, "shiny")
- return shiny == "shiny" and true or false
- end
- function getShinyNameByPokeball(pokeball)
- local shiny = getItemAttribute(pokeball, "shiny")
- return shiny and "Shiny "..getItemAttribute(pokeball, "poke").."" or getItemAttribute(pokeball, "poke")
- end
- function setStatusPokeballByStatusStr(pokeball, status)
- local attr = string.explode(status, ",")
- local x = {"poke", "hp", "offense", "defense", "speed", "vitality", "specialattack", "happy", "gender", "hands", "description", "fakedesc", "boost", "ball", "defeated", "shiny"}
- for i =1, #attr do
- doItemSetAttribute(pokeball, x[i], attr[i])
- end
- end
- function copieAllStatusBalls(pokeball)
- local x = {"poke", "hp", "offense", "defense", "speed", "vitality", "specialattack", "happy", "gender", "hands", "description", "fakedesc", "boost", "ball", "defeated", "shiny"}
- str = ""
- sep = ","
- for i =1, #x do
- local attr = getItemAttribute(pokeball, x[i]) or 0
- local t = attr ..sep
- str = str..t
- end
- return str
- end
- function atualizaPokes(cid)
- local item = getPlayerSlotItem(cid, 8)
- if item.uid <= 0 then return true end
- if not getItemAttribute(item.uid, "poke") then
- return true
- end
- for i, x in pairs(fotos) do
- if string.lower(getItemAttribute(item.uid, "poke")) == string.lower(i) then
- doTransformItem(getPlayerSlotItem(cid, 7).uid, fotos[i])
- if useOTClient then
- doPlayerSendCancel(cid, '12//,show')
- end
- if useKpdoDlls then
- doUpdateMoves(cid)
- end
- end
- end
- end
- function doSendPokemon(cid, pokemon)
- if getPlayerStorageValue(cid, 17000) >= 1 or getPlayerStorageValue(cid, 17001) >= 1 or getPlayerStorageValue(cid, 63215) >= 1
- or getPlayerStorageValue(cid, 75846) >= 1 or getPlayerStorageValue(cid, 5700) >= 1 then --alterado v1.9 <<
- return true
- end
- if exhaustion.get(cid, 6666) and exhaustion.get(cid, 6666) > 0 then return true end
- if #getCreatureSummons(cid) > 1 and getPlayerStorageValue(cid, 212124) <= 0 then --alterado v1.6
- if getPlayerStorageValue(cid, 637501) == -2 or getPlayerStorageValue(cid, 637501) >= 1 then
- BackTeam(cid)
- end
- end
- if #getCreatureSummons(cid) > 0 then
- t = getPlayerSlotItem(cid, 8)
- local btype = getPokeballType(t.itemid)
- local effect = pokeballs[btype].effect or 21
- doReturnPokemon(cid, getCreatureSummons(cid)[1], t,effect)
- end
- t = getPlayerSlotItem(cid, 8)
- if t.uid ~= 0 then
- pokeslot = getItemAttribute(t.uid, "poke")
- if pokeslot == pokemon then
- t = getPlayerSlotItem(cid, 8)
- doGoPokemon(cid, t)
- atualizaPokes(cid)
- return true
- end
- if getPokemonByName(cid, pokemon) then
- local poke = getPokemonByName(cid, pokemon)
- local attr = copieAllStatusBalls(t.uid)
- local id = t.itemid
- doRemoveItem(t.uid)
- local attr2 = copieAllStatusBalls(poke)
- local id2 = getThing(poke).itemid
- doRemoveItem(getPokemonByName(cid, pokemon))
- createBallByStatus(cid, attr2, id2)
- createBallByStatus(cid, attr, id)
- t = getPlayerSlotItem(cid, 8)
- doGoPokemon(cid, t)
- atualizaPokes(cid)
- return true
- end
- end
- if getPokemonByName(cid, pokemon) then
- local id = getThing(getPokemonByName(cid, pokemon)).itemid
- local attr = copieAllStatusBalls(getPokemonByName(cid, pokemon))
- doRemoveItem(getPokemonByName(cid, pokemon))
- createBallByStatus(cid, attr, id)
- t = getPlayerSlotItem(cid, 8)
- doGoPokemon(cid, t)
- atualizaPokes(cid)
- return true
- end
- return false
- end
- function sendPokeInfo(cid)
- local activeimg = true
- local poke = getPlayerSlotItem(cid, 8)
- local pokeslot = getItemAttribute(poke.uid, "poke")
- local pokeboost = getItemAttribute(poke.uid, "boost") or 0
- local pokehappy = getPlayerStorageValue(getCreatureSummons(cid)[1], 1008) or 1
- doPlayerSendCancel(cid, "NewInfo/"..pokeslot.."/"..pokeboost.."/"..pokehappy.."")
- if activeimg then
- local img = "ShowPoke/"
- doPlayerSendCancel(cid, img..pokeslot)
- end
- end
- function doShowSelectChar(cid)
- doPlayerSendCancel(cid, "ShowChar")
- end
- function doCloseSelectChar(cid)
- doPlayerSendCancel(cid, "CloseChar")
- end
- function doShowLookPlayer(cid, target, msg)
- doPlayerSendCancel(cid, "ShowLook/"..getPlayerStorageValue(target, 21121).."/"..msg.."")
- end
- function doCloseInfoPoke(cid)
- local activeimg = true
- doPlayerSendCancel(cid, "InfoClosed")
- if activeimg then
- local close = "ClosePoke"
- doPlayerSendCancel(cid, close)
- end
- end
- function sendAllPokemonsBarPoke(cid)
- local container = getPlayerSlotItem(cid, 3).uid
- local pokes = "Pokebar"
- local t = getPlayerSlotItem(cid, 8)
- if t.uid ~= 0 then
- pokeslot = getItemAttribute(t.uid, "poke")
- pokes = pokes.."/"..pokeslot..""
- end
- local pokeballs = getPokeballsInContainer(container)
- for i =1, #pokeballs do
- pokemons = getItemAttribute(pokeballs[i], "poke")
- pokes = pokes.."/"..pokemons..""
- end
- doPlayerSendCancel(cid, pokes)
- end
- function isPlayerOnline(uid)
- return isInArray(getPlayersOnline(), uid)
- end
- function doRevivePokemon(cid, pokemon)
- if getPlayerItemCount(cid, 12344) <= 0 then return doPlayerSendCancel(cid, "Voce nao tem nenhum revive.") end
- local cooldownMoves = {
- ["Selfdestruct"] = 30,
- ["Selfdestruction"] = 30,
- }
- local balls = getPokeballsInContainerNew(getPlayerSlotItem(cid, 3).uid)
- if isPokeball(getPlayerSlotItem(cid, CONST_SLOT_FEET).itemid) then
- table.insert(balls, getPlayerSlotItem(cid, CONST_SLOT_FEET))
- end
- for i =1, #balls do
- local ball = balls[i]
- -- print("Pokemon: "..pokemon.." attrpoke> "..(getItemAttribute(ball.uid, "poke") or "sempoke").." attrnick> "..(getItemAttribute(ball.uid, "nick") or "sem nick"))
- if getItemAttribute(ball.uid, "poke") == pokemon or getItemAttribute(ball.uid, "nick") == pokemon then
- -- print("IGUAL")
- for type, index in pairs(pokeballs) do
- -- print(index.on.." / "..index.off)
- if ball.itemid == index.on or ball.itemid == index.off then
- -- print("revive")
- doTransformItem(ball.uid, index.on)
- doSetItemAttribute(ball.uid, "hp", 1)
- local name = getItemAttribute(ball.uid, "poke")
- for c = 1, 15 do
- local str = "move"..c
- local move = movestable[name][str]; move = move and cooldownMoves[move.name]
- setCD(ball.uid, str, move or 0)
- end
- setCD(ball.uid, "control", 0)
- setCD(ball.uid, "blink", 0) --alterado v1.6
- doSendMagicEffect(getThingPos(cid), 13)
- doPlayerRemoveItem(cid, 12344, 1)
- doCureBallStatus(ball.uid, "all")
- doUpdatePokemonsBar(cid)
- cleanBuffs2(ball.uid) --alterado v1.5
- return
- end
- end
- end
- end
- end
- function getPokeballsInContainerNew(container)
- if not isContainer(container) then return {} end
- 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 = getPokeballsInContainerNew(item.uid)
- for i=0, #itemsbag do
- table.insert(items, itemsbag[i])
- end
- elseif isPokeball(item.itemid) then
- table.insert(items, item)
- end
- end
- end
- return items
- end
- function getVitalityByMaster(cid)
- if not isCreature(cid) then return 0 end
- local ball = getPlayerSlotItem(cid, 8).uid
- if not ball or ball <= 1 or not pokes[getItemAttribute(ball, 'poke')] then return true end
- return pokes[getItemAttribute(ball, 'poke')].vitality * (getPlayerLevel(cid) + (getItemAttribute(ball, 'boost') or 0))
- end
- function onPokeHealthChange(cid, zerar)
- if not isCreature(cid) then return true end
- if zerar then doPlayerSendCancel(cid, '#ph#,0,0') end
- local ball = getPlayerSlotItem(cid, 8).uid
- if not ball or ball <= 1 or not pokes[getItemAttribute(ball, 'poke')] then return true end
- if #getCreatureSummons(cid) >= 1 and getPlayerStorageValue(cid, 212124) <= 0 then --alterado v1.6
- local pokemon = getCreatureSummons(cid)[1]
- local pokelife = (getCreatureHealth(pokemon) / getCreatureMaxHealth(pokemon))
- doItemSetAttribute(ball, "hp", pokelife)
- end
- local rd = 1 - (tonumber(getItemAttribute(ball, "hp")))
- local maxHp = HPperVITsummon * getVitalityByMaster(cid)
- local hp = maxHp -(maxHp * rd)
- doPlayerSendCancel(cid, '#ph#,'.. math.floor(hp) ..','.. math.floor(maxHp))
- end
- function doOTCSendPokemonHealth(cid)
- local ball = getPlayerSlotItem(cid, CONST_SLOT_FEET)
- local pokemon = getCreatureSummons(cid)
- if not ball.uid or ball.uid <= 1 then
- return doSendPlayerExtendedOpcode(cid, 122, "0|0")
- end
- if #pokemon >= 1 then
- return doSendPlayerExtendedOpcode(cid, 122, getCreatureHealth(pokemon[1]).."|"..getCreatureMaxHealth(pokemon[1]))
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement