• 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+ spell problem

norrow

Member
Joined
Dec 16, 2012
Messages
129
Reaction score
7
Location
Poland
Hello i have problem in this spell
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setArea(createCombatArea(AREA_SQUARE1X1))

function onGetFormulaValues(player, skill, attack, factor)
    local min = (player:getLevel() / 5) + (skill * attack * 0.03) + 7
    local max = (player:getLevel() / 5) + (skill * attack * 0.05) + 11
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant)
    if isPlayer() then
        player:teleportTo(cid, player:getPosition(getCreatureTarget(cid)))
        return combat:execute(creature, variant)
    end
end
doesn't work without error in console
 
try this
Lua:
function onCastSpell(creature, variant, isHotkey)
    local target = creature:getTarget()
    if not target:isPlayer() then
        creature:sendCancelMessage("You need to target a player first.")
        return true
    end

    creature:teleportTo(target:getPosition())
    return combat:execute(creature, variant)
end
 
Lua:
function onCastSpell(creature, variant)
    if isPlayer() then
        player:teleportTo(cid, player:getPosition(getCreatureTarget(cid)))
        return combat:execute(creature, variant)
    end
end
then
change to:
Lua:
function onCastSpell(creature, variant)
    local player = creature:getTarget()
    if player:isPlayer() then
        creature:teleportTo(cid, player:getPosition(getCreatureTarget(cid)))
        return combat:execute(creature, variant)
    end
end
 
Last edited:
Unfortunately it doesn't work
Post automatically merged:

Anyone can help me? Where is problem ? In function? Spell give tex world but dont take dmg and teleport to player
 
Last edited:
How would you like this spell to work? Explain exactly how you want it to work. Your script is a mess right now.
maybe you wanted something like this?

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setArea(createCombatArea(AREA_SQUARE1X1))

function onGetFormulaValues(player, skill, attack, factor)
    local min = (player:getLevel() / 5) + (skill * attack * 0.03) + 7
    local max = (player:getLevel() / 5) + (skill * attack * 0.05) + 11
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant)
    if creature:isPlayer() then
        creature:teleportTo(creature:getTarget():getPosition(), false)
        return combat:execute(creature, variant)
    end
end
Make sure you have
XML:
range="5" casterTargetOrDirection="1" blockwalls="1"
in your spells.xml configuration
 
Last edited:
Back
Top