• 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
15
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
 
LUA:
local speed = 10
local pzprotect = true
local distance = 15

local directions = {
    [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}
}

local function nextPositionByLookDirection(cid, pos)
    local dir = getCreatureLookDirection(cid)
    local tpos = directions[dir]
    if tpos then
        return {x = pos.x + tpos.x, y = pos.y + tpos.y, z = pos.z}
    end
    return pos
end

local function isWalkable(cid, pos, creature, proj, pz)
    if getTileThingByPos(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 end
    
    local n = proj and 2 or 3
    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

local function onWalk(cid)
    if isCreature(cid) then
        local pos = getCreaturePosition(cid)
        local poslook = nextPositionByLookDirection(cid, pos)
        poslook.stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE
        
        if isWalkable(cid, poslook, false, false, pzprotect) then
            doMoveCreature(cid, getCreatureLookDirection(cid))
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
        else
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
        end
    end
end

function onCastSpell(cid, var)
    for i = 0, distance do
        addEvent(onWalk, speed * i, cid)
    end
    return true
end
try this
 
While it functions correctly on certain tiles, the dash is improperly passing through walls, and when I'm in PK mode, it enters the PZ. Can someone advise me on how to fix this issue in OTX?
 
The solution is simple: just migrate to TFS 1.x+. OTX and TFS 0.x are outdated and practically useless. With TFS 1.x, you’ll find solutions faster and more efficiently.

If you insist on staying with OTX or TFS 0.x, you’ll have to wait for a developer who still works with those older versions to answer your questions. It may take a long time—no idea when—but be patient.
 
Back
Top