Oskar1121

Untitled

Oct 4th, 2018
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. local condition = createConditionObject(CONDITION_EXHAUST)
  2. setConditionParam(condition, CONDITION_PARAM_TICKS, 750)
  3. setConditionParam(condition, CONDITION_PARAM_SUBID, 128)
  4.  
  5. local REGENERATION_HEALTH = 1
  6. local REGENERATION_MANA = 2
  7.  
  8. local CHECKING_STORAGE_DO_NOT_CHANGE = 4999
  9.  
  10. local config = {
  11. [11372] = {regeneration = {REGENERATION_HEALTH, 8, REGENERATION_MANA, 8}, removeItem = false, effect = 12},
  12. [11373] = {regeneration = {REGENERATION_HEALTH, 35, REGENERATION_MANA, 35}, removeItem = false, effect = 46},
  13. [11394] = {regeneration = {REGENERATION_HEALTH, 50, REGENERATION_MANA, 50}, removeItem = true, effect = 12},
  14. [11393] = {regeneration = {REGENERATION_HEALTH, 80, REGENERATION_MANA, 80}, removeItem = true, effect = 12}
  15. }
  16.  
  17. local function getVariable(cid, variable)
  18. return tonumber(getCreatureStorage(cid, CHECKING_STORAGE_DO_NOT_CHANGE)) >= 2 ^ variable
  19. end
  20.  
  21. function onUse(cid, item, fromPos, itemEx, toPos)
  22. local var = config[item.itemid]
  23. if not var then
  24. return false
  25. end
  26.  
  27. if getCreatureCondition(cid, CONDITION_EXHAUST, 128)then
  28. return false
  29. end
  30.  
  31. doAddCondition(cid, condition)
  32.  
  33. for i = 1, #var.regeneration / 2 do
  34. local value, color = 0, 0
  35. if var.regeneration[i * 2 - 1] == REGENERATION_HEALTH then
  36. local health = getCreatureMaxHealth(cid)
  37. value, color = math.min(health - getCreatureHealth(cid), health * var.regeneration[i * 2] / 100), 68
  38.  
  39. if getVariable(cid, 11) then
  40. value = value * 1.1
  41. end
  42.  
  43. doCreatureAddHealth(cid, value)
  44. elseif var.regeneration[i * 2 - 1] == REGENERATION_MANA then
  45. local mana = getCreatureMaxMana(cid)
  46. value, color = math.min(mana - getCreatureMana(cid), mana * var.regeneration[i * 2] / 100), 22
  47.  
  48. if getVariable(cid, 11) then
  49. value = value * 1.1
  50. end
  51.  
  52. doCreatureAddMana(cid, value)
  53. end
  54.  
  55. if value > 0 and color > 0 then
  56. doSendAnimatedText(getThingPos(cid), value, color)
  57. end
  58. end
  59.  
  60. if var.removeItem then
  61. doRemoveItem(item.uid, 1)
  62. end
  63.  
  64. doSendMagicEffect(getThingPos(cid), var.effect)
  65. return true
  66. end
Advertisement
Add Comment
Please, Sign In to add comment