Oskar1121

Untitled

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