Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.85 KB | None | 0 0
  1. local config = {
  2. removeOnUse = "yes",
  3. usableOnTarget = "yes", -- can be used on target? (fe. healing friend)
  4. splashable = "no",
  5. realAnimation = "no", -- make text effect visible only for players in range 1x1
  6. healthMultiplier = 1.0,
  7. manaMultiplier = 1.0
  8. }
  9.  
  10. config.removeOnUse = getBooleanFromString(config.removeOnUse)
  11. config.usableOnTarget = getBooleanFromString(config.usableOnTarget)
  12. config.splashable = getBooleanFromString(config.splashable)
  13. config.realAnimation = getBooleanFromString(config.realAnimation)
  14.  
  15. local POTIONS = {
  16.  
  17.  
  18. [8704] = {empty = 7636, splash = 2, health = {50, 100}}, -- small health potion
  19. [7618] = {empty = 7636, splash = 2, health = {100, 200}}, -- health potion
  20. [7588] = {empty = 7634, splash = 2, health = {200, 400}, level = 50, vocations = {3, 4, 2, 7, 8, 9}, vocStr = "warriors and guardians and rangers"}, -- strong health potion
  21. [7591] = {empty = 7635, splash = 2, health = {500, 700}, level = 80, vocations = {4, 3, 8, 9}, vocStr = "warriors and guardians"}, -- great health potion
  22. [8473] = {empty = 7635, splash = 2, health = {800, 1000}, level = 130, vocations = {4, 3, 8, 9}, vocStr = "warriors and guardians"}, -- ultimate health potion
  23.  
  24. [7620] = {empty = 7636, splash = 7, mana = {70, 130} vocations = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, -- mana potion
  25. [7589] = {empty = 7634, splash = 7, mana = {110, 190}, level = 50, vocations = {1, 5, 6, 8, 10}, vocStr = "nymphs and elementalists"}, -- strong mana potion
  26. [7590] = {empty = 7635, splash = 7, mana = {350, 450}, level = 80, vocations = {1, 5, 6, 10}, vocStr = "nymphs and elementalists"}, -- great mana potion
  27.  
  28. [8472] = {empty = 7635, splash = 3, health = {200, 400}, mana = {110, 190}, level = 80, vocations = {2, 6}, vocStr = "Rangers"} -- great spirit potion
  29. }
  30.  
  31. local exhaust = createConditionObject(CONDITION_EXHAUST)
  32. setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))
  33.  
  34. function onUse(cid, item, fromPosition, itemEx, toPosition)
  35. local potion = POTIONS[item.itemid]
  36. if(not potion) then
  37. return false
  38. end
  39.  
  40. if(not isPlayer(itemEx.uid) or (not config.usableOnTarget and cid ~= itemEx.uid)) then
  41. if(not config.splashable) then
  42. return false
  43. end
  44.  
  45. if(toPosition.x == CONTAINER_POSITION) then
  46. toPosition = getThingPos(item.uid)
  47. end
  48.  
  49. doDecayItem(doCreateItem(2016, potion.splash, toPosition))
  50. doTransformItem(item.uid, potion.empty)
  51. return true
  52. end
  53.  
  54. if(hasCondition(cid, CONDITION_EXHAUST_HEAL)) then
  55. doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
  56. return true
  57. end
  58.  
  59. if(((potion.level and getPlayerLevel(cid) < potion.level) or (potion.vocations and not isInArray(potion.vocations, getPlayerVocation(cid)))) and
  60. not getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES))
  61. then
  62. doCreatureSay(itemEx.uid, "Only " .. potion.vocStr .. (potion.level and (" of level " .. potion.level) or "") .. " or above may drink this fluid.", TALKTYPE_ORANGE_1)
  63. return true
  64. end
  65.  
  66. local health = potion.health
  67. if(health and not doCreatureAddHealth(itemEx.uid, math.ceil(math.random(health[1], health[2]) * config.healthMultiplier))) then
  68. return false
  69. end
  70.  
  71. local mana = potion.mana
  72. if(mana and not doPlayerAddMana(itemEx.uid, math.ceil(math.random(mana[1], mana[2]) * config.manaMultiplier))) then
  73. return false
  74. end
  75.  
  76. doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE)
  77. if(not realAnimation) then
  78. doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1)
  79. else
  80. for i, tid in ipairs(getSpectators(getCreaturePosition(cid), 1, 1)) do
  81. if(isPlayer(tid)) then
  82. doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1, false, tid)
  83. end
  84. end
  85. end
  86.  
  87. doAddCondition(cid, exhaust)
  88. if(not potion.empty or config.removeOnUse) then
  89. doRemoveItem(item.uid)
  90. return true
  91. end
  92.  
  93. doTransformItem(item.uid, potion.empty)
  94. return true
  95. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement