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

Creative Spell

flaviiojr

Active Member
Joined
Jan 20, 2017
Messages
230
Solutions
13
Reaction score
39
a spell where it would work as follows:
the creature casting the spell will have an effect of it to the player, as shown in the image below ... regardless of location, the effect will follow a path to the player ...
Any ideas?
Bg3I3ia.jpg
I thank you all very much!
TFS 1.3
 
Solution
dq162x.jpg
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
--combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)

function onGetFormulaValues(cid, level, maglevel)
    return -math.max(35, (3 * maglevel + 2 * level) * 0.35), -math.max(55, (3 * maglevel + 2 * level) * 0.55)
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, var)
    local target = creature:getTarget()
    if(not target) then
        return false
    end

    local startPos = creature:getPosition()
    local endPos = target:getPosition()
    local path =...
dq162x.jpg
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
--combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)

function onGetFormulaValues(cid, level, maglevel)
    return -math.max(35, (3 * maglevel + 2 * level) * 0.35), -math.max(55, (3 * maglevel + 2 * level) * 0.55)
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, var)
    local target = creature:getTarget()
    if(not target) then
        return false
    end

    local startPos = creature:getPosition()
    local endPos = target:getPosition()
    local path = creature:getPathTo(endPos)
    if(path) then
        for i = 1, #path do
            startPos:getNextPosition(path[i])
            combat:execute(creature, Variant(startPos))
        end

        if(startPos.x < endPos.x) then --some workaround since getPathTo don't give us full path
            if(startPos.y ~= endPos.y) then
                startPos.x = startPos.x + 1
                combat:execute(creature, Variant(startPos))
            end
        elseif(startPos.x > endPos.x) then
            if(startPos.y ~= endPos.y) then
                startPos.x = startPos.x - 1
                combat:execute(creature, Variant(startPos))
            end
        end

        combat:execute(creature, Variant(endPos))
    else
        return false
    end

    return true
end
To use only diagonal pathfinding as in your photo you need to edit "getPathTo" in source.
 
Solution
dq162x.jpg
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
--combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)

function onGetFormulaValues(cid, level, maglevel)
    return -math.max(35, (3 * maglevel + 2 * level) * 0.35), -math.max(55, (3 * maglevel + 2 * level) * 0.55)
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, var)
    local target = creature:getTarget()
    if(not target) then
        return false
    end

    local startPos = creature:getPosition()
    local endPos = target:getPosition()
    local path = creature:getPathTo(endPos)
    if(path) then
        for i = 1, #path do
            startPos:getNextPosition(path[i])
            combat:execute(creature, Variant(startPos))
        end

        if(startPos.x < endPos.x) then --some workaround since getPathTo don't give us full path
            if(startPos.y ~= endPos.y) then
                startPos.x = startPos.x + 1
                combat:execute(creature, Variant(startPos))
            end
        elseif(startPos.x > endPos.x) then
            if(startPos.y ~= endPos.y) then
                startPos.x = startPos.x - 1
                combat:execute(creature, Variant(startPos))
            end
        end

        combat:execute(creature, Variant(endPos))
    else
        return false
    end

    return true
end
To use only diagonal pathfinding as in your photo you need to edit "getPathTo" in source.
It worked perfectly, dude !! Thank you so much !
 
Back
Top