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

Solved Teleport spell

Leandro__

New Member
Joined
Dec 2, 2014
Messages
24
Reaction score
0
Need help in a script like the god teleport /a to player, but he cant pass trought doors/walls/threes, but can pass trought players, and just small distances 2-4 :)
 
Interesting idea. I haven't got the tools or time to make one of those at the moment, but you could start off by creating a simple teleport spell, using a function to restrict the range, I think there is an implemented function called getDistanceBetween or something alike.

Then there are methods in the source defining if a square, player or item is reachable. Not exactly sure if it's available in LUA, but that is what you are seeking.

Ignazio
 
Tfs 1.0, i should configure in the spell the min and the max to teleport, and always when cast it should be random beetween the min and max :p

Thats possible?
 
Last edited by a moderator:
Code:
local function isWalkable(pos, creatures)
     local tile = Tile(pos)
     if (creatures and tile:getCreatureCount() > 0) or tile:hasFlag(TILESTATE_BLOCKSOLID) then
         return false
     end
     return true
end

function onCastSpell(creature, var)
     local steps = math.random(2, 4)
     for x = 1, steps do
         position = creature:getPosition()
         position:getNextPosition(creature:getDirection(), x)
 
         position = creature:getClosestFreePosition(position, false)
         if position.x == 0 or not isWalkable(position, x == steps and true or false) then
             creature:sendCancelMessage("You cannot teleport there.")
             return false
         end
     end
     creature:teleportTo(position)
     return true
end
 
@Limos

One last doubt, how i do to check the player look dir, and do x effect , from x dir.

Like:

ifplayer look dir = 1 then sendmagiceffectX
ifplayer look dir = 2 then sendmagiceffectY
 
Code:
local function isWalkable(pos, creatures)
     local tile = Tile(pos)
     if (creatures and tile:getCreatureCount() > 0) or tile:hasFlag(TILESTATE_BLOCKSOLID) then
         return false
     end
     return true
end

function onCastSpell(creature, var)
     local steps, pos = math.random(2, 4), creature:getPosition()
     pos:sendMagicEffect(CONST_ME_POFF)
     for x = 1, steps do
         position = creature:getPosition()
         position:getNextPosition(creature:getDirection(), x)
  
         position = creature:getClosestFreePosition(position, false)
         if position.x == 0 or not isWalkable(position, x == steps and true or false) then
             creature:sendCancelMessage("You failed to jump, there is something blocking.")
             position:sendMagicEffect(CONST_ME_POFF)
             return false
         end
     end
     creature:teleportTo(position)
     pos:sendMagicEffect(CONST_ME_POFF)    
     position:sendMagicEffect(CONST_ME_MAGIC_BLUE)
     return true
end
 
Code:
local effects = {
     [0] = 1,
     [1] = 3,
     [2] = 2,
     [3] = 4
}
Code:
position:sendMagicEffect(effects[creature:getDirection()])
 
Code:
local effects = {
     [0] = 83,
     [1] = 84,
     [2] = 85,
     [3] = 86
}
        if effects == 83 then
        local Pos = creature:getPosition()
        local position = Position(Pos.x + 1, Pos.y, Pos.z):sendMagicEffect(86)
        end

How i can get the effect or dir and then send X effect? Tried this way but the effect dont happen, when im looking to any dir
 
If you want all position in between to show a magiceffect you can add them to a table and get them with a loop.
Code:
local t = {}
Above the end that closes the for loop
Code:
table.insert(t, position)
Then the effect like this
Code:
for pos = 1, #t do
       t[pos]:sendMagicEffect(effects[creature:getDirection()])
end
 
Back
Top