WhiteOut
OT Builder
I am used to making my own spells and what not, but i'v been away from OT's quiet awhile and getting back into them but need a little help. This is a fully working Teleport Spell which I did get from:
http://otland.net/threads/teleport-spell-rune-that-tp-you-anywhere-you-see-on-your-screen.199017/
Please Help With Following: It teleports you two spots, but also goes through walls (pz/houses aren't a problem) but I want it NOT to go through walls or anything blocking 1 pos in front of player something along the lines of (if pos in front isn't walkable then can't teleport)
Hakrai gets all credit I am simply just wanting to tweak the spell to make it more RL map friendly.
Spells/Scripts/Teleport.lua
Lib/050-Function.lua
Thanks for looking it over and please help me out if you could.
I'm Using TFS 8.6 (Works Perectly With TFS 0.3.6)
http://otland.net/threads/teleport-spell-rune-that-tp-you-anywhere-you-see-on-your-screen.199017/
Please Help With Following: It teleports you two spots, but also goes through walls (pz/houses aren't a problem) but I want it NOT to go through walls or anything blocking 1 pos in front of player something along the lines of (if pos in front isn't walkable then can't teleport)
Hakrai gets all credit I am simply just wanting to tweak the spell to make it more RL map friendly.
Spells/Scripts/Teleport.lua
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)
function onCastSpell(cid, var)
local pos = getClosestFreeTile(cid, getPosByDir(getCreaturePosition(cid), getCreatureLookDirection(cid), 2), false, false)
if(not pos or isInArray({pos.x, pos.y}, 0)) or (getTilePzInfo(pos)) or not isWalkable(pos) then
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
return false
end
local cpos = getCreaturePosition(cid)
if(doTeleportThing(cid, pos, true)) then
doSendMagicEffect(pos, CONST_ME_TELEPORT)
end
return doCombat(cid, combat, var)
end
Lib/050-Function.lua
Code:
function isWalkable(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 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
Thanks for looking it over and please help me out if you could.
I'm Using TFS 8.6 (Works Perectly With TFS 0.3.6)