Advertisement
Guest User

pokemonLife.lua

a guest
Jan 31st, 2015
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. local msgs = {
  2. back = {"Come back, poke!", "Thanks for helping, poke!", "That's enough, come back!", "You were great, poke!", "Excellent work, poke!", "Well done, poke!"}
  3. }
  4.  
  5. function onDeath(cid)
  6. local owner = getCreatureMaster(cid)
  7.  
  8. if isPlayer(owner) then
  9.  
  10. doTransformItem(getPlayerSlotItem(owner, 8).uid, getItemInfo(getPlayerSlotItem(owner, 8).itemid).ballDischarged)
  11. doPlayerSendTextMessage(owner, 22, "Your pokemon fainted.")
  12. doCreatureSay(owner, msgs.back[math.random(1, #msgs.back)]:gsub("poke", getCreatureName(cid)), TALKTYPE_ORANGE_1)
  13. doItemSetAttribute(getPlayerSlotItem(owner, 8).uid, "pokeHealth", "0")
  14. end
  15. return true
  16. end
  17.  
  18. function onStatsChange(cid, attacker, type, combat, value)
  19. if type == STATSCHANGE_HEALTHLOSS then
  20. if isCreature(attacker) then
  21. if isMonster(cid) then
  22. local multiplier = 0
  23. if getMonsterInfo(getCreatureName(cid)).pokeEffective:find(getCombatName(combat)) then
  24. multiplier = 2
  25. elseif getMonsterInfo(getCreatureName(cid)).pokeIneffective:find(getCombatName(combat)) then
  26. multiplier = 0.5
  27. elseif getMonsterInfo(getCreatureName(cid)).pokeNormal:find(getCombatName(combat)) then
  28. multiplier = 1
  29. end
  30.  
  31. doTargetCombatHealth(attacker, cid, combat, - (value * multiplier), - (value * multiplier), 255)
  32. end
  33. end
  34. end
  35. return true
  36. end
  37.  
  38. function onSpawn(cid)
  39. local gainHealth = (getMonsterInfo(getCreatureName(cid)).health * getMonsterInfo(getCreatureName(cid)).wildLevel)
  40.  
  41. setCreatureMaxHealth(cid, (getCreatureMaxHealth(cid) + gainHealth))
  42. doCreatureAddHealth(cid, (getCreatureMaxHealth(cid) - getCreatureHealth(cid)))
  43. return true
  44. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement