• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Healing over time

Northnorial

Member
Joined
May 30, 2009
Messages
742
Reaction score
5
Location
Germany
I found the two following scripts here on OtLand,

the first one is not showing the healing damage,
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)

local condition = createConditionObject(CONDITION_REGENERATION)
setConditionParam(condition, CONDITION_PARAM_BUFF_SPELL, true)
setConditionParam(condition, CONDITION_PARAM_TICKS, 1 * 60 * 1000)
setConditionParam(condition, CONDITION_PARAM_HEALTHGAIN, 500)
setConditionParam(condition, CONDITION_PARAM_HEALTHTICKS, 3000)
setCombatCondition(combat, condition)

local area = createCombatArea(AREA_CIRCLE3X3)
setCombatArea(combat, area)

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end

the second tho is showing the healing damage,
Code:
healRegen = {}

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)

local condition = createConditionObject(CONDITION_REGENERATION)
setConditionParam(condition, CONDITION_PARAM_SUBID, 1)
setConditionParam(condition, CONDITION_PARAM_BUFF_SPELL, true)
setCombatCondition(combat, condition)

local area = createCombatArea(AREA_CIRCLE3X3)
setCombatArea(combat, area)

function regen(cid,var,n)
n = n or 0
    if isPlayer(cid) then
        doCreatureAddHealth(cid, 20)
        if (n < 20) then
            healRegen[cid] = addEvent(regen, 3 * 1000, cid, var, n+1)
        end
    end
return true
end

function onCastSpell(cid, var)
    if healRegen[cid] then
        stopEvent(healRegen[cid])
    end
    doCombat(cid, combat, var)
    healRegen[cid] = addEvent(regen, 250, cid, var, 0)
return true
end

I could really use some explanation why the first one is and the second is not showing the healing damage.
Also I would like to know what numbers like if (n < 20) then or addEvent(regen, 250, cid, var, 0) do...

Thanks in advance! :)
 
The "n" variable is increased by one each round, "cid, var, n+1" I guess its supposed to be number?
The addEvent is what the function says, its a scheduled object that should be executed at (second parameter, in this case 3 * 1000 = 3 seconds).
So what the script does is to check if the n variable is below 20 then heal the player and then wait 3 second to repeat the function. It will also increase n by one for each round.
 
Back
Top