Oskar1121

Untitled

Oct 4th, 2018
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 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. local var = tonumber(getCreatureStorage(cid, CHECKING_STORAGE_DO_NOT_CHANGE))
  19. if var < 2 ^ variable then
  20. return true
  21. end
  22.  
  23. for i = CHECKING_LAST_ID, variable, -1 do
  24. if var >= 2 ^ i then
  25. if i == variable then
  26. return false
  27. end
  28.  
  29. var = var - (2 ^ i)
  30. end
  31. end
  32.  
  33. return true
  34. end
  35.  
  36. function onUse(cid, item, fromPos, itemEx, toPos)
  37. local var = config[item.itemid]
  38. if not var then
  39. return false
  40. end
  41.  
  42. if getCreatureCondition(cid, CONDITION_EXHAUST, 128)then
  43. return false
  44. end
  45.  
  46. doAddCondition(cid, condition)
  47.  
  48. for i = 1, #var.regeneration / 2 do
  49. local value, color = 0, 0
  50. if var.regeneration[i * 2 - 1] == REGENERATION_HEALTH then
  51. local health = getCreatureMaxHealth(cid)
  52. value, color = math.min(health - getCreatureHealth(cid), health * var.regeneration[i * 2] / 100), 68
  53.  
  54. print(tostring(getVariable(cid, 11)))
  55. if not getVariable(cid, 11) then
  56. value = value * 1.1
  57. end
  58.  
  59. doCreatureAddHealth(cid, value)
  60. elseif var.regeneration[i * 2 - 1] == REGENERATION_MANA then
  61. local mana = getCreatureMaxMana(cid)
  62. value, color = math.min(mana - getCreatureMana(cid), mana * var.regeneration[i * 2] / 100), 22
  63.  
  64. if not getVariable(cid, 11) then
  65. value = value * 1.1
  66. end
  67.  
  68. doCreatureAddMana(cid, value)
  69. end
  70.  
  71. if value > 0 and color > 0 then
  72. doSendAnimatedText(getThingPos(cid), value, color)
  73. end
  74. end
  75.  
  76. if var.removeItem then
  77. doRemoveItem(item.uid, 1)
  78. end
  79.  
  80. doSendMagicEffect(getThingPos(cid), var.effect)
  81. return true
  82. end
Advertisement
Add Comment
Please, Sign In to add comment