Advertisement
Kevick

Untitled

Jul 28th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.59 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. doItemSetAttribute(pokeball.uid, "poke", theevo)
  139. doItemSetAttribute(pokeball.uid, "description", "Contains a "..theevo..".")
  140.  
  141. doPlayerSendTextMessage(cid, 27, "Congratulations! Your "..getPokeName(item2.uid).." evolved into a "..theevo.."!")
  142.  
  143. doSendMagicEffect(getThingPos(item2.uid), 18)
  144. doTransformItem(getPlayerSlotItem(cid, 7).uid, fotos[theevo])
  145. doTransformItem(getPlayerSlotItem(cid, 8).uid, pokeballs[theevo].use)
  146.  
  147.  
  148.  
  149. doSendMagicEffect(getThingPos(cid), 173)
  150.  
  151. local oldpos = getThingPos(item2.uid)
  152. local oldlod = getCreatureLookDir(item2.uid)
  153. doRemoveCreature(item2.uid)
  154.  
  155. doSummonMonster(cid, theevo, getThingPos(cid))
  156.  
  157. local pk = getCreatureSummons(cid)[1]
  158.  
  159. doCreatureSetLookDir(pk, oldlod)
  160.  
  161. sendFinishEvolutionEffect(pk, true)
  162. addEvent(sendFinishEvolutionEffect, 550, pk, true)
  163. addEvent(sendFinishEvolutionEffect, 1050, pk)
  164.  
  165. doPlayerRemoveItem(cid, stone1, 1)
  166. doPlayerRemoveItem(cid, stone2, 1)
  167.  
  168. doAddPokemonInOwnList(cid, theevo)
  169.  
  170. local happy = getItemAttribute(pokeball.uid, "happy")
  171.  
  172. doItemSetAttribute(pokeball.uid, "happy", happy + happyGainedOnEvolution)
  173.  
  174. if happy + happyGainedOnEvolution > 255 then
  175. doItemSetAttribute(pokeball.uid, "happy", 255)
  176. end
  177.  
  178. adjustStatus(pk, pokeball.uid, true, false)
  179. --doTeleportThing(getCreatureSummons(cid)[1], getThingPos(cid))
  180.  
  181. if useKpdoDlls then
  182. doUpdateMoves(cid)
  183. end
  184. end
  185.  
  186. function doMathDecimal(number, casas)
  187.  
  188. if math.floor(number) == number then return number end
  189.  
  190. local c = casas and casas + 1 or 3
  191.  
  192. for a = 0, 10 do
  193. if math.floor(number) < math.pow(10, a) then
  194. local str = string.sub(""..number.."", 1, a + c)
  195. return tonumber(str)
  196. end
  197. end
  198.  
  199. return number
  200. end
  201.  
  202. function doAdjustWithDelay(cid, pk, health, vit, status)
  203. if isCreature(cid) then
  204. adjustStatus(pk, getPlayerSlotItem(cid, 8).uid, health, vir, status)
  205. end
  206. end
  207.  
  208. function adjustStatus(pk, item, health, vite, conditions)
  209. if getPlayerStorageValue(getCreatureMaster(pk), 990) >= 1 then
  210. setPlayerStorageValue(pk, 6598754, 1)
  211. end
  212.  
  213. if not isCreature(pk) then return true end
  214. doRegenerateWithHeld(getCreatureMaster(pk), pk)
  215. --doTeleportThing(pk, getClosestFreeTile(pk, getThingPos(cid)), true)
  216.  
  217. local gender = getItemAttribute(item, "gender") and getItemAttribute(item, "gender") or 0
  218. addEvent(doCreatureSetSkullType, 10, pk, gender)
  219.  
  220. setPlayerStorageValue(pk, 1001, pokes[getCreatureName(pk)].offense * (getMasterLevel(pk) + getPokemonBoost(pk)))
  221. setPlayerStorageValue(pk, 1002, pokes[getCreatureName(pk)].defense)
  222. setPlayerStorageValue(pk, 1003, pokes[getCreatureName(pk)].agility)
  223. setPlayerStorageValue(pk, 1004, pokes[getCreatureName(pk)].vitality * (getMasterLevel(pk) + getPokemonBoost(pk)))
  224. setPlayerStorageValue(pk, 1005, pokes[getCreatureName(pk)].specialattack * (getMasterLevel(pk) + getPokemonBoost(pk)))
  225. -- Defense --
  226. local bonusdef = {}
  227. local Tiers = {
  228. [1] = {bonus = DefBonus1},
  229. [2] = {bonus = DefBonus2},
  230. [3] = {bonus = DefBonus3},
  231. [4] = {bonus = DefBonus4},
  232. [5] = {bonus = DefBonus5},
  233. [6] = {bonus = DefBonus6},
  234. [7] = {bonus = DefBonus7},
  235. }
  236. local Tier = getItemAttribute(item, "heldx")
  237.  
  238. if Tier and Tier > 0 and Tier < 8 then
  239. bonusdef = Tiers[Tier].bonus
  240. else
  241. bonusdef = 1
  242. end
  243. -- Defense --
  244. -- Boost --
  245. local bonusboost = {}
  246. local Tiers2 = {
  247. [36] = {bonus = BoostBonus1},
  248. [37] = {bonus = BoostBonus2},
  249. [38] = {bonus = BoostBonus3},
  250. [39] = {bonus = BoostBonus4},
  251. [40] = {bonus = BoostBonus5},
  252. [41] = {bonus = BoostBonus6},
  253. [42] = {bonus = BoostBonus7},
  254. }
  255. if Tier and Tier > 35 and Tier < 43 then
  256. bonusboost = Tiers2[Tier].bonus
  257. else
  258. bonusboost = 0
  259. end
  260. -- Boost --
  261.  
  262. if vite == true then
  263. local pct = getCreatureHealth(pk) / getCreatureMaxHealth(pk)
  264. local vit = getVitality(pk)
  265. setCreatureMaxHealth(pk, ( vit * HPperVITsummon ))
  266. doCreatureAddHealth(pk, pct * vit * HPperVITsummon)
  267. end
  268.  
  269. doRegainSpeed(pk)
  270.  
  271. local nick = getItemAttribute(item, "poke")
  272.  
  273. if isGhostPokemon(pk) then
  274. setPlayerStorageValue(pk, 8981, 1)
  275. updateGhostWalk(pk)
  276. end
  277.  
  278. if string.find(tostring(nick), "Shiny") then
  279. nick = tostring(nick):match("Shiny (.*)")
  280. end
  281.  
  282. if getItemAttribute(item, "nick") then
  283. nick = getItemAttribute(item, "nick")
  284. end
  285.  
  286. setPlayerStorageValue(pk, 1007, nick)
  287.  
  288. doCreatureSetNick(pk, nick)
  289.  
  290. if not getItemAttribute(item, "happy") then
  291. doItemSetAttribute(item, "happy", 120)
  292. end
  293.  
  294. if not getItemAttribute(item, "hunger") then
  295. doItemSetAttribute(item, "hunger", 5)
  296. end
  297.  
  298. local happy = getItemAttribute(item, "happy")
  299. if happy < 0 then
  300. happy = 1
  301. end
  302. setPlayerStorageValue(pk, 1008, happy)
  303.  
  304. local hunger = getItemAttribute(item, "hunger")
  305. setPlayerStorageValue(pk, 1009, hunger)
  306.  
  307. if health == true then
  308. local mh = HPperVITsummon * getVitality(pk)
  309. local rd = 1 - (tonumber(getItemAttribute(item, "hp")))
  310. setCreatureMaxHealth(pk, mh)
  311. doCreatureAddHealth(pk, getCreatureMaxHealth(pk))
  312. doCreatureAddHealth(pk, -(getCreatureMaxHealth(pk) * rd))
  313. end
  314.  
  315. if isSummon(pk) and conditions then
  316. local burn = getItemAttribute(item, "burn")
  317. if burn and burn >= 0 then
  318. local ret = {id = pk, cd = burn, check = false, damage = getItemAttribute(item, "burndmg"), cond = "Burn"}
  319. addEvent(doCondition2, 3500, ret)
  320. end
  321.  
  322. local poison = getItemAttribute(item, "poison")
  323. if poison and poison >= 0 then
  324. local ret = {id = pk, cd = poison, check = false, damage = getItemAttribute(item, "poisondmg"), cond = "Poison"}
  325. addEvent(doCondition2, 1500, ret)
  326. end
  327.  
  328. local confuse = getItemAttribute(item, "confuse")
  329. if confuse and confuse >= 0 then
  330. local ret = {id = pk, cd = confuse, check = false, cond = "Confusion"}
  331. addEvent(doCondition2, 1200, ret)
  332. end
  333.  
  334. local sleep = getItemAttribute(item, "sleep")
  335. if sleep and sleep >= 0 then
  336. local ret = {id = pk, cd = sleep, check = false, first = true, cond = "Sleep"}
  337. doCondition2(ret)
  338. end
  339.  
  340. local miss = getItemAttribute(item, "miss")
  341. if miss and miss >= 0 then
  342. local ret = {id = pk, cd = miss, eff = getItemAttribute(item, "missEff"), check = false, spell = getItemAttribute(item, "missSpell"), cond = "Miss"}
  343. doCondition2(ret)
  344. end
  345.  
  346. local fear = getItemAttribute(item, "fear")
  347. if fear and fear >= 0 then
  348. local ret = {id = pk, cd = fear, check = false, skill = getItemAttribute(item, "fearSkill"), cond = "Fear"}
  349. doCondition2(ret)
  350. end
  351.  
  352. local silence = getItemAttribute(item, "silence")
  353. if silence and silence >= 0 then
  354. local ret = {id = pk, cd = silence, eff = getItemAttribute(item, "silenceEff"), check = false, cond = "Silence"}
  355. doCondition2(ret)
  356. end
  357.  
  358. local stun = getItemAttribute(item, "stun")
  359. if stun and stun >= 0 then
  360. local ret = {id = pk, cd = stun, eff = getItemAttribute(item, "stunEff"), check = false, spell = getItemAttribute(item, "stunSpell"), cond = "Stun"}
  361. doCondition2(ret)
  362. end
  363.  
  364. local paralyze = getItemAttribute(item, "paralyze")
  365. if paralyze and paralyze >= 0 then
  366. local ret = {id = pk, cd = paralyze, eff = getItemAttribute(item, "paralyzeEff"), check = false, first = true, cond = "Paralyze"}
  367. doCondition2(ret)
  368. end
  369.  
  370. local slow = getItemAttribute(item, "slow")
  371. if slow and slow >= 0 then
  372. local ret = {id = pk, cd = slow, eff = getItemAttribute(item, "slowEff"), check = false, first = true, cond = "Slow"}
  373. doCondition2(ret)
  374. end
  375.  
  376. local leech = getItemAttribute(item, "leech")
  377. if leech and leech >= 0 then
  378. local ret = {id = pk, cd = leech, attacker = 0, check = false, damage = getItemAttribute(item, "leechdmg"), cond = "Leech"}
  379. doCondition2(ret)
  380. end
  381.  
  382. for i = 1, 3 do
  383. local buff = getItemAttribute(item, "Buff"..i)
  384. if buff and buff >= 0 then
  385. local ret = {id = pk, cd = buff, eff = getItemAttribute(item, "Buff"..i.."eff"), check = false,
  386. buff = getItemAttribute(item, "Buff"..i.."skill"), first = true, attr = "Buff"..i}
  387. doCondition2(ret)
  388. end
  389. end
  390.  
  391. end
  392. --alterado v1.9
  393. if getItemAttribute(item, "boost") and getItemAttribute(item, "boost") >= 50 and getItemAttribute(item, "aura") then
  394. sendAuraEffect(pk, auraSyst[getItemAttribute(item, "aura")])
  395. end
  396.  
  397. if getPlayerStorageValue(getCreatureMaster(pk), 6598754) >= 1 then
  398. setPlayerStorageValue(pk, 6598754, 1)
  399. elseif getPlayerStorageValue(getCreatureMaster(pk), 6598755) >= 1 then
  400. setPlayerStorageValue(pk, 6598755, 1)
  401. end
  402.  
  403. return true
  404. end
  405.  
  406. function getOffense(cid)
  407. if not isCreature(cid) then return 0 end
  408. return tonumber(getPlayerStorageValue(cid, 1001))
  409. end
  410.  
  411. function getDefense(cid)
  412. if not isCreature(cid) then return 0 end
  413. return tonumber(getPlayerStorageValue(cid, 1002))
  414. end
  415.  
  416. function getSpeed(cid)
  417. if not isCreature(cid) then return 0 end
  418. return tonumber(getPlayerStorageValue(cid, 1003))
  419. end
  420.  
  421. function getVitality(cid)
  422. if not isCreature(cid) then return 0 end
  423. return tonumber(getPlayerStorageValue(cid, 1004))
  424. end
  425.  
  426. function getSpecialAttack(cid)
  427. if not isCreature(cid) then return 0 end
  428. return tonumber(getPlayerStorageValue(cid, 1005))
  429. end
  430.  
  431. function getHappiness(cid)
  432. if not isCreature(cid) then return 0 end
  433. return tonumber(getPlayerStorageValue(cid, 1008))
  434. end
  435.  
  436. function getSpecialDefense(cid)
  437. if not isCreature(cid) then return 0 end
  438. return getSpecialAttack(cid) * 0.85 + getDefense(cid) * 0.2
  439. end
  440.  
  441. function getPokemonLevel(cid, dex)
  442. if not isCreature(cid) then return 0 end
  443. if not dex then --alterado v1.9
  444. if ehMonstro(cid) and getPlayerStorageValue(cid, 1000) > 0 then
  445. return getPlayerStorageValue(cid, 1000)
  446. elseif ehMonstro(cid) then
  447. return pokes[getCreatureName(cid)].wildLvl
  448. end
  449. end
  450. return pokes[getCreatureName(cid)].level
  451. end
  452.  
  453. function getPokemonLevelByName(name)
  454. return pokes[name] and pokes[name].level or 0 --alterado v1.9
  455. end
  456.  
  457. function getMasterLevel(poke)
  458. if not isSummon(poke) then return 0 end
  459. return getPlayerLevel(getCreatureMaster(poke))
  460. end
  461.  
  462. function getPokemonBoost(poke)
  463. if not isSummon(poke) then return 0 end
  464. return getItemAttribute(getPlayerSlotItem(getCreatureMaster(poke), 8).uid, "boost") or 0
  465. end
  466.  
  467. function getPokeballBoost(ball)
  468. if not isPokeball(ball.itemid) then return 0 end --alterado v1.8
  469. return getItemAttribute(ball.uid, "boost") or 0
  470. end
  471.  
  472. function getPokeName(cid)
  473. if not isSummon(cid) then return getCreatureName(cid) end
  474. if getCreatureName(cid) == "Evolution" then return getPlayerStorageValue(cid, 1007) end
  475.  
  476. local item = getPlayerSlotItem(getCreatureMaster(cid), 8):
  477. if getItemAttribute(item.uid, "nick") then
  478. return getItemAttribute(item.uid, "nick")
  479. end
  480. if string.find(tostring(getCreatureName(cid)), "Shiny") then
  481. local newName = tostring(getCreatureName(cid)):match("Shiny (.*)")
  482. return newName
  483. end
  484. return getCreatureName(cid)
  485. end
  486.  
  487. function getPokeballName(item, truename)
  488. if not truename and getItemAttribute(item, "nick") then
  489. return getItemAttribute(item, "nick")
  490. end
  491. return getItemAttribute(item, "poke")
  492. end
  493.  
  494. function getPokemonName(cid)
  495. return getCreatureName(cid)
  496. end
  497.  
  498. function getPokemonGender(cid) --alterado v1.9
  499. return getCreatureSkullType(cid)
  500. end
  501.  
  502. function setPokemonGender(cid, gender)
  503. if isCreature(cid) and gender then --alterado v1.8
  504. doCreatureSetSkullType(cid, gender)
  505. return true
  506. end
  507. return false
  508. end
  509.  
  510. function getWildPokemonExp(cid)
  511. return getPlayerStorageValue(cid, 1006)
  512. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement