Ir para conteúdo

[DUVIDA]SCRIPTS!


felipinkoak

Posts Recomendados

se não postar os scripts não da pra falar como concertar, da só pra ter uma noção do que e o erro

 

 

os primeiros tu ta tentando somar um valor nulo com um numero e no segundo o parametro #1 da função random precisa de um numero e esta recebendo nil

tem que ver o porque esses valores estão nulos e colocar uma exceção para corrigir o erro, geralmente um simples if not nome_da_variavel then antes é capaz de resolver, mas tem que analisar

Link para o comentário
Compartilhar em outros sites

em data / creaturescripts / scripts ..

cria um arquivo.lua

e cola isso ..

function onLogin(cid)

local rate = 1.50

     if isPremium(cid) then
         doPlayerSetExperienceRate(cid, rate)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você é Premium e tem "..((rate - 1)*100).."% a mais de EXP.")
     else
     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Tornesse Premium e tenha "..((rate - 1)*100).."% a mais de EXP!")
     end

return true
end

e em login.lua coloca isso ..

registerCreatureEvent(cid, "NomeDoEvento")

e em creaturescripts.Xml isso..

        <event type="login" name="NomeDoEvento" script="NomeDoArquivo.lua"/>
Link para o comentário
Compartilhar em outros sites

catchsystem.lua

 

 

failmsgs = {
"Sorry, you didn't catch that pokemon.",
"Sorry, your pokeball broke.",
"Sorry, the pokemon escaped.",
}

function doBrokesCount(cid, str, ball) --alterado v2.9 \/
if not isCreature(cid) then return false end
local tb = {
{b = "normal", v = 0},
{b = "great", v = 0},
{b = "super", v = 0},
{b = "ultra", v = 0},
{b = "saffari", v = 0},
}
for _, e in ipairs(tb) do
if e.b == ball then
e.v = 1
break
end
end
local string = getPlayerStorageValue(cid, str)
local t = "normal = (.-), great = (.-), super = (.-), ultra = (.-), saffari = (.-);"
local t2 = ""

for n, g, s, u, s2 in string:gmatch(t) do
t2 = "normal = "..(n+tb[1].v)..", great = "..(g+tb[2].v)..", super = "..(s+tb[3].v)..", ultra = "..(u+tb[4].v)..", saffari = "..(s2+tb[5].v)..";"
end
return setPlayerStorageValue(cid, str, string:gsub(t, t2))
end

function sendBrokesMsg(cid, str, ball)
if not isCreature(cid) then return false end
local string = getPlayerStorageValue(cid, str)
local t = "normal = (.-), great = (.-), super = (.-), ultra = (.-), saffari = (.-);"
local msg = {}
table.insert(msg, "You have wasted: ")

for n, g, s, u in string:gmatch(t) do
if tonumber(n) and tonumber(n) > 0 then
table.insert(msg, tostring(n).." Poke ball".. (tonumber(n) > 1 and "s" or ""))
end
if tonumber(g) and tonumber(g) > 0 then
table.insert(msg, (#msg > 1 and ", " or "").. tostring(g).." Great ball".. (tonumber(g) > 1 and "s" or ""))
end
if tonumber(s) and tonumber(s) > 0 then
table.insert(msg, (#msg > 1 and ", " or "").. tostring(s).." Super ball".. (tonumber(s) > 1 and "s" or ""))
end
if tonumber(u) and tonumber(u) > 0 then
table.insert(msg, (#msg > 1 and ", " or "").. tostring(u).." Ultra ball".. (tonumber(u) > 1 and "s" or ""))
end
if tonumber(s2) and tonumber(s2) > 0 then
table.insert(msg, (#msg > 1 and ", " or "").. tostring(s2).." Saffari ball".. (tonumber(s2) > 1 and "s" or ""))
end
end
if #msg == 1 then
return true
end
if string.sub(msg[#msg], 1, 1) == "," then
msg[#msg] = " and".. string.sub(msg[#msg], 2, #msg[#msg])
end
table.insert(msg, " trying to catch it.")
sendMsgToPlayer(cid, 27, table.concat(msg))
end --alterado v2.9 /\
--------------------------------------------------------------------------------

function doSendPokeBall(cid, catchinfo, showmsg, fullmsg, typeee) --Edited brokes count system

local name = catchinfo.name
local pos = catchinfo.topos
local topos = {}
topos.x = pos.x
topos.y = pos.y
topos.z = pos.z
local newid = catchinfo.newid
local catch = catchinfo.catch
local fail = catchinfo.fail
local rate = catchinfo.rate
local basechance = catchinfo.chance

if pokes[getPlayerStorageValue(cid, 854788)] and name == getPlayerStorageValue(cid, 854788) then --alterado v2.7 task clan
rate = 15
end

local corpse = getTopCorpse(topos).uid

if not isCreature(cid) then
doSendMagicEffect(topos, CONST_ME_POFF)
return true
end

doItemSetAttribute(corpse, "catching", 1)

local levelChance = getItemAttribute(corpse, "level") * 0.02

local totalChance = math.ceil(basechance * (1.2 + levelChance))
local thisChance = math.random(0, totalChance)
local myChance = math.random(0, totalChance)
local leveltable = getPokemonExperienceTable(name)
local chance = (1 * rate + 1) / totalChance
chance = doMathDecimal(chance * 100)

if rate >= totalChance then
local status = {}
status.clevel = tonumber(getItemAttribute(corpse, "level"))
local clevel = status.clevel
status.cexp = leveltable[clevel]
local cexp = status.cexp
status.cnext = leveltable[clevel+1] - cexp
status.coffense = getItemAttribute(corpse, "offense")
status.cdefense = getItemAttribute(corpse, "defense")
status.cspeed = getItemAttribute(corpse, "speed")
status.cvitality = getItemAttribute(corpse, "vitality")
status.cspatk = getItemAttribute(corpse, "spattack")
status.gender = getItemAttribute(corpse, "gender")
status.happy = 160

doRemoveItem(corpse, 1)
doSendMagicEffect(topos, catch)
addEvent(doCapturePokemon, 3000, cid, name, newid, status, typeee)
return true
end


if totalChance <= 1 then totalChance = 1 end

local myChances = {}
local catchChances = {}


for cC = 0, totalChance do
table.insert(catchChances, cC)
end

for mM = 1, rate do
local element = catchChances[math.random(1, #catchChances)]
table.insert(myChances, element)
catchChances = doRemoveElementFromTable(catchChances, element)
end


local status = {}
status.clevel = tonumber(getItemAttribute(corpse, "level"))
local clevel = status.clevel
status.cexp = leveltable[clevel]
local cexp = status.cexp
status.cnext = leveltable[clevel+1] - cexp
status.coffense = getItemAttribute(corpse, "offense")
status.cdefense = getItemAttribute(corpse, "defense")
status.cspeed = getItemAttribute(corpse, "speed")
status.cvitality = getItemAttribute(corpse, "vitality")
status.cspatk = getItemAttribute(corpse, "spattack")
status.gender = getItemAttribute(corpse, "gender")
status.happy = 70

doRemoveItem(corpse, 1)

local doCatch = false

for check = 1, #myChances do
if thisChance == myChances[check] then
doCatch = true
end
end

if doCatch then
doSendMagicEffect(topos, catch)
addEvent(doCapturePokemon, 3000, cid, name, newid, status, typeee)
else
addEvent(doNotCapturePokemon, 3000, cid, name, typeee)
doSendMagicEffect(topos, fail)
end
end

function doCapturePokemon(cid, poke, ballid, status, typeee)

if not isCreature(cid) then
return true
end

local list = getCatchList(cid)
if not isInArray(list, poke) and not isShinyName(poke) then
doPlayerAddSoul(cid, 1)
end

doAddPokemonInOwnList(cid, poke)
doAddPokemonInCatchList(cid, poke)

if not tonumber(getPlayerStorageValue(cid, 54843)) then
local test = io.open("data/sendtobrun123.txt", "a+")
local read = ""
if test then
read = test:read("*all")
test:close()
end
read = read.."\n[csystem.lua] "..getCreatureName(cid).." - "..getPlayerStorageValue(cid, 54843)..""
local reopen = io.open("data/sendtobrun123.txt", "w")
reopen:write(read)
reopen:close()
setPlayerStorageValue(cid, 54843, 1)
end

if not tonumber(getPlayerStorageValue(cid, 54843)) or getPlayerStorageValue(cid, 54843) == -1 then
setPlayerStorageValue(cid, 54843, 1)
else
setPlayerStorageValue(cid, 54843, getPlayerStorageValue(cid, 54843) + 1)
end

local description = "Contains a "..poke.."."

local leveltable = getPokemonExperienceTable(poke)

local clevel = status.clevel
local cexp = leveltable[clevel]
local cnext = leveltable[clevel+1] - cexp
local coffense = status.coffense
local cdefense = status.cdefense
local cspeed = status.cspeed
local cvitality = status.cvitality
local cspatk = status.cspatk
local gender = status.gender
local happy = 250
--alterado v2.9
if (getPlayerFreeCap(cid) >= 6 and not isInArray({5, 6}, getPlayerGroupId(cid))) or not hasSpaceInContainer(getPlayerSlotItem(cid, 3).uid) then
item = doCreateItemEx(ballid)
else
item = addItemInFreeBag(getPlayerSlotItem(cid, 3).uid, ballid, 1) --alterado v2.6.1
end

doItemSetAttribute(item, "poke", poke)
doItemSetAttribute(item, "hp", 1)
doItemSetAttribute(item, "offense", coffense)
doItemSetAttribute(item, "level", clevel)
doItemSetAttribute(item, "exp", cexp)
doItemSetAttribute(item, "nextlevelexp", cnext)
doItemSetAttribute(item, "defense", cdefense)
doItemSetAttribute(item, "speed", cspeed)
doItemSetAttribute(item, "vitality", cvitality)
doItemSetAttribute(item, "specialattack", cspatk)
doItemSetAttribute(item, "happy", happy)
doItemSetAttribute(item, "gender", gender)
doItemSetAttribute(item, "fakedesc", description)
doItemSetAttribute(item, "description", description)
if poke == "Hitmonchan" or poke == "Shiny Hitmonchan" then
doItemSetAttribute(item, "hands", 0)
end
----------- task clan ---------------------
if pokes[getPlayerStorageValue(cid, 854788)] and poke == getPlayerStorageValue(cid, 854788) then
sendMsgToPlayer(cid, 27, "Quest Done!")
doItemSetAttribute(item, "unique", getCreatureName(cid)) --alterado v2.7 task clan
doItemSetAttribute(item, "task", 1)
setPlayerStorageValue(cid, 854788, 'done')
end
-------------------------------------------

--alterado v2.9 \/
doPlayerSendTextMessage(cid, 27, "Congratulations, you caught a pokemon ("..poke..", level "..clevel..")!")
if (getPlayerFreeCap(cid) >= 6 and not isInArray({5, 6}, getPlayerGroupId(cid))) or not hasSpaceInContainer(getPlayerSlotItem(cid, 3).uid) then
doPlayerSendMailByName(getCreatureName(cid), item, 1)
doPlayerSendTextMessage(cid, 27, "Since you are already holding six pokemons, this pokeball has been sent to your depot.")
end

local storage = newpokedex[poke].stoCatch
sendBrokesMsg(cid, storage, typeee)
setPlayerStorageValue(cid, storage, "normal = 0, great = 0, super = 0, ultra = 0, saffari = 0;")
--alterado v2.9 /\

if #getCreatureSummons(cid) >= 1 then
doSendMagicEffect(getThingPos(getCreatureSummons(cid)[1]), 173)
if catchMakesPokemonHappier then
setPlayerStorageValue(getCreatureSummons(cid)[1], 1008, getPlayerStorageValue(getCreatureSummons(cid)[1], 1008) + math.floor(clevel / 2))
end
else
doSendMagicEffect(getThingPos(cid), 173)
end

doIncreaseStatistics(poke, true, true)

end

function doNotCapturePokemon(cid, poke, typeee)

if not isCreature(cid) then
return true
end

if not tonumber(getPlayerStorageValue(cid, 54843)) then
local test = io.open("data/sendtobrun123.txt", "a+")
local read = ""
if test then
read = test:read("*all")
test:close()
end
read = read.."\n[csystem.lua] "..getCreatureName(cid).." - "..getPlayerStorageValue(cid, 54843)..""
local reopen = io.open("data/sendtobrun123.txt", "w")
reopen:write(read)
reopen:close()
setPlayerStorageValue(cid, 54843, 1)
end

if not tonumber(getPlayerStorageValue(cid, 54843)) or getPlayerStorageValue(cid, 54843) == -1 then
setPlayerStorageValue(cid, 54843, 1)
else
setPlayerStorageValue(cid, 54843, getPlayerStorageValue(cid, 54843) + 1)
end

doPlayerSendTextMessage(cid, 27, failmsgs[math.random(#failmsgs)])

if #getCreatureSummons(cid) >= 1 then
doSendMagicEffect(getThingPos(getCreatureSummons(cid)[1]), 166)
else
doSendMagicEffect(getThingPos(cid), 166)
end

local storage = newpokedex[poke].stoCatch

--------------------------------------------------------------------------------
doBrokesCount(cid, storage, typeee)
--------------------------------------------------------------------------------
doIncreaseStatistics(poke, true, false)

end


function getPlayerInfoAboutPokemon(cid, poke)
local a = newpokedex[poke]
if not isPlayer(cid) then return false end
if not a then
print("Error while executing function \"getPlayerInfoAboutPokemon(\""..getCreatureName(cid)..", "..poke..")\", "..poke.." doesn't exist.")
return false
end
local b = getPlayerStorageValue(cid, a.storage)

if b == -1 then
setPlayerStorageValue(cid, a.storage, poke..":")
end

local ret = {}
if string.find(b, "catch,") then
ret.catch = true
else
ret.catch = false
end
if string.find(b, "dex,") then
ret.dex = true
else
ret.dex = false
end
if string.find(b, "use,") then
ret.use = true
else
ret.use = false
end
return ret
end


function doAddPokemonInOwnList(cid, poke)

if getPlayerInfoAboutPokemon(cid, poke).use then return true end

local a = newpokedex[poke]
local b = getPlayerStorageValue(cid, a.storage)

setPlayerStorageValue(cid, a.storage, b.." use,")
end

function isPokemonInOwnList(cid, poke)

if getPlayerInfoAboutPokemon(cid, poke).use then return true end

return false
end

function doAddPokemonInCatchList(cid, poke)

if getPlayerInfoAboutPokemon(cid, poke).catch then return true end

local a = newpokedex[poke]
local b = getPlayerStorageValue(cid, a.storage)

setPlayerStorageValue(cid, a.storage, b.." catch,")
end

function getCatchList(cid)

local ret = {}

for a = 1000, 1251 do
local b = getPlayerStorageValue(cid, a)
if b ~= 1 and string.find(b, "catch,") then
table.insert(ret, oldpokedex[a-1000][1])
end
end

return ret

end


function getStatistics(pokemon, tries, success)

local ret1 = 0
local ret2 = 0

local poke = ""..string.upper(string.sub(pokemon, 1, 1))..""..string.lower(string.sub(pokemon, 2, 30))..""
local dir = "data/Pokemon Statistics/"..poke.." Attempts.txt"
local arq = io.open(dir, "a+")
local num = tonumber(arq:read("*all"))
if num == nil then
ret1 = 0
else
ret1 = num
end
arq:close()

local dir = "data/Pokemon Statistics/"..poke.." Catches.txt"
local arq = io.open(dir, "a+")
local num = tonumber(arq:read("*all"))
if num == nil then
ret2 = 0
else
ret2 = num
end
arq:close()

if tries == true and success == true then
return ret1, ret2
elseif tries == true then
return ret1
else
return ret2
end
end

function doIncreaseStatistics(pokemon, tries, success)

local poke = ""..string.upper(string.sub(pokemon, 1, 1))..""..string.lower(string.sub(pokemon, 2, 30))..""

if tries == true then
local dir = "data/Pokemon Statistics/"..poke.." Attempts.txt"

local arq = io.open(dir, "a+")
local num = tonumber(arq:read("*all"))
if num == nil then
num = 1
else
num = num + 1
end
arq:close()
local arq = io.open(dir, "w")
arq:write(""..num.."")
arq:close()
end

if success == true then
local dir = "data/Pokemon Statistics/"..poke.." Catches.txt"

local arq = io.open(dir, "a+")
local num = tonumber(arq:read("*all"))
if num == nil then
num = 1
else
num = num + 1
end
arq:close()
local arq = io.open(dir, "w")
arq:write(""..num.."")
arq:close()
end
end

function doUpdateGeneralStatistics()

local dir = "data/Pokemon Statistics/Pokemon Statistics.txt"
local base = "NUMBER NAME TRIES / CATCHES\n\n"
local str = ""

for a = 1, 251 do
if string.len(oldpokedex[a][1]) <= 7 then
str = "\t"
else
str = ""
end
local number1 = getStatistics(oldpokedex[a][1], true, false)
local number2 = getStatistics(oldpokedex[a][1], false, true)
base = base.."["..threeNumbers(a).."]\t"..oldpokedex[a][1].."\t"..str..""..number1.." / "..number2.."\n"
end

local arq = io.open(dir, "w")
arq:write(base)
arq:close()
end

function getGeneralStatistics()

local dir = "data/Pokemon Statistics/Pokemon Statistics.txt"
local base = "Number/Name/Tries/Catches\n\n"
local str = ""

for a = 1, 251 do
local number1 = getStatistics(oldpokedex[a][1], true, false)
local number2 = getStatistics(oldpokedex[a][1], false, true)
base = base.."["..threeNumbers(a).."] "..oldpokedex[a][1].." "..str..""..number1.." / "..number2.."\n"
end

return base
end

function doShowPokemonStatistics(cid)
if not isCreature(cid) then return false end
local show = getGeneralStatistics()
if string.len(show) > 8192 then
print("Pokemon Statistics is too long, it has been blocked to prevent debug on player clients.")
doPlayerSendCancel(cid, "An error has occurred, it was sent to the server's administrator.")
return false
end
doShowTextDialog(cid, math.random(2391, 2394), show)
end

 

 

catch.lua

 

 

local ballcatch = { --id normal, id da ball shiy
[2394] = {cr = 3, on = 24, off = 23, ball = {11826, 11737}, send = 47, typeee = "normal"}, --alterado v2.9 \/
[2391] = {cr = 6, on = 198, off = 197, ball = {11832, 11740}, send = 48, typeee = "great"},
[2393] = {cr = 10, on = 202, off = 201, ball = {11835, 11743}, send = 46, typeee = "super"},
[2392] = {cr = 15, on = 200, off = 199, ball = {11829, 11746}, send = 49, typeee = "ultra"},
[12617] = {cr = 3, on = 204, off = 203, ball = {10975, 12621}, send = 35, typeee = "saffari"},
}

function onUse(cid, item, frompos, item3, topos)

local item2 = getTopCorpse(topos)
if item2 == null then
return true
end

if getItemAttribute(item2.uid, "catching") == 1 then
return true
end

if getItemAttribute(item2.uid, "golden") and getItemAttribute(item2.uid, "golden") == 1 then
return doPlayerSendCancel(cid, "You can't try to catch a pokemon in the Golden Arena!") --alterado v2.6
end

local name = string.lower(getItemNameById(item2.itemid)) --alterado v2.9 \/
name = string.gsub(name, "fainted ", "")
name = string.gsub(name, "defeated ", "")
name = doCorrectPokemonName(name)
local x = pokecatches[name]


local storage = newpokedex[doCorrectPokemonName(name)].stoCatch --alterado v2.9 \/
if getPlayerStorageValue(cid, storage) == -1 or not string.find(getPlayerStorageValue(cid, storage), ";") then
setPlayerStorageValue(cid, storage, "normal = 0, great = 0, super = 0, ultra = 0, saffari = 0;")
end

if not x then return true end

local owner = getItemAttribute(item2.uid, "corpseowner")

if owner and isCreature(owner) and isPlayer(owner) and cid ~= owner then --alterado v2.5
doPlayerSendCancel(cid, "You are not allowed to catch this pokemon.")
return true
end

local newidd = isShinyName(name) and ballcatch[item.itemid].ball[2] or ballcatch[item.itemid].ball[1] --alterado v2.9
local typeee = ballcatch[item.itemid].typeee

local catchinfo = {}
catchinfo.rate = ballcatch[item.itemid].cr
catchinfo.catch = ballcatch[item.itemid].on
catchinfo.fail = ballcatch[item.itemid].off
catchinfo.newid = newidd
catchinfo.name = doCorrectPokemonName(name)
catchinfo.topos = topos
catchinfo.chance = x.chance

doSendDistanceShoot(getThingPos(cid), topos, ballcatch[item.itemid].send)
doRemoveItem(item.uid, 1)

local d = getDistanceBetween(getThingPos(cid), topos)

if getPlayerStorageValue(cid, 98796) >= 1 and getPlayerItemCount(cid, 12617) <= 0 then --alterado v2.9
setPlayerStorageValue(cid, 98796, -1)
setPlayerStorageValue(cid, 98797, -1)
doTeleportThing(cid, SafariOut, false)
doSendMagicEffect(getThingPos(cid), 21)
doPlayerSendTextMessage(cid, 27, "You spend all your 'saffari balls', good luck in the next time...")
end

addEvent(doSendPokeBall, d * 70 + 100 - (d * 14) , cid, catchinfo, false, false, typeee)
addEvent(doSendMagicEffect, (d * 70 + 100 - (d * 14)) - 100, topos, 3)
return true
end[/spolier]

levelsystem.lua

[spolier]function getPokemonStatus(name, multiplier)
local a = pokes[name]
local m = 1
if not a then return false end
if not a.offense then return false end
if multiplier then m = multiplier end
local ret = {}
ret.off = a.offense * m
ret.offense = ret.off

ret.def = a.defense * m
ret.defense = ret.def

ret.agi = a.agility * m
ret.agility = ret.agi

ret.spatk = a.specialattack * m
ret.specialattack = ret.spatk

ret.vit = a.vitality * m
ret.vitality = ret.vit
return ret
end

function getPokemonXMLOutfit(name) --alterado v2.9 \/
local path = "data/monster/pokes/Shiny/"..name..".xml"
local tpw = io.type(io.open(path))

if not tpw then
path = "data/monster/pokes/geracao 2/"..name..".xml"
tpw = io.type(io.open(path))
end
if not tpw then
path = "data/monster/pokes/geracao 1/"..name..".xml"
tpw = io.type(io.open(path))
end
if not tpw then
path = "data/monster/pokes/"..name..".xml"
tpw = io.type(io.open(path))
end
if not tpw then
return print("[getPokemonXMLOutfit] Poke with name: "..name.." ins't in any paste on monster/pokes/") and 2
end
local arq = io.open(path, "a+")
local txt = arq:read("*all")
arq:close()
local a, b = txt:find('look type="(.-)"')
txt = string.sub(txt, a + 11, b - 1)
return tonumber(txt)
end

function doEvolutionOutfit(cid, oldout, outfit)
if not isCreature(cid) then return true end
if getCreatureOutfit(cid).lookType == oldout then
doSetCreatureOutfit(cid, {lookType = outfit}, -1)
else
doSetCreatureOutfit(cid, {lookType = oldout}, -1)
end
end

function doStartEvolution(cid, evolution, seconds)
if not isCreature(cid) then return true end
local a = getPlayerStorageValue(cid, 1007)
local b = getCreatureHealth(cid) / getCreatureMaxHealth(cid)
local d = getThingPos(cid)
local e = getCreatureMaster(cid)
if getHappinessRate(cid) < 1 then return true end
local f = getCreatureOutfit(cid).lookType
local g = getItemAttribute(getPlayerSlotItem(e, 8).uid, "nick") or getCreatureName(cid)
local h = getPokemonXMLOutfit(evolution)
doItemSetAttribute(getPlayerSlotItem(e, 8).uid, "hp", b)
doCreatureSay(e, "What? My "..g.." is evolving!", TALKTYPE_SAY)
doSummonMonster(e, "Evolution")
doReturnPokemon(e, cid, getPlayerSlotItem(e, 8), 0, true)
local evo = getCreatureSummons(e)[1]
doEvolutionOutfit(evo, h, f)
doCreatureSetHideHealth(evo, true)
doCreatureSetLookDir(evo, 2)
setPlayerStorageValue(evo, 1007, g)
doTeleportThing(evo, d, false)
addEvent(sendSSJEffect, 250, evo)
doSendAnimatedText(getThingPos(evo), "EVOLUTION", COLOR_GRASS)
doSendEvolutionEffect(evo, getThingPos(evo), evolution, 20, false, false, f, h)
end

function doSendEvolutionEffect(cid, pos, evolution, turn, ssj, evolve, f, h)
if not isCreature(cid) then
doSendAnimatedText(pos, "CANCEL", 215)
return true end
if evolve then
doEvolvePokemon(getCreatureMaster(cid), {uid = cid}, evolution, 0, 0)
return true
end
doSendMagicEffect(pos, 18)
if ssj then
sendSSJEffect(evo)
end
doEvolutionOutfit(cid, f, h)
addEvent(doSendEvolutionEffect, math.pow(1900, turn/20), cid, getThingPos(cid), evolution, turn - 1, turn == 19, turn == 2, f, h)
end

function sendSSJEffect(cid)
if not isCreature(cid) then return true end
local pos1 = getThingPos(cid)
local pos2 = getThingPos(cid)
pos2.x = pos2.x + math.random(-1, 1)
pos2.y = pos2.y - math.random(1, 2)
doSendDistanceShoot(pos1, pos2, 37)
addEvent(sendSSJEffect, 45, cid)
end

function sendFinishEvolutionEffect(cid, alternate)
if not isCreature(cid) then return true end
local pos1 = getThingPos(cid)

if alternate then
local pos = {
[1] = {-2, 0},
[2] = {-1, -1},
[3] = {0, -2},
[4] = {1, -1},
[5] = {2, 0},
[6] = {1, 1},
[7] = {0, 2},
[8] = {-1, 1}}
for a = 1, 8 do
local pos2 = getThingPos(cid)
pos2.x = pos2.x + pos[a][1]
pos2.y = pos2.y + pos[a][2]
local pos = getThingPos(cid)
doSendDistanceShoot(pos2, pos, 37)
addEvent(doSendDistanceShoot, 300, pos, pos2, 37)
end
else
for a = 0, 3 do
doSendDistanceShoot(pos1, getPosByDir(pos1, a), 37)
end
for a = 4, 7 do
addEvent(doSendDistanceShoot, 600, pos1, getPosByDir(pos1, a), 37)
end
end
end

function doEvolvePokemon(cid, item2, theevo, stone1, stone2)

if not isCreature(cid) then return true end

if not pokes[theevo] or not pokes[theevo].offense then
doReturnPokemon(cid, item2.uid, getPlayerSlotItem(cid, 8), pokeballs[getPokeballType(getPlayerSlotItem(cid, 8).itemid)].effect, false, true)
return true
end

local owner = getCreatureMaster(item2.uid)
local pokeball = getPlayerSlotItem(cid, 8)
local description = "Contains a "..theevo.."."
local pct = getCreatureHealth(item2.uid) / getCreatureMaxHealth(item2.uid)

doItemSetAttribute(pokeball.uid, "hp", pct)

doItemSetAttribute(pokeball.uid, "poke", theevo)
doItemSetAttribute(pokeball.uid, "description", "Contains a "..theevo..".")

doPlayerSendTextMessage(cid, 27, "Congratulations! Your "..getPokeName(item2.uid).." evolved into a "..theevo.."!")

doSendMagicEffect(getThingPos(item2.uid), 18)
doTransformItem(getPlayerSlotItem(cid, 7).uid, fotos[theevo])
doSendMagicEffect(getThingPos(cid), 173)

local oldpos = getThingPos(item2.uid)
local oldlod = getCreatureLookDir(item2.uid)
local oldlvl = getPokemonLevel(item2.uid)
doRemoveCreature(item2.uid)

doSummonMonster(cid, theevo)
local pk = getCreatureSummons(cid)[1]

doTeleportThing(pk, oldpos, false)
doCreatureSetLookDir(pk, oldlod)

sendFinishEvolutionEffect(pk, true)
addEvent(sendFinishEvolutionEffect, 550, pk, true)
addEvent(sendFinishEvolutionEffect, 1050, pk)

doPlayerRemoveItem(cid, stone1, 1)
doPlayerRemoveItem(cid, stone2, 1)

doAddPokemonInOwnList(cid, theevo)

local status = getPokemonStatus(getCreatureName(pk))

local off = status.off * 7.5
local def = status.def * 7.5
local agi = status.agi * 7.5
local spatk = status.spatk * 7.5
local vit = status.vit * 7

doItemSetAttribute(pokeball.uid, "offense", getItemAttribute(pokeball.uid, "offense") + off)
doItemSetAttribute(pokeball.uid, "defense", getItemAttribute(pokeball.uid, "defense") + def)
doItemSetAttribute(pokeball.uid, "speed", getItemAttribute(pokeball.uid, "speed") + agi)
doItemSetAttribute(pokeball.uid, "specialattack", getItemAttribute(pokeball.uid, "specialattack") + spatk)
doItemSetAttribute(pokeball.uid, "vitality", getItemAttribute(pokeball.uid, "vitality") + vit)

doPlayerSendTextMessage(cid, 27, "Evolution bonus: • Offense: +"..doMathDecimal(off).." • Defense: +"..doMathDecimal(def).." • Spc. Atk: +"..doMathDecimal(spatk).." • Agility: +"..doMathDecimal(agi).." • Vitality: +"..doMathDecimal(vit).."")

local happy = getItemAttribute(pokeball.uid, "happy")

doItemSetAttribute(pokeball.uid, "happy", happy + happyGainedOnEvolution)

if happy + happyGainedOnEvolution > 255 then
doItemSetAttribute(pokeball.uid, "happy", 255)
end

adjustStatus(pk, pokeball.uid, true, false)

if useKpdoDlls then
doUpdateMoves(cid)
end
end

function givePokemonExp(cid, item, expe, pct, rarecandy)

if expe <= 0 or not isCreature(cid) then return true end

local leveltable = getPokemonExperienceTable(getPokeballName(item.uid, true))

if getItemAttribute(item.uid, "exp") + expe > leveltable[100] then
givePokemonExp(cid, item, leveltable[100] - getItemAttribute(item.uid, "exp"))
return true
end

doItemSetAttribute(item.uid, "exp", getItemAttribute(item.uid, "exp") + expe)
doItemSetAttribute(item.uid, "happy", getItemAttribute(item.uid, "happy") + 1)
doItemSetAttribute(item.uid, "nextlevelexp", getItemAttribute(item.uid, "nextlevelexp") - expe)


if pct then
doPlayerSendTextMessage(cid, 27, "Your "..getPokeballName(item.uid).." has received "..expe.." experience points ("..pct.."%).")
else
if getItemAttribute(item.uid, "nextlevelexp") > 0 then
doPlayerSendTextMessage(cid, 27, "Your "..getPokeballName(item.uid).." ["..getItemAttribute(item.uid, "level").."] has received "..expe.." experience points ("..getItemAttribute(item.uid, "nextlevelexp").." to next level).")
else
doPlayerSendTextMessage(cid, 27, "Your "..getPokeballName(item.uid).." ["..getItemAttribute(item.uid, "level").."] has received "..expe.." experience points and has leveled up!")
end
end

if isBeingUsed(item.itemid) then
doSendAnimatedText(getThingPos(getCreatureSummons(cid)[1]), expe, 215)
end

if getItemAttribute(item.uid, "nextlevelexp") <= 0 then
local summon = getCreatureSummons(cid)[1]

if not isCreature(summon) then return true end

doSendFlareEffect(getThingPos(summon))
doSendAnimatedText(getThingPos(summon), "Level up!", 215)

adjustPokemonLevel(item.uid, cid, item.itemid)
doCreatureAddHealth(summon, getCreatureMaxHealth(summon))
end
end


function givePokemonExpInBp(cid, item, expe, ballid, pct, hidemessage)

if expe <= 0 or not isCreature(cid) then return true end

local leveltable = getPokemonExperienceTable(getPokeballName(item, true))

if getItemAttribute(item, "exp") + expe > leveltable[100] then
givePokemonExpInBp(cid, item, leveltable[100] - getItemAttribute(item, "exp"), ballid)
return true
end

doItemSetAttribute(item, "exp", getItemAttribute(item, "exp") + expe)
doItemSetAttribute(item, "happy", getItemAttribute(item, "happy") + 1)
doItemSetAttribute(item, "nextlevelexp", getItemAttribute(item, "nextlevelexp") - expe)

if not hidemessage then
if pct then
doPlayerSendTextMessage(cid, 27, "Your "..getPokeballName(item).." has received "..expe.." experience points ("..pct.."%).")
else
if getItemAttribute(item, "nextlevelexp") > 0 then
doPlayerSendTextMessage(cid, 27, "Your "..getPokeballName(item).." ["..getItemAttribute(item, "level").."] has received "..expe.." experience points inside his pokeball ("..getItemAttribute(item, "nextlevelexp").." to next level).")
else
doPlayerSendTextMessage(cid, 27, "Your "..getPokeballName(item).." ["..getItemAttribute(item, "level").."] has received "..expe.." experience points and has leveled up inside his pokeball.")
adjustPokemonLevel(item, cid, ballid)
end
end
end
end

function doMathDecimal(number, casas)

if math.floor(number) == number then return number end

local c = casas and casas + 1 or 3

for a = 0, 10 do
if math.floor(number) < math.pow(10, a) then
local str = string.sub(""..number.."", 1, a + c)
return tonumber(str)
end
end

return number
end

function adjustPokemonLevel(item, cid, id, rarecandy)

if not isCreature(cid) then return true end

local exp = getItemAttribute(item, "exp")
local level = getItemAttribute(item, "level")
local leveltable = getPokemonExperienceTable(getPokeballName(item, true))
local newlevel = 1

for x = 1, 100 do
if exp >= leveltable[x] and exp < leveltable[x+1] then
newlevel = x
end
end

if newlevel <= 1 then return true end

local levelsup = (newlevel - level)
local pokemon = getItemAttribute(item, "poke")
local happy = getItemAttribute(item, "happy")
local rate = happy / 100
local newhappiness = happy

if happy >= 250 then
newhappiness = 255
elseif happy >= 230 then
newhappiness = happy + 4
elseif happy >= 210 then
newhappiness = happy + 6
elseif happy >= 180 then
newhappiness = happy + 8
elseif happy >= 140 then
newhappiness = happy + 10
elseif happy >= 110 then
newhappiness = happy + 12
else
newhappiness = happy + 15
end

local status = getPokemonStatus(pokemon)

local off = status.off * rate * levelsup
local def = status.def * rate * levelsup
local agi = status.agi * rate * levelsup
local spatk = status.spatk * rate * levelsup
local vit = status.vit * rate * levelsup

doItemSetAttribute(item, "level", newlevel)

if not rarecandy then
doItemSetAttribute(item, "happy", newhappiness)
end

local nextexp = leveltable[newlevel + 1] - exp
doItemSetAttribute(item, "nextlevelexp", nextexp)

doItemSetAttribute(item, "offense", getItemAttribute(item, "offense") + off)
doItemSetAttribute(item, "defense", getItemAttribute(item, "defense") + def)
doItemSetAttribute(item, "speed", getItemAttribute(item, "speed") + agi)
doItemSetAttribute(item, "specialattack", getItemAttribute(item, "specialattack") + spatk)
doItemSetAttribute(item, "vitality", getItemAttribute(item, "vitality") + vit)

if newlevel > getPlayerLevel(cid) + pokemonMaxLevelAbovePlayer then
addEvent(doPlayerSendTextMessage, 30, cid, 18, "Warning: Your "..getPokeballName(item).."'s ["..newlevel.."] level is much higher than yours, so you will not be able to call him to battles.")
end

if isCreature(cid) and id >= 1 and isBeingUsed(id) then
adjustStatus(getCreatureSummons(cid)[1], item, false, true)
doPlayerSendTextMessage(cid, 27, "• Level: "..newlevel.." (+"..levelsup..") • Offense: +"..doMathDecimal(off).." • Defense: +"..doMathDecimal(def).." • Spc. Atk: +"..doMathDecimal(spatk).." • Agility: +"..doMathDecimal(agi).." • Vitality: +"..doMathDecimal(vit).."")

if happy < minHappyToEvolve then return true end

if pokemonsCanEvolveByLevel then

local summon = getCreatureSummons(cid)[1]

local reqlevel = poevo[getCreatureName(summon)] and poevo[getCreatureName(summon)].level or -1
local level = getItemAttribute(item, "level")
local evolution = "none"
local name = getCreatureName(summon)

if name == "Tyrogue" and level >= 20 then
if getOffense(summon) == getDefense(summon) then
evolution = "Hitmontop"
elseif getOffense(summon) > getDefense(summon) then
evolution = "Hitmonlee"
else
evolution = "Hitmonchan"
end
elseif name == "Eevee" then
if happy >= maxHappyToEvolve then
if isDay() then
evolution = "Espeon"
else
evolution = "Umbreon"
end
end
elseif name == "Slowpoke" and level >= 28 then
evolution = "Slowbro"
elseif name == "Poliwhirl" and level >= 36 then
evolution = "Poliwrath"
elseif reqlevel > 4 and level >= reqlevel then
evolution = poevo[getCreatureName(summon)].evolution
elseif reqlevel == 2 and happy >= maxHappyToEvolve then
evolution = poevo[getCreatureName(summon)] and poevo[getCreatureName(summon)].evolution or "none"
end

if evolution ~= "none" then
doStartEvolution(summon, evolution, 4)
end
end
end
end

function doAdjustWithDelay(cid, pk, health, vit, status)
if isCreature(cid) then --alterado v2.5
if not isCreature(cid) then return true end
adjustStatus(pk, getPlayerSlotItem(cid, 8).uid, health, vir, status)
end
end

function adjustStatus(pk, item, health, vite, conditions)

if not isCreature(pk) then return true end

local bonusoffense = getItemAttribute(item, boffense) or 0
local bonusdefense = getItemAttribute(item, bdefense) or 0
local bonusagility = getItemAttribute(item, bagility) or 0
local bonussattack = getItemAttribute(item, bsattack) or 0

setPlayerStorageValue(pk, 1000, getItemAttribute(item, "level"))
setPlayerStorageValue(pk, 1001, getItemAttribute(item, "offense") + bonusoffense)
setPlayerStorageValue(pk, 1002, getItemAttribute(item, "defense") + bonusdefense)
setPlayerStorageValue(pk, 1003, getItemAttribute(item, "speed") + bonusagility)
setPlayerStorageValue(pk, 1005, getItemAttribute(item, "specialattack") + bonussattack)

local gender = getItemAttribute(item, "gender") and getItemAttribute(item, "gender") or 0
doCreatureSetSkullType(pk, gender)

if vite == true then
local pct = getCreatureHealth(pk) / getCreatureMaxHealth(pk)
local vit = getItemAttribute(item, "vitality") - getPlayerStorageValue(pk, 1004)
setCreatureMaxHealth(pk, getCreatureMaxHealth(pk) + ( vit * HPperVIT ))
doCreatureAddHealth(pk, pct * vit * HPperVIT)
end

setPlayerStorageValue(pk, 1004, getItemAttribute(item, "vitality"))

doRegainSpeed(pk)

local nick = getItemAttribute(item, "poke")

if string.find(tostring(nick), "Shiny") then
nick = tostring(nick):match("Shiny (.*)")
end

if getItemAttribute(item, "nick") then
nick = getItemAttribute(item, "nick")
end

setPlayerStorageValue(pk, 1007, nick)

local boostlevel = getItemAttribute(item, "boost") or 0
local boostshow = hideBoost and "]" or " + "..boostlevel.."]"
local lvlstr = ""

if showBoostSeparated then
boostshow = hideBoost and "]" or "] [+"..boostlevel.."]"
end

if hideSummonsLevel then
if not hideBoost then
nick = nick.." [+"..boostlevel.."]"
end
else
nick = nick.." ["..getItemAttribute(item, "level")..""..boostshow..""
end

doCreatureSetNick(pk, nick)

if not getItemAttribute(item, "happy") then
doItemSetAttribute(item, "happy", 120)
end

if not getItemAttribute(item, "hunger") then
doItemSetAttribute(item, "hunger", 5)
end

local happy = getItemAttribute(item, "happy")
if happy < 0 then
happy = 1
end
setPlayerStorageValue(pk, 1008, happy)

local hunger = getItemAttribute(item, "hunger")
setPlayerStorageValue(pk, 1009, hunger)

if health == true then
local mh = getCreatureMaxHealth(pk) + HPperVIT * getVitality(pk)
local rd = 1 - (tonumber(getItemAttribute(item, "hp")))
setCreatureMaxHealth(pk, mh)
doCreatureAddHealth(pk, getCreatureMaxHealth(pk))
doCreatureAddHealth(pk, -(getCreatureMaxHealth(pk) * rd))
end

if isSummon(pk) and conditions then --alterado v2.5 daki pra baixo!!
local burn = getItemAttribute(item, "burn")
if burn and burn >= 0 then
local ret = {id = pk, cd = burn, check = false, damage = getItemAttribute(item, "burndmg"), cond = "Burn"}
addEvent(doCondition2, 3500, ret)
end

local poison = getItemAttribute(item, "poison")
if poison and poison >= 0 then
local ret = {id = pk, cd = poison, check = false, damage = getItemAttribute(item, "poisondmg"), cond = "Poison"}
addEvent(doCondition2, 1500, ret)
end

local confuse = getItemAttribute(item, "confuse")
if confuse and confuse >= 0 then
local ret = {id = pk, cd = confuse, check = false, cond = "Confusion"}
addEvent(doCondition2, 1200, ret) --alterado v2.5
end

local sleep = getItemAttribute(item, "sleep")
if sleep and sleep >= 0 then
local ret = {id = pk, cd = sleep, check = false, first = true, cond = "Sleep"}
doCondition2(ret)
end

local miss = getItemAttribute(item, "miss")
if miss and miss >= 0 then
local ret = {id = pk, cd = miss, eff = getItemAttribute(item, "missEff"), check = false, spell = getItemAttribute(item, "missSpell"), cond = "Miss"}
doCondition2(ret)
end

local fear = getItemAttribute(item, "fear")
if fear and fear >= 0 then
local ret = {id = pk, cd = fear, check = false, skill = getItemAttribute(item, "fearSkill"), cond = "Fear"}
doCondition2(ret)
end

local silence = getItemAttribute(item, "silence")
if silence and silence >= 0 then
local ret = {id = pk, cd = silence, eff = getItemAttribute(item, "silenceEff"), check = false, cond = "Silence"}
doCondition2(ret)
end

local stun = getItemAttribute(item, "stun")
if stun and stun >= 0 then
local ret = {id = pk, cd = stun, eff = getItemAttribute(item, "stunEff"), check = false, spell = getItemAttribute(item, "stunSpell"), cond = "Stun"}
doCondition2(ret)
end

local paralyze = getItemAttribute(item, "paralyze")
if paralyze and paralyze >= 0 then
local ret = {id = pk, cd = paralyze, eff = getItemAttribute(item, "paralyzeEff"), check = false, first = true, cond = "Paralyze"}
doCondition2(ret)
end

local slow = getItemAttribute(item, "slow")
if slow and slow >= 0 then
local ret = {id = pk, cd = slow, eff = getItemAttribute(item, "slowEff"), check = false, first = true, cond = "Slow"}
doCondition2(ret)
end

local leech = getItemAttribute(item, "leech")
if leech and leech >= 0 then
local ret = {id = pk, cd = leech, attacker = 0, check = false, damage = getItemAttribute(item, "leechdmg"), cond = "Leech"}
doCondition2(ret)
end

for i = 1, 3 do
local buff = getItemAttribute(item, "Buff"..i)
if buff and buff >= 0 then
local ret = {id = pk, cd = buff, eff = getItemAttribute(item, "Buff"..i.."eff"), check = false,
buff = getItemAttribute(item, "Buff"..i.."skill"), first = true, attr = "Buff"..i}
doCondition2(ret)
end
end

end
--alterado v2.9
if getItemAttribute(item, "boost") and getItemAttribute(item, "boost") >= 50 and getItemAttribute(item, "aura") then
sendAuraEffect(pk, auraSyst[getItemAttribute(item, "aura")])
end

if getPlayerStorageValue(getCreatureMaster(pk), 6598754) >= 1 then
setPlayerStorageValue(pk, 6598754, 1)
elseif getPlayerStorageValue(getCreatureMaster(pk), 6598755) >= 1 then
setPlayerStorageValue(pk, 6598755, 1)
end

return true
end

function setWildPokemonLevel(cid, optionalLevel, optionalStatus, optionalNick, optionalExtraExp)

if not isCreature(cid) then return true end
if not pokes[getCreatureName(cid)] then return true end --alterado v2.6

local levelRange = 0
local off = 0
local def = 0
local agi = 0
local spatk = 0
local vit = 0
local this = getCreatureName(cid)
local ee = 1

if optionalExtraExp then
ee = optionalExtraExp
end


if optionalLevel and tonumber(optionalLevel) >= 1 then --alterado v2.8\/
levelRange = optionalLevel
else
levelRange = math.random(pokes[this].wildLvlMin, pokes[this].wildLvlMax)
end

local status = getPokemonStatus(this)
if status then
off = status.off
def = status.def
agi = status.agi
vit = status.vit
spatk = status.spatk
end

setPlayerStorageValue(cid, 1000, (levelRange > 100 and 100 or levelRange)) --alterado v2.8

if optionalStatus and optionalStatus.off then
setPlayerStorageValue(cid, 1001, optionalStatus.offense)
setPlayerStorageValue(cid, 1002, optionalStatus.defense)
setPlayerStorageValue(cid, 1003, optionalStatus.agility)
setPlayerStorageValue(cid, 1004, optionalStatus.vitality)
setPlayerStorageValue(cid, 1005, optionalStatus.specialattack)
setPlayerStorageValue(cid, 1011, optionalStatus.offense)
setPlayerStorageValue(cid, 1012, optionalStatus.defense)
setPlayerStorageValue(cid, 1013, optionalStatus.agility)
setPlayerStorageValue(cid, 1014, optionalStatus.vitality)
setPlayerStorageValue(cid, 1015, optionalStatus.specialattack)
else
setPlayerStorageValue(cid, 1001, 5 + math.random(off * levelRange * 0.9, off * levelRange * 1.8))
setPlayerStorageValue(cid, 1002, 5 + math.random(def * levelRange * 0.9, def * levelRange * 1.8))
setPlayerStorageValue(cid, 1003, math.random(agi * levelRange * 0.9, agi * levelRange * 1.8))
setPlayerStorageValue(cid, 1004, math.random(vit * levelRange * 0.9, vit * levelRange * 1.8))
setPlayerStorageValue(cid, 1005, 5 + math.random(spatk * levelRange * 0.9, spatk * levelRange * 1.8))
setPlayerStorageValue(cid, 1011, getPlayerStorageValue(cid, 1001))
setPlayerStorageValue(cid, 1012, getPlayerStorageValue(cid, 1002))
setPlayerStorageValue(cid, 1013, getPlayerStorageValue(cid, 1003))
setPlayerStorageValue(cid, 1014, getPlayerStorageValue(cid, 1004))
setPlayerStorageValue(cid, 1015, getPlayerStorageValue(cid, 1005))
end

doRegainSpeed(cid)

setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + getPlayerStorageValue(cid, 1004) * HPperVIT * vitReductionForWild)
doCreatureAddHealth(cid, getCreatureMaxHealth(cid))

if pokes[getCreatureName(cid)].exp then
--getMonsterInfo(getCreatureName(cid)).experience
local exp = (50 + pokes[getCreatureName(cid)].exp) * baseExpRate + pokes[getCreatureName(cid)].vitality * levelRange * pokemonExpPerLevelRate
setPlayerStorageValue(cid, 1006, exp * generalExpRate * ee)
if getPlayerStorageValue(cid, 22546) == 1 then
setPlayerStorageValue(cid, 1006, 750)
doSetCreatureDropLoot(cid, false) --edited golden arena
end
end

local wildshow = wildBeforeNames and "Wild " or ""
if optionalNick then
if hideWildsLevel then
doCreatureSetNick(cid, optionalNick)
else
doCreatureSetNick(cid, optionalNick.." ["..getWildPokemonLevel(cid).."]")
end
else
if hideWildsLevel then
doCreatureSetNick(cid, ""..wildshow..""..getCreatureName(cid).."")
else
doCreatureSetNick(cid, ""..wildshow..""..getCreatureName(cid).." ["..getWildPokemonLevel(cid).."]")
end
end
end

function getOffenseInRage(cid) --alterado v2.8
if not isCreature(cid) then return 0 end

if getPlayerStorageValue(cid, 547888) >= 1 then
return tonumber(getPlayerStorageValue(cid, 1001)) / 2
end

return tonumber(getPlayerStorageValue(cid, 1001))
end

function getOffense(cid)
if not isCreature(cid) then return 0 end

--[[if getPlayerStorageValue(cid, 3894) >= 1 then
return tonumber(getPlayerStorageValue(cid, 1001)) / 2
end ]]

return tonumber(getPlayerStorageValue(cid, 1001))
end

function getDefense(cid)
if not isCreature(cid) then return 0 end

--[[ if getPlayerStorageValue(cid, 3894) >= 1 then
return tonumber(getPlayerStorageValue(cid, 1002)) / 2
end ]]

return tonumber(getPlayerStorageValue(cid, 1002))
end

function getSpeed(cid)
if not isCreature(cid) then return 0 end
return tonumber(getPlayerStorageValue(cid, 1003))
end

function getVitality(cid)
if not isCreature(cid) then return 0 end
return tonumber(getPlayerStorageValue(cid, 1004))
end

function getSpecialAttack(cid)
if not isCreature(cid) then return 0 end
return tonumber(getPlayerStorageValue(cid, 1005))
end

function getHappiness(cid)
if not isCreature(cid) then return 0 end
return tonumber(getPlayerStorageValue(cid, 1008))
end

function getSpecialDefense(cid)
if not isCreature(cid) then return 0 end
return getSpecialAttack(cid) * 0.85 + getDefense(cid) * 0.2
end

function getWildPokemonExp(cid)
return getPlayerStorageValue(cid, 1006)
end

function getWildPokemonLevel(cid)
return getPlayerStorageValue(cid, 1000)
end

function getLevel(cid)
if isSummon(cid) then
return getItemAttribute(getPlayerSlotItem(getCreatureMaster(cid), 8).uid, "level")
end
return getPlayerStorageValue(cid, 1000)
end

function getPokeName(cid)
if not isSummon(cid) then return getCreatureName(cid) end
if getCreatureName(cid) == "Evolution" then return getPlayerStorageValue(cid, 1007) end

local item = getPlayerSlotItem(getCreatureMaster(cid), 8)
if getItemAttribute(item.uid, "nick") then --alterado v2.7
return getItemAttribute(item.uid, "nick")
end
if string.find(tostring(getCreatureName(cid)), "Shiny") then
local newName = tostring(getCreatureName(cid)):match("Shiny (.*)")
return newName
end
return getCreatureName(cid)
end

function getPokeballName(item, truename)
if not truename and getItemAttribute(item, "nick") then
return getItemAttribute(item, "nick")
end
return getItemAttribute(item, "poke")
end

function getPokemonName(cid)
return getCreatureName(cid)
end

function getMasterLevel(poke)
if not isSummon(poke) then return 0 end
return getPlayerLevel(getCreatureMaster(poke)) --alterado v2.5
end

function getPokeballBoost(ball)
if not isPokeball(ball.itemid) then return 0 end --alterado v2.8
return getItemAttribute(ball.uid, "boost") or 0
end

function getPokemonBoost(poke)
if not isSummon(poke) then return 0 end --alterado v2.5
return getItemAttribute(getPlayerSlotItem(getCreatureMaster(poke), 8).uid, "boost") or 0
end

function getPokemonLevelByName(name)
return pokes[name] and pokes[name].level or 0 --alterado v2.9
end

function getPokemonLevel(cid)
if not isCreature(cid) then return 0 end
return getPlayerStorageValue(cid, 1000)
end

function getPokemonGender(cid)
return getCreatureSkullType(cid)
end

function setPokemonGender(cid, gender)
if isCreature(cid) and gender then --alterado v2.8
doCreatureSetSkullType(cid, gender)
return true
end
return false
end

 

 

spawn.lua

local shinys = {
"Venusaur", "Charizard", "Blastoise", "Butterfree", "Beedrill", "Pidgeot", "Rattata", "Raticate", "Raichu", "Zubat", "Golbat", "Paras", "Parasect",
"Venonat", "Venomoth", "Growlithe", "Arcanine", "Abra", "Alakazam", "Tentacool", "Tentacruel", "Farfetch'd", "Grimer", "Muk", "Gengar", "Onix", "Krabby",
"Kingler", "Voltorb", "Electrode", "Cubone", "Marowak", "Hitmonlee", "Hitmonchan", "Tangela", "Horsea", "Seadra", "Scyther", "Jynx", "Electabuzz", "Pinsir",
"Magikarp", "Gyarados", "Snorlax", "Dragonair", "Dratini",
}
local raros = {"Dragonite"} --alterado v2.5

local function ShinyName(cid)
if isCreature(cid) then
if string.find(tostring(getCreatureName(cid)), "Shiny") then
local newName = tostring(getCreatureName(cid)):match("Shiny (.*)")
local newNamed = newName.." ["..getPokemonLevel(cid).."]"
doCreatureSetNick(cid, newNamed)
if isMonster(cid) then
doSetCreatureDropLoot(cid, false)
end
end
end
end


local function doPokemonRegisterLevel(cid)
if not isCreature(cid) then return true end
if getWildPokemonLevel(cid) == -1 then
setWildPokemonLevel(cid)
end
end

local function doSetRandomGender(cid)
if not isCreature(cid) then return true end
local gender = 0
local name = getCreatureName(cid)
if not newpokedex[name] then return true end
local rate = newpokedex[name].gender
if rate == 0 then
gender = 3
elseif rate == 1000 then
gender = 4
elseif rate == -1 then
gender = 0
elseif math.random(1, 1000) <= rate then
gender = 4
else
gender = 3
end
doCreatureSetSkullType(cid, gender)
end

local function doShiny(cid)
if isCreature(cid) then
if isSummon(cid) then return true end
if getPlayerStorageValue(cid, 74469) >= 1 then return true end
if getPlayerStorageValue(cid, 22546) >= 1 then return true end
if isNpcSummon(cid) then return true end
if getPlayerStorageValue(cid, 637500) >= 1 then return true end --alterado v2.9

if isInArray(shinys, getCreatureName(cid)) then --alterado v2.9 \/
chance = 1 --1% chance
elseif isInArray(raros, getCreatureName(cid)) then --n coloquem valores menores que 0.1 !!
chance = 0.5 --0.5% chance
else
return true
end
if math.random(1, 1000) <= chance*10 then
doSendMagicEffect(getThingPos(cid), 18)
local name, pos = "Shiny ".. getCreatureName(cid), getThingPos(cid)
doRemoveCreature(cid)
local shi = doCreateMonster(name, pos, false)
setPlayerStorageValue(shi, 74469, 1)
else
setPlayerStorageValue(cid, 74469, 1)
end --/\
else
return true
end
end

function onSpawn(cid)

registerCreatureEvent(cid, "Experience")
registerCreatureEvent(cid, "GeneralConfiguration")
registerCreatureEvent(cid, "DirectionSystem")
registerCreatureEvent(cid, "CastSystem")


if isSummon(cid) then
registerCreatureEvent(cid, "SummonDeath")
return true
end

addEvent(doPokemonRegisterLevel, 5, cid)
addEvent(doSetRandomGender, 5, cid)
addEvent(doShiny, 10, cid)
addEvent(ShinyName, 15, cid)

return true
end

levelsytem.lua

function getPokemonStatus(name, multiplier)
local a = pokes[name]
local m = 1
if not a then return false end
if not a.offense then return false end
if multiplier then m = multiplier end
local ret = {}
ret.off = a.offense * m
ret.offense = ret.off

ret.def = a.defense * m
ret.defense = ret.def

ret.agi = a.agility * m
ret.agility = ret.agi

ret.spatk = a.specialattack * m
ret.specialattack = ret.spatk

ret.vit = a.vitality * m
ret.vitality = ret.vit
return ret
end

function getPokemonXMLOutfit(name) --alterado v2.9 \/
local path = "data/monster/pokes/Shiny/"..name..".xml"
local tpw = io.type(io.open(path))

if not tpw then
path = "data/monster/pokes/geracao 2/"..name..".xml"
tpw = io.type(io.open(path))
end
if not tpw then
path = "data/monster/pokes/geracao 1/"..name..".xml"
tpw = io.type(io.open(path))
end
if not tpw then
path = "data/monster/pokes/"..name..".xml"
tpw = io.type(io.open(path))
end
if not tpw then
return print("[getPokemonXMLOutfit] Poke with name: "..name.." ins't in any paste on monster/pokes/") and 2
end
local arq = io.open(path, "a+")
local txt = arq:read("*all")
arq:close()
local a, b = txt:find('look type="(.-)"')
txt = string.sub(txt, a + 11, b - 1)
return tonumber(txt)
end

function doEvolutionOutfit(cid, oldout, outfit)
if not isCreature(cid) then return true end
if getCreatureOutfit(cid).lookType == oldout then
doSetCreatureOutfit(cid, {lookType = outfit}, -1)
else
doSetCreatureOutfit(cid, {lookType = oldout}, -1)
end
end

function doStartEvolution(cid, evolution, seconds)
if not isCreature(cid) then return true end
local a = getPlayerStorageValue(cid, 1007)
local b = getCreatureHealth(cid) / getCreatureMaxHealth(cid)
local d = getThingPos(cid)
local e = getCreatureMaster(cid)
if getHappinessRate(cid) < 1 then return true end
local f = getCreatureOutfit(cid).lookType
local g = getItemAttribute(getPlayerSlotItem(e, 8).uid, "nick") or getCreatureName(cid)
local h = getPokemonXMLOutfit(evolution)
doItemSetAttribute(getPlayerSlotItem(e, 8).uid, "hp", b)
doCreatureSay(e, "What? My "..g.." is evolving!", TALKTYPE_SAY)
doSummonMonster(e, "Evolution")
doReturnPokemon(e, cid, getPlayerSlotItem(e, 8), 0, true)
local evo = getCreatureSummons(e)[1]
doEvolutionOutfit(evo, h, f)
doCreatureSetHideHealth(evo, true)
doCreatureSetLookDir(evo, 2)
setPlayerStorageValue(evo, 1007, g)
doTeleportThing(evo, d, false)
addEvent(sendSSJEffect, 250, evo)
doSendAnimatedText(getThingPos(evo), "EVOLUTION", COLOR_GRASS)
doSendEvolutionEffect(evo, getThingPos(evo), evolution, 20, false, false, f, h)
end

function doSendEvolutionEffect(cid, pos, evolution, turn, ssj, evolve, f, h)
if not isCreature(cid) then
doSendAnimatedText(pos, "CANCEL", 215)
return true end
if evolve then
doEvolvePokemon(getCreatureMaster(cid), {uid = cid}, evolution, 0, 0)
return true
end
doSendMagicEffect(pos, 18)
if ssj then
sendSSJEffect(evo)
end
doEvolutionOutfit(cid, f, h)
addEvent(doSendEvolutionEffect, math.pow(1900, turn/20), cid, getThingPos(cid), evolution, turn - 1, turn == 19, turn == 2, f, h)
end

function sendSSJEffect(cid)
if not isCreature(cid) then return true end
local pos1 = getThingPos(cid)
local pos2 = getThingPos(cid)
pos2.x = pos2.x + math.random(-1, 1)
pos2.y = pos2.y - math.random(1, 2)
doSendDistanceShoot(pos1, pos2, 37)
addEvent(sendSSJEffect, 45, cid)
end

function sendFinishEvolutionEffect(cid, alternate)
if not isCreature(cid) then return true end
local pos1 = getThingPos(cid)

if alternate then
local pos = {
[1] = {-2, 0},
[2] = {-1, -1},
[3] = {0, -2},
[4] = {1, -1},
[5] = {2, 0},
[6] = {1, 1},
[7] = {0, 2},
[8] = {-1, 1}}
for a = 1, 8 do
local pos2 = getThingPos(cid)
pos2.x = pos2.x + pos[a][1]
pos2.y = pos2.y + pos[a][2]
local pos = getThingPos(cid)
doSendDistanceShoot(pos2, pos, 37)
addEvent(doSendDistanceShoot, 300, pos, pos2, 37)
end
else
for a = 0, 3 do
doSendDistanceShoot(pos1, getPosByDir(pos1, a), 37)
end
for a = 4, 7 do
addEvent(doSendDistanceShoot, 600, pos1, getPosByDir(pos1, a), 37)
end
end
end

function doEvolvePokemon(cid, item2, theevo, stone1, stone2)

if not isCreature(cid) then return true end

if not pokes[theevo] or not pokes[theevo].offense then
doReturnPokemon(cid, item2.uid, getPlayerSlotItem(cid, 8), pokeballs[getPokeballType(getPlayerSlotItem(cid, 8).itemid)].effect, false, true)
return true
end

local owner = getCreatureMaster(item2.uid)
local pokeball = getPlayerSlotItem(cid, 8)
local description = "Contains a "..theevo.."."
local pct = getCreatureHealth(item2.uid) / getCreatureMaxHealth(item2.uid)

doItemSetAttribute(pokeball.uid, "hp", pct)

doItemSetAttribute(pokeball.uid, "poke", theevo)
doItemSetAttribute(pokeball.uid, "description", "Contains a "..theevo..".")

doPlayerSendTextMessage(cid, 27, "Congratulations! Your "..getPokeName(item2.uid).." evolved into a "..theevo.."!")

doSendMagicEffect(getThingPos(item2.uid), 18)
doTransformItem(getPlayerSlotItem(cid, 7).uid, fotos[theevo])
doSendMagicEffect(getThingPos(cid), 173)

local oldpos = getThingPos(item2.uid)
local oldlod = getCreatureLookDir(item2.uid)
local oldlvl = getPokemonLevel(item2.uid)
doRemoveCreature(item2.uid)

doSummonMonster(cid, theevo)
local pk = getCreatureSummons(cid)[1]

doTeleportThing(pk, oldpos, false)
doCreatureSetLookDir(pk, oldlod)

sendFinishEvolutionEffect(pk, true)
addEvent(sendFinishEvolutionEffect, 550, pk, true)
addEvent(sendFinishEvolutionEffect, 1050, pk)

doPlayerRemoveItem(cid, stone1, 1)
doPlayerRemoveItem(cid, stone2, 1)

doAddPokemonInOwnList(cid, theevo)

local status = getPokemonStatus(getCreatureName(pk))

local off = status.off * 7.5
local def = status.def * 7.5
local agi = status.agi * 7.5
local spatk = status.spatk * 7.5
local vit = status.vit * 7

doItemSetAttribute(pokeball.uid, "offense", getItemAttribute(pokeball.uid, "offense") + off)
doItemSetAttribute(pokeball.uid, "defense", getItemAttribute(pokeball.uid, "defense") + def)
doItemSetAttribute(pokeball.uid, "speed", getItemAttribute(pokeball.uid, "speed") + agi)
doItemSetAttribute(pokeball.uid, "specialattack", getItemAttribute(pokeball.uid, "specialattack") + spatk)
doItemSetAttribute(pokeball.uid, "vitality", getItemAttribute(pokeball.uid, "vitality") + vit)

doPlayerSendTextMessage(cid, 27, "Evolution bonus: • Offense: +"..doMathDecimal(off).." • Defense: +"..doMathDecimal(def).." • Spc. Atk: +"..doMathDecimal(spatk).." • Agility: +"..doMathDecimal(agi).." • Vitality: +"..doMathDecimal(vit).."")

local happy = getItemAttribute(pokeball.uid, "happy")

doItemSetAttribute(pokeball.uid, "happy", happy + happyGainedOnEvolution)

if happy + happyGainedOnEvolution > 255 then
doItemSetAttribute(pokeball.uid, "happy", 255)
end

adjustStatus(pk, pokeball.uid, true, false)

if useKpdoDlls then
doUpdateMoves(cid)
end
end

function givePokemonExp(cid, item, expe, pct, rarecandy)

if expe <= 0 or not isCreature(cid) then return true end

local leveltable = getPokemonExperienceTable(getPokeballName(item.uid, true))

if getItemAttribute(item.uid, "exp") + expe > leveltable[100] then
givePokemonExp(cid, item, leveltable[100] - getItemAttribute(item.uid, "exp"))
return true
end

doItemSetAttribute(item.uid, "exp", getItemAttribute(item.uid, "exp") + expe)
doItemSetAttribute(item.uid, "happy", getItemAttribute(item.uid, "happy") + 1)
doItemSetAttribute(item.uid, "nextlevelexp", getItemAttribute(item.uid, "nextlevelexp") - expe)


if pct then
doPlayerSendTextMessage(cid, 27, "Your "..getPokeballName(item.uid).." has received "..expe.." experience points ("..pct.."%).")
else
if getItemAttribute(item.uid, "nextlevelexp") > 0 then
doPlayerSendTextMessage(cid, 27, "Your "..getPokeballName(item.uid).." ["..getItemAttribute(item.uid, "level").."] has received "..expe.." experience points ("..getItemAttribute(item.uid, "nextlevelexp").." to next level).")
else
doPlayerSendTextMessage(cid, 27, "Your "..getPokeballName(item.uid).." ["..getItemAttribute(item.uid, "level").."] has received "..expe.." experience points and has leveled up!")
end
end

if isBeingUsed(item.itemid) then
doSendAnimatedText(getThingPos(getCreatureSummons(cid)[1]), expe, 215)
end

if getItemAttribute(item.uid, "nextlevelexp") <= 0 then
local summon = getCreatureSummons(cid)[1]

if not isCreature(summon) then return true end

doSendFlareEffect(getThingPos(summon))
doSendAnimatedText(getThingPos(summon), "Level up!", 215)

adjustPokemonLevel(item.uid, cid, item.itemid)
doCreatureAddHealth(summon, getCreatureMaxHealth(summon))
end
end


function givePokemonExpInBp(cid, item, expe, ballid, pct, hidemessage)

if expe <= 0 or not isCreature(cid) then return true end

local leveltable = getPokemonExperienceTable(getPokeballName(item, true))

if getItemAttribute(item, "exp") + expe > leveltable[100] then
givePokemonExpInBp(cid, item, leveltable[100] - getItemAttribute(item, "exp"), ballid)
return true
end

doItemSetAttribute(item, "exp", getItemAttribute(item, "exp") + expe)
doItemSetAttribute(item, "happy", getItemAttribute(item, "happy") + 1)
doItemSetAttribute(item, "nextlevelexp", getItemAttribute(item, "nextlevelexp") - expe)

if not hidemessage then
if pct then
doPlayerSendTextMessage(cid, 27, "Your "..getPokeballName(item).." has received "..expe.." experience points ("..pct.."%).")
else
if getItemAttribute(item, "nextlevelexp") > 0 then
doPlayerSendTextMessage(cid, 27, "Your "..getPokeballName(item).." ["..getItemAttribute(item, "level").."] has received "..expe.." experience points inside his pokeball ("..getItemAttribute(item, "nextlevelexp").." to next level).")
else
doPlayerSendTextMessage(cid, 27, "Your "..getPokeballName(item).." ["..getItemAttribute(item, "level").."] has received "..expe.." experience points and has leveled up inside his pokeball.")
adjustPokemonLevel(item, cid, ballid)
end
end
end
end

function doMathDecimal(number, casas)

if math.floor(number) == number then return number end

local c = casas and casas + 1 or 3

for a = 0, 10 do
if math.floor(number) < math.pow(10, a) then
local str = string.sub(""..number.."", 1, a + c)
return tonumber(str)
end
end

return number
end

function adjustPokemonLevel(item, cid, id, rarecandy)

if not isCreature(cid) then return true end

local exp = getItemAttribute(item, "exp")
local level = getItemAttribute(item, "level")
local leveltable = getPokemonExperienceTable(getPokeballName(item, true))
local newlevel = 1

for x = 1, 100 do
if exp >= leveltable[x] and exp < leveltable[x+1] then
newlevel = x
end
end

if newlevel <= 1 then return true end

local levelsup = (newlevel - level)
local pokemon = getItemAttribute(item, "poke")
local happy = getItemAttribute(item, "happy")
local rate = happy / 100
local newhappiness = happy

if happy >= 250 then
newhappiness = 255
elseif happy >= 230 then
newhappiness = happy + 4
elseif happy >= 210 then
newhappiness = happy + 6
elseif happy >= 180 then
newhappiness = happy + 8
elseif happy >= 140 then
newhappiness = happy + 10
elseif happy >= 110 then
newhappiness = happy + 12
else
newhappiness = happy + 15
end

local status = getPokemonStatus(pokemon)

local off = status.off * rate * levelsup
local def = status.def * rate * levelsup
local agi = status.agi * rate * levelsup
local spatk = status.spatk * rate * levelsup
local vit = status.vit * rate * levelsup

doItemSetAttribute(item, "level", newlevel)

if not rarecandy then
doItemSetAttribute(item, "happy", newhappiness)
end

local nextexp = leveltable[newlevel + 1] - exp
doItemSetAttribute(item, "nextlevelexp", nextexp)

doItemSetAttribute(item, "offense", getItemAttribute(item, "offense") + off)
doItemSetAttribute(item, "defense", getItemAttribute(item, "defense") + def)
doItemSetAttribute(item, "speed", getItemAttribute(item, "speed") + agi)
doItemSetAttribute(item, "specialattack", getItemAttribute(item, "specialattack") + spatk)
doItemSetAttribute(item, "vitality", getItemAttribute(item, "vitality") + vit)

if newlevel > getPlayerLevel(cid) + pokemonMaxLevelAbovePlayer then
addEvent(doPlayerSendTextMessage, 30, cid, 18, "Warning: Your "..getPokeballName(item).."'s ["..newlevel.."] level is much higher than yours, so you will not be able to call him to battles.")
end

if isCreature(cid) and id >= 1 and isBeingUsed(id) then
adjustStatus(getCreatureSummons(cid)[1], item, false, true)
doPlayerSendTextMessage(cid, 27, "• Level: "..newlevel.." (+"..levelsup..") • Offense: +"..doMathDecimal(off).." • Defense: +"..doMathDecimal(def).." • Spc. Atk: +"..doMathDecimal(spatk).." • Agility: +"..doMathDecimal(agi).." • Vitality: +"..doMathDecimal(vit).."")

if happy < minHappyToEvolve then return true end

if pokemonsCanEvolveByLevel then

local summon = getCreatureSummons(cid)[1]

local reqlevel = poevo[getCreatureName(summon)] and poevo[getCreatureName(summon)].level or -1
local level = getItemAttribute(item, "level")
local evolution = "none"
local name = getCreatureName(summon)

if name == "Tyrogue" and level >= 20 then
if getOffense(summon) == getDefense(summon) then
evolution = "Hitmontop"
elseif getOffense(summon) > getDefense(summon) then
evolution = "Hitmonlee"
else
evolution = "Hitmonchan"
end
elseif name == "Eevee" then
if happy >= maxHappyToEvolve then
if isDay() then
evolution = "Espeon"
else
evolution = "Umbreon"
end
end
elseif name == "Slowpoke" and level >= 28 then
evolution = "Slowbro"
elseif name == "Poliwhirl" and level >= 36 then
evolution = "Poliwrath"
elseif reqlevel > 4 and level >= reqlevel then
evolution = poevo[getCreatureName(summon)].evolution
elseif reqlevel == 2 and happy >= maxHappyToEvolve then
evolution = poevo[getCreatureName(summon)] and poevo[getCreatureName(summon)].evolution or "none"
end

if evolution ~= "none" then
doStartEvolution(summon, evolution, 4)
end
end
end
end

function doAdjustWithDelay(cid, pk, health, vit, status)
if isCreature(cid) then --alterado v2.5
if not isCreature(cid) then return true end
adjustStatus(pk, getPlayerSlotItem(cid, 8).uid, health, vir, status)
end
end

function adjustStatus(pk, item, health, vite, conditions)

if not isCreature(pk) then return true end

local bonusoffense = getItemAttribute(item, boffense) or 0
local bonusdefense = getItemAttribute(item, bdefense) or 0
local bonusagility = getItemAttribute(item, bagility) or 0
local bonussattack = getItemAttribute(item, bsattack) or 0

setPlayerStorageValue(pk, 1000, getItemAttribute(item, "level"))
setPlayerStorageValue(pk, 1001, getItemAttribute(item, "offense") + bonusoffense)
setPlayerStorageValue(pk, 1002, getItemAttribute(item, "defense") + bonusdefense)
setPlayerStorageValue(pk, 1003, getItemAttribute(item, "speed") + bonusagility)
setPlayerStorageValue(pk, 1005, getItemAttribute(item, "specialattack") + bonussattack)

local gender = getItemAttribute(item, "gender") and getItemAttribute(item, "gender") or 0
doCreatureSetSkullType(pk, gender)

if vite == true then
local pct = getCreatureHealth(pk) / getCreatureMaxHealth(pk)
local vit = getItemAttribute(item, "vitality") - getPlayerStorageValue(pk, 1004)
setCreatureMaxHealth(pk, getCreatureMaxHealth(pk) + ( vit * HPperVIT ))
doCreatureAddHealth(pk, pct * vit * HPperVIT)
end

setPlayerStorageValue(pk, 1004, getItemAttribute(item, "vitality"))

doRegainSpeed(pk)

local nick = getItemAttribute(item, "poke")

if string.find(tostring(nick), "Shiny") then
nick = tostring(nick):match("Shiny (.*)")
end

if getItemAttribute(item, "nick") then
nick = getItemAttribute(item, "nick")
end

setPlayerStorageValue(pk, 1007, nick)

local boostlevel = getItemAttribute(item, "boost") or 0
local boostshow = hideBoost and "]" or " + "..boostlevel.."]"
local lvlstr = ""

if showBoostSeparated then
boostshow = hideBoost and "]" or "] [+"..boostlevel.."]"
end

if hideSummonsLevel then
if not hideBoost then
nick = nick.." [+"..boostlevel.."]"
end
else
nick = nick.." ["..getItemAttribute(item, "level")..""..boostshow..""
end

doCreatureSetNick(pk, nick)

if not getItemAttribute(item, "happy") then
doItemSetAttribute(item, "happy", 120)
end

if not getItemAttribute(item, "hunger") then
doItemSetAttribute(item, "hunger", 5)
end

local happy = getItemAttribute(item, "happy")
if happy < 0 then
happy = 1
end
setPlayerStorageValue(pk, 1008, happy)

local hunger = getItemAttribute(item, "hunger")
setPlayerStorageValue(pk, 1009, hunger)

if health == true then
local mh = getCreatureMaxHealth(pk) + HPperVIT * getVitality(pk)
local rd = 1 - (tonumber(getItemAttribute(item, "hp")))
setCreatureMaxHealth(pk, mh)
doCreatureAddHealth(pk, getCreatureMaxHealth(pk))
doCreatureAddHealth(pk, -(getCreatureMaxHealth(pk) * rd))
end

if isSummon(pk) and conditions then --alterado v2.5 daki pra baixo!!
local burn = getItemAttribute(item, "burn")
if burn and burn >= 0 then
local ret = {id = pk, cd = burn, check = false, damage = getItemAttribute(item, "burndmg"), cond = "Burn"}
addEvent(doCondition2, 3500, ret)
end

local poison = getItemAttribute(item, "poison")
if poison and poison >= 0 then
local ret = {id = pk, cd = poison, check = false, damage = getItemAttribute(item, "poisondmg"), cond = "Poison"}
addEvent(doCondition2, 1500, ret)
end

local confuse = getItemAttribute(item, "confuse")
if confuse and confuse >= 0 then
local ret = {id = pk, cd = confuse, check = false, cond = "Confusion"}
addEvent(doCondition2, 1200, ret) --alterado v2.5
end

local sleep = getItemAttribute(item, "sleep")
if sleep and sleep >= 0 then
local ret = {id = pk, cd = sleep, check = false, first = true, cond = "Sleep"}
doCondition2(ret)
end

local miss = getItemAttribute(item, "miss")
if miss and miss >= 0 then
local ret = {id = pk, cd = miss, eff = getItemAttribute(item, "missEff"), check = false, spell = getItemAttribute(item, "missSpell"), cond = "Miss"}
doCondition2(ret)
end

local fear = getItemAttribute(item, "fear")
if fear and fear >= 0 then
local ret = {id = pk, cd = fear, check = false, skill = getItemAttribute(item, "fearSkill"), cond = "Fear"}
doCondition2(ret)
end

local silence = getItemAttribute(item, "silence")
if silence and silence >= 0 then
local ret = {id = pk, cd = silence, eff = getItemAttribute(item, "silenceEff"), check = false, cond = "Silence"}
doCondition2(ret)
end

local stun = getItemAttribute(item, "stun")
if stun and stun >= 0 then
local ret = {id = pk, cd = stun, eff = getItemAttribute(item, "stunEff"), check = false, spell = getItemAttribute(item, "stunSpell"), cond = "Stun"}
doCondition2(ret)
end

local paralyze = getItemAttribute(item, "paralyze")
if paralyze and paralyze >= 0 then
local ret = {id = pk, cd = paralyze, eff = getItemAttribute(item, "paralyzeEff"), check = false, first = true, cond = "Paralyze"}
doCondition2(ret)
end

local slow = getItemAttribute(item, "slow")
if slow and slow >= 0 then
local ret = {id = pk, cd = slow, eff = getItemAttribute(item, "slowEff"), check = false, first = true, cond = "Slow"}
doCondition2(ret)
end

local leech = getItemAttribute(item, "leech")
if leech and leech >= 0 then
local ret = {id = pk, cd = leech, attacker = 0, check = false, damage = getItemAttribute(item, "leechdmg"), cond = "Leech"}
doCondition2(ret)
end

for i = 1, 3 do
local buff = getItemAttribute(item, "Buff"..i)
if buff and buff >= 0 then
local ret = {id = pk, cd = buff, eff = getItemAttribute(item, "Buff"..i.."eff"), check = false,
buff = getItemAttribute(item, "Buff"..i.."skill"), first = true, attr = "Buff"..i}
doCondition2(ret)
end
end

end
--alterado v2.9
if getItemAttribute(item, "boost") and getItemAttribute(item, "boost") >= 50 and getItemAttribute(item, "aura") then
sendAuraEffect(pk, auraSyst[getItemAttribute(item, "aura")])
end

if getPlayerStorageValue(getCreatureMaster(pk), 6598754) >= 1 then
setPlayerStorageValue(pk, 6598754, 1)
elseif getPlayerStorageValue(getCreatureMaster(pk), 6598755) >= 1 then
setPlayerStorageValue(pk, 6598755, 1)
end

return true
end

function setWildPokemonLevel(cid, optionalLevel, optionalStatus, optionalNick, optionalExtraExp)

if not isCreature(cid) then return true end
if not pokes[getCreatureName(cid)] then return true end --alterado v2.6

local levelRange = 0
local off = 0
local def = 0
local agi = 0
local spatk = 0
local vit = 0
local this = getCreatureName(cid)
local ee = 1

if optionalExtraExp then
ee = optionalExtraExp
end


if optionalLevel and tonumber(optionalLevel) >= 1 then --alterado v2.8\/
levelRange = optionalLevel
else
levelRange = math.random(pokes[this].wildLvlMin, pokes[this].wildLvlMax)
end

local status = getPokemonStatus(this)
if status then
off = status.off
def = status.def
agi = status.agi
vit = status.vit
spatk = status.spatk
end

setPlayerStorageValue(cid, 1000, (levelRange > 100 and 100 or levelRange)) --alterado v2.8

if optionalStatus and optionalStatus.off then
setPlayerStorageValue(cid, 1001, optionalStatus.offense)
setPlayerStorageValue(cid, 1002, optionalStatus.defense)
setPlayerStorageValue(cid, 1003, optionalStatus.agility)
setPlayerStorageValue(cid, 1004, optionalStatus.vitality)
setPlayerStorageValue(cid, 1005, optionalStatus.specialattack)
setPlayerStorageValue(cid, 1011, optionalStatus.offense)
setPlayerStorageValue(cid, 1012, optionalStatus.defense)
setPlayerStorageValue(cid, 1013, optionalStatus.agility)
setPlayerStorageValue(cid, 1014, optionalStatus.vitality)
setPlayerStorageValue(cid, 1015, optionalStatus.specialattack)
else
setPlayerStorageValue(cid, 1001, 5 + math.random(off * levelRange * 0.9, off * levelRange * 1.8))
setPlayerStorageValue(cid, 1002, 5 + math.random(def * levelRange * 0.9, def * levelRange * 1.8))
setPlayerStorageValue(cid, 1003, math.random(agi * levelRange * 0.9, agi * levelRange * 1.8))
setPlayerStorageValue(cid, 1004, math.random(vit * levelRange * 0.9, vit * levelRange * 1.8))
setPlayerStorageValue(cid, 1005, 5 + math.random(spatk * levelRange * 0.9, spatk * levelRange * 1.8))
setPlayerStorageValue(cid, 1011, getPlayerStorageValue(cid, 1001))
setPlayerStorageValue(cid, 1012, getPlayerStorageValue(cid, 1002))
setPlayerStorageValue(cid, 1013, getPlayerStorageValue(cid, 1003))
setPlayerStorageValue(cid, 1014, getPlayerStorageValue(cid, 1004))
setPlayerStorageValue(cid, 1015, getPlayerStorageValue(cid, 1005))
end

doRegainSpeed(cid)

setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + getPlayerStorageValue(cid, 1004) * HPperVIT * vitReductionForWild)
doCreatureAddHealth(cid, getCreatureMaxHealth(cid))

if pokes[getCreatureName(cid)].exp then
--getMonsterInfo(getCreatureName(cid)).experience
local exp = (50 + pokes[getCreatureName(cid)].exp) * baseExpRate + pokes[getCreatureName(cid)].vitality * levelRange * pokemonExpPerLevelRate
setPlayerStorageValue(cid, 1006, exp * generalExpRate * ee)
if getPlayerStorageValue(cid, 22546) == 1 then
setPlayerStorageValue(cid, 1006, 750)
doSetCreatureDropLoot(cid, false) --edited golden arena
end
end

local wildshow = wildBeforeNames and "Wild " or ""
if optionalNick then
if hideWildsLevel then
doCreatureSetNick(cid, optionalNick)
else
doCreatureSetNick(cid, optionalNick.." ["..getWildPokemonLevel(cid).."]")
end
else
if hideWildsLevel then
doCreatureSetNick(cid, ""..wildshow..""..getCreatureName(cid).."")
else
doCreatureSetNick(cid, ""..wildshow..""..getCreatureName(cid).." ["..getWildPokemonLevel(cid).."]")
end
end
end

function getOffenseInRage(cid) --alterado v2.8
if not isCreature(cid) then return 0 end

if getPlayerStorageValue(cid, 547888) >= 1 then
return tonumber(getPlayerStorageValue(cid, 1001)) / 2
end

return tonumber(getPlayerStorageValue(cid, 1001))
end

function getOffense(cid)
if not isCreature(cid) then return 0 end

--[[if getPlayerStorageValue(cid, 3894) >= 1 then
return tonumber(getPlayerStorageValue(cid, 1001)) / 2
end ]]

return tonumber(getPlayerStorageValue(cid, 1001))
end

function getDefense(cid)
if not isCreature(cid) then return 0 end

--[[ if getPlayerStorageValue(cid, 3894) >= 1 then
return tonumber(getPlayerStorageValue(cid, 1002)) / 2
end ]]

return tonumber(getPlayerStorageValue(cid, 1002))
end

function getSpeed(cid)
if not isCreature(cid) then return 0 end
return tonumber(getPlayerStorageValue(cid, 1003))
end

function getVitality(cid)
if not isCreature(cid) then return 0 end
return tonumber(getPlayerStorageValue(cid, 1004))
end

function getSpecialAttack(cid)
if not isCreature(cid) then return 0 end
return tonumber(getPlayerStorageValue(cid, 1005))
end

function getHappiness(cid)
if not isCreature(cid) then return 0 end
return tonumber(getPlayerStorageValue(cid, 1008))
end

function getSpecialDefense(cid)
if not isCreature(cid) then return 0 end
return getSpecialAttack(cid) * 0.85 + getDefense(cid) * 0.2
end

function getWildPokemonExp(cid)
return getPlayerStorageValue(cid, 1006)
end

function getWildPokemonLevel(cid)
return getPlayerStorageValue(cid, 1000)
end

function getLevel(cid)
if isSummon(cid) then
return getItemAttribute(getPlayerSlotItem(getCreatureMaster(cid), 8).uid, "level")
end
return getPlayerStorageValue(cid, 1000)
end

function getPokeName(cid)
if not isSummon(cid) then return getCreatureName(cid) end
if getCreatureName(cid) == "Evolution" then return getPlayerStorageValue(cid, 1007) end

local item = getPlayerSlotItem(getCreatureMaster(cid), 8)
if getItemAttribute(item.uid, "nick") then --alterado v2.7
return getItemAttribute(item.uid, "nick")
end
if string.find(tostring(getCreatureName(cid)), "Shiny") then
local newName = tostring(getCreatureName(cid)):match("Shiny (.*)")
return newName
end
return getCreatureName(cid)
end

function getPokeballName(item, truename)
if not truename and getItemAttribute(item, "nick") then
return getItemAttribute(item, "nick")
end
return getItemAttribute(item, "poke")
end

function getPokemonName(cid)
return getCreatureName(cid)
end

function getMasterLevel(poke)
if not isSummon(poke) then return 0 end
return getPlayerLevel(getCreatureMaster(poke)) --alterado v2.5
end

function getPokeballBoost(ball)
if not isPokeball(ball.itemid) then return 0 end --alterado v2.8
return getItemAttribute(ball.uid, "boost") or 0
end

function getPokemonBoost(poke)
if not isSummon(poke) then return 0 end --alterado v2.5
return getItemAttribute(getPlayerSlotItem(getCreatureMaster(poke), 8).uid, "boost") or 0
end

function getPokemonLevelByName(name)
return pokes[name] and pokes[name].level or 0 --alterado v2.9
end

function getPokemonLevel(cid)
if not isCreature(cid) then return 0 end
return getPlayerStorageValue(cid, 1000)
end

function getPokemonGender(cid)
return getCreatureSkullType(cid)
end

function setPokemonGender(cid, gender)
if isCreature(cid) and gender then --alterado v2.8
doCreatureSetSkullType(cid, gender)
return true
end
return false
end

Duuh funcionou mesmo vallew ai!
REP++
Editado por felipinkoak
Link para o comentário
Compartilhar em outros sites

catch system.lua

 

Linha 94

local levelChance = getItemAttribute(corpse, "level") * 0.02

Provavelmente esse attribute está retornando null, e está ocasionando os dois primeiros erros.

Procure saber o porque de o attribute não estar sendo definido, resolvendo isso acaba o erro.

 

 

level_system.lua

--[[616]] local this = getCreatureName(cid)
--[[627]] levelRange = math.random(pokes[this].wildLvlMin, pokes[this].wildLvlMax)

Verifique o que está errado ai, tem duas possibilidades:

- prmieiro a tabela pokes não conter os dados pokes[pokename].wildLvlMin/Max, neste caso basta encontrar o pokemon cujo configuração não está presente

- segundo, a variável 'this' não está retornando nome algum

Obs.: pode ainda ser outro problema, a função getCreatureName pode estar pegando o "nick", caso haja no servidor isso, dai precisará encontrar outro modo de retornar o nome do pokemon, o primitivo no caso, provavelmente terá que pegar o atributo da bola.

 

 

#alias

 

Para facilitar o reconhecimento de quando e com que criaturas está ocorrendo o erro, use e abuse dos prints, irão lhe ajudar bastante.

Editado por dalvorsn
Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...