Advertisement
Kevick

Level System.lua --XTIBIA

Sep 27th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 15.48 KB | None | 0 0
  1. function adjustWildPoke(cid, optionalLevel)
  2.     if isMonster(cid) and pokes[getCreatureName(cid)] then
  3.        
  4.         local level = (optionalLevel and optionalLevel >= 1) and optionalLevel or getPokemonLevel(cid) --alterado v1.8
  5.        
  6.         setPlayerStorageValue(cid, 1000, level) --alterado v1.8
  7.         setPlayerStorageValue(cid, 1001, pokes[getCreatureName(cid)].offense * level)
  8.         setPlayerStorageValue(cid, 1002, pokes[getCreatureName(cid)].defense)
  9.         setPlayerStorageValue(cid, 1003, pokes[getCreatureName(cid)].agility)
  10.         setPlayerStorageValue(cid, 1004, pokes[getCreatureName(cid)].vitality * level)
  11.         setPlayerStorageValue(cid, 1005, pokes[getCreatureName(cid)].specialattack * level)
  12.        
  13.         doRegainSpeed(cid) --alterado!
  14.         setCreatureMaxHealth(cid, (getVitality(cid) * HPperVITwild))
  15.         doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
  16.        
  17.         if pokes[getCreatureName(cid)].exp then
  18.             local exp = pokes[getCreatureName(cid)].exp * baseExpRate + pokes[getCreatureName(cid)].vitality * pokemonExpPerLevelRate
  19.             setPlayerStorageValue(cid, 1006, (exp * generalExpRate/2)*10)
  20.             if getPlayerStorageValue(cid, 22546) == 1 then
  21.                 setPlayerStorageValue(cid, 1006, 750)
  22.                 doSetCreatureDropLoot(cid, false)
  23.             end
  24.         end
  25.     end
  26. end
  27.  
  28. function getPokemonXMLOutfit(name) --alterado v1.9 \/
  29.     local path = "data/monster/pokes/Shiny/"..name..".xml"
  30.     local tpw = io.type(io.open(path))
  31.    
  32.     if not tpw then
  33.         path = "data/monster/pokes/geracao 2/"..name..".xml"
  34.         tpw = io.type(io.open(path))
  35.     end
  36.     if not tpw then
  37.         path = "data/monster/pokes/geracao 1/"..name..".xml"
  38.         tpw = io.type(io.open(path))
  39.     end
  40.     if not tpw then
  41.         path = "data/monster/pokes/"..name..".xml"
  42.         tpw = io.type(io.open(path))
  43.     end
  44.     if not tpw then
  45.         return print("[getPokemonXMLOutfit] Poke with name: "..name.." ins't in any paste on monster/pokes/") and 2
  46.     end
  47.     local arq = io.open(path, "a+")
  48.     local txt = arq:read("*all")
  49.     arq:close()
  50.     local a, b = txt:find('look type="(.-)"')
  51.     txt = string.sub(txt, a + 11, b - 1)
  52.     return tonumber(txt)
  53. end
  54.  
  55. function doEvolutionOutfit(cid, oldout, outfit)
  56.     if not isCreature(cid) then return true end
  57.     if getCreatureOutfit(cid).lookType == oldout then
  58.         doSetCreatureOutfit(cid, {lookType = outfit}, -1)
  59.     else
  60.         doSetCreatureOutfit(cid, {lookType = oldout}, -1)
  61.     end
  62. end
  63.  
  64. function doSendEvolutionEffect(cid, pos, evolution, turn, ssj, evolve, f, h)
  65.     if not isCreature(cid) then
  66.         doSendAnimatedText(pos, "CANCEL", 215)
  67.         return true
  68.     end
  69.     if evolve then
  70.         doEvolvePokemon(getCreatureMaster(cid), {uid = cid}, evolution, 0, 0)
  71.         return true
  72.     end
  73.     doSendMagicEffect(pos, 18)
  74.     if ssj then
  75.         sendSSJEffect(evo)
  76.     end
  77.     doEvolutionOutfit(cid, f, h)
  78.     addEvent(doSendEvolutionEffect, math.pow(1900, turn/20), cid, getThingPos(cid), evolution, turn - 1, turn == 19, turn == 2, f, h)
  79. end
  80.  
  81. function sendSSJEffect(cid)
  82.     if not isCreature(cid) then return true end
  83.     local pos1 = getThingPos(cid)
  84.     local pos2 = getThingPos(cid)
  85.     pos2.x = pos2.x + math.random(-1, 1)
  86.     pos2.y = pos2.y - math.random(1, 2)
  87.     doSendDistanceShoot(pos1, pos2, 37)
  88.     addEvent(sendSSJEffect, 45, cid)
  89. end
  90.  
  91. function sendFinishEvolutionEffect(cid, alternate)
  92.     if not isCreature(cid) then return true end
  93.     local pos1 = getThingPos(cid)
  94.    
  95.     if alternate then
  96.         local pos = {
  97.             [1] = {-2, 0},
  98.             [2] = {-1, -1},
  99.             [3] = {0, -2},
  100.             [4] = {1, -1},
  101.             [5] = {2, 0},
  102.             [6] = {1, 1},
  103.             [7] = {0, 2},
  104.         [8] = {-1, 1}}
  105.         for a = 1, 8 do
  106.             local pos2 = getThingPos(cid)
  107.             pos2.x = pos2.x + pos[a][1]
  108.             pos2.y = pos2.y + pos[a][2]
  109.             local pos = getThingPos(cid)
  110.             doSendDistanceShoot(pos2, pos, 37)
  111.             addEvent(doSendDistanceShoot, 300, pos, pos2, 37)
  112.         end
  113.     else
  114.         for a = 0, 3 do
  115.             doSendDistanceShoot(pos1, getPosByDir(pos1, a), 37)
  116.         end
  117.         for a = 4, 7 do
  118.             addEvent(doSendDistanceShoot, 600, pos1, getPosByDir(pos1, a), 37)
  119.         end
  120.     end
  121. end
  122.  
  123. function doEvolvePokemon(cid, item2, theevo, stone1, stone2)
  124.    
  125.     if not isCreature(cid) then return true end
  126.    
  127.     if not pokes[theevo] or not pokes[theevo].offense then
  128.         doReturnPokemon(cid, item2.uid, getPlayerSlotItem(cid, 8), pokeballs[getPokeballType(getPlayerSlotItem(cid, 8).itemid)].effect, false, true)
  129.         return true
  130.     end
  131.    
  132.     local owner = getCreatureMaster(item2.uid)
  133.     local pokeball = getPlayerSlotItem(cid, 8)
  134.     local description = "Contains a "..theevo.."."
  135.     local pct = getCreatureHealth(item2.uid) / getCreatureMaxHealth(item2.uid)
  136.    
  137.     doItemSetAttribute(pokeball.uid, "hp", pct)
  138.    
  139.     doItemSetAttribute(pokeball.uid, "poke", theevo)
  140.     doItemSetAttribute(pokeball.uid, "description", "Contains a "..theevo..".")
  141.    
  142.     doPlayerSendTextMessage(cid, 27, "Congratulations! Your "..getPokeName(item2.uid).." evolved into a "..theevo.."!")
  143.    
  144.     doSendMagicEffect(getThingPos(item2.uid), 18)
  145.     doTransformItem(getPlayerSlotItem(cid, 7).uid, fotos[theevo])
  146.     doSendMagicEffect(getThingPos(cid), 173)
  147.    
  148.     local oldpos = getThingPos(item2.uid)
  149.     local oldlod = getCreatureLookDir(item2.uid)
  150.     doRemoveCreature(item2.uid)
  151.    
  152.     doSummonMonster(cid, theevo)
  153.     local pk = getCreatureSummons(cid)[1]
  154.    
  155.     doTeleportThing(pk, oldpos, false)
  156.     doCreatureSetLookDir(pk, oldlod)
  157.    
  158.     sendFinishEvolutionEffect(pk, true)
  159.     addEvent(sendFinishEvolutionEffect, 550, pk, true)
  160.     addEvent(sendFinishEvolutionEffect, 1050, pk)
  161.    
  162.     doPlayerRemoveItem(cid, stone1, 1)
  163.     doPlayerRemoveItem(cid, stone2, 1)
  164.    
  165.     doAddPokemonInOwnList(cid, theevo)
  166.    
  167.     local happy = getItemAttribute(pokeball.uid, "happy")
  168.    
  169.     doItemSetAttribute(pokeball.uid, "happy", happy + happyGainedOnEvolution)
  170.    
  171.     if happy + happyGainedOnEvolution > 255 then
  172.         doItemSetAttribute(pokeball.uid, "happy", 255)
  173.     end
  174.    
  175.     adjustStatus(pk, pokeball.uid, true, false)
  176.    
  177.     if useKpdoDlls then
  178.         doUpdateMoves(cid)
  179.     end
  180. end
  181.  
  182. function doMathDecimal(number, casas)
  183.    
  184.     if math.floor(number) == number then return number end
  185.    
  186.     local c = casas and casas + 1 or 3
  187.    
  188.     for a = 0, 10 do
  189.         if math.floor(number) < math.pow(10, a) then
  190.             local str = string.sub(""..number.."", 1, a + c)
  191.             return tonumber(str)
  192.         end
  193.     end
  194.    
  195.     return number
  196. end
  197.  
  198. function doAdjustWithDelay(cid, pk, health, vit, status)
  199.     if isCreature(cid) then
  200.         adjustStatus(pk, getPlayerSlotItem(cid, 8).uid, health, vir, status)
  201.     end
  202. end
  203.  
  204. function adjustStatus(pk, item, health, vite, conditions)
  205.    
  206.     if not isCreature(pk) then return true end
  207.    
  208.     local gender = getItemAttribute(item, "gender") and getItemAttribute(item, "gender") or 0
  209.     addEvent(doCreatureSetSkullType, 10, pk, gender)
  210.    
  211.     -- Defense --
  212.     local bonusdef = {}
  213.     local Tiers = {
  214.         [1] = {bonus = DefBonus1},
  215.     }
  216.     local Tier = getItemAttribute(item, "heldx")
  217.    
  218.     if Tier and Tier > 0 and Tier < 8 then
  219.         bonusdef = Tiers[Tier].bonus
  220.     else
  221.         bonusdef = 1
  222.     end
  223.     -- Defense --
  224.     -- Boost --
  225.     local bonusboost = {}
  226.     local Tiers2 = {
  227.         [36] = {bonus = BoostBonus1},
  228.     }
  229.     if Tier and Tier > 35 and Tier < 43 then
  230.         bonusboost = Tiers2[Tier].bonus
  231.     else
  232.         bonusboost = 0
  233.     end
  234.     -- Boost --
  235.     -- Haste --
  236.     local hastespeed = {}
  237.     local Tiers3 = {
  238.         [99] = {bonus = Hasteadd1},
  239.     }
  240.     if Tier and Tier > 98 and Tier < 106 then
  241.         hastespeed = Tiers3[Tier].bonus
  242.     else
  243.         hastespeed = 0
  244.     end
  245.     -- Haste --
  246.     -- Vitality --
  247.     local vitapoint = {}
  248.     local Tiers4 = {
  249.         [92] = {bonus = Vitality1},
  250.     }
  251.     if Tier and Tier > 91 and Tier < 99 then
  252.         vitapoint = Tiers4[Tier].bonus
  253.     else
  254.         vitapoint = 1
  255.     end
  256.     -- Vitality --
  257.     setPlayerStorageValue(pk, 1001, pokes[getCreatureName(pk)].offense + (getPokemonBoost(pk)) + bonusboost)
  258.     setPlayerStorageValue(pk, 1002, (pokes[getCreatureName(pk)].defense) * bonusdef + bonusboost)
  259.     setPlayerStorageValue(pk, 1003, pokes[getCreatureName(pk)].agility + hastespeed)
  260.     setPlayerStorageValue(pk, 1004, (pokes[getCreatureName(pk)].vitality + (getPokemonBoost(pk)) + bonusboost) * vitapoint)
  261.     setPlayerStorageValue(pk, 1005, pokes[getCreatureName(pk)].specialattack + (getPokemonBoost(pk)) + bonusboost)
  262.    
  263.     if vite == true then
  264.         local pct = getCreatureHealth(pk) / getCreatureMaxHealth(pk)
  265.         local vit = getVitality(pk)
  266.         setCreatureMaxHealth(pk, ( vit * HPperVITsummon ))
  267.         doCreatureAddHealth(pk, pct * vit * HPperVITsummon)
  268.     end
  269.    
  270.     doRegainSpeed(pk)
  271.    
  272.     local nick = getItemAttribute(item, "poke")
  273.    
  274.     if isGhostPokemon(pk) then
  275.         setPlayerStorageValue(pk, 8981, 1)
  276.         updateGhostWalk(pk)
  277.     end
  278.    
  279.     if string.find(tostring(nick), "Shiny") then
  280.         nick = tostring(nick):match("Shiny (.*)")
  281.     end
  282.    
  283.     if getItemAttribute(item, "nick") then
  284.         nick = getItemAttribute(item, "nick")
  285.     end
  286.    
  287.     setPlayerStorageValue(pk, 1007, nick)
  288.    
  289.     doCreatureSetNick(pk, nick)
  290.    
  291.     if not getItemAttribute(item, "happy") then
  292.         doItemSetAttribute(item, "happy", 120)
  293.     end
  294.    
  295.     if not getItemAttribute(item, "hunger") then
  296.         doItemSetAttribute(item, "hunger", 5)
  297.     end
  298.    
  299.     local happy = getItemAttribute(item, "happy")
  300.     if happy < 0 then
  301.         happy = 1
  302.     end
  303.     setPlayerStorageValue(pk, 1008, happy)
  304.    
  305.     local hunger = getItemAttribute(item, "hunger")
  306.     setPlayerStorageValue(pk, 1009, hunger)
  307.    
  308.     if health == true then
  309.         local mh = HPperVITsummon * getVitality(pk)
  310.         local rd = 1 - (tonumber(getItemAttribute(item, "hp")))
  311.         setCreatureMaxHealth(pk, mh)
  312.         doCreatureAddHealth(pk, getCreatureMaxHealth(pk))
  313.         doCreatureAddHealth(pk, -(getCreatureMaxHealth(pk) * rd))
  314.     end
  315.    
  316.     if isSummon(pk) and conditions then
  317.         local burn = getItemAttribute(item, "burn")
  318.         if burn and burn >= 0 then
  319.             local ret = {id = pk, cd = burn, check = false, damage = getItemAttribute(item, "burndmg"), cond = "Burn"}
  320.             addEvent(doCondition2, 3500, ret)
  321.         end
  322.        
  323.         local poison = getItemAttribute(item, "poison")
  324.         if poison and poison >= 0 then
  325.             local ret = {id = pk, cd = poison, check = false, damage = getItemAttribute(item, "poisondmg"), cond = "Poison"}
  326.             addEvent(doCondition2, 1500, ret)
  327.         end
  328.        
  329.         local confuse = getItemAttribute(item, "confuse")
  330.         if confuse and confuse >= 0 then
  331.             local ret = {id = pk, cd = confuse, check = false, cond = "Confusion"}
  332.             addEvent(doCondition2, 1200, ret)
  333.         end
  334.        
  335.         local sleep = getItemAttribute(item, "sleep")
  336.         if sleep and sleep >= 0 then
  337.             local ret = {id = pk, cd = sleep, check = false, first = true, cond = "Sleep"}
  338.             doCondition2(ret)
  339.         end
  340.        
  341.         local miss = getItemAttribute(item, "miss")
  342.         if miss and miss >= 0 then
  343.             local ret = {id = pk, cd = miss, eff = getItemAttribute(item, "missEff"), check = false, spell = getItemAttribute(item, "missSpell"), cond = "Miss"}
  344.             doCondition2(ret)
  345.         end
  346.        
  347.         local fear = getItemAttribute(item, "fear")
  348.         if fear and fear >= 0 then
  349.             local ret = {id = pk, cd = fear, check = false, skill = getItemAttribute(item, "fearSkill"), cond = "Fear"}
  350.             doCondition2(ret)
  351.         end
  352.        
  353.         local silence = getItemAttribute(item, "silence")
  354.         if silence and silence >= 0 then
  355.             local ret = {id = pk, cd = silence, eff = getItemAttribute(item, "silenceEff"), check = false, cond = "Silence"}
  356.             doCondition2(ret)
  357.         end
  358.        
  359.         local stun = getItemAttribute(item, "stun")
  360.         if stun and stun >= 0 then
  361.             local ret = {id = pk, cd = stun, eff = getItemAttribute(item, "stunEff"), check = false, spell = getItemAttribute(item, "stunSpell"), cond = "Stun"}
  362.             doCondition2(ret)
  363.         end
  364.        
  365.         local paralyze = getItemAttribute(item, "paralyze")
  366.         if paralyze and paralyze >= 0 then
  367.             local ret = {id = pk, cd = paralyze, eff = getItemAttribute(item, "paralyzeEff"), check = false, first = true, cond = "Paralyze"}
  368.             doCondition2(ret)
  369.         end
  370.        
  371.         local slow = getItemAttribute(item, "slow")
  372.         if slow and slow >= 0 then
  373.             local ret = {id = pk, cd = slow, eff = getItemAttribute(item, "slowEff"), check = false, first = true, cond = "Slow"}
  374.             doCondition2(ret)
  375.         end
  376.        
  377.         local leech = getItemAttribute(item, "leech")
  378.         if leech and leech >= 0 then
  379.             local ret = {id = pk, cd = leech, attacker = 0, check = false, damage = getItemAttribute(item, "leechdmg"), cond = "Leech"}
  380.             doCondition2(ret)
  381.         end
  382.        
  383.         for i = 1, 3 do
  384.             local buff = getItemAttribute(item, "Buff"..i)
  385.             if buff and buff >= 0 then
  386.                 local ret = {id = pk, cd = buff, eff = getItemAttribute(item, "Buff"..i.."eff"), check = false,
  387.                 buff = getItemAttribute(item, "Buff"..i.."skill"), first = true, attr = "Buff"..i}
  388.                 doCondition2(ret)
  389.             end
  390.         end
  391.        
  392.     end
  393.     --alterado v1.9
  394.     if getItemAttribute(item, "boost") and getItemAttribute(item, "boost") >= 50 and getItemAttribute(item, "aura") then
  395.         sendAuraEffect(pk, auraSyst[getItemAttribute(item, "aura")])
  396.     end
  397.    
  398.     if getPlayerStorageValue(getCreatureMaster(pk), 6598754) >= 1 then
  399.         setPlayerStorageValue(pk, 6598754, 1)
  400.     elseif getPlayerStorageValue(getCreatureMaster(pk), 6598755) >= 1 then
  401.         setPlayerStorageValue(pk, 6598755, 1)
  402.     end
  403.    
  404.     return true
  405. end
  406.  
  407. function getOffense(cid)
  408.     if not isCreature(cid) then return 0 end
  409.     return tonumber(getPlayerStorageValue(cid, 1001))
  410. end
  411.  
  412. function getDefense(cid)
  413.     if not isCreature(cid) then return 0 end
  414.     return tonumber(getPlayerStorageValue(cid, 1002))
  415. end
  416.  
  417. function getSpeed(cid)
  418.     if not isCreature(cid) then return 0 end
  419.     return tonumber(getPlayerStorageValue(cid, 1003))
  420. end
  421.  
  422. function getVitality(cid)
  423.     if not isCreature(cid) then return 0 end
  424.     return tonumber(getPlayerStorageValue(cid, 1004))
  425. end
  426.  
  427. function getSpecialAttack(cid)
  428.     if not isCreature(cid) then return 0 end
  429.     return tonumber(getPlayerStorageValue(cid, 1005))
  430. end
  431.  
  432. function getHappiness(cid)
  433.     if not isCreature(cid) then return 0 end
  434.     return tonumber(getPlayerStorageValue(cid, 1008))
  435. end
  436.  
  437. function getSpecialDefense(cid)
  438.     if not isCreature(cid) then return 0 end
  439.     return getSpecialAttack(cid) * 0.85 + getDefense(cid) * 0.2
  440. end
  441.  
  442. function getPokemonLevel(cid, dex)
  443.     if not isCreature(cid) then return 0 end
  444.     if not dex then --alterado v1.9
  445.         if ehMonstro(cid) and getPlayerStorageValue(cid, 1000) > 0 then
  446.             return getPlayerStorageValue(cid, 1000)
  447.         elseif ehMonstro(cid) then
  448.             return pokes[getCreatureName(cid)].wildLvl
  449.         end
  450.     end
  451.     return pokes[getCreatureName(cid)].level
  452. end
  453.  
  454. function getPokemonLevelByName(name)
  455.     return pokes[name] and pokes[name].level or 0 --alterado v1.9
  456. end
  457.  
  458. function getMasterLevel(poke)
  459.     if not isSummon(poke) then return 0 end
  460.     return getPlayerLevel(getCreatureMaster(poke))
  461. end
  462.  
  463. function getPokemonBoost(poke)
  464.     if not isSummon(poke) then return 0 end
  465.     return getItemAttribute(getPlayerSlotItem(getCreatureMaster(poke), 8).uid, "boost") or 0
  466. end
  467.  
  468. function getPokeballBoost(ball)
  469.     if not isPokeball(ball.itemid) then return 0 end --alterado v1.8
  470.     return getItemAttribute(ball.uid, "boost") or 0
  471. end
  472.  
  473. function getPokeName(cid)
  474.     if not isSummon(cid) then return getCreatureName(cid) end
  475.     if getCreatureName(cid) == "Evolution" then return getPlayerStorageValue(cid, 1007) end
  476.    
  477.     local item = getPlayerSlotItem(getCreatureMaster(cid), 8)
  478.     if getItemAttribute(item.uid, "nick") then
  479.         return getItemAttribute(item.uid, "nick")
  480.     end
  481.     if string.find(tostring(getCreatureName(cid)), "Shiny") then
  482.         local newName = tostring(getCreatureName(cid)):match("Shiny (.*)")
  483.         return newName
  484.     end
  485.     return getCreatureName(cid)
  486. end
  487.  
  488. function getPokeballName(item, truename)
  489.     if not truename and getItemAttribute(item, "nick") then
  490.         return getItemAttribute(item, "nick")
  491.     end
  492.     return getItemAttribute(item, "poke")
  493. end
  494.  
  495. function getPokemonName(cid)
  496.     return getCreatureName(cid)
  497. end
  498.  
  499. function getPokemonGender(cid) --alterado v1.9
  500.     return getCreatureSkullType(cid)
  501. end
  502.  
  503. function setPokemonGender(cid, gender)
  504.     if isCreature(cid) and gender then --alterado v1.8
  505.         doCreatureSetSkullType(cid, gender)
  506.         return true
  507.     end
  508.     return false
  509. end
  510.  
  511. function getWildPokemonExp(cid)
  512.     return getPlayerStorageValue(cid, 1006)
  513. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement