Potion that increase the HP every "x" seconds

Discussion in 'Requests' started by kingsley666, Oct 10, 2018.

  1. kingsley666

    kingsley666 Member

    Joined:
    Jul 24, 2011
    Messages:
    146
    Likes Received:
    23
    Best Answers:
    0
    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 :)
     
  2. Best Answer:
    Post #4 by Apollos, Oct 11, 2018
  3. jestem pro

    jestem pro That is the question

    Joined:
    Apr 20, 2013
    Messages:
    535
    Likes Received:
    58
    Best Answers:
    9
    Code (Lua):
    1. local amounthp = 10000    -- how much hp it heals
    2. local every = 5 * 1000                                 -- every 5 seconds
    3. local timer = 4                                             -- how many times it heals
    4.  
    5. if timer > 0 then
    6. addEvent(doCreatureAddHealth, cid, amounthp, every , timer-1)
    7. end
    How about it?
    If player relog it won't be working anymore.
     
  4. kingsley666

    kingsley666 Member

    Joined:
    Jul 24, 2011
    Messages:
    146
    Likes Received:
    23
    Best Answers:
    0
    I tryed your code with no result, nor error.

    Sorry i forgot to tell i'm using TFS 1.2
     
  5. Apollos

    Apollos Dude who does stuff

    Joined:
    Apr 22, 2009
    Messages:
    411
    Likes Received:
    232
    Best Answers:
    26
    Best Answer
    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.
    Code (Lua):
    1. local condition = Condition(CONDITION_REGENERATION)
    2. condition:setParameter(CONDITION_PARAM_TICKS, 1 * 60 * 1000) -- in milliseconds so this is equal to 60 seconds
    3. condition:setParameter(CONDITION_PARAM_HEALTHGAIN, 40) -- 40 health gained every tick
    4. condition:setParameter(CONDITION_PARAM_HEALTHTICKS, 3000) -- how often heal is gained, also in miliseconds so every 3 seconds
    5. condition:setParameter(CONDITION_PARAM_BUFF_SPELL, true)
    6.  
    7. function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    8.     if type(target) == "userdata" and not target:isPlayer() then
    9.         return false
    10.     end
    11.  
    12.     if target:addCondition(condition) then
    13.         target:say("Aah...", TALKTYPE_MONSTER_SAY)
    14.         item:transform(2006)
    15.         return true
    16.     end
    17.     return false
    18. end
     
    Last edited: Oct 11, 2018
    kingsley666 likes this.
  6. kingsley666

    kingsley666 Member

    Joined:
    Jul 24, 2011
    Messages:
    146
    Likes Received:
    23
    Best Answers:
    0
    @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.
     
    Apollos likes this.

Share This Page

Loading...