Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
1,431
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.30 KB | None | 0 0
  1. function getPokemonByName(cid, pokemon)
  2. local arraypoke = {}
  3. local container = getPlayerSlotItem(cid, 3).uid
  4. local pokeballs = getPokeballsInContainer(container)
  5. for i =1, #pokeballs do
  6. name = getItemAttribute(pokeballs[i], "poke")
  7. if pokemon == name then
  8. table.insert(arraypoke, pokeballs[i])
  9. return arraypoke[1]
  10. end
  11. end
  12. return false
  13. end
  14.  
  15. function tranfBallInShiny(pokeball)
  16. doItemSetAttribute(pokeball, "shiny", "shiny")
  17. return true
  18. end
  19.  
  20. function getShinyByPokeball(pokeball)
  21. local shiny = getItemAttribute(pokeball, "shiny")
  22. return shiny == "shiny" and true or false
  23. end
  24.  
  25.  
  26. function getShinyNameByPokeball(pokeball)
  27. local shiny = getItemAttribute(pokeball, "shiny")
  28. return shiny and "Shiny "..getItemAttribute(pokeball, "poke").."" or getItemAttribute(pokeball, "poke")
  29. end
  30.  
  31.  
  32. function setStatusPokeballByStatusStr(pokeball, status)
  33. local attr = string.explode(status, ",")
  34. local x = {"poke", "hp", "offense", "defense", "speed", "vitality", "specialattack", "happy", "gender", "hands", "description", "fakedesc", "boost", "ball", "defeated", "shiny"}
  35. for i =1, #attr do
  36. doItemSetAttribute(pokeball, x[i], attr[i])
  37. end
  38. end
  39.  
  40.  
  41. function copieAllStatusBalls(pokeball)
  42. local x = {"poke", "hp", "offense", "defense", "speed", "vitality", "specialattack", "happy", "gender", "hands", "description", "fakedesc", "boost", "ball", "defeated", "shiny"}
  43. str = ""
  44. sep = ","
  45. for i =1, #x do
  46. local attr = getItemAttribute(pokeball, x[i]) or 0
  47. local t = attr ..sep
  48. str = str..t
  49. end
  50.  
  51. return str
  52. end
  53.  
  54.  
  55. function atualizaPokes(cid)
  56. local item = getPlayerSlotItem(cid, 8)
  57. if item.uid <= 0 then return true end
  58. if not getItemAttribute(item.uid, "poke") then
  59. return true
  60. end
  61. for i, x in pairs(fotos) do
  62. if string.lower(getItemAttribute(item.uid, "poke")) == string.lower(i) then
  63. doTransformItem(getPlayerSlotItem(cid, 7).uid, fotos[i])
  64. if useOTClient then
  65. doPlayerSendCancel(cid, '12//,show')
  66. end
  67. if useKpdoDlls then
  68. doUpdateMoves(cid)
  69. end
  70.  
  71. end
  72. end
  73. end
  74.  
  75.  
  76.  
  77. function doSendPokemon(cid, pokemon)
  78.  
  79.  
  80. if getPlayerStorageValue(cid, 17000) >= 1 or getPlayerStorageValue(cid, 17001) >= 1 or getPlayerStorageValue(cid, 63215) >= 1
  81. or getPlayerStorageValue(cid, 75846) >= 1 or getPlayerStorageValue(cid, 5700) >= 1 then --alterado v1.9 <<
  82. return true
  83. end
  84.  
  85. if exhaustion.get(cid, 6666) and exhaustion.get(cid, 6666) > 0 then return true end
  86.  
  87. if #getCreatureSummons(cid) > 1 and getPlayerStorageValue(cid, 212124) <= 0 then --alterado v1.6
  88. if getPlayerStorageValue(cid, 637501) == -2 or getPlayerStorageValue(cid, 637501) >= 1 then
  89. BackTeam(cid)
  90. end
  91. end
  92.  
  93. if #getCreatureSummons(cid) > 0 then
  94. t = getPlayerSlotItem(cid, 8)
  95. local btype = getPokeballType(t.itemid)
  96. local effect = pokeballs[btype].effect or 21
  97.  
  98. doReturnPokemon(cid, getCreatureSummons(cid)[1], t,effect)
  99. end
  100.  
  101. t = getPlayerSlotItem(cid, 8)
  102. if t.uid ~= 0 then
  103. pokeslot = getItemAttribute(t.uid, "poke")
  104.  
  105.  
  106. if pokeslot == pokemon then
  107. t = getPlayerSlotItem(cid, 8)
  108. doGoPokemon(cid, t)
  109. atualizaPokes(cid)
  110. return true
  111. end
  112.  
  113. if getPokemonByName(cid, pokemon) then
  114. local poke = getPokemonByName(cid, pokemon)
  115. local attr = copieAllStatusBalls(t.uid)
  116. local id = t.itemid
  117. doRemoveItem(t.uid)
  118. local attr2 = copieAllStatusBalls(poke)
  119. local id2 = getThing(poke).itemid
  120. doRemoveItem(getPokemonByName(cid, pokemon))
  121. createBallByStatus(cid, attr2, id2)
  122. createBallByStatus(cid, attr, id)
  123. t = getPlayerSlotItem(cid, 8)
  124. doGoPokemon(cid, t)
  125. atualizaPokes(cid)
  126. return true
  127. end
  128. end
  129.  
  130.  
  131. if getPokemonByName(cid, pokemon) then
  132. local id = getThing(getPokemonByName(cid, pokemon)).itemid
  133. local attr = copieAllStatusBalls(getPokemonByName(cid, pokemon))
  134. doRemoveItem(getPokemonByName(cid, pokemon))
  135. createBallByStatus(cid, attr, id)
  136. t = getPlayerSlotItem(cid, 8)
  137. doGoPokemon(cid, t)
  138. atualizaPokes(cid)
  139. return true
  140. end
  141. return false
  142. end
  143.  
  144.  
  145. function sendPokeInfo(cid)
  146. local activeimg = true
  147. local poke = getPlayerSlotItem(cid, 8)
  148. local pokeslot = getItemAttribute(poke.uid, "poke")
  149. local pokeboost = getItemAttribute(poke.uid, "boost") or 0
  150. local pokehappy = getPlayerStorageValue(getCreatureSummons(cid)[1], 1008) or 1
  151. doPlayerSendCancel(cid, "NewInfo/"..pokeslot.."/"..pokeboost.."/"..pokehappy.."")
  152. if activeimg then
  153. local img = "ShowPoke/"
  154. doPlayerSendCancel(cid, img..pokeslot)
  155. end
  156. end
  157.  
  158. function doShowSelectChar(cid)
  159. doPlayerSendCancel(cid, "ShowChar")
  160. end
  161.  
  162. function doCloseSelectChar(cid)
  163. doPlayerSendCancel(cid, "CloseChar")
  164. end
  165.  
  166. function doShowLookPlayer(cid, target, msg)
  167. doPlayerSendCancel(cid, "ShowLook/"..getPlayerStorageValue(target, 21121).."/"..msg.."")
  168. end
  169.  
  170. function doCloseInfoPoke(cid)
  171. local activeimg = true
  172. doPlayerSendCancel(cid, "InfoClosed")
  173. if activeimg then
  174. local close = "ClosePoke"
  175. doPlayerSendCancel(cid, close)
  176. end
  177. end
  178.  
  179. function sendAllPokemonsBarPoke(cid)
  180. local container = getPlayerSlotItem(cid, 3).uid
  181. local pokes = "Pokebar"
  182. local t = getPlayerSlotItem(cid, 8)
  183. if t.uid ~= 0 then
  184. pokeslot = getItemAttribute(t.uid, "poke")
  185. pokes = pokes.."/"..pokeslot..""
  186. end
  187. local pokeballs = getPokeballsInContainer(container)
  188. for i =1, #pokeballs do
  189. pokemons = getItemAttribute(pokeballs[i], "poke")
  190. pokes = pokes.."/"..pokemons..""
  191. end
  192. doPlayerSendCancel(cid, pokes)
  193. end
  194.  
  195. function isPlayerOnline(uid)
  196. return isInArray(getPlayersOnline(), uid)
  197. end
  198.  
  199. function doRevivePokemon(cid, pokemon)
  200. if getPlayerItemCount(cid, 12344) <= 0 then return doPlayerSendCancel(cid, "Voce nao tem nenhum revive.") end
  201. local cooldownMoves = {
  202. ["Selfdestruct"] = 30,
  203. ["Selfdestruction"] = 30,
  204. }
  205. local balls = getPokeballsInContainerNew(getPlayerSlotItem(cid, 3).uid)
  206. if isPokeball(getPlayerSlotItem(cid, CONST_SLOT_FEET).itemid) then
  207. table.insert(balls, getPlayerSlotItem(cid, CONST_SLOT_FEET))
  208. end
  209. for i =1, #balls do
  210. local ball = balls[i]
  211. -- print("Pokemon: "..pokemon.." attrpoke> "..(getItemAttribute(ball.uid, "poke") or "sempoke").." attrnick> "..(getItemAttribute(ball.uid, "nick") or "sem nick"))
  212. if getItemAttribute(ball.uid, "poke") == pokemon or getItemAttribute(ball.uid, "nick") == pokemon then
  213. -- print("IGUAL")
  214. for type, index in pairs(pokeballs) do
  215. -- print(index.on.." / "..index.off)
  216. if ball.itemid == index.on or ball.itemid == index.off then
  217. -- print("revive")
  218. doTransformItem(ball.uid, index.on)
  219. doSetItemAttribute(ball.uid, "hp", 1)
  220. local name = getItemAttribute(ball.uid, "poke")
  221. for c = 1, 15 do
  222. local str = "move"..c
  223. local move = movestable[name][str]; move = move and cooldownMoves[move.name]
  224. setCD(ball.uid, str, move or 0)
  225. end
  226. setCD(ball.uid, "control", 0)
  227. setCD(ball.uid, "blink", 0) --alterado v1.6
  228. doSendMagicEffect(getThingPos(cid), 13)
  229. doPlayerRemoveItem(cid, 12344, 1)
  230. doCureBallStatus(ball.uid, "all")
  231. doUpdatePokemonsBar(cid)
  232. cleanBuffs2(ball.uid) --alterado v1.5
  233. return
  234. end
  235. end
  236. end
  237. end
  238. end
  239.  
  240.  
  241. function getPokeballsInContainerNew(container)
  242. if not isContainer(container) then return {} end
  243. local items = {}
  244. if isContainer(container) and getContainerSize(container) > 0 then
  245. for slot=0, (getContainerSize(container)-1) do
  246. local item = getContainerItem(container, slot)
  247. if isContainer(item.uid) then
  248. local itemsbag = getPokeballsInContainerNew(item.uid)
  249. for i=0, #itemsbag do
  250. table.insert(items, itemsbag[i])
  251. end
  252. elseif isPokeball(item.itemid) then
  253. table.insert(items, item)
  254. end
  255. end
  256. end
  257. return items
  258. end
  259.  
  260. function getVitalityByMaster(cid)
  261. if not isCreature(cid) then return 0 end
  262. local ball = getPlayerSlotItem(cid, 8).uid
  263. if not ball or ball <= 1 or not pokes[getItemAttribute(ball, 'poke')] then return true end
  264. return pokes[getItemAttribute(ball, 'poke')].vitality * (getPlayerLevel(cid) + (getItemAttribute(ball, 'boost') or 0))
  265. end
  266.  
  267. function onPokeHealthChange(cid, zerar)
  268. if not isCreature(cid) then return true end
  269. if zerar then doPlayerSendCancel(cid, '#ph#,0,0') end
  270. local ball = getPlayerSlotItem(cid, 8).uid
  271. if not ball or ball <= 1 or not pokes[getItemAttribute(ball, 'poke')] then return true end
  272.  
  273. if #getCreatureSummons(cid) >= 1 and getPlayerStorageValue(cid, 212124) <= 0 then --alterado v1.6
  274. local pokemon = getCreatureSummons(cid)[1]
  275. local pokelife = (getCreatureHealth(pokemon) / getCreatureMaxHealth(pokemon))
  276. doItemSetAttribute(ball, "hp", pokelife)
  277. end
  278.  
  279. local rd = 1 - (tonumber(getItemAttribute(ball, "hp")))
  280. local maxHp = HPperVITsummon * getVitalityByMaster(cid)
  281. local hp = maxHp -(maxHp * rd)
  282. doPlayerSendCancel(cid, '#ph#,'.. math.floor(hp) ..','.. math.floor(maxHp))
  283. end
  284.  
  285. function doOTCSendPokemonHealth(cid)
  286. local ball = getPlayerSlotItem(cid, CONST_SLOT_FEET)
  287. local pokemon = getCreatureSummons(cid)
  288. if not ball.uid or ball.uid <= 1 then
  289. return doSendPlayerExtendedOpcode(cid, 122, "0|0")
  290. end
  291. if #pokemon >= 1 then
  292. return doSendPlayerExtendedOpcode(cid, 122, getCreatureHealth(pokemon[1]).."|"..getCreatureMaxHealth(pokemon[1]))
  293. end
  294. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement