• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Auto regeneration

qx

New Member
Joined
Aug 16, 2016
Messages
13
Reaction score
0
Hi, I'm trying to make it so players never need to eat any food, and they still automatically regenerate health and mana. Anybody know what I can change to make this happen? Thanks.
 
Sorry, but both of your suggestions are terrible. OP is better of using a condition (where ticks is set to -1, and disappears when the player logs out) that is added each time a player logins.

Code:
local regenCondition = Condition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)
regenCondition:setTicks(-1)
regenCondition:setParameter(CONDITION_PARAM_HEALTHGAIN, 2)
regenCondition:setParameter(CONDITION_PARAM_HEALTHTICKS, 2000)
regenCondition:setParameter(CONDITION_PARAM_MANAGAIN, 2)
regenCondition:setParameter(CONDITION_PARAM_MANATICKS, 2000)

function onLogin(player)
    player:addCondition(regenCondition)
    return true
end

Is there a way that I could change this from 2 hp/mp per tick to 2% of the players max health and max mana? Thanks guys
 
either you make your own healing "condition" as suggested before that can be set with dynamic values, or you generate separate mp/hp healing conditions (think it works, if you have different ids on them atleast), from 1 to whatever the max might be
 
Is there a way that I could change this from 2 hp/mp per tick to 2% of the players max health and max mana? Thanks guys


Code:
function onThink(cid, interval)
local p = Player(cid)
local php = p:getMaxHealth()
local pmp = p:getMaxMana()
local h = p:getHealth()
local m = p:getMana()

function hp ()
p:addHealth(php / 100 * 2  )
end

function mp ()
p:addMana(pmp / 100 * 2  )
end

if last_interval == nil then
      last_interval = os.clock()
    end
    if (os.clock() - last_interval) > 0 then

if h < php or m < pmp then

addEvent(hp,1000)
addEvent(mp,1000)
return true
end

last_interval= os.clock()

end
    return true
end

addEvent(hp,1000)
addEvent(mp,1000)

1000 its 1 second, you can use 100 or 10000+ etc.

not tested.

its a creatureevent.
 
I'm assuming Zothion means like this

IDK if there is a better way. I'm not very good with conditions. (I also don't use TFS 1.x :/ )

Code:
local regenCondition1 = Condition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)
regenCondition1:setTicks(-1)
regenCondition1:setParameter(CONDITION_PARAM_HEALTHGAIN, 2)
regenCondition1:setParameter(CONDITION_PARAM_HEALTHTICKS, 2000)
regenCondition1:setParameter(CONDITION_PARAM_MANAGAIN, 2)
regenCondition1:setParameter(CONDITION_PARAM_MANATICKS, 2000)

local regenCondition2 = Condition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)
regenCondition2:setTicks(-1)
regenCondition2:setParameter(CONDITION_PARAM_HEALTHGAIN, 4)
regenCondition2:setParameter(CONDITION_PARAM_HEALTHTICKS, 2000)
regenCondition2:setParameter(CONDITION_PARAM_MANAGAIN, 4)
regenCondition2:setParameter(CONDITION_PARAM_MANATICKS, 2000)

local regenCondition3 = Condition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)
regenCondition3:setTicks(-1)
regenCondition3:setParameter(CONDITION_PARAM_HEALTHGAIN, 6)
regenCondition3:setParameter(CONDITION_PARAM_HEALTHTICKS, 2000)
regenCondition3:setParameter(CONDITION_PARAM_MANAGAIN, 6)
regenCondition3:setParameter(CONDITION_PARAM_MANATICKS, 2000)

function onLogin(player)
    local level = player:getLevel()
    if level < 20 then
        player:addCondition(regenCondition1)
    elseif level < 100 then
        player:addCondition(regenCondition2)
    else
        player:addCondition(regenCondition3)
    end
    return true
end
 
