• 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!

manarune for paladins

zxzxzx

New Member
Joined
Mar 12, 2011
Messages
334
Reaction score
3
Hello! I have manarune script which give mana and hp and this script don't working on tfs 1.2 - can somebody help me? (the problem is in functions)

the script:

Code:
local exhaust = createConditionObject(CONDITION_EXHAUST_HEAL)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 1000) -- time in seconds x1000

function onUse(cid, item, fromPosition, itemEx, toPosition)

local hpmax, manamax = getCreatureMaxHealth(cid), getPlayerMaxMana(cid)
local minhp, maxhp = 8, 10 -- this means 3% minimum hp healing and 5% maximum hp healing
local minmana, maxmana = 7, 8 -- this means 3% minimum mana healing and 5% maximum mana healing
local hp_add, mana_add = math.random((hpmax * (minhp/100)), (hpmax * (maxhp/100))), math.random((manamax * (minmana/100)), (manamax * (maxmana/100)))

if(getCreatureCondition(cid, CONDITION_EXHAUST_HEAL) == TRUE) then
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doPlayerSendCancel(cid, "You are exhausted")
return true
end
doCreatureAddHealth(cid, hp_add)
doPlayerAddMana(cid, mana_add)
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
doPlayerSendTextMessage(cid, MESSAGE_EXPERIENCE, "+"..math.floor(hp_add).." health and +"..math.floor(mana_add).." mana", getCreaturePosition(cid), hp_add, TEXTCOLOR_GREEN)
doAddCondition(cid, exhaust)
return true
end
 
I know that, but I do not know how to do it and every time I tries to do it I have erros.. :/ Could you do that for me?
 
I would done smth like this:

Code:
local config = {
    healthPercent = {40, 60},
    manaPercent = {30, 50}
}

local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, 1000)

local function healPercent(value, percent)
    return (value * percent) / 100
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if target.itemid ~= 1 or target.type ~= THING_TYPE_PLAYER then
        return false
    end

    if player:getCondition(CONDITION_EXHAUST_HEAL) then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_YOUAREEXHAUSTED))
        return true
    end

    local maxHealth = player:getMaxHealth()
    if not doTargetCombatHealth(0, target, COMBAT_HEALING, healPercent(maxHealth, config.healthPercent[1]), healPercent(maxHealth, config.healthPercent[2]), CONST_ME_MAGIC_BLUE) then
        return false
    end

    local maxMana = player:getMaxHealth()
    if not doTargetCombatMana(0, target, healPercent(maxMana, config.manaPercent[1]), healPercent(maxMana, config.manaPercent[2]), CONST_ME_MAGIC_BLUE) then
        return false
    end

    player:addCondition(exhaust)
    return true
end
 
nice but can I use dmg calculation method similar to that

" template = {min = (((playerinfo.level * 4) + (playerinfo.mlevel * 10)) + 0.0) , max =(((playerinfo.level * 5) + (playerinfo.mlevel * 10)) + 0.0)},"

to mana and hp at the same time?
 
refresh only change the calculate method like up

So you would remove this stuff here since it isn't necessary for what you want.
local config = {
healthPercent = {40, 60},
manaPercent = {30, 50}
}

local function healPercent(value, percent)
return (value * percent) / 100
end

local maxHealth = player:getMaxHealth()
local maxMana = player:getMaxHealth()

Then you would add:
Code:
local level, ml = player:getLevel(), player:getMagicLevel()

Then change:

if not doTargetCombatHealth(0, target, COMBAT_HEALING, healPercent(maxHealth, config.healthPercent[1]), healPercent(maxHealth, config.healthPercent[2]), CONST_ME_MAGIC_BLUE) then

and

if not doTargetCombatMana(0, target, healPercent(maxMana, config.manaPercent[1]), healPercent(maxMana, config.manaPercent[2]), CONST_ME_MAGIC_BLUE) then

to your desired level/ml formula. Such as: (level*5)+(ml*10)
 
I tried but I have errors, I want use method from this spell:
Code:
function onUse(cid, item, frompos, itemEx, topos)
local playerinfo = -- Please don't touch
{
level = getPlayerLevel(cid),
mlevel = getPlayerMagLevel(cid),
voc = getPlayerVocation(cid)
}
local config =
{
strenght = "template", ---Values: template (strenght dependent on level and magic level), constant (on all level adding same mana)
template = {min = (((playerinfo.level * 4) + (playerinfo.mlevel * 10)) + 0.0) , max =(((playerinfo.level * 5) + (playerinfo.mlevel * 10)) + 0.0)}, -- liczymy - lvl * 4 /1.5 = x m lvl * 2 /1.5 = x lvl + m lvl = Minimum, lvl * 6 /1.5 = x m lvl * 4 /1.5 = x lvl + m lvl = Maximum
constant = {min = 400, max = 800},--only if strenght is constant
exhaustion = 1,--exhaustion in secs
exhaustion_value = 56789, --exhaustion storage value
minimum_level = 1,--minimum level to use manarune
minimum_mlevel = 0,--minimum magic level to use manarune
cannot_use_voc = {1,2,3,5,6,7} --id vocation which cannot use
}
local rand = 0
if(isPlayer(itemEx.uid) == false) then
return true
end
if(playerinfo.level < config.minimum_level) then
return true
end
if(playerinfo.mlevel < config.minimum_mlevel) then
return true
end
if(isInArray(config.cannot_use_voc, playerinfo.voc)) then
return true
end
if(config.strenght ~= "template" and config.strenght ~= "constant") then
config.strenght = "constant"
end
if(getPlayerStorageValue(cid, config.exhaustion_value) > os.time()) then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You are exhausted.")
return true
end
if(config.strenght == "template") then
rand = math.random(config.template.min, config.template.max)
elseif (config.strenght == "constant") then
rand = math.random(config.constant.min, config.constant.max)
end
doPlayerAddMana(cid, rand)
setPlayerStorageValue(cid, config.exhaustion_value, (os.time() + config.exhaustion))
doCreatureSay(cid, "+"..math.floor(rand).." mana", TALKTYPE_ORANGE_1)
return true
end


How I can do this? (Im a such of noob).. :c,I only want to add HP healing together with MANA healing ;p
 
Back
Top