Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local backmessages = {"Good job, ", "Well done, ", "Back, ", "Enough, ", "Great, "}
- local gomessages = {"Time to battle, ", "Go, ", "Do your job, ", "It's your time, "}
- local backmsg = backmessages[math.random(#backmessages)]
- local gomsg = gomessages[math.random(#gomessages)]
- function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
- local orig = player:getPosition()
- local pokename = item:getAttribute("text")
- local hp = item:getAttribute("defense")
- local maxhp = item:getAttribute("attack")
- if item ~= player:getSlotItem(CONST_SLOT_ARMOR) then
- player:say("You must put your pokeball in the correct place!", TALKTYPE_MONSTER_SAY)
- return true
- end
- if item:getId() == 2650 then
- if #player:getSummons() == 0 then
- if orig:getTile():hasFlag(TILESTATE_PROTECTIONZONE) then
- player:say("You can't use Pokemon in safezone.", TALKTYPE_MONSTER_SAY)
- return false
- end
- local monster = Game.createMonster(pokename, orig)
- local monsterpos = monster:getPosition()
- player:registerEvent("PlayerDeath")
- monster:setMaster(player)
- monster:setMaxHealth(maxhp)
- local getHealthOrig = monster:getHealth()
- player:setStorageValue(1020, 1)
- monster:addHealth(hp)
- monster:addHealth(hp - getHealthOrig)
- player:say(gomsg..""..pokename.."!", TALKTYPE_MONSTER_SAY)
- monsterpos:sendMagicEffect(22)
- item:transform(2651, 1)
- end
- else
- if item:getId() == 2651 then
- if hp == 0 then
- player:say("Your pokemon are fainted.", TALKTYPE_MONSTER_SAY)
- else
- for _,z in pairs(player:getSummons()) do
- local monsterposback = z:getPosition()
- local healthpoke = z:getHealth()
- item:setAttribute("defense", ""..healthpoke.."")
- player:setStorageValue(1020, 0)
- monsterposback:sendMagicEffect(22)
- player:say(backmsg..""..pokename.."!", TALKTYPE_MONSTER_SAY)
- z:remove()
- item:transform(2650, 1)
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement