• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

TFS 1.X+ spell problem

norrow

Member
Joined
Dec 16, 2012
Messages
128
Reaction score
6
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
 

emil92b

Intermediate OT User
Joined
Aug 21, 2013
Messages
325
Solutions
13
Reaction score
125
Location
Sweden
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
 

Owuzee

New Member
Joined
Jan 31, 2023
Messages
8
Reaction score
1
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:
OP
OP
N

norrow

Member
Joined
Dec 16, 2012
Messages
128
Reaction score
6
Location
Poland
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:

Trollheim

Active Member
Joined
May 27, 2022
Messages
36
Reaction score
49
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:
Top