Advertisement
Guest User

Untitled

a guest
Apr 21st, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. local backmessages = {"Good job, ", "Well done, ", "Back, ", "Enough, ", "Great, "}
  2. local gomessages = {"Time to battle, ", "Go, ", "Do your job, ", "It's your time, "}
  3. local backmsg = backmessages[math.random(#backmessages)]
  4. local gomsg = gomessages[math.random(#gomessages)]
  5.  
  6. function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
  7.  
  8.  
  9. local orig = player:getPosition()
  10.  
  11. local pokename = item:getAttribute("text")
  12. local hp = item:getAttribute("defense")
  13. local maxhp = item:getAttribute("attack")
  14.  
  15. if item ~= player:getSlotItem(CONST_SLOT_ARMOR) then
  16. player:say("You must put your pokeball in the correct place!", TALKTYPE_MONSTER_SAY)
  17. return true
  18. end
  19.  
  20. if item:getId() == 2650 then
  21.  
  22. if #player:getSummons() == 0 then
  23. if orig:getTile():hasFlag(TILESTATE_PROTECTIONZONE) then
  24. player:say("You can't use Pokemon in safezone.", TALKTYPE_MONSTER_SAY)
  25. return false
  26. end
  27. local monster = Game.createMonster(pokename, orig)
  28. local monsterpos = monster:getPosition()
  29. player:registerEvent("PlayerDeath")
  30. monster:setMaster(player)
  31. monster:setMaxHealth(maxhp)
  32. local getHealthOrig = monster:getHealth()
  33. player:setStorageValue(1020, 1)
  34. monster:addHealth(hp)
  35. monster:addHealth(hp - getHealthOrig)
  36. player:say(gomsg..""..pokename.."!", TALKTYPE_MONSTER_SAY)
  37. monsterpos:sendMagicEffect(22)
  38. item:transform(2651, 1)
  39. end
  40. else
  41. if item:getId() == 2651 then
  42.  
  43. if hp == 0 then
  44. player:say("Your pokemon are fainted.", TALKTYPE_MONSTER_SAY)
  45. else
  46.  
  47. for _,z in pairs(player:getSummons()) do
  48. local monsterposback = z:getPosition()
  49. local healthpoke = z:getHealth()
  50. item:setAttribute("defense", ""..healthpoke.."")
  51. player:setStorageValue(1020, 0)
  52. monsterposback:sendMagicEffect(22)
  53. player:say(backmsg..""..pokename.."!", TALKTYPE_MONSTER_SAY)
  54. z:remove()
  55. item:transform(2650, 1)
  56. end
  57. end
  58. end
  59. end
  60. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement