Advertisement
Kevick

Lib/Script/Level System.lua

Apr 27th, 2016
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 29.57 KB | None | 0 0
  1. function getPokemonStatus(name, multiplier)
  2.     local a = pokes[name]
  3.     local m = 1
  4.     if not a then return false end
  5.     if not a.offense then return false end
  6.     if multiplier then m = multiplier end
  7. local ret = {}
  8.     ret.off = a.offense * m
  9.     ret.offense = ret.off
  10.  
  11.     ret.def = a.defense * m
  12.     ret.defense = ret.def
  13.  
  14.     ret.agi = a.agility * m
  15.     ret.agility = ret.agi
  16.  
  17.     ret.spatk = a.specialattack * m
  18.     ret.specialattack = ret.spatk
  19.  
  20.     ret.vit = a.vitality * m
  21.     ret.vitality = ret.vit
  22. return ret
  23. end
  24.  
  25. function getPokemonXMLOutfit(name)                --alterado v2.9 \/
  26. local path = "data/monster/pokes/Shiny Kanto/"..name..".xml"
  27. local tpw = io.type(io.open(path))
  28.  
  29. if not tpw then
  30.    path = "data/monster/pokes/Nesil 2/"..name..".xml"
  31.    tpw = io.type(io.open(path))
  32. end
  33. if not tpw then
  34.    path = "data/monster/pokes/Nesil 1/"..name..".xml"
  35.    tpw = io.type(io.open(path))
  36. end
  37. if not tpw then
  38.    path = "data/monster/pokes/Nesil 3/"..name..".xml"
  39.    tpw = io.type(io.open(path))
  40. end
  41. if not tpw then
  42.    path = "data/monster/pokes/Nesil 4/"..name..".xml"
  43.    tpw = io.type(io.open(path))
  44. end
  45. if not tpw then
  46.    path = "data/monster/pokes/Nesil 5/"..name..".xml"
  47.    tpw = io.type(io.open(path))
  48. end
  49. if not tpw then
  50.    path = "data/monster/pokes/Novelty/"..name..".xml"
  51.    tpw = io.type(io.open(path))
  52. end
  53. if not tpw then
  54.    path = "data/monster/pokes/Shiny Hoenn/"..name..".xml"
  55.    tpw = io.type(io.open(path))
  56. end
  57. if not tpw then
  58.    path = "data/monster/pokes/Shiny Johto/"..name..".xml"
  59.    tpw = io.type(io.open(path))
  60. end
  61. if not tpw then
  62.    path = "data/monster/pokes/Shiny Sinnoh/"..name..".xml"
  63.    tpw = io.type(io.open(path))
  64. end
  65. if not tpw then
  66.    path = "data/monster/pokes/"..name..".xml"
  67.    tpw = io.type(io.open(path))
  68. end  
  69. if not tpw then
  70.    return print("[getPokemonXMLOutfit] Poke with name: "..name.." ins't in any paste on monster/pokes/") and 2
  71. end
  72.    local arq = io.open(path, "a+")
  73.    local txt = arq:read("*all")
  74.    arq:close()
  75.    local a, b = txt:find('look type="(.-)"')
  76.    txt = string.sub(txt, a + 11, b - 1)
  77. return tonumber(txt)
  78. end
  79.  
  80. function doEvolutionOutfit(cid, oldout, outfit)
  81.     if not isCreature(cid) then return true end
  82.         if getCreatureOutfit(cid).lookType == oldout then
  83.             doSetCreatureOutfit(cid, {lookType = outfit}, -1)
  84.         else
  85.             doSetCreatureOutfit(cid, {lookType = oldout}, -1)
  86.         end
  87. end
  88.  
  89. function doStartEvolution(cid, evolution, seconds)
  90.     if not isCreature(cid) then return true end
  91.     local a = getPlayerStorageValue(cid, 1007)
  92.     local b = getCreatureHealth(cid) / getCreatureMaxHealth(cid)
  93.     local d = getThingPos(cid)
  94.     local e = getCreatureMaster(cid)
  95.     if getHappinessRate(cid) < 1 then return true end
  96.     local f = getCreatureOutfit(cid).lookType
  97.     local g = getItemAttribute(getPlayerSlotItem(e, 8).uid, "nick") or getCreatureName(cid)
  98.     local h = getPokemonXMLOutfit(evolution)
  99.     doItemSetAttribute(getPlayerSlotItem(e, 8).uid, "hp", b)
  100.     doCreatureSay(e, "What? My "..g.." is evolving!", TALKTYPE_SAY)
  101.     doSummonMonster(e, "Evolution")
  102.     doReturnPokemon(e, cid, getPlayerSlotItem(e, 8), 0, true)
  103.     local evo = getCreatureSummons(e)[1]
  104.     doEvolutionOutfit(evo, h, f)
  105.     doCreatureSetHideHealth(evo, true)
  106.     doCreatureSetLookDir(evo, 2)
  107.     setPlayerStorageValue(evo, 1007, g)
  108.     doTeleportThing(evo, d, false)
  109.     addEvent(sendSSJEffect, 250, evo)
  110.     doSendAnimatedText(getThingPos(evo), "EVOLUTION", COLOR_GRASS)
  111.     doSendEvolutionEffect(evo, getThingPos(evo), evolution, 20, false, false, f, h)
  112. end
  113.  
  114. function doSendEvolutionEffect(cid, pos, evolution, turn, ssj, evolve, f, h)
  115.     if not isCreature(cid) then
  116.         doSendAnimatedText(pos, "CANCEL", 215)
  117.     return true end
  118.     if evolve then
  119.         doEvolvePokemon(getCreatureMaster(cid), {uid = cid}, evolution, 0, 0)
  120.     return true
  121.     end
  122.     doSendMagicEffect(pos, 18)
  123.         if ssj then
  124.             sendSSJEffect(evo)
  125.         end
  126.     doEvolutionOutfit(cid, f, h)
  127.     addEvent(doSendEvolutionEffect, math.pow(1900, turn/20), cid, getThingPos(cid), evolution, turn - 1, turn == 19, turn == 2, f, h)
  128. end
  129.  
  130. function sendSSJEffect(cid)
  131.     if not isCreature(cid) then return true end
  132.     local pos1 = getThingPos(cid)
  133.     local pos2 = getThingPos(cid)
  134.     pos2.x = pos2.x + math.random(-1, 1)
  135.     pos2.y = pos2.y - math.random(1, 2)
  136.     doSendDistanceShoot(pos1, pos2, 37)
  137.     addEvent(sendSSJEffect, 45, cid)
  138. end
  139.  
  140. function sendFinishEvolutionEffect(cid, alternate)
  141.     if not isCreature(cid) then return true end
  142.     local pos1 = getThingPos(cid)
  143.  
  144.     if alternate then
  145.         local pos = {
  146.         [1] = {-2, 0},
  147.         [2] = {-1, -1},
  148.         [3] = {0, -2},
  149.         [4] = {1, -1},
  150.         [5] = {2, 0},
  151.         [6] = {1, 1},
  152.         [7] = {0, 2},
  153.         [8] = {-1, 1}}
  154.         for a = 1, 8 do
  155.             local pos2 = getThingPos(cid)
  156.             pos2.x = pos2.x + pos[a][1]
  157.             pos2.y = pos2.y + pos[a][2]
  158.             local pos = getThingPos(cid)
  159.             doSendDistanceShoot(pos2, pos, 37)
  160.             addEvent(doSendDistanceShoot, 300, pos, pos2, 37)
  161.         end
  162.     else
  163.         for a = 0, 3 do
  164.             doSendDistanceShoot(pos1, getPosByDir(pos1, a), 37)
  165.         end
  166.         for a = 4, 7 do
  167.             addEvent(doSendDistanceShoot, 600, pos1, getPosByDir(pos1, a), 37)
  168.         end
  169.     end
  170. end
  171.  
  172. function doEvolvePokemon(cid, item2, theevo, stone1, stone2)
  173.  
  174.     if not isCreature(cid) then return true end
  175.  
  176.     if not pokes[theevo] or not pokes[theevo].offense then
  177.     doReturnPokemon(cid, item2.uid, getPlayerSlotItem(cid, 8), pokeballs[getPokeballType(getPlayerSlotItem(cid, 8).itemid)].effect, false, true)
  178.     return true
  179.     end
  180.  
  181.     local owner = getCreatureMaster(item2.uid)
  182.     local pokeball = getPlayerSlotItem(cid, 8)
  183.     local description = "Contains a "..theevo.."."
  184.     local pct = getCreatureHealth(item2.uid) / getCreatureMaxHealth(item2.uid)
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.         doItemSetAttribute(pokeball.uid, "hp", pct)
  192.  
  193.         doItemSetAttribute(pokeball.uid, "poke", theevo)
  194.         doItemSetAttribute(pokeball.uid, "description", "Contains a "..theevo..".")
  195.  
  196.         doPlayerSendTextMessage(cid, 27, "Parabens! Seu "..getPokeName(item2.uid).." Evoluiu Para "..theevo.."!")      
  197.  
  198.         doSendMagicEffect(getThingPos(item2.uid), 18)
  199.         doTransformItem(getPlayerSlotItem(cid, 7).uid, fotos[theevo])
  200.         doSendMagicEffect(getThingPos(cid), 173)
  201.        
  202.  
  203.         local oldpos = getThingPos(item2.uid)
  204.         local oldlod = getCreatureLookDir(item2.uid)
  205.         local oldlvl = getPokemonLevel(item2.uid)
  206.         doRemoveCreature(item2.uid)
  207.  
  208.         doSummonMonster(cid, theevo)
  209.         local pk = getCreatureSummons(cid)[1]
  210.  
  211.         doTeleportThing(pk, oldpos, false)
  212.         doCreatureSetLookDir(pk, oldlod)
  213.  
  214.         sendFinishEvolutionEffect(pk, true)
  215.         addEvent(sendFinishEvolutionEffect, 550, pk, true)
  216.         addEvent(sendFinishEvolutionEffect, 1050, pk)
  217.        
  218.         doPlayerRemoveItem(cid, stone1, 1)
  219.         doPlayerRemoveItem(cid, stone2, 1)
  220.  
  221.         doAddPokemonInOwnList(cid, theevo)
  222.  
  223.         local status = getPokemonStatus(getCreatureName(pk))
  224.  
  225.         local off = status.off * 7.5
  226.         local def = status.def * 7.5
  227.         local agi = status.agi * 7.5
  228.         local spatk = status.spatk * 7.5
  229.         local vit = status.vit * 7.5
  230.  
  231.         doItemSetAttribute(pokeball.uid, "offense", getItemAttribute(pokeball.uid, "offense") + off)
  232.         doItemSetAttribute(pokeball.uid, "defense", getItemAttribute(pokeball.uid, "defense") + def)
  233.         doItemSetAttribute(pokeball.uid, "speed", getItemAttribute(pokeball.uid, "speed") + agi)
  234.         doItemSetAttribute(pokeball.uid, "specialattack", getItemAttribute(pokeball.uid, "specialattack") + spatk)
  235.         doItemSetAttribute(pokeball.uid, "vitality", getItemAttribute(pokeball.uid, "vitality") + vit)
  236.  
  237.         doPlayerSendTextMessage(cid, 27, "Evoluçao Bonus: • Offense: +"..doMathDecimal(off).."  • Defense: +"..doMathDecimal(def).."  • Spc. Atk: +"..doMathDecimal(spatk).."  • Agility: +"..doMathDecimal(agi).."  • Vitality: +"..doMathDecimal(vit).."")
  238.  
  239.         local happy = getItemAttribute(pokeball.uid, "happy")
  240.  
  241.         doItemSetAttribute(pokeball.uid, "happy", happy + happyGainedOnEvolution)
  242.  
  243.         if happy + happyGainedOnEvolution > 255 then
  244.             doItemSetAttribute(pokeball.uid, "happy", 255)
  245.         end
  246.  
  247.         adjustStatus(pk, pokeball.uid, true, false)
  248.  
  249.         if useKpdoDlls then
  250.             doUpdateMoves(cid)
  251.         end
  252. end
  253.  
  254. function givePokemonExp(cid, item, expe, pct, rarecandy)
  255.  
  256.     if expe <= 0 or not isCreature(cid) then return true end
  257.  
  258.     local leveltable = getPokemonExperienceTable(getPokeballName(item.uid, true))
  259.  
  260.         if getItemAttribute(item.uid, "exp") + expe > leveltable[300] then
  261.             givePokemonExp(cid, item, leveltable[300] - getItemAttribute(item.uid, "exp"))
  262.         return true
  263.         end
  264.  
  265.     doItemSetAttribute(item.uid, "exp", getItemAttribute(item.uid, "exp") + expe)
  266.     doItemSetAttribute(item.uid, "happy", getItemAttribute(item.uid, "happy") + 1)
  267.     doItemSetAttribute(item.uid, "nextlevelexp", getItemAttribute(item.uid, "nextlevelexp") - expe)
  268.  
  269.  
  270.     if pct then
  271.         doPlayerSendTextMessage(cid, 19, "Seu "..getPokeballName(item.uid).." Recebeu ("..expe..") experience points ("..pct.."%).")
  272.     else
  273.         if getItemAttribute(item.uid, "nextlevelexp") > 0 then
  274.             doPlayerSendTextMessage(cid, 19, "Seu Pokemon "..getPokeballName(item.uid).." ["..getItemAttribute(item.uid, "level").."] recebeu ("..expe..") de Exp • Faltam ("..getItemAttribute(item.uid, "nextlevelexp")..") De Exp.")
  275.         else
  276.             doPlayerSendTextMessage(cid, 19, "[LEVEL UP] Parabens, Seu Pokemon "..getPokeballName(item.uid).." ["..getItemAttribute(item.uid, "level").."] recebeu ("..expe..") De EXP e Upou de Level!")
  277.         end
  278.     end
  279.  
  280.     if isBeingUsed(item.itemid) then
  281.     doSendAnimatedText(getThingPos(getCreatureSummons(cid)[1]), expe, 215)
  282.     end
  283.  
  284.     if getItemAttribute(item.uid, "nextlevelexp") <= 0 then
  285.         local summon = getCreatureSummons(cid)[1]
  286.    
  287.         if not isCreature(summon) then return true end
  288.  
  289.         doSendFlareEffect(getThingPos(summon))
  290.         setPlayerStorageValue(summon,5050,getPlayerStorageValue(summon,5050)+1)    ------ STORAGE QUE GANHA AO UPAR DE LVL POKE
  291.         doSendAnimatedText(getThingPos(summon), "Level up!", 215)
  292.  
  293.         adjustPokemonLevel(item.uid, cid, item.itemid)
  294.         doCreatureAddHealth(summon, getCreatureMaxHealth(summon))
  295.     end
  296. end
  297.  
  298. function givePokemonExpInBp(cid, item, expe, ballid, pct, hidemessage)
  299.  
  300.     if expe <= 0 or not isCreature(cid) then return true end
  301.  
  302.     local leveltable = getPokemonExperienceTable(getPokeballName(item, true))
  303.  
  304.     if getItemAttribute(item, "exp") + expe > leveltable[300] then
  305.         givePokemonExpInBp(cid, item, leveltable[300] - getItemAttribute(item, "exp"), ballid)
  306.     return true
  307.     end
  308.  
  309.     doItemSetAttribute(item, "exp", getItemAttribute(item, "exp") + expe)
  310.     doItemSetAttribute(item, "happy", getItemAttribute(item, "happy") + 1)
  311.     doItemSetAttribute(item, "nextlevelexp", getItemAttribute(item, "nextlevelexp") - expe)
  312.  
  313.     if not hidemessage then
  314.         if pct then
  315.             doPlayerSendTextMessage(cid, 19, "Seu "..getPokeballName(item).." Recebeu ("..expe..") experience points ("..pct.."%).")           
  316.         else
  317.             if getItemAttribute(item, "nextlevelexp") > 0 then
  318.                 doPlayerSendTextMessage(cid, 19, "Seu "..getPokeballName(item).." ["..getItemAttribute(item, "level").."] recebeu ("..expe..") de Exp dentro de sua pokeball • Faltam ("..getItemAttribute(item, "nextlevelexp")..") de Exp para o proximo level.")
  319.             else
  320.                 doPlayerSendTextMessage(cid, 19, "Seu "..getPokeballName(item).." ["..getItemAttribute(item, "level").."] recebeu ("..expe..") de Exp, e Upou De Level  dentro de sua Pokeball!.")
  321.                 adjustPokemonLevel(item, cid, ballid)
  322.             end
  323.         end
  324.     end
  325. end
  326.  
  327.  
  328. function doMathDecimal(number, casas)
  329.  
  330.     if math.floor(number) == number then return number end
  331.  
  332.     local c = casas and casas + 1 or 3
  333.  
  334.     for a = 0, 10 do
  335.         if math.floor(number) < math.pow(10, a) then
  336.             local str = string.sub(""..number.."", 1, a + c)
  337.             return tonumber(str)   
  338.         end
  339.     end
  340.  
  341. return number
  342. end
  343.  
  344. function adjustPokemonLevel(item, cid, id, rarecandy)
  345.  
  346.     if not isCreature(cid) then return true end
  347.  
  348.     local exp = getItemAttribute(item, "exp")
  349.     local level = getItemAttribute(item, "level")
  350.     local bonus_level = getItemAttribute(item, "b_level") or 0
  351.  
  352.      
  353.     local leveltable = getPokemonExperienceTable(getPokeballName(item, true))
  354.     local newlevel = 1
  355.  
  356.     for x = 1, 300 do
  357.         if exp >= leveltable[x] and exp < leveltable[x+1] then
  358.             newlevel = x
  359.         end
  360.     end
  361.  
  362.     if newlevel <= 1 then return true end
  363.  
  364.     local levelsup = (newlevel - level)
  365.  
  366.     local pokemon = getItemAttribute(item, "poke")
  367.     local happy = getItemAttribute(item, "happy")
  368.     local rate = happy / happy
  369.     local newhappiness = happy
  370.  
  371.     if happy >= 250 then
  372.         newhappiness = 255
  373.     elseif happy >= 230 then
  374.         newhappiness = happy + 4
  375.     elseif happy >= 210 then
  376.         newhappiness = happy + 6
  377.     elseif happy >= 180 then
  378.         newhappiness = happy + 8
  379.     elseif happy >= 140 then
  380.         newhappiness = happy + 10
  381.     elseif happy >= 110 then
  382.         newhappiness = happy + 12
  383.     else
  384.         newhappiness = happy + 15
  385.     end
  386.  
  387.     local status = getPokemonStatus(pokemon)
  388.    
  389.  
  390.     local off = status.off * rate * levelsup
  391.     local def = status.def * rate * levelsup
  392.     local agi = status.agi * rate * levelsup
  393.     local spatk = status.spatk * rate * levelsup
  394.     local vit = status.vit * rate * levelsup
  395.  
  396.     doItemSetAttribute(item, "level", newlevel)
  397.     doItemSetAttribute(item, "b_level", bonus_level + 1)
  398.    
  399.  
  400.     if not rarecandy then
  401.         doItemSetAttribute(item, "happy", newhappiness)
  402.     end
  403.  
  404.     local nextexp = leveltable[newlevel + 1] - exp
  405.     doItemSetAttribute(item, "nextlevelexp", nextexp)
  406.    
  407.  
  408.  
  409.     doItemSetAttribute(item, "offense", getItemAttribute(item, "offense") + off)
  410.     doItemSetAttribute(item, "defense", getItemAttribute(item, "defense") + def)
  411.     doItemSetAttribute(item, "speed", getItemAttribute(item, "speed") + agi)
  412.     doItemSetAttribute(item, "specialattack", getItemAttribute(item, "specialattack") + spatk)
  413.     doItemSetAttribute(item, "vitality", getItemAttribute(item, "vitality") + vit)
  414.  
  415.     if newlevel > getPlayerLevel(cid) + pokemonMaxLevelAbovePlayer then
  416.         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.")
  417.     end
  418.  
  419.     if isCreature(cid) and id >= 1 and isBeingUsed(id) then
  420.         adjustStatus(getCreatureSummons(cid)[1], item, false, true)
  421.         doPlayerSendTextMessage(cid, 27, "• Level: "..newlevel.." (+"..levelsup..")  • Offense: +"..doMathDecimal(off).."  • Defense: +"..doMathDecimal(def).."  • Spc. Atk: +"..doMathDecimal(spatk).."  • Agility: +"..doMathDecimal(agi).."  • Vitality: +"..doMathDecimal(vit).."")
  422.  
  423.         if happy < minHappyToEvolve then return true end
  424.  
  425.         if pokemonsCanEvolveByLevel then
  426.  
  427.             local summon = getCreatureSummons(cid)[1]
  428.  
  429.             local reqlevel = poevo[getCreatureName(summon)] and poevo[getCreatureName(summon)].level or -1
  430.             local level = getItemAttribute(item, "level")
  431.             local evolution = "none"
  432.             local name = getCreatureName(summon)
  433.  
  434.             if name == "Tyrogue" and level >= 20 then
  435.                 if getOffense(summon) == getDefense(summon) then
  436.                     evolution = "Hitmontop"
  437.                 elseif getOffense(summon) > getDefense(summon) then
  438.                     evolution = "Hitmonlee"
  439.                 else
  440.                     evolution = "Hitmonchan"
  441.                 end
  442.             elseif name == "Eevee" then
  443.                 if happy >= maxHappyToEvolve then
  444.                     if isDay() then
  445.                         evolution = "Espeon"
  446.                     else
  447.                         evolution = "Umbreon"
  448.                     end
  449.                 end
  450.             elseif name == "Slowpoke" and level >= 28 then
  451.                 evolution = "Slowbro"
  452.             elseif name == "Poliwhirl" and level >= 36 then
  453.                 evolution = "Poliwrath"
  454.             elseif reqlevel > 4 and level >= reqlevel then
  455.                 evolution = poevo[getCreatureName(summon)].evolution
  456.             elseif reqlevel == 2 and happy >= maxHappyToEvolve then
  457.                 evolution = poevo[getCreatureName(summon)] and poevo[getCreatureName(summon)].evolution or "none"
  458.             end
  459.  
  460.             if evolution ~= "none" then
  461.                 doStartEvolution(summon, evolution, 4)
  462.             end
  463.         end
  464.     end
  465. end
  466.  
  467. function doAdjustWithDelay(cid, pk, health, vit, status)
  468. if isCreature(cid) then                                   --alterado v2.5
  469.    if not isCreature(cid) then return true end
  470.    adjustStatus(pk, getPlayerSlotItem(cid, 8).uid, health, vir, status)
  471. end
  472. end
  473.  
  474. function adjustStatus(pk, item, health, vite, conditions)
  475.  
  476.     if not isCreature(pk) then return true end
  477.  
  478.     local bonusoffense = getItemAttribute(item, boffense) or 0
  479.     local bonusdefense = getItemAttribute(item, bdefense) or 0
  480.     local bonusagility = getItemAttribute(item, bagility) or 0
  481.     local bonussattack = getItemAttribute(item, bsattack) or 0
  482.  
  483.     setPlayerStorageValue(pk, 1000, getItemAttribute(item, "level"))
  484.     setPlayerStorageValue(pk, 1001, getItemAttribute(item, "offense") + bonusoffense)
  485.     setPlayerStorageValue(pk, 1002, getItemAttribute(item, "defense") + bonusdefense)
  486.     setPlayerStorageValue(pk, 1003, getItemAttribute(item, "speed") + bonusagility)
  487.     setPlayerStorageValue(pk, 1005, getItemAttribute(item, "specialattack") + bonussattack)
  488.  
  489.     local gender = getItemAttribute(item, "gender") and getItemAttribute(item, "gender") or 0
  490.     doCreatureSetSkullType(pk, gender)
  491.  
  492.     if vite == true then
  493.         local pct = getCreatureHealth(pk) / getCreatureMaxHealth(pk)
  494.         local vit = getItemAttribute(item, "vitality") - getPlayerStorageValue(pk, 1004)
  495.         setCreatureMaxHealth(pk, getCreatureMaxHealth(pk) + ( vit * HPperVIT ))
  496.         doCreatureAddHealth(pk, pct * vit * HPperVIT)
  497.     end
  498.  
  499.     setPlayerStorageValue(pk, 1004, getItemAttribute(item, "vitality"))
  500.  
  501.     doRegainSpeed(pk)
  502.  
  503.     local nick = getItemAttribute(item, "poke")
  504.    
  505.     if string.find(tostring(nick), "Shiny") then
  506.        nick = tostring(nick):match("(Shiny .*)")
  507.     end
  508.  
  509.     if getItemAttribute(item, "nick") then
  510.         nick = getItemAttribute(item, "nick")
  511.     end
  512.  
  513.     setPlayerStorageValue(pk, 1007, nick)
  514.  
  515.     local boostlevel = getItemAttribute(item, "boost") or 0
  516.     local boostshow = hideBoost and "]" or " + "..boostlevel.."]"
  517.     local lvlstr = ""
  518.  
  519.     if showBoostSeparated then
  520.         boostshow = hideBoost and "]" or "] [+"..boostlevel.."]"
  521.     end
  522.  
  523.     if hideSummonsLevel then
  524.         if not hideBoost then
  525.             nick = nick.." [+"..boostlevel.."]"
  526.         end
  527.     else
  528.         nick = nick.." ["..getItemAttribute(item, "level")..""..boostshow..""
  529.     end
  530.  
  531.  
  532.     if not getItemAttribute(item, "happy") then
  533.         doItemSetAttribute(item, "happy", 120)
  534.     end
  535.  
  536.     if not getItemAttribute(item, "hunger") then
  537.         doItemSetAttribute(item, "hunger", 5)
  538.     end
  539.  
  540.     local happy = getItemAttribute(item, "happy")
  541.         if happy < 0 then
  542.             happy = 1
  543.         end
  544.     setPlayerStorageValue(pk, 1008, happy)
  545.  
  546.     local hunger = getItemAttribute(item, "hunger")
  547.     setPlayerStorageValue(pk, 1009, hunger)
  548.  
  549.     if health == true then
  550.         local mh = getCreatureMaxHealth(pk) + HPperVIT * getVitality(pk)
  551.         local rd = 1 - (tonumber(getItemAttribute(item, "hp")))
  552.         setCreatureMaxHealth(pk, mh)
  553.         doCreatureAddHealth(pk, getCreatureMaxHealth(pk))
  554.         doCreatureAddHealth(pk, -(getCreatureMaxHealth(pk) * rd))
  555.     end
  556.  
  557.     if isSummon(pk) and conditions then                        --alterado v2.5 daki pra baixo!!
  558.         local burn = getItemAttribute(item, "burn")  
  559.         if burn and burn >= 0 then
  560.            local ret = {id = pk, cd = burn, check = false, damage = getItemAttribute(item, "burndmg"), cond = "Burn"}
  561.            addEvent(doCondition2, 3500, ret)
  562.         end
  563.  
  564.         local poison = getItemAttribute(item, "poison")
  565.         if poison and poison >= 0 then
  566.            local ret = {id = pk, cd = poison, check = false, damage = getItemAttribute(item, "poisondmg"), cond = "Poison"}
  567.            addEvent(doCondition2, 1500, ret)
  568.         end
  569.  
  570.         local confuse = getItemAttribute(item, "confuse")
  571.         if confuse and confuse >= 0 then
  572.            local ret = {id = pk, cd = confuse, check = false, cond = "Confusion"}
  573.            addEvent(doCondition2, 1200, ret)                                                --alterado v2.5
  574.         end
  575.  
  576.         local sleep = getItemAttribute(item, "sleep")
  577.         if sleep and sleep >= 0 then
  578.            local ret = {id = pk, cd = sleep, check = false, first = true, cond = "Sleep"}
  579.            doCondition2(ret)
  580.         end
  581.        
  582.         local miss = getItemAttribute(item, "miss")    
  583.         if miss and miss >= 0 then      
  584.           local ret = {id = pk, cd = miss, eff = getItemAttribute(item, "missEff"), check = false, spell = getItemAttribute(item, "missSpell"), cond = "Miss"}
  585.           doCondition2(ret)
  586.         end
  587.        
  588.         local fear = getItemAttribute(item, "fear")
  589.         if fear and fear >= 0 then
  590.            local ret = {id = pk, cd = fear, check = false, skill = getItemAttribute(item, "fearSkill"), cond = "Fear"}
  591.            doCondition2(ret)
  592.         end
  593.        
  594.         local silence = getItemAttribute(item, "silence")
  595.         if silence and silence >= 0 then      
  596.            local ret = {id = pk, cd = silence, eff = getItemAttribute(item, "silenceEff"), check = false, cond = "Silence"}
  597.            doCondition2(ret)
  598.         end                                    
  599.        
  600.         local stun = getItemAttribute(item, "stun")
  601.         if stun and stun >= 0 then
  602.            local ret = {id = pk, cd = stun, eff = getItemAttribute(item, "stunEff"), check = false, spell = getItemAttribute(item, "stunSpell"), cond = "Stun"}
  603.            doCondition2(ret)
  604.         end
  605.                                                        
  606.         local paralyze = getItemAttribute(item, "paralyze")
  607.         if paralyze and paralyze >= 0 then
  608.            local ret = {id = pk, cd = paralyze, eff = getItemAttribute(item, "paralyzeEff"), check = false, first = true, cond = "Paralyze"}
  609.            doCondition2(ret)
  610.         end  
  611.                                                      
  612.         local slow = getItemAttribute(item, "slow")
  613.         if slow and slow >= 0 then
  614.            local ret = {id = pk, cd = slow, eff = getItemAttribute(item, "slowEff"), check = false, first = true, cond = "Slow"}
  615.            doCondition2(ret)
  616.         end                                              
  617.        
  618.         local leech = getItemAttribute(item, "leech")
  619.         if leech and leech >= 0 then
  620.            local ret = {id = pk, cd = leech, attacker = 0, check = false, damage = getItemAttribute(item, "leechdmg"), cond = "Leech"}
  621.            doCondition2(ret)
  622.         end                              
  623.        
  624.         for i = 1, 3 do
  625.             local buff = getItemAttribute(item, "Buff"..i)
  626.             if buff and buff >= 0 then
  627.                local ret = {id = pk, cd = buff, eff = getItemAttribute(item, "Buff"..i.."eff"), check = false,
  628.                buff = getItemAttribute(item, "Buff"..i.."skill"), first = true, attr = "Buff"..i}
  629.                doCondition2(ret)
  630.             end
  631.         end
  632.                
  633.     end
  634.                                                                        --alterado v2.9
  635.     if getItemAttribute(item, "boost") and getItemAttribute(item, "boost") >= 50 and getItemAttribute(item, "aura") then
  636.        sendAuraEffect(pk, auraSyst[getItemAttribute(item, "aura")])        
  637.     end
  638.    
  639.     if getPlayerStorageValue(getCreatureMaster(pk), 6598754) >= 1 then
  640.         setPlayerStorageValue(pk, 6598754, 1)                              
  641.     elseif getPlayerStorageValue(getCreatureMaster(pk), 6598755) >= 1 then
  642.         setPlayerStorageValue(pk, 6598755, 1)
  643.     end
  644.  
  645. return true
  646. end
  647.  
  648. function setWildPokemonLevel(cid, optionalLevel, optionalStatus, optionalNick, optionalExtraExp)
  649.  
  650.     if not isCreature(cid) then return true end
  651.     if not pokes[getCreatureName(cid)] then return true end  --alterado v2.6
  652.  
  653.     local levelRange = 0
  654.     local off = 0
  655.     local def = 0
  656.     local agi = 0
  657.     local spatk = 0
  658.     local vit = 0
  659.     local this = getCreatureName(cid)
  660.     local ee = 1
  661.  
  662.     if optionalExtraExp then
  663.         ee = optionalExtraExp
  664.     end
  665.  
  666.  
  667.     if optionalLevel and tonumber(optionalLevel) >= 1 then                --alterado v2.8\/
  668.         levelRange = optionalLevel
  669.     else
  670.         levelRange = math.random(pokes[this].wildLvlMin, pokes[this].wildLvlMax)
  671.     end                                                                                          
  672.  
  673.     local status = getPokemonStatus(this)
  674.         if status then
  675.             off = status.off
  676.             def = status.def
  677.             agi = status.agi
  678.             vit = status.vit
  679.             spatk = status.spatk
  680.         end
  681.  
  682.     setPlayerStorageValue(cid, 1000, (levelRange > 300 and 300 or levelRange)) --alterado v2.8
  683.  
  684.     if optionalStatus and optionalStatus.off then
  685.         setPlayerStorageValue(cid, 1001, optionalStatus.offense)
  686.         setPlayerStorageValue(cid, 1002, optionalStatus.defense)
  687.         setPlayerStorageValue(cid, 1003, optionalStatus.agility)
  688.         setPlayerStorageValue(cid, 1004, optionalStatus.vitality)
  689.         setPlayerStorageValue(cid, 1005, optionalStatus.specialattack)
  690.         setPlayerStorageValue(cid, 1011, optionalStatus.offense)
  691.         setPlayerStorageValue(cid, 1012, optionalStatus.defense)
  692.         setPlayerStorageValue(cid, 1013, optionalStatus.agility)
  693.         setPlayerStorageValue(cid, 1014, optionalStatus.vitality)
  694.         setPlayerStorageValue(cid, 1015, optionalStatus.specialattack)
  695.     else
  696.         setPlayerStorageValue(cid, 1001, 5 + math.random(off * levelRange * 0.9, off * levelRange * 1.8))
  697.         setPlayerStorageValue(cid, 1002, 5 + math.random(def * levelRange * 0.9, def * levelRange * 1.8))
  698.         setPlayerStorageValue(cid, 1003, math.random(agi * levelRange * 0.9, agi * levelRange * 1.8))
  699.         setPlayerStorageValue(cid, 1004, math.random(vit * levelRange * 0.9, vit * levelRange * 1.8))
  700.         setPlayerStorageValue(cid, 1005, 5 + math.random(spatk * levelRange * 0.9, spatk * levelRange * 1.8))
  701.         setPlayerStorageValue(cid, 1011, getPlayerStorageValue(cid, 1001))
  702.         setPlayerStorageValue(cid, 1012, getPlayerStorageValue(cid, 1002))
  703.         setPlayerStorageValue(cid, 1013, getPlayerStorageValue(cid, 1003))
  704.         setPlayerStorageValue(cid, 1014, getPlayerStorageValue(cid, 1004))
  705.         setPlayerStorageValue(cid, 1015, getPlayerStorageValue(cid, 1005))
  706.     end
  707.  
  708.     doRegainSpeed(cid)
  709.  
  710.     setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + getPlayerStorageValue(cid, 1004) * HPperVIT * vitReductionForWild)
  711.     doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
  712.    
  713.     if pokes[getCreatureName(cid)].exp then
  714.         --getMonsterInfo(getCreatureName(cid)).experience
  715.         local exp = (50 + pokes[getCreatureName(cid)].exp) * baseExpRate + pokes[getCreatureName(cid)].vitality * levelRange * pokemonExpPerLevelRate
  716.         setPlayerStorageValue(cid, 1006, exp * generalExpRate * ee)
  717.         if getPlayerStorageValue(cid, 22546) == 1 then
  718.           setPlayerStorageValue(cid, 1006, 750)
  719.           doSetCreatureDropLoot(cid, false)         --edited golden arena
  720.        end  
  721.     end
  722.  
  723.     local wildshow = wildBeforeNames and "Wild " or ""
  724.     if optionalNick then
  725.         if hideWildsLevel then
  726.             doCreatureSetNick(cid, optionalNick)
  727.         else
  728.             doCreatureSetNick(cid, optionalNick.." ["..getWildPokemonLevel(cid).."]")
  729.         end
  730.     else
  731.         if hideWildsLevel then
  732.             doCreatureSetNick(cid, ""..wildshow..""..getCreatureName(cid).."")
  733.         end
  734.     end
  735. end
  736.  
  737. function getOffenseInRage(cid)  --alterado v2.8
  738.     if not isCreature(cid) then return 0 end
  739.  
  740.     if getPlayerStorageValue(cid, 547888) >= 1 then
  741.         return tonumber(getPlayerStorageValue(cid, 1001)) / 2
  742.     end
  743.  
  744. return tonumber(getPlayerStorageValue(cid, 1001))
  745. end
  746.  
  747. function getOffense(cid)
  748.     if not isCreature(cid) then return 0 end
  749.  
  750.     --[[if getPlayerStorageValue(cid, 3894) >= 1 then
  751.         return tonumber(getPlayerStorageValue(cid, 1001)) / 2
  752.     end ]]
  753.  
  754. return tonumber(getPlayerStorageValue(cid, 1001))
  755. end
  756.  
  757. function getDefense(cid)
  758.     if not isCreature(cid) then return 0 end
  759.  
  760. --[[    if getPlayerStorageValue(cid, 3894) >= 1 then
  761.         return tonumber(getPlayerStorageValue(cid, 1002)) / 2
  762.     end  ]]
  763.  
  764. return tonumber(getPlayerStorageValue(cid, 1002))
  765. end
  766.  
  767. function getSpeed(cid)
  768.     if not isCreature(cid) then return 0 end
  769. return tonumber(getPlayerStorageValue(cid, 1003))
  770. end
  771.  
  772. function getVitality(cid)
  773.     if not isCreature(cid) then return 0 end
  774. return tonumber(getPlayerStorageValue(cid, 1004))
  775. end
  776.  
  777. function getSpecialAttack(cid)
  778.     if not isCreature(cid) then return 0 end
  779. return tonumber(getPlayerStorageValue(cid, 1005))
  780. end
  781.  
  782. function getHappiness(cid)
  783.     if not isCreature(cid) then return 0 end
  784. return tonumber(getPlayerStorageValue(cid, 1008))
  785. end
  786.  
  787. function getSpecialDefense(cid)
  788.     if not isCreature(cid) then return 0 end
  789. return getSpecialAttack(cid) * 0.85 + getDefense(cid) * 0.2
  790. end
  791.  
  792. function getWildPokemonExp(cid)
  793. return getPlayerStorageValue(cid, 1006)
  794. end
  795.  
  796. function getWildPokemonLevel(cid)    
  797. return getPlayerStorageValue(cid, 1000)
  798. end
  799.  
  800. function getLevel(cid)
  801.     if isSummon(cid) then
  802.     return getItemAttribute(getPlayerSlotItem(getCreatureMaster(cid), 8).uid, "level")
  803.     end
  804. return getPlayerStorageValue(cid, 1000)
  805. end
  806.  
  807. function getPokeName(cid)
  808.     if not isSummon(cid) then return getCreatureName(cid) end
  809.     if getCreatureName(cid) == "Evolution" then return getPlayerStorageValue(cid, 1007) end
  810.    
  811. local item = getPlayerSlotItem(getCreatureMaster(cid), 8)
  812.     if getItemAttribute(item.uid, "nick") then                          --alterado v2.7
  813.        return getItemAttribute(item.uid, "nick")
  814.     end
  815.     if string.find(tostring(getCreatureName(cid)), "Shiny") then
  816.       local newName = tostring(getCreatureName(cid)):match("(Shiny .*)")
  817.       return newName
  818.     end
  819. return getCreatureName(cid)
  820. end
  821.  
  822. function getPokeballName(item, truename)
  823. if not truename and getItemAttribute(item, "nick") then
  824. return getItemAttribute(item, "nick")
  825. end
  826. return getItemAttribute(item, "poke")
  827. end
  828.  
  829. function getPokemonName(cid)
  830. return getCreatureName(cid)
  831. end
  832.  
  833. function getMasterLevel(poke)
  834.     if not isSummon(poke) then return 0 end
  835. return getPlayerLevel(getCreatureMaster(poke)) --alterado v2.5
  836. end
  837.  
  838. function getPokeballBoost(ball)
  839.     if not isPokeball(ball.itemid) then return 0 end  --alterado v2.8
  840. return getItemAttribute(ball.uid, "boost") or 0
  841. end
  842.  
  843. function getPokemonBoost(poke)
  844.     if not isSummon(poke) then return 0 end       --alterado v2.5
  845. return getItemAttribute(getPlayerSlotItem(getCreatureMaster(poke), 8).uid, "boost") or 0
  846. end
  847.  
  848. function getPokemonLevelByName(name)
  849. return pokes[name] and pokes[name].level or 0  --alterado v2.9
  850. end
  851.  
  852. function getPokemonLevel(cid)
  853.     if not isCreature(cid) then return 0 end
  854. return getPlayerStorageValue(cid, 1000)
  855. end
  856.  
  857. function getPokemonGender(cid)
  858. return getCreatureSkullType(cid)
  859. end
  860.  
  861. function setPokemonGender(cid, gender)
  862. if isCreature(cid) and gender then        --alterado v2.8
  863.    doCreatureSetSkullType(cid, gender)
  864.    return true
  865. end
  866. return false
  867. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement