Oskar1121

Untitled

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