Code:
local hps = {}
local mps = {}
for i=1,x do
local regenCondition1 = Condition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)
regenCondition1:setTicks(-1)
regenCondition1:setParameter(CONDITION_PARAM_MANAGAIN, i)
regenCondition1:setParameter(CONDITION_PARAM_MANATICKS, 2000)
local regenCondition2 = Condition(CONDITION_REGENERATION, 2)
regenCondition2:setTicks(-1)
regenCondition2:setParameter(CONDITION_PARAM_MANAGAIN, i)
regenCondition2:setParameter(CONDITION_PARAM_MANATICKS, 2000)
hps[i] = regenCondition1
mps[i] = regenCondition2
end
something like that to avoid having to create them all manually
 
Is there a way that I could change this from 2 hp/mp per tick to 2% of the players max health and max mana? Thanks guys
Code:
local regenCondition = Condition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)
regenCondition:setTicks(-1)
regenCondition:setParameter(CONDITION_PARAM_HEALTHTICKS, 2000)
regenCondition:setParameter(CONDITION_PARAM_MANATICKS, 2000)

function onLogin(player)
    regenCondition:setParameter(CONDITION_PARAM_HEALTHGAIN, math.ceil(player:getMaxHealth() * 0.02))
    regenCondition:setParameter(CONDITION_PARAM_MANAGAIN, math.ceil(player:getMaxMana() * 0.02))
    player:addCondition(regenCondition)
    return true
end
 
if you dont want promotions to have same reg as normal vocs
Promoted vocations are numbers 5,6,7 and 8. it means that
vocation 1 with promotion 1 is vocation 5 in xml,
vocation 2 with promotion 1 is vocation in xml6,
vocation 3 vith promotion 1 is vocation in xml 7 and
vocation 4 with promotion 1 is vocation in xml 8.
Database stores vocations always from 1 to 4, no matter how many vocations there are. database has a column named promotion, where promotions are stored.
So for example
vocation 4 with promotion 1 is vocation 8 in xml,
vocation 4 with promotion 2 is vocation 12 in xml,
vocation 4 with promotion 3 is vocation 16 in xml
etc.
GetPlayerVocation function checks for xml numbers like 6,5,7,8,9,10,11,12,13,14,15,16 and more.
Using this table:
Code:
local t = {
  [1] = {nr = 5, hp = 1, mp = 2}, -- MS
  [2] = {nr = 6, hp = 5, mp = 4}, -- ED
  [3] = {nr = 7, hp = 2, mp = 5}, -- RP
  [4] = {nr = 8, hp = 3, mp = 6}, -- EK
}
only vocation from 5 to 8 (1-4 with promotion 1) can regenerate their health and mana.
 
Code:
local regenCondition = Condition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)
regenCondition:setTicks(-1)
regenCondition:setParameter(CONDITION_PARAM_HEALTHTICKS, 2000)
regenCondition:setParameter(CONDITION_PARAM_MANATICKS, 2000)

function onLogin(player)
    regenCondition:setParameter(CONDITION_PARAM_HEALTHGAIN, math.ceil(player:getMaxHealth() * 0.02))
    regenCondition:setParameter(CONDITION_PARAM_MANAGAIN, math.ceil(player:getMaxMana() * 0.02))
    player:addCondition(regenCondition)
    return true
end
This effs me up.
How does regenCondition know to find the rest of it's parameter's inside the login function? Dx
 
Code:
local regenCondition = Condition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)
regenCondition:setTicks(-1)
regenCondition:setParameter(CONDITION_PARAM_HEALTHTICKS, 2000)
regenCondition:setParameter(CONDITION_PARAM_MANATICKS, 2000)

function onLogin(player)
    regenCondition:setParameter(CONDITION_PARAM_HEALTHGAIN, math.ceil(player:getMaxHealth() * 0.02))
    regenCondition:setParameter(CONDITION_PARAM_MANAGAIN, math.ceil(player:getMaxMana() * 0.02))
    player:addCondition(regenCondition)
    return true
endg
This works just fine. The rest of you are confusing the hell out of me lol. But thanks for the help everybody :D
 
Back
Top