Mimic Spell:
function onCastSpell(cid, var)
local tempo = 30 -- tempo em segundos que vai durar o controle.
local target = getCreatureTarget(cid)
local position = getPlayerPosition(cid)
doCreatureSetNoMove(target, true)
setPlayerStorageValue(cid, 5421, os.time()+tempo)
movePlayer(position, target, cid)
return true
end
function movePlayer(position, target, cid)
if isCreature(target) and isPlayer(cid) then
local pos = getCreaturePosition(target)
if getPlayerPosition(cid).x ~= position.x then
pos = {x = getCreaturePosition(target).x+(getPlayerPosition(cid).x +(- 1 * position.x)), y = getCreaturePosition(target).y, z = getCreaturePosition(target).z}
elseif getPlayerPosition(cid).y ~= position.y then
pos = {x = getCreaturePosition(target).x, y = getCreaturePosition(target).y+(getPlayerPosition(cid).y +(- 1 * position.y)), z = getCreaturePosition(target).z}
end
if isWalkable(pos) then
doTeleportThing(target, pos)
end
if (getPlayerStorageValue(cid, 5421) - os.time()) > 0 then
addEvent(movePlayer, 100, getPlayerPosition(cid), target, cid)
else
doPlayerSendTextMessage(cid, 22, "Você perdeu o controle.")
doCreatureSetNoMove(target, false)
end
end
end
function isWalkable(pos, creature, pz, proj) -- nord
if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
local creature = getTopCreature(pos)
if creature.type > 0 then return false end
if getTilePzInfo(pos) and not pz then return false 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