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

TFS 0.X spell in 1 sqm after 2 sqms

Solution
One of the way to create a spell that atk only on 3rd SQM in front is to create an spell area in your lib or paste this area directly in spell script:
Lua:
ATTACKONLYONTHIRDSQMINFRONT = {
{0, 1, 0},
{0, 0, 0},
{0, 0, 0},
{0, 2, 0}
}
3 = caster (hit yourself)
2 = caster (not hit yourself)
1 = target tile (execute dmg and effect, etc.)
0 = skip tile
and assign it into area in spell:
Lua:
local area = createCombatArea(ATTACKONLYONTHIRDSQMINFRONT)
combat:setArea(area)
Don't forget to set direction="1" at this spell line in your spells.XML file.

Hope it helps.
Fresh.
One of the way to create a spell that atk only on 3rd SQM in front is to create an spell area in your lib or paste this area directly in spell script:
Lua:
ATTACKONLYONTHIRDSQMINFRONT = {
{0, 1, 0},
{0, 0, 0},
{0, 0, 0},
{0, 2, 0}
}
3 = caster (hit yourself)
2 = caster (not hit yourself)
1 = target tile (execute dmg and effect, etc.)
0 = skip tile
and assign it into area in spell:
Lua:
local area = createCombatArea(ATTACKONLYONTHIRDSQMINFRONT)
combat:setArea(area)
Don't forget to set direction="1" at this spell line in your spells.XML file.

Hope it helps.
Fresh.
 
Last edited:
Solution
Create your own area, like this

Lua:
area = {

    {0, 0, 0, 1, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 2, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0}

}

local createArea = createCombatArea(area)
local combat = Combat()
combat:setArea(createArea)

then values and effects

Lua:
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
combat:setFormula(COMBAT_FORMULA_DAMAGE, -200, 0, -250, 0)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)

or if the spell has to be dependent on skills:
Lua:
function onGetFormulaValues(player, level, maglevel)
    local min = (level / 5) + (maglevel * 4.5) + 20
    local max = (level / 5) + (maglevel * 7.6) + 48
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

and lines, to execute it:
Lua:
function onCastSpell(creature, variant)
    return combat:execute(creature, variant)
end


and in spells.xml use these parameters:
XML:
direction="1" aggressive="1" blockwalls="1" needtarget="0"


and.. this is your spell:
Lua:
area = {

    {0, 0, 0, 1, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 2, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0}

}

local createArea = createCombatArea(area)
local combat = Combat()
combat:setArea(createArea)
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ENERGYHIT)

function onGetFormulaValues(player, level, maglevel)
    local min = (level / 5) + (maglevel * 4.5) + 20
    local max = (level / 5) + (maglevel * 7.6) + 48
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant)
    return combat:execute(creature, variant)
end
 
Back
Top