--<event type="statschange" name="SpellBuff" event="script" value="spellbuff.lua"/>--
--<event type="login" name="RegisterBuff" event="script" value="spellbuff.lua"/>--
local vocations = {4, 8} -- ID das vocations que receberao o buff
local percentageToActive = 0.30 -- 30%
local bonusSkill = 20 -- Quantidade de skill que o buff vai dar
local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, -1)
setConditionParam(condition, CONDITION_PARAM_SKILL_MELEE, bonusSkill)
setConditionParam(condition, CONDITION_PARAM_SUBID, 10)
setConditionParam(condition, CONDITION_PARAM_BUFF, true)
function onStatsChange(cid, attacker, type, combat, value)
local health_now, health_max = getCreatureHealth(cid), getCreatureMaxHealth(cid)
if (type == STATSCHANGE_HEALTHGAIN) then
if (health_now + value) > math.ceil(health_max * percentageToActive) then
doRemoveCondition(cid, CONDITION_ATTRIBUTES, 10)
end
elseif (type == STATSCHANGE_HEALTHLOSS) then
if (health_now - value) > 0 and (health_now - value) < math.ceil(health_max * percentageToActive) then
doAddCondition(cid, condition)
end
end
return true
end
function onLogin(cid)
if isInArray(vocations, getPlayerVocation(cid)) then
registerCreatureEvent(cid, "SpellBuff")
end
return true
end