MaXwEllDeN

Teleport Lucas

Oct 9th, 2013
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.71 KB | None | 0 0
  1. local config = {
  2.     times = 4,
  3.     speed = 350, -- em milisegundos
  4.  
  5.     min_damage = 1000,
  6.     max_damage = 1600,
  7.  
  8. }
  9.  
  10. local pos = {
  11.     [0] = {y = -1},
  12.     [1] = {x = 1},
  13.     [2] = {y = 1},
  14.     [3] = {x = -1},
  15.  
  16. }
  17.  
  18. local area_walk = {
  19.     [0] = createCombatArea({
  20.         {0, 0, 0},
  21.         {1, 2, 1},
  22.         {0, 0, 0},
  23.     }),
  24.  
  25.     [1] = createCombatArea({
  26.         {0, 1, 0},
  27.         {0, 2, 0},
  28.         {0, 1, 0},
  29.     }),
  30.  
  31.     [2] = createCombatArea({
  32.         {0, 0, 0},
  33.         {1, 2, 1},
  34.         {0, 0, 0},
  35.     }),
  36.  
  37.     [3] = createCombatArea({
  38.         {0, 1, 0},
  39.         {0, 2, 0},
  40.         {0, 1, 0},
  41.     }),
  42. }
  43.  
  44. local areas = {
  45.     [0] = createCombatArea({
  46.         {0, 0, 0},
  47.         {0, 2, 0},
  48.         {1, 1, 1},
  49.     }),
  50.  
  51.     [1] = createCombatArea({
  52.         {1, 0, 0},
  53.         {1, 2, 0},
  54.         {1, 0, 0},
  55.     }),
  56.  
  57.     [2] = createCombatArea({
  58.         {1, 1, 1},
  59.         {0, 2, 0},
  60.         {0, 0, 0},
  61.     }),
  62.  
  63.     [3] = createCombatArea({
  64.         {0, 0, 1},
  65.         {0, 2, 1},
  66.         {0, 0, 1},
  67.     }),
  68. }
  69.  
  70. function isWalkablelks(cid, pos)
  71.     pos.stackpos = 0
  72.     if getTileThingByPos(pos).uid ~= 0 then
  73.         local n = getTileInfo(pos)
  74.         if n.protection == false and n.house == false and getTopCreature(pos).uid == 0 and doTileQueryAdd(cid, pos) == RETURNVALUE_NOERROR then
  75.             return true
  76.         end
  77.     end
  78.  
  79.     return false
  80. end
  81.  
  82. local function Walk(cid, dir, times, atime)
  83.     local function doSendAura(cid)
  84.         mayNotMove(cid, false)
  85.     end
  86.  
  87.     local move = mayNotMove(cid, false)
  88.     local atime = atime or 1
  89.  
  90.     if isCreature(cid) then
  91.         if atime < times then
  92.             local cp = getThingPos(cid)
  93.             local x = pos[dir].x or 0
  94.             local y = pos[dir].y or 0
  95.             local topos = {x = cp.x + x, y = cp.y + y, z = cp.z}
  96.             local efeitox = {x=cp.x+4, y=cp.y-2, z=cp.z}
  97.             local target  = getTopCreature(topos).uid
  98.  
  99.             if not getTilePzInfo(topos) and isCreature(target) and not isNpc(target) then
  100.                 doAreaCombatHealth(cid, COMBAT_ENERGYDAMAGE, getThingPos(cid), areas[dir], -config.min_damage, -config.max_damage, 4)
  101.                 doCreatureSay(cid, 'Hakunamatata!', 19)
  102.                 mayNotMove(cid, false)
  103.                 addEvent(doSendAura, 1500, cid)
  104.                 setPlayerStorageValue(cid, 24753, -1)
  105.                 return false
  106.             elseif isWalkablelks(cid, topos) then
  107.                 doAreaCombatHealth(cid, COMBAT_ENERGYDAMAGE, getThingPos(cid), area_walk[dir], -config.min_damage, -config.max_damage, 4)
  108.                 doTeleportThing(cid, topos)
  109.             else
  110.                 doSendMagicEffect(cp, 3)
  111.  
  112.                 addEvent(doSendAura, 1500, cid)
  113.                 setPlayerStorageValue(cid, 24753, -1)
  114.                 return false
  115.             end
  116.  
  117.             addEvent(Walk, config.speed, cid, dir, times, atime + 1)
  118.             return true
  119.         end
  120.  
  121.         addEvent(doSendAura, 1500, cid)
  122.         setPlayerStorageValue(cid, 24753, -1)
  123.     end
  124.     return false
  125. end
  126.  
  127. function onCastSpell(cid, var)
  128.     if getPlayerStorageValue(cid, 24753) > 0 then
  129.         return false
  130.     end
  131.  
  132.     Walk(cid, getCreatureLookDirection(cid), config.times)
  133.     mayNotMove(cid, true)
  134.     return true
  135. end
Advertisement
Add Comment
Please, Sign In to add comment