Potion that increase the HP every "x" seconds

kingsley666

Intermediate OT User
Joined
Jul 24, 2011
Messages
146
Reaction score
24
Location
Venezuela
Hello, hope you are doing good,

I created this thread because i have no idea how to do this, i want to create a potion that increase the hp of the character by "x" health every "y" time for "z" times, is like the utura spell but in action.

I was trying to use the combat function but it is missing the variant paramenter. :(

I hope you can help me :)
 

jestem pro

That is the question
Joined
Apr 20, 2013
Messages
554
Reaction score
64
Lua:
local amounthp = 10000    -- how much hp it heals
local every = 5 * 1000                                 -- every 5 seconds
local timer = 4                                             -- how many times it heals

if timer > 0 then
addEvent(doCreatureAddHealth, cid, amounthp, every , timer-1)
end
How about it?
If player relog it won't be working anymore.
 
OP
kingsley666

kingsley666

Intermediate OT User
Joined
Jul 24, 2011
Messages
146
Reaction score
24
Location
Venezuela
I tryed your code with no result, nor error.

Sorry i forgot to tell i'm using TFS 1.2
 

Apollos

Dude who does stuff
Joined
Apr 22, 2009
Messages
562
Reaction score
338
Location
United States
I tryed your code with no result, nor error.

Sorry i forgot to tell i'm using TFS 1.2
Untested so let me know if it works. So you know, all I really did was look at the intense recovery spell for a reference and adapted it to a potion. These kinds of scripts are the perfect types to practice and learn with, just keep trying and researching and I'm sure you will figure out how to do it.
Lua:
local condition = Condition(CONDITION_REGENERATION)
condition:setParameter(CONDITION_PARAM_TICKS, 1 * 60 * 1000) -- in milliseconds so this is equal to 60 seconds
condition:setParameter(CONDITION_PARAM_HEALTHGAIN, 40) -- 40 health gained every tick
condition:setParameter(CONDITION_PARAM_HEALTHTICKS, 3000) -- how often heal is gained, also in miliseconds so every 3 seconds
condition:setParameter(CONDITION_PARAM_BUFF_SPELL, true)

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if type(target) == "userdata" and not target:isPlayer() then
        return false
    end

    if target:addCondition(condition) then
        target:say("Aah...", TALKTYPE_MONSTER_SAY)
        item:transform(2006)
        return true
    end
    return false
end
 
Last edited:
OP
kingsley666

kingsley666

Intermediate OT User
Joined
Jul 24, 2011
Messages
146
Reaction score
24
Location
Venezuela
Untested so let me know if it works. So you know, all I really did was look at the intense recovery spell for a reference and adapted it to a potion. These kinds of scripts are the perfect types to practice and learn with, just keep trying and researching and I'm sure you will figure out how to do it.
Lua:
local condition = Condition(CONDITION_REGENERATION)
condition:setParameter(CONDITION_PARAM_TICKS, 1 * 60 * 1000) -- in milliseconds so this is equal to 60 seconds
condition:setParameter(CONDITION_PARAM_HEALTHGAIN, 40) -- 40 health gained every tick
condition:setParameter(CONDITION_PARAM_HEALTHTICKS, 3000) -- how often heal is gained, also in miliseconds so every 3 seconds
condition:setParameter(CONDITION_PARAM_BUFF_SPELL, true)

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if type(target) == "userdata" and not target:isPlayer() then
        return false
    end

    if target:addCondition(condition) then
        target:say("Aah...", TALKTYPE_MONSTER_SAY)
        item:transform(2006)
        return true
    end
    return false
end
@Apollos This is what i needed, it is working perfectly, i'm still learning to code with TFS, i also tryed to use the condition fuction but i didn't know how to set it to the player :oops:.

Thank you very much for your help.
 
Top