• 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 1.X+ SPELLS work with range and without range

mano368

Senior Support Team Member
Staff member
Support Team
Joined
Sep 2, 2011
Messages
646
Solutions
46
Reaction score
296
Location
Brazil
Is it possible to make a spell like energy strike to work in two diferent ways?

If player is premium, the spell works as normal, "following" your target or player direction.
If player is free, the spell works only using player direction(same as exori vis without target)

Thanks for help!
 
nvm, already done!

done using
Lua:
if(variant:getNumber() ~= 0)


here is a exemple script if someone needs using premium as requeriment to attack from distance!

Lua:
local distance = Combat()
distance:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
distance:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_TELEPORT)
distance:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)

function onGetFormulaValues(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 1.4) + 8
    local max = (level / 5) + (magicLevel * 2.2) + 14
    return -min, -max
end

distance:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_TELEPORT)

function onGetFormulaValues(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 1.4) + 8
    local max = (level / 5) + (magicLevel * 2.2) + 14
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant)
    if creature:isPremium() then
        if(variant:getNumber() ~= 0) then
            return distance:execute(creature, variant)
        else
            return combat:execute(creature, variant)
        end
    else
    return combat:execute(creature, variant)
    end
end
 
nvm, already done!

done using
Lua:
if(variant:getNumber() ~= 0)


here is a exemple script if someone needs using premium as requeriment to attack from distance!

Lua:
local distance = Combat()
distance:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
distance:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_TELEPORT)
distance:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)

function onGetFormulaValues(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 1.4) + 8
    local max = (level / 5) + (magicLevel * 2.2) + 14
    return -min, -max
end

distance:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_TELEPORT)

function onGetFormulaValues(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 1.4) + 8
    local max = (level / 5) + (magicLevel * 2.2) + 14
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant)
    if creature:isPremium() then
        if(variant:getNumber() ~= 0) then
            return distance:execute(creature, variant)
        else
            return combat:execute(creature, variant)
        end
    else
    return combat:execute(creature, variant)
    end
end
Nice!
I am trying to do something similar. However the caster always attacks from distance. Maybe you can post how the spell is configured in spells.xml?
Thanks!
 
Nice!
I am trying to do something similar. However the caster always attacks from distance. Maybe you can post how the spell is configured in spells.xml?
Thanks!
I dont remeber but if u select a target it will trigger as ranged spell
 
Back
Top