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

Solved Healing Spell Help

Apollos

Dude who does stuff
Premium User
Joined
Apr 22, 2009
Messages
845
Solutions
123
Reaction score
690
Location
United States
Very beginner scripter, want to make this healing spell actually heal, as of now it causes the right animation but doesn't heal and gives swords.

Code:
local combatWater = createCombatObject()
setCombatParam(combatWater, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combatWater, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combatWater, COMBAT_PARAM_AGGRESSIVE, 0)
setCombatParam(combatWater, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)

local combatFire = createCombatObject()
setCombatParam(combatFire, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combatFire, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
setCombatParam(combatFire, COMBAT_PARAM_AGGRESSIVE, 0)
setCombatParam(combatFire, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)

local combatEarth = createCombatObject()
setCombatParam(combatEarth, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combatEarth, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
setCombatParam(combatEarth, COMBAT_PARAM_AGGRESSIVE, 0)
setCombatParam(combatEarth, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)

local combatAir = createCombatObject()
setCombatParam(combatAir, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combatAir, COMBAT_PARAM_EFFECT, CONST_ME_STUN)
setCombatParam(combatAir, COMBAT_PARAM_AGGRESSIVE, 0)
setCombatParam(combatAir, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)

function onGetFormulaValues(cid, level, maglevel)
    min = ((level / 5) + (maglevel * 1.4) + 8)
    max = ((level / 5) + (maglevel * 1.8) + 11)
    return min, max

end


function onCastSpell(cid, var)
local voc = getPlayerVocation(cid)
if voc == 9 or voc == 10 or voc == 11 or voc == 12 then
doCombat(cid, combatWater, var)
elseif voc == 1 or voc == 2 or voc == 3 or voc == 4 then
doCombat(cid, combatFire, var)
elseif voc == 13 or voc == 14 or voc == 15 or voc == 16 then
doCombat(cid, combatEarth, var)
elseif voc == 5 or voc == 6 or voc == 7 or voc == 8 then
doCombat(cid, combatAir, var)
end
return true
end
 
Solution
To avoid getting swords, try change flag COMBAT_PARAM_AGGRESSIVE in combats to COMBAT_PARAM_PASSIVE (im not sure if its correct enum)
its
Code:
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)
also to remove offensive behavior you can put in spells.xml aggressive="0"

----

To call damage values try add for every combat callback. For example
Code:
function onGetFormulaValues1(cid, level, maglevel)
    min = ((level / 5) + (maglevel * 1.4) + 8)
    max = ((level / 5) + (maglevel * 1.8) + 11)
    return min, max
end
It doesn't matter if your spell have aggressive="0" or COMBAT_PARAM_AGGRESSIVE 0 if your min and max returns...
Try returning formula values negated and swapped.
Code:
return -max, -min

That way they will heal instead of hit and will still be in the correct order.
 
I am learning tfs LUA now, but maybe my advices will help you.

To avoid getting swords, try change flag COMBAT_PARAM_AGGRESSIVE in combats to COMBAT_PARAM_PASSIVE (im not sure if its correct enum)

To call damage values try add for every combat callback. For example

Code:
function onGetFormulaValues1(cid, level, maglevel)
    min = ((level / 5) + (maglevel * 1.4) + 8)
    max = ((level / 5) + (maglevel * 1.8) + 11)
    return min, max

end

combat1:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues1")

just before onCastSpell function
 
You missed:
Code:
setCombatCallback(combatWater, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
setCombatCallback(combatFire, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
setCombatCallback(combatEarth, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
setCombatCallback(combatAir, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
Rewritten and working, use doSendMagicEffect to reduce size:
Code:
-- this spell in spells.xml must have (needtarget="1") or (selftarget="1")
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)
setCombatParam(combat, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)

function onGetFormulaValues(cid, level, maglevel)
    min = ((level / 5) + (maglevel * 1.4) + 8)
    max = ((level / 5) + (maglevel * 1.8) + 11)
    return min, max
end

setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(cid, var)
    local voc = getPlayerVocation(cid)
    local effectToDisplay = 0
    if voc >= 1 and voc <= 4 then
        effectToDisplay = CONST_ME_MAGIC_RED
    elseif voc >= 5 and voc <= 8 then
        effectToDisplay = CONST_ME_STUN
    elseif voc >= 9 and voc <= 12 then
        effectToDisplay = CONST_ME_MAGIC_BLUE
    elseif voc >= 13 and voc <= 16 then
        effectToDisplay = CONST_ME_MAGIC_GREEN
    end
    doSendMagicEffect(getCreaturePosition(variantToNumber(var)), effectToDisplay)
    doCombat(cid, combat, var)
    return true
end
 
To avoid getting swords, try change flag COMBAT_PARAM_AGGRESSIVE in combats to COMBAT_PARAM_PASSIVE (im not sure if its correct enum)
its
Code:
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)
also to remove offensive behavior you can put in spells.xml aggressive="0"

----

To call damage values try add for every combat callback. For example
Code:
function onGetFormulaValues1(cid, level, maglevel)
    min = ((level / 5) + (maglevel * 1.4) + 8)
    max = ((level / 5) + (maglevel * 1.8) + 11)
    return min, max
end
It doesn't matter if your spell have aggressive="0" or COMBAT_PARAM_AGGRESSIVE 0 if your min and max returns value lower then 1. If these values are lower then 1 or they are negative values then that spell will always makes you in combat. Such situation is when level 1 with mlv 0 is using extra, that exura is trying to heal him for 0.3 health, which is lower then 1 and makes in combat (swords).

----

Code:
combat1:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues1")
if you have onGetFormulaValues1(cid, level, maglevel) with cid, level, maglevel you should use CALLBACK_PARAM_MAGICVALUE not SKILLVALUE.

----

this:
Code:
combat1:setCallback
is from TFS 1.0 and OTX 2 and you shouldn't mix it with codes. If TFS 1.0 you have:
Code:
CALLBACK_PARAM_LEVELMAGICVALUE
 
Solution
Back
Top