[Ajuda] Regeneração Por Segundo Baseado Em Porcentagem Da Vida.

digomaciel
em Scripts

digomaciel

The PoPs
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 08/12/05Posts: 11

Gostaria de criar uma magia que regenera-se 3% da vida do personagem por segundo. A magia so pode ser usada por Knights e Elite Knights. Duração de 30 segundos e a cada segundo piscar azul nele (CONST_ME_MAGIC_BLUE)

 

local tempo = 30 * 1000

local cooldown = 30

local cont = 0

 

local combat = createCombatObject()

setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING)

setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)

setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)

function onGetFormulaValues(cid, level, maglevel)

regeneration = (185+level*15)*0.03

return regeneration

end

setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

 

while cont<tempo do

cont = cont + 1

local combat = createCombatObject()

setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING)

setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)

setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)

function onGetFormulaValues(cid, level, maglevel)

regeneration = (185+level*15)*0.03

return regeneration

end

setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

end

 

function cooldownready(cid)

doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Cooldown of Enrage Regeneration is ready.")

end

 

function onCastSpell(cid, var)

if exhaustion.check(cid, 50002) == false then

exhaustion.set(cid, 50002, cooldown)

addEvent(cooldownready, cooldown*1000, cid)

return doCombat(cid, combat, var)

else

doPlayerSendCancel(cid, "Cooldown[" ..exhaustion.get(cid, 50001).."]")

end

end

 

Grato.

33vl0td.gif

Vodkart

Sumus Validus
avatar
Herói
Herói

INFOS

Grupo: HeróiRegistrado: 21/05/10Posts: 3406Gênero: Masculino
local config = {
seconds = 30,
HpPercent = 3, -- 3%
storage = 98762,
exausted = 30
}
function doRefilSecond(cid, Hp, delay) -- function by vodka
if not isCreature(cid) then return LUA_ERROR end
doCreatureAddHealth(cid, Hp)
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
if delay ~= 1 then addEvent(doRefilSecond, 1000, cid, Hp, delay -1) end
return nil end

function onCastSpell(cid, var)
if getPlayerStorageValue(cid, config.storage) >= os.time() then
doPlayerSendCancel(cid, "wait " .. getPlayerStorageValue(cid, config.storage) - os.time() .. " seconds to use this spell again.") return false
end
doRefilSecond(cid, math.ceil(((config.HpPercent*getCreatureMaxHealth(cid))/100)), config.seconds)
return setPlayerStorageValue(cid, config.storage, os.time()+config.exausted) 
end

bossisg.png

digomaciel

The PoPs
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 08/12/05Posts: 11

Funcionou perfeitamente, muito obrigado!

33vl0td.gif

Vilden

Loading. . .
avatar
Infante
Infante

INFOS

Grupo: InfanteRegistrado: 09/05/08Posts: 1597

Dúvida sanada, movido.

Atenciosamente, Vilden.