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

helps in converting this spell to otx2

Magnanimo

New Member
Joined
May 19, 2017
Messages
14
Solutions
1
Reaction score
1
I can't make this spell work on otx2.
This spell should make the player walk 15 sqm in the direction they are looking, however it only works on floors that have not been added in items.xml.

when I remove or change this part:

asProperty(tile.uid, 7) then

the script works, but it goes through items like walls and trees.



Lua:
local speed = 10 -- velocidade do player ao usar o dash (vai de 0 a mil)
local pzprotect = true -- nao deixa entrar em pz com a spell
local distance = 15 -- quantos sqms anda
local function nextPositionByLookDirection(cid, pos)
    local r = {}
    local data =
        {
            [NORTH] = {x = 0, y = -1, z = 0},
            [EAST] = {x = 1, y = 0, z = 0},
            [SOUTH] = {x = 0, y = 1, z = 0},
            [WEST] = {x = -1, y = 0, z = 0}
        }
    for dir, tpos in pairs(data) do
        if getCreatureLookDirection(cid) == dir then
            r = {x = pos.x + tpos.x, y = pos.y + tpos.y, z = pos.z + tpos.z}
            break
        end
    end
    return r
end
local function isWalkable(cid, pos, creature, proj, pz)-- by Nord
    if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
    if getTileThingByPos(nextPositionByLookDirection(cid, pos)).itemid == 0 then return false end
    if getTopCreature(pos).uid > 0 and creature then return false end
    if getTileInfo(pos).protection and pz then return false, true end
    local n = not proj and 3 or 2
    for i = 0, 255 do
        pos.stackpos = i
        local tile = getTileThingByPos(pos)
        if tile.itemid ~= 0 and not isCreature(tile.uid) then
            if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
                return false
            end
        end
    end
    return true
end
function onWalk(cid)
    if isCreature(cid) then
        local poslook = getCreatureLookPosition(cid)
        poslook.stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE
        if isWalkable(cid, poslook, false, false, pzprotect) then
            if not isCreature(getThingfromPos(poslook).uid) then
                doMoveCreature(cid, getPlayerLookDirection(cid))
                doSendMagicEffect(getPlayerPosition(cid), 14)
            else
                doSendMagicEffect(getPlayerPosition(cid), 31)
            end
        else
            doSendMagicEffect(getPlayerPosition(cid), 31)
        end
    end
return true
end
function onCastSpell(cid, var)
    for i = 0, distance do
        addEvent(onWalk, speed * i,cid)
    end
return true
end
 
Top