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

Lua Position of spell when mooving!

narkotyko

New Member
Joined
Jan 16, 2016
Messages
22
Reaction score
0
Hello i have a problem, my spell is ok but when i move the spell em is like getting out of position, why? Screen:
On second i casted spell with position on first pickture and move to left. Why is happening that?

Code:
local test12 = test()
test12:setParameter(test_PARAM_TYPE, 2)
test12:setParameter(test_PARAM_EFFECT, 6)
test12:setArea(createtestArea(FALA_G_P))
function onGetFormulaValues12(player, skill, attack, factor)
    local min = (player:getLevel() / 5) + (skill * attack * 0.03) + 70
    local max = (player:getLevel() / 5) + (skill * attack * 0.05) + 110
    return -min, -max
end
test12:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues12")

local test23 = test()
test23:setParameter(test_PARAM_TYPE, 2)
test23:setParameter(test_PARAM_EFFECT, 5)
test23:setArea(createtestArea(FALA_G_S2))
function onGetFormulaValues23(player, skill, attack, factor)
    local min = (player:getLevel() / 5) + (skill * attack * 0.03) + 70
    local max = (player:getLevel() / 5) + (skill * attack * 0.05) + 110
    return -min, -max
end
test23:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues23")

local test34 = test()
test34:setParameter(test_PARAM_TYPE, 2)
test34:setParameter(test_PARAM_EFFECT, 8)
test34:setArea(createtestArea(FALA_G_K))
function onGetFormulaValues34(player, skill, attack, factor)
    local min = (player:getLevel() / 5) + (skill * attack * 0.03) + 70
    local max = (player:getLevel() / 5) + (skill * attack * 0.05) + 110
    return -min, -max
end
test34:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues34")

local test45 = test()
test45:setParameter(test_PARAM_TYPE, 2)
test45:setParameter(test_PARAM_EFFECT, 9)
test45:setArea(createtestArea(FALA_L_P))
function onGetFormulaValues45(player, skill, attack, factor)
    local min = (player:getLevel() / 5) + (skill * attack * 0.03) + 70
    local max = (player:getLevel() / 5) + (skill * attack * 0.05) + 110
    return -min, -max
end
test45:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues45")

local test56 = test()
test56:setParameter(test_PARAM_TYPE, 2)
test56:setParameter(test_PARAM_EFFECT, 10)
test56:setArea(createtestArea(FALA_L_S2))
function onGetFormulaValues56(player, skill, attack, factor)
    local min = (player:getLevel() / 5) + (skill * attack * 0.03) + 70
    local max = (player:getLevel() / 5) + (skill * attack * 0.05) + 110
    return -min, -max
end
test56:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues56")

local test67 = test()
test67:setParameter(test_PARAM_TYPE, 2)
test67:setParameter(test_PARAM_EFFECT, 7)
test67:setArea(createtestArea(FALA_L_K))
function onGetFormulaValues67(player, skill, attack, factor)
    local min = (player:getLevel() / 5) + (skill * attack * 0.03) + 70
    local max = (player:getLevel() / 5) + (skill * attack * 0.05) + 110
    return -min, -max
end
test67:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues67")

local test21 = test()
test21:setParameter(test_PARAM_TYPE, 2)
test21:setParameter(test_PARAM_EFFECT, 8)
test21:setArea(createtestArea(FALA_D_P))
function onGetFormulaValues21(player, skill, attack, factor)
    local min = (player:getLevel() / 5) + (skill * attack * 0.03) + 70
    local max = (player:getLevel() / 5) + (skill * attack * 0.05) + 110
    return -min, -max
end
test21:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues21")

local test32 = test()
test32:setParameter(test_PARAM_TYPE, 2)
test32:setParameter(test_PARAM_EFFECT, 5)
test32:setArea(createtestArea(FALA_D_S2))
function onGetFormulaValues32(player, skill, attack, factor)
    local min = (player:getLevel() / 5) + (skill * attack * 0.03) + 70
    local max = (player:getLevel() / 5) + (skill * attack * 0.05) + 110
    return -min, -max
end
test32:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues32")

local test43 = test()
test43:setParameter(test_PARAM_TYPE, 2)
test43:setParameter(test_PARAM_EFFECT, 6)
test43:setArea(createtestArea(FALA_D_K))
function onGetFormulaValues43(player, skill, attack, factor)
    local min = (player:getLevel() / 5) + (skill * attack * 0.03) + 70
    local max = (player:getLevel() / 5) + (skill * attack * 0.05) + 110
    return -min, -max
end
test32:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues43")

local test54 = test()
test54:setParameter(test_PARAM_TYPE, 2)
test54:setParameter(test_PARAM_EFFECT, 7)
test54:setArea(createtestArea(FALA_P_P))
function onGetFormulaValues54(player, skill, attack, factor)
    local min = (player:getLevel() / 5) + (skill * attack * 0.03) + 70
    local max = (player:getLevel() / 5) + (skill * attack * 0.05) + 110
    return -min, -max
end
test54:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues54")

local test65 = test()
test65:setParameter(test_PARAM_TYPE, 2)
test65:setParameter(test_PARAM_EFFECT, 10)
test65:setArea(createtestArea(FALA_P_S2))
function onGetFormulaValues65(player, skill, attack, factor)
    local min = (player:getLevel() / 5) + (skill * attack * 0.03) + 70
    local max = (player:getLevel() / 5) + (skill * attack * 0.05) + 110
    return -min, -max
end
test65:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues65")

local test76 = test()
test76:setParameter(test_PARAM_TYPE, 2)
test76:setParameter(test_PARAM_EFFECT, 9)
test76:setArea(createtestArea(FALA_P_K))
function onGetFormulaValues76(player, skill, attack, factor)
    local min = (player:getLevel() / 5) + (skill * attack * 0.03) + 70
    local max = (player:getLevel() / 5) + (skill * attack * 0.05) + 110
    return -min, -max
end
test76:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues76")

function test3579(variant,cid)
    local creature = Creature(cid)   
    local p = Player(cid)
    if p:getDirection() == 1 then    --right 
            test54:execute(creature, variant)
            test65:execute(creature, variant)
            test76:execute(creature, variant)
        elseif p:getDirection() == 2 then    --down
            test21:execute(creature, variant)
            test32:execute(creature, variant)
            test43:execute(creature, variant)
        elseif p:getDirection() == 3 then   --left
            test45:execute(creature, variant) 
            test56:execute(creature, variant) 
            test67:execute(creature, variant) 
        elseif p:getDirection() == 0 then   --up
            test12:execute(creature, variant) 
            test23:execute(creature, variant)       
            test34:execute(creature, variant)           
    end
end
function onCastSpell(creature, variant)
    addEvent(speak1, 0, creature:getId())
    addEvent(speak12341, 3000, creature:getId())
    addEvent(test3579, 3000,variant,creature:getId())
       
end
function speak1(cid)
    local p = Player(cid)
    p:say("Test!!", TALKTYPE_MONSTER_SAY)
    return true
end
function speak12341(cid)
    local p = Player(cid)
    p:say("End of test!", TALKTYPE_MONSTER_SAY)
    return true
end
I know is getting position on cast, but how repair this and take direction when casted after time used?
 

Attachments

Last edited:
cause you're changing your position when the script lasts. It checks all the time your direction. When you move the effect too.
 
You'll need to update the Variant when you cast the spell.

I believe "variant" holds the information of Position and Direction. So you'd need to create a new one when casting to update the position and direction.
 
cause you're changing your position when the script lasts. It checks all the time your direction. When you move the effect too.
i know but need solution for this..
You'll need to update the Variant when you cast the spell.

I believe "variant" holds the information of Position and Direction. So you'd need to create a new one when casting to update the position and direction.
how can i update that? is some kind of function for this like update(variant) or something?
 
in TFS 0.X you could use positionToVariant(pos), numberToVariant(num), etc.

The above functions don't exist in TFS 1.X, but I am sure there are other ways to update the Variant.
Might be VariantCreate(pos)

Hopefully someone more knowledgable in TFS 1.X can help, because I don't use the new TFS.
 
That works in TFS 1.x as well (if you take advantage of compat.lua that is), otherwise you could just use Variant(number or string or position).
 
Back
Top