Oskar1121

Untitled

Oct 4th, 2018
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 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. print(getCreatureStorage(cid, CHECKING_STORAGE_DO_NOT_CHANGE))
  40. print(2 ^ 11)
  41. if getVariable(cid, 11) then
  42. value = value * 1.1
  43. end
  44.  
  45. doCreatureAddHealth(cid, value)
  46. elseif var.regeneration[i * 2 - 1] == REGENERATION_MANA then
  47. local mana = getCreatureMaxMana(cid)
  48. value, color = math.min(mana - getCreatureMana(cid), mana * var.regeneration[i * 2] / 100), 22
  49.  
  50. if getVariable(cid, 11) then
  51. value = value * 1.1
  52. end
  53.  
  54. doCreatureAddMana(cid, value)
  55. end
  56.  
  57. if value > 0 and color > 0 then
  58. doSendAnimatedText(getThingPos(cid), value, color)
  59. end
  60. end
  61.  
  62. if var.removeItem then
  63. doRemoveItem(item.uid, 1)
  64. end
  65.  
  66. doSendMagicEffect(getThingPos(cid), var.effect)
  67. return true
  68. end
Advertisement
Add Comment
Please, Sign In to add comment