Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local condition = createConditionObject(CONDITION_EXHAUST)
- setConditionParam(condition, CONDITION_PARAM_TICKS, 750)
- setConditionParam(condition, CONDITION_PARAM_SUBID, 128)
- local REGENERATION_HEALTH = 1
- local REGENERATION_MANA = 2
- local CHECKING_STORAGE_DO_NOT_CHANGE = 4999
- local config = {
- [11372] = {regeneration = {REGENERATION_HEALTH, 8, REGENERATION_MANA, 8}, removeItem = false, effect = 12},
- [11373] = {regeneration = {REGENERATION_HEALTH, 35, REGENERATION_MANA, 35}, removeItem = false, effect = 46},
- [11394] = {regeneration = {REGENERATION_HEALTH, 50, REGENERATION_MANA, 50}, removeItem = true, effect = 12},
- [11393] = {regeneration = {REGENERATION_HEALTH, 80, REGENERATION_MANA, 80}, removeItem = true, effect = 12}
- }
- local function getVariable(cid, variable)
- return tonumber(getCreatureStorage(cid, CHECKING_STORAGE_DO_NOT_CHANGE)) >= 2 ^ variable
- end
- function onUse(cid, item, fromPos, itemEx, toPos)
- local var = config[item.itemid]
- if not var then
- return false
- end
- if getCreatureCondition(cid, CONDITION_EXHAUST, 128)then
- return false
- end
- doAddCondition(cid, condition)
- for i = 1, #var.regeneration / 2 do
- local value, color = 0, 0
- if var.regeneration[i * 2 - 1] == REGENERATION_HEALTH then
- local health = getCreatureMaxHealth(cid)
- value, color = math.min(health - getCreatureHealth(cid), health * var.regeneration[i * 2] / 100), 68
- if getVariable(cid, 11) then
- value = value * 1.1
- end
- doCreatureAddHealth(cid, value)
- elseif var.regeneration[i * 2 - 1] == REGENERATION_MANA then
- local mana = getCreatureMaxMana(cid)
- value, color = math.min(mana - getCreatureMana(cid), mana * var.regeneration[i * 2] / 100), 22
- if getVariable(cid, 11) then
- value = value * 1.1
- end
- doCreatureAddMana(cid, value)
- end
- if value > 0 and color > 0 then
- doSendAnimatedText(getThingPos(cid), value, color)
- end
- end
- if var.removeItem then
- doRemoveItem(item.uid, 1)
- end
- doSendMagicEffect(getThingPos(cid), var.effect)
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment