Actions >
#getCreatureSummons(cid) == 0 then
return true
end
if getCreatureSpeed(getCreatureSummons(cid)[1]) == 0 then
doPlayerSendCancel(cid, "Você não pode pedir o seu pokemon para se mover agora.")
return true
end
if getPlayerStorageValue(getCreatureSummons(cid)[1], 12) == 1 then
doPlayerSendCancel(cid, "Você não pode pedir o seu pokemon para se mover agora.")
return true
end
doPlayerSay(cid, ""..getCreatureName(getCreatureSummons(cid)[1])..", move!", 1)
doChangeSpeed(getCreatureSummons(cid)[1], -getCreatureSpeed(getCreatureSummons(cid)[1]))
setPlayerStorageValue(getCreatureSummons(cid)[1], 12, 1)
local function move(params)
if isCreature(params.cid) then
if isCreature(getCreatureSummons(params.cid)[1]) then
if getPlayerStorageValue(getCreatureSummons(params.cid)[1], 12) == 0 then
return true
end
if getDistanceBetween(getThingPos(getCreatureSummons(params.cid)[1]), topos) == 0 then
if getCreatureSpeed(getCreatureSummons(params.cid)[1]) == 0 then
local function speeed(params)
if isCreature(params.sum) then
if getCreatureSpeed(params.sum) == 0 then
doChangeSpeed(params.sum, getCreatureBaseSpeed(params.sum))
end
end
end
addEvent(speeed, 600, {sum = getCreatureSummons(params.cid)[1]})
end
setPlayerStorageValue(getCreatureSummons(params.cid)[1], 12, 0)
setPlayerStorageValue(cid, etudao, -1)
return true
end
local dire = getDirectionTo(getThingPos(getCreatureSummons(cid)[1]), params.topos)
if dire >= 0 and dire <= 7 then
if dire == NORTHWEST then
if math.random(1,100) >= 51 then
dire = NORTH
if isWalkable(getPosByDir(getThingPos(getCreatureSummons(params.cid)[1]), dire), params.ccid, 0, 0) then
dire = NORTH
else
dire = WEST
end
else
dire = WEST
if isWalkable(getPosByDir(getThingPos(getCreatureSummons(params.cid)[1]), dire), params.ccid, 0, 0) then
dire = WEST
else
dire = NORTH
end
end
elseif dire == SOUTHWEST then
if math.random(1,100) >= 51 then
dire = SOUTH
if isWalkable(getPosByDir(getThingPos(getCreatureSummons(params.cid)[1]), dire), params.ccid, 0, 0) then
dire = SOUTH
else
dire = WEST
end
else
dire = WEST
if isWalkable(getPosByDir(getThingPos(getCreatureSummons(params.cid)[1]), dire), params.ccid, 0, 0) then
dire = WEST
else
dire = SOUTH
end
end
elseif dire == SOUTHEAST then
if math.random(1,100) >= 51 then
dire = SOUTH
if isWalkable(getPosByDir(getThingPos(getCreatureSummons(params.cid)[1]), dire), params.ccid, 0, 0) then
dire = SOUTH
else
dire = EAST
end
else
dire = EAST
if isWalkable(getPosByDir(getThingPos(getCreatureSummons(params.cid)[1]), dire), params.ccid, 0, 0) then
dire = EAST
else
dire = SOUTH
end
end
elseif dire == NORTHEAST then
if math.random(1,100) >= 51 then
dire = NORTH
if isWalkable(getPosByDir(getThingPos(getCreatureSummons(params.cid)[1]), dire), params.ccid, 0, 0) then
dire = NORTH
else
dire = EAST
end
else
dire = EAST
if isWalkable(getPosByDir(getThingPos(getCreatureSummons(params.cid)[1]), dire), params.ccid, 0, 0) then
dire = EAST
else
dire = NORTH
end
end
end
local dire = dire
if getCreatureSpeed(getCreatureSummons(params.cid)[1]) == 0 then
doChangeSpeed(getCreatureSummons(params.cid)[1], getCreatureBaseSpeed(getCreatureSummons(params.cid)[1]))
doPushCreature(getCreatureSummons(params.cid)[1], dire, 1, 0)
doChangeSpeed(getCreatureSummons(params.cid)[1], -getCreatureSpeed(getCreatureSummons(params.cid)[1]))
else
doPushCreature(getCreatureSummons(params.cid)[1], dire, 1, 0)
doChangeSpeed(getCreatureSummons(params.cid)[1], -getCreatureSpeed(getCreatureSummons(params.cid)[1]))
end
end
end
end
end
local function voltarnormal(params)
if isCreature(params.cid) then
if isCreature(getCreatureSummons(params.cid)[1]) then
setPlayerStorageValue(cid, etudao, -1)
if getCreatureSpeed(getCreatureSummons(params.cid)[1]) == 0 then
local function speeed(params)
if isCreature(params.sum) then
if getCreatureSpeed(params.sum) == 0 then
doChangeSpeed(params.sum, getCreatureBaseSpeed(params.sum))
end
end
end
addEvent(speeed, 0, {sum = getCreatureSummons(params.cid)[1]})
end
setPlayerStorageValue(getCreatureSummons(params.cid)[1], 12, 0)
end
end
end
local pois = getThingPos(item2.uid)
local speed = getCreatureBaseSpeed(getCreatureSummons(cid)[1])
local temk = 1000 -(2.3 * speed)
local SummonPos = getThingPos(getCreatureSummons(cid)[1])
local travelx = math.abs((topos.x) - (SummonPos.x))
local travely = math.abs((topos.y) - (SummonPos.y))
local travel = ((travelx) + (travely))
addEvent(move, 0, {cid = cid, ccid = getCreatureSummons(cid)[1], topos = pois, item2 = item2.uid})
for i = 1, travel-1 do
addEvent(move, temk*i, {cid = cid, ccid = getCreatureSummons(cid)[1], topos = pois, item2 = item2.uid})
end
addEvent(voltarnormal, temk*travel, {cid = cid})
exhaustion.set(cid, etudao, travel)
return true
end
Coloca isso na Lib
function doPushCreature(uid,direction,distance,time)
if isCreature(uid) == TRUE then
local rand = (2*math.random(0,1))-1
local rand2 = math.random(-1,0)
if direction == 0 then
signal = {0,rand,-rand,rand,-rand,0,-1,-1,-1,0,0,0}
elseif direction == 1 then
signal = {1,1,1,0,0,0,0,rand,-rand,rand,-rand,0}
elseif direction == 2 then
signal = {0,rand,-rand,rand,-rand,0,1,1,1,0,0,0}
elseif direction == 3 then
signal = {-1,-1,-1,0,0,0,0,rand,-rand,rand,-rand,0}
elseif direction == 4 then
signal = {-1,rand2,(-rand2)-1,0,1,rand2+1,rand2,0}
elseif direction == 5 then
signal = {1,-rand2,-((-rand2)-1),0,1,rand2+1,rand2,0}
elseif direction == 6 then
signal = {-1,rand2,(-rand2)-1,0,-1,(-rand2)-1,rand2,0}
else
signal = {1,-rand2,-((-rand2)-1),0,-1,(-rand2)-1,rand2,0}
end
local pos = getThingPos(uid)
nsig = #signal
nvar = 0
repeat
nvar = nvar+1
newpos = {x=pos.x+(signal[nvar]),y=pos.y+(signal[(nsig/2)+nvar]),z=pos.z}
newtile = {x=newpos.x,y=newpos.y,z=newpos.z,stackpos=0}
until getTileThingByPos(newtile).uid ~= 0 and hasProperty(getTileThingByPos(newtile).uid,3) == FALSE and queryTileAddThing(uid,newpos) == 1 or nvar == (nsig/2)
if distance == nil or distance == 1 then
doTeleportThing(uid,newpos,TRUE)
else
distance = distance-1
doTeleportThing(uid,newpos,TRUE)
if time ~= nil then
addEvent(doPushCreature,time,uid,direction,distance,time)
else
addEvent(doPushCreature,500,uid,direction,distance,500)
end
end
end
end