-- Creaturescripts.xml: <event type="think" name="Healing" script="healing.lua"/>
-- login.lua: registerCreatureEvent(cid, "Healing")
-- for more ask andu @ otland.net
local config = {
useTfsVersion1 = "no", -- use "yes" for tfs 1.0+ and otx 2.0+. For old tfs, and other engines use "no".
inCombat = {
healthPercent = 0.0, -- % of max health
manaPercent = 0.0 -- % of max mana
},
outOfCombat = {
healthPercent = 15.0, -- % of max health
manaPercent = 7.5 -- % of max mana
},
energyGain = 10 -- melee/tank etc (in my server players what have exactly 100 mana are melee/tanks)
}
if config.useTfsVersion1 == "yes" then
function hasCondition(cid, condition)
local c = Creature(cid)
return c ~= nil and c:getCondition(condition, CONDITIONID_DEFAULT) or false
end
end
function onThink(cid, interval)
if isPlayer(cid) == true then
local hp, mp = 0, 0
if hasCondition(cid, CONDITION_INFIGHT) == true then
hp = config.inCombat.healthPercent
mp = config.inCombat.manaPercent
else
hp = config.outOfCombat.healthPercent
mp = config.outOfCombat.manaPercent
end
local hpheal, mpheal = getCreatureMaxHealth(cid)*(hp/100), getPlayerMaxMana(cid) * (mp / 100)
if hpheal >= 1 and getCreatureHealth(cid) < getCreatureMaxHealth(cid) then
doCreatureAddHealth(cid, hpheal)
end
if getPlayerMana(cid) < getPlayerMaxMana(cid) then
if getPlayerMaxMana(cid) > 100 then
if mpheal >= 1 then
doPlayerAddMana(cid, mpheal)
end
else
doPlayerAddMana(cid, config.energyGain) -- energy
end
end
end
return true
end