adrianoswatt

doPushCreatureTo

Jun 2nd, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 19.14 KB | None | 0 0
  1. function doPushCreatureTo(uid, direction, distance, speed)   --//doPushCreature(creature,getPlayerLookDir(cid))
  2. -- Desenvolvido por Dokmos 30/01/2009
  3. -- Apoio Dinastias
  4. local pos = getThingPos(uid)
  5. local PARAM = {{1}, {500}}
  6. local DIRECTION = {
  7. {{0,0},{6,7},{1,3}}, {{1,1},{5,7},{0,2}}, {{2,2},{4,5},{1,3}}, {{3,3},{4,6},{0,2}},
  8. {{4,4},{2,3}}, {{5,5}, {1,2}}, {{6,6},{0,1}}, {{7,7},{0,3}}
  9. }
  10. table.insert(PARAM[1], distance)
  11. table.insert(PARAM[2], speed)
  12.  
  13.         for dvar = 1, #DIRECTION[direction+1] do
  14.         rand = math.random(2)
  15.         d = DIRECTION[direction+1][dvar][rand]
  16.         dir = {x = (math.fmod(d,2)*(-(d-2))+math.floor(d/4)*math.fmod(d,2)*d-math.floor(d/4)), y = (((d-1)*(d-1-(d-1)*math.abs(d-2))*(1-math.floor(d/4)))-(math.floor(d/4)*(math.floor(d/6)*2-1)))}
  17.         newtile = {x = (pos.x+dir.x), y = (pos.y+dir.y), z = pos.z}
  18.                 if  (getTileThingByPos(newtile).uid ~= 0) and (hasProperty(getTileThingByPos(newtile).uid,3) == FALSE) and (queryTileAddThing(uid,newtile) == 1) then break end
  19.         rand = (math.fmod(rand,2)+1)
  20.         d = DIRECTION[direction+1][dvar][rand]
  21.         dir = {x = (math.fmod(d,2)*(-(d-2))+math.floor(d/4)*math.fmod(d,2)*d-math.floor(d/4)), y = (((d-1)*(d-1-(d-1)*math.abs(d-2))*(1-math.floor(d/4)))-(math.floor(d/4)*(math.floor(d/6)*2-1)))}
  22.         newtile = {x = (pos.x+dir.x), y = (pos.y+dir.y), z = pos.z}
  23.                 if  (getTileThingByPos(newtile).uid ~= 0) and (hasProperty(getTileThingByPos(newtile).uid,3) == FALSE) and (queryTileAddThing(uid,newtile) == 1) then break end
  24.                 if (dvar == #DIRECTION[direction+1]) then
  25.                 newtile = pos
  26.                 end
  27.         end
  28.        
  29.         doTeleportThing(uid, newtile, true)
  30.         if (PARAM[1][#PARAM[1]] > 1) then
  31.         addEvent(doPushCreature, PARAM[2][#PARAM[2]], uid, direction, (distance-1), speed)
  32.         end    
  33. end
  34. --///////////////////////////////////////////////////////////////////////////////////////////////////////--
  35. local dirpref = {
  36. [1] =  {[NORTH] = {[1] = {NORTH}, [2] = {EAST, WEST}, [3] = {NORTHEAST, NORTHWEST}},
  37.     [EAST] = {[1] = {EAST}, [2] = {NORTH, SOUTH}, [3] = {NORTHEAST, SOUTHEAST}},
  38.     [SOUTH] = {[1] = {SOUTH}, [2] = {EAST, WEST}, [3] = {SOUTHEAST, SOUTHWEST}},
  39.     [WEST] = {[1] = {WEST}, [2] = {SOUTH, NORTH}, [3] = {NORTHWEST, SOUTHWEST}},
  40.     [NORTHEAST] = {[1] = {NORTH, EAST}, [2] = {NORTHEAST}, [3] = {SOUTH, WEST}},
  41.     [SOUTHEAST] = {[1] = {SOUTH, EAST}, [2] = {SOUTHEAST}, [3] = {NORTH, WEST}},
  42.     [SOUTHWEST] = {[1] = {SOUTH, WEST}, [2] = {SOUTHWEST}, [3] = {NORTH, EAST}},
  43.     [NORTHWEST] = {[1] = {NORTH, WEST}, [2] = {NORTHWEST}, [3] = {EAST, SOUTH}}},
  44. [2] =  {[NORTH] = {[1] = {NORTH}, [2] = {WEST, EAST}, [3] = {NORTHWEST, NORTHEAST}},
  45.     [EAST] = {[1] = {EAST}, [2] = {SOUTH, NORTH}, [3] = {SOUTHEAST, NORTHEAST}},
  46.     [SOUTH] = {[1] = {SOUTH}, [2] = {WEST, EAST}, [3] = {SOUTHWEST, SOUTHEAST}},
  47.     [WEST] = {[1] = {WEST}, [2] = {NORTH, SOUTH}, [3] = {SOUTHWEST, NORTHWEST}},
  48.     [NORTHEAST] = {[1] = {EAST, NORTH}, [2] = {NORTHEAST}, [3] = {WEST, SOUTH}},
  49.     [SOUTHEAST] = {[1] = {EAST, SOUTH}, [2] = {SOUTHEAST}, [3] = {WEST, NORTH}},
  50.     [SOUTHWEST] = {[1] = {WEST, SOUTH}, [2] = {SOUTHWEST}, [3] = {EAST, NORTH}},
  51.     [NORTHWEST] = {[1] = {WEST, NORTH}, [2] = {NORTHWEST}, [3] = {SOUTH, EAST}}},
  52. }
  53.  
  54. function doPushCreature(uid,direction,distance,time)
  55.    if isCreature(uid) == TRUE then
  56.       local rand = (2*math.random(0,1))-1
  57.       local rand2 = math.random(-1,0)
  58.       if direction == 0 then
  59.          signal = {0,rand,-rand,rand,-rand,0,-1,-1,-1,0,0,0}
  60.       elseif direction == 1 then
  61.          signal = {1,1,1,0,0,0,0,rand,-rand,rand,-rand,0}
  62.       elseif direction == 2 then
  63.          signal = {0,rand,-rand,rand,-rand,0,1,1,1,0,0,0}
  64.       elseif direction == 3 then
  65.          signal = {-1,-1,-1,0,0,0,0,rand,-rand,rand,-rand,0}
  66.       elseif direction == 4 then
  67.          signal = {-1,rand2,(-rand2)-1,0,1,rand2+1,rand2,0}
  68.       elseif direction == 5 then
  69.          signal = {1,-rand2,-((-rand2)-1),0,1,rand2+1,rand2,0}
  70.       elseif direction == 6 then
  71.          signal = {-1,rand2,(-rand2)-1,0,-1,(-rand2)-1,rand2,0}
  72.       else
  73.          signal = {1,-rand2,-((-rand2)-1),0,-1,(-rand2)-1,rand2,0}
  74.       end
  75.       local pos = getThingPos(uid)
  76.       nsig = #signal
  77.       nvar = 0
  78.  
  79.       repeat
  80.          nvar = nvar+1
  81.          newpos = {x=pos.x+(signal[nvar]),y=pos.y+(signal[(nsig/2)+nvar]),z=pos.z}
  82.          newtile = {x=newpos.x,y=newpos.y,z=newpos.z,stackpos=0}
  83.       until getTileThingByPos(newtile).uid ~= 0 and hasProperty(getTileThingByPos(newtile).uid,3) == FALSE and canWalkOnPos(newtile, true, false, true, true, false) and queryTileAddThing(uid,newpos) == 1 or nvar == (nsig/2)
  84.                                                                                                                    --alterado v1.5
  85.       if distance == nil or distance == 1 then
  86.          doTeleportThing(uid,newpos,TRUE)  
  87.       else
  88.          distance = distance-1
  89.          doTeleportThing(uid,newpos,TRUE)
  90.          if time ~= nil then
  91.             addEvent(doPushCreature,time,uid,direction,distance,time)
  92.          else
  93.             addEvent(doPushCreature,500,uid,direction,distance,500)
  94.          end       
  95.       end
  96.    end  
  97. end
  98.  
  99. function doComparePosition(pos1, pos2)
  100.     if pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z then
  101.     return true
  102.     end
  103. return false
  104. end
  105.  
  106. function walkTo(cid, direction, finalp, useExtraMoveOrder)
  107.     if not isCreature(cid) then return true end
  108.  
  109.     doChangeSpeed(cid, 5)
  110.     local x = getThingPos(cid)
  111.     local ratedelaywalk = 1
  112.     local finalpos = {x = finalp.x, y = finalp.y, z = finalp.z}
  113.  
  114.         if not canWalkOnPos(finalpos, false, false, true, true, true) then
  115.             finalpos = getClosestFreeTile(cid, finalpos)
  116.         end
  117.  
  118.         if not finalpos then
  119.         return false
  120.         end
  121.  
  122.     local dir = getDirectionToWalk(cid, finalpos, 2, 0, 0, false, true, 300)
  123.     if dir and tonumber(dir) ~= nil and tonumber(dir) >= 0 and tonumber(dir) <= 7 then
  124.         if dir >= 4 then
  125.             ratedelaywalk = 0.4
  126.         end
  127.         doPushCreature(cid, dir, 1, getNextStepDelay(cid, dir) * ratedelaywalk)
  128.         return getNextStepDelay(cid, dir) * ratedelaywalk
  129.     elseif useExtraMoveOrder then
  130.  
  131. local random = math.random(1, 2)
  132.  
  133.     for ta = 1, 3 do
  134.         for tb = 1, #dirpref[random][direction][ta] do
  135.             local y = getPosByDir(getThingPos(cid), dirpref[random][direction][ta][tb])
  136.             local w = getCreatureLP(cid)
  137.             local z = getDirectionTo(y, getThingPos(cid)) -- direção q vai marcar
  138.             local j = getDirectionTo(getThingPos(cid), y) -- direção q ele vai
  139.             if canWalkOnPos(y, true, false, true, true, true) and w ~= j then
  140.                 if dirpref[random][direction][ta][tb] >= 4 then
  141.                     ratedelaywalk = 0.5
  142.                 end
  143.                 doPushCreature(cid, dirpref[random][direction][ta][tb], 1, getNextStepDelay(cid, dirpref[random][direction][ta][tb]) * ratedelaywalk)
  144.                 markLP(cid, z)
  145.             return getNextStepDelay(cid, dirpref[random][direction][ta][tb]) * ratedelaywalk
  146.             end
  147.         end
  148.     end
  149.     end
  150. return false
  151. end
  152.  
  153. function getCreatureLP(cid)
  154. return getPlayerStorageValue(cid, 197)
  155. end
  156.  
  157. function markLP(cid, dir)
  158. setPlayerStorageValue(cid, 197, dir)
  159. end
  160.  
  161. function markPos(sid, pos)
  162. if not isCreature(sid) then return end
  163. setPlayerStorageValue(sid, 145, pos.x)
  164. setPlayerStorageValue(sid, 146, pos.y)
  165. setPlayerStorageValue(sid, 147, pos.z)
  166. end
  167.  
  168. function markFlyingPos(sid, pos)
  169. if not isCreature(sid) then return end
  170. setPlayerStorageValue(sid, 33145, pos.x)
  171. setPlayerStorageValue(sid, 33146, pos.y)
  172. setPlayerStorageValue(sid, 33147, pos.z)
  173. end
  174.  
  175. function getFlyingMarkedPos(sid)
  176. if not isCreature(sid) then return end
  177. local xx = getPlayerStorageValue(sid, 33145)
  178. local yy = getPlayerStorageValue(sid, 33146)
  179. local zz = getPlayerStorageValue(sid, 33147)
  180. return {x = xx, y = yy, z = zz, stackpos = 0}
  181. end
  182.  
  183. function getMarkedPos(sid)
  184. if not isCreature(sid) then return end
  185. local xx = getPlayerStorageValue(sid, 145)
  186. local yy = getPlayerStorageValue(sid, 146)
  187. local zz = getPlayerStorageValue(sid, 147)
  188. return {x = xx, y = yy, z = zz}
  189. end
  190.  
  191. function getOwnerPos(sid)
  192. if not isCreature(sid) then return end
  193. local xx = getPlayerStorageValue(sid, 148)
  194. local yy = getPlayerStorageValue(sid, 149)
  195. local zz = getPlayerStorageValue(sid, 150)
  196. return {x = xx, y = yy, z = zz}
  197. end
  198.  
  199. function markOwnerPos(sid, pos)
  200. if not isCreature(sid) then return end
  201. setPlayerStorageValue(sid, 148, pos.x)
  202. setPlayerStorageValue(sid, 149, pos.y)
  203. setPlayerStorageValue(sid, 150, pos.z)
  204. end
  205.  
  206. function recheck(sid, skill, pos, stackPos)
  207.     if not isCreature(sid) or not isCreature(getCreatureMaster(sid)) then return end
  208.     local cid = getCreatureMaster(sid)
  209.  
  210.     if skill == "cut" then
  211.  
  212.         local item = getTileItemById(pos, 2767)
  213.         doCreatureSay(sid, "CUT!", TALKTYPE_MONSTER)
  214.         markPos(sid, {x=1,y=1,z=7})
  215.         doFaceCreature(sid, pos)
  216.         doSendMagicEffect(getThingPos(item.uid), 141)
  217.         doTransformItem(item.uid, 6216)
  218.             local function growBush()
  219.             doTransformItem(getTileItemById(pos, 6216).uid, 2767)
  220.             end
  221.         addEvent(growBush, intervalToRegrowBushAndStones * 1000)
  222.  
  223.     elseif skill == "rock smash" then
  224.  
  225.         local item = getTileItemById(pos, 1285)
  226.         doCreatureSay(sid, "ROCK SMASH!", TALKTYPE_MONSTER)
  227.         markPos(sid, {x=1,y=1,z=7})
  228.         doFaceCreature(sid, pos)
  229.         doSendMagicEffect(getThingPos(item.uid), 118)
  230.         doTransformItem(item.uid, 3610)
  231.             local function growRock()
  232.             doTransformItem(getTileItemById(pos, 3610).uid, 1285)
  233.             end
  234.         addEvent(growRock, intervalToRegrowBushAndStones * 1000)
  235.        
  236.     elseif skill == "headbutt" then  --alterado v1.6
  237.    
  238.     local master = getCreatureMaster(sid)
  239.     local array = {}                          
  240.     local lvl = {25, 40, 60, 80, 1000} --lvls
  241.  
  242.     for i = 1, #lvl do
  243.         if getPlayerLevel(master) <= lvl[i] then
  244.            array = headbutt[lvl[i]]
  245.            break
  246.         end
  247.     end
  248.     local rand = array[math.random(#array)]
  249.     for j = 1, rand[2] do
  250.         local poke = doCreateMonster(rand[1], getClosestFreeTile(sid, pos))
  251.         doSetMonsterPassive(poke)              
  252.         doWildAttackPlayer(poke, master)
  253.     end
  254.     local item = getTileItemById(pos, 11604)    --id do item   arvore normal
  255.     doCreatureSay(sid, "HEADBUTT!", TALKTYPE_MONSTER)
  256.     markPos(sid, {x=1,y=1,z=7})
  257.     doFaceCreature(sid, pos)
  258.     doSendMagicEffect(getThingPos(item.uid), 118)
  259.     doTransformItem(item.uid, 10505)  --id do item   arvore quebrada
  260.     local function growHead()
  261.           doTransformItem(getTileItemById(pos, 10505).uid, 11604) --id do item  arvore quebrada, arvore normal
  262.     end
  263.     addEvent(growHead, choose(5, 10, 20, 30) * 60 * 1000)   --o tempo pra arvore voltar ao normal varia de 5~30min
  264.    
  265.     elseif skill == "dig" then
  266.         local item = getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = stackPos})
  267.         doCreatureSay(sid, "DIG!", TALKTYPE_MONSTER)
  268.         markPos(sid, {x=1,y=1,z=7})
  269.         doFaceCreature(sid, pos)
  270.         doSendMagicEffect(getThingPos(item.uid), 3)
  271.         doTransformItem(item.uid, item.itemid+1)
  272.             local function closeHole()
  273.             doTransformItem(getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).uid, item.itemid)
  274.             end
  275.         addEvent(closeHole, intervalToRegrowBushAndStones * 1000)
  276.    
  277.     elseif skill == "fly" then
  278.    
  279.         --if not isPremium(cid) then
  280.         --doPlayerSendCancel(cid, "Only premium members are allowed to fly.")
  281.         --return true
  282.         --end
  283.         local pokemon = flys[getPokemonName(getCreatureSummons(cid)[1])]
  284.         doPlayerSendTextMessage(cid, 27, "Type \"up\" or \"h1\" to fly/levitate higher and \"down\" or \"h2\" to fly/levitate lower.") --alterado v1.8
  285.         doChangeSpeed(cid, -getCreatureSpeed(cid))
  286.         local speed = 150 + PlayerSpeed/2 + getSpeed(sid)
  287.         doChangeSpeed(cid, speed)
  288.         setPlayerStorageValue(cid, 54844, speed)
  289.         doSetCreatureOutfit(cid, {lookType = pokemon[1] + 351}, -1)
  290.         doItemSetAttribute(getPlayerSlotItem(cid, 8).uid, "hp", getCreatureHealth(getCreatureSummons(cid)[1]) / getCreatureMaxHealth(getCreatureSummons(cid)[1]))
  291.         doRemoveCreature(getCreatureSummons(cid)[1])
  292.         setPlayerStorageValue(cid, 17000, 1)
  293.         if getCreatureOutfit(cid).lookType == 667 or getCreatureOutfit(cid).lookType == 999 then
  294.            markPosEff(cid, getThingPos(cid))
  295.            sendMovementEffect(cid, 136, getThingPos(cid))     --edited efeito quando anda com o porygon
  296.         end
  297.         local item = getPlayerSlotItem(cid, 8)
  298.         if getItemAttribute(item.uid, "boost") and getItemAttribute(item.uid, "boost") >= 50 and getPlayerStorageValue(cid, 42368) <= 0 then  
  299.            sendAuraEffect(cid, auraSyst[getItemAttribute(item.uid, "aura")])              --alterado v1.8
  300.         end
  301.        
  302.         if useOTClient then
  303.            doPlayerSendCancel(cid, '12//,hide') --alterado v1.8
  304.         end
  305.        
  306.     return true
  307.  
  308.     elseif skill == "ride" then
  309.    
  310.         local pokemon = rides[getPokemonName(getCreatureSummons(cid)[1])]
  311.         doChangeSpeed(cid, -getCreatureSpeed(cid))
  312.         local speed = 50 + PlayerSpeed/2 + getSpeed(sid)
  313.         doChangeSpeed(cid, speed)
  314.         setPlayerStorageValue(cid, 54844, speed)
  315.         doSetCreatureOutfit(cid, {lookType = pokemon[1] + 351}, -1)
  316.         doItemSetAttribute(getPlayerSlotItem(cid, 8).uid, "hp", getCreatureHealth(getCreatureSummons(cid)[1]) / getCreatureMaxHealth(getCreatureSummons(cid)[1]))
  317.         doRemoveCreature(getCreatureSummons(cid)[1])
  318.         setPlayerStorageValue(cid, 17001, 1)
  319.         local item = getPlayerSlotItem(cid, 8)
  320.         if getItemAttribute(item.uid, "boost") and getItemAttribute(item.uid, "boost") >= 50 and getPlayerStorageValue(cid, 42368) <= 0 then  
  321.            sendAuraEffect(cid, auraSyst[getItemAttribute(item.uid, "aura")])                     --alterado v1.8
  322.         end
  323.        
  324.         if useOTClient then
  325.            doPlayerSendCancel(cid, '12//,hide') --alterado v1.8
  326.         end
  327.  
  328.     return true
  329.     end
  330.  
  331.     if getOwnerPos(sid).x ~= getThingPos(getCreatureMaster(sid)).x or getOwnerPos(sid).y ~= getThingPos(getCreatureMaster(sid)).y or isCreature(getCreatureTarget(getCreatureMaster(sid))) then
  332.         doRegainSpeed(sid)
  333.         markPos(sid, {x=1,y=1,z=7})
  334.     return true
  335.     end
  336.  
  337.     addEvent(recheck, 120, sid)
  338. end
  339.  
  340. function goThere(sid, thepos, skill, target, rept, stackPos)
  341.     if not isCreature(sid) or not isCreature(getCreatureMaster(sid)) then return true end
  342.     if getCreatureNoMove(sid) or isSleeping(sid) or isParalyze(sid) then return true end            --alterado v1.6
  343.     if thepos.x ~= getMarkedPos(sid).x or thepos.y ~= getMarkedPos(sid).y then return true end
  344.     if isCreature(getCreatureTarget(getCreatureMaster(sid))) and target == false or (rept and rept <= 0) then
  345.         doRegainSpeed(sid)
  346.         markPos(sid, {x=1,y=1,z=7})
  347.     return true
  348.     end
  349.  
  350. if (skill == "ride" or skill == "fly") and getDistanceBetween(getThingPos(sid), getMarkedPos(sid)) <= 1 then
  351.  
  352.     local currentPos = getThingPos(getCreatureMaster(sid))
  353.     local summonPos = getThingPos(sid)
  354.     local masterPos = getCreatureLastPosition(sid)
  355.  
  356.     if (getThingPos(sid).x == getThingPos(getCreatureMaster(sid)).x and getThingPos(sid).y == getThingPos(getCreatureMaster(sid)).y) or (currentPos.x == masterPos.x and currentPos.y == masterPos.y) then
  357.     recheck(sid, skill, thepos)
  358.     return true
  359.     end
  360.  
  361.     if currentPos.x == thepos.x and currentPos.y == thepos.y then
  362.         if getDirectionTo(getThingPos(sid), getThingPos(getCreatureMaster(sid))) <= 3 then
  363.             doRegainSpeed(sid)
  364.             local ndelay = getNextStepDelay(sid, 0)
  365.             doTeleportThing(sid, thepos, true)
  366.             doChangeSpeed(sid, -getCreatureSpeed(sid))
  367.             markPos(sid, getThingPos(getCreatureMaster(sid)))
  368.             addEvent(goThere, ndelay, sid, getMarkedPos(sid), skill, target, stackPos)
  369.         else
  370.             doChangeSpeed(sid, - getCreatureSpeed(sid))
  371.             doRegainSpeed(sid)
  372.             markPos(sid, getThingPos(getCreatureMaster(sid)))
  373.             local x = walkTo(sid, getDirectionTo(getThingPos(sid), getMarkedPos(sid)), getMarkedPos(sid), skill == "ride" or skill == "fly")
  374.             doChangeSpeed(sid, - getCreatureSpeed(sid))
  375.             addEvent(goThere, x, sid, getMarkedPos(sid), skill, target, stackPos)
  376.             end
  377.     return true
  378.     else
  379.         markPos(sid, getThingPos(getCreatureMaster(sid)))
  380.         doChangeSpeed(sid, - getCreatureSpeed(sid))
  381.         doRegainSpeed(sid)
  382.         local ndelay = getNextStepDelay(sid, 0)
  383.             if getDirectionTo(getThingPos(sid), getMarkedPos(sid)) >= 4 then
  384.                 local x = walkTo(sid, getDirectionTo(getThingPos(sid), getMarkedPos(sid)), getMarkedPos(sid), skill == "ride" or skill == "fly")
  385.             else
  386.                 doTeleportThing(sid, getPosByDir(getThingPos(sid), getDirectionTo(getThingPos(sid), getMarkedPos(sid))))
  387.             end
  388.         doChangeSpeed(sid, - getCreatureSpeed(sid))
  389.         addEvent(goThere, x and x or ndelay, sid, getMarkedPos(sid), skill, target, stackPos)
  390.     return true
  391.     end
  392.  
  393. addEvent(recheck, 350, sid, skill, thepos, stackPos)
  394. return true
  395. end
  396.  
  397. if getThingPos(sid).x == getMarkedPos(sid).x and getThingPos(sid).y == getMarkedPos(sid).y then
  398.     if isCreature(getCreatureTarget(sid)) then
  399.     doFaceCreature(sid, getThingPos(getCreatureTarget(sid)))
  400.     end
  401.     if skill == "blink" then
  402.        doChangeSpeed(sid, - getCreatureSpeed(sid))   --edited blink
  403.     end
  404. addEvent(recheck, 350, sid, skill, thepos, stackPos)
  405. return true
  406. end
  407.  
  408. if (getOwnerPos(sid).x ~= getThingPos(getCreatureMaster(sid)).x or getOwnerPos(sid).y ~= getThingPos(getCreatureMaster(sid)).y) and isCreature(getCreatureTarget(getCreatureMaster(sid))) == false and skill == "move" then
  409. doRegainSpeed(sid)
  410. markPos(sid, {x=1,y=1,z=7})
  411. return true
  412. end
  413.  
  414. doRegainSpeed(sid)
  415.  
  416. local holeid = thepos
  417. holeid.stackpos = 0
  418. holeid = getTileThingByPos(holeid).itemid
  419.  
  420. if getDistanceBetween(getThingPos(sid), getMarkedPos(sid)) <= 1 and (not isWalkable(getPosByDir(getThingPos(sid), getDirectionTo(getThingPos(sid), getMarkedPos(sid))), true, false, false, true) or isInArray(specialabilities["digholes"], holeid)) then
  421.     if isGhostPokemon(sid) and getPlayerStorageValue(getCreatureMaster(sid), 990) <= 0 then
  422.         local todir = getDirectionTo(getThingPos(sid), getMarkedPos(sid))
  423.         if todir <= 3 then
  424.             doTeleportThing(sid, getMarkedPos(sid), true)
  425.         else
  426.             local gotopos = getPosByDir(getThingPos(sid), dirpref[math.random(1, 2)][todir][1][math.random(1, 2)])
  427.             doTeleportThing(sid, gotopos, true)
  428.             addEvent(goThere, getNextStepDelay(sid, 0), sid, getMarkedPos(sid), skill, target)
  429.             return true
  430.         end
  431.     end
  432. doFaceCreature(sid, getMarkedPos(sid))
  433. addEvent(recheck, 180, sid, skill, thepos, stackPos)
  434. doChangeSpeed(sid, - getCreatureSpeed(sid))
  435. return true
  436. end
  437.  
  438. local ret = 0
  439.     if getDistanceBetween(getThingPos(sid), getMarkedPos(sid)) <= 1 then
  440.         ret = walkTo(sid, getDirectionTo(getThingPos(sid), getMarkedPos(sid)), getMarkedPos(sid), skill == "ride" or skill == "fly" or isGhostPokemon(sid))
  441.         if not tonumber(ret) then
  442.             doFaceCreature(sid, getMarkedPos(sid))
  443.             addEvent(recheck, 180, sid, skill, thepos, stackPos)
  444.             doChangeSpeed(sid, - getCreatureSpeed(sid))
  445.         return true
  446.         end
  447.     else                                                                                                                          --alterado
  448.         ret = walkTo(sid, getDirectionTo(getThingPos(sid), getMarkedPos(sid)), getMarkedPos(sid), skill == "ride" or skill == "fly" or not isGhostPokemon(sid))-- and isSightClear(getThingPos(sid), getMarkedPos(sid), false)))
  449.     end
  450.  
  451. if not tonumber(ret) then
  452. doPlayerSendCancel(getCreatureMaster(sid), "Destination is not reachable.")
  453. markPos(sid, {x=1,y=1,z=10})
  454. return true
  455. end
  456.  
  457. doChangeSpeed(sid, - getCreatureSpeed(sid))
  458. addEvent(goThere, tonumber(ret), sid, getMarkedPos(sid), skill, target, rept and rept - 1 or 22)
  459. end
Add Comment
Please, Sign In to add comment