Guest User

Untitled

a guest
Jul 4th, 2015
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.49 KB | None | 0 0
  1. local quant_hit = 4 -- quantidade de hits que ira dar no target
  2. local timeHit = 0.5 -- segundos de diferença para cada hit
  3.  
  4. local quant_sqm = 1 -- sqms que ira empurrar o target
  5. local sqmTime = 0.01 -- segundos para empurrar após hitar, exemplo de meio segundo.
  6.  
  7. local playerEffect = 134 -- efeito no player.
  8.  
  9. local tiles_exception = {8277,8283,410,459,6169,6130,411,369,1385,1394,1395,5260,9574,9573,5023,1387,470,4836} -- sqms que não podera ser criado os itens, ou seja, os buracos de escada.
  10.  
  11. local combat = createCombatObject()
  12. setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
  13. setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DROWNDAMAGE)
  14. setCombatFormula(combat, COMBAT_FORMULA_SKILL, 1, 0, 1, 0)
  15.  
  16. local condition = createConditionObject(CONDITION_PARALYZE)
  17. setConditionParam(condition, CONDITION_PARAM_TICKS, -1)
  18. setConditionParam(condition, CONDITION_PARAM_SPEED, -100)
  19. setConditionFormula(condition, 0, 0, 0, 0)
  20. setCombatCondition(combat, condition)
  21.  
  22. function onCastSpell(cid, var)
  23. local target = getCreatureTarget(cid)
  24. if getGlobalStorageValue(45000) >= os.time() then
  25.  
  26. local position_target = nil
  27. local cont = 0
  28. for i=-1, 1 do
  29. for j=-1,1 do
  30. position_target = {x=getCreaturePosition(target).x+i, y=getCreaturePosition(target).y+j, z=getCreaturePosition(target).z}
  31. if isWalkable(position_target) then
  32. cont = cont+1
  33. break
  34. end
  35. end
  36. if cont > 0 then
  37. break
  38. end
  39. position_target = nil
  40. end
  41.  
  42. local px = math.random(-1,1)
  43. local py = 0
  44. if px == -1 or px == 1 then
  45. py = 0
  46. elseif px == 0 then
  47. local n = {1,-1}
  48. py = n[math.random(1,#n)]
  49. end
  50. local poscentral = {x=getCreaturePosition(target).x+px, y=getCreaturePosition(target).y+py, z=getCreaturePosition(target).z}
  51. if isWalkable(poscentral) then
  52. position_target = poscentral
  53. end
  54.  
  55. if getDistanceBetween(getCreaturePosition(cid), getCreaturePosition(target)) <= 1 then
  56. position_target = getCreaturePosition(cid)
  57. end
  58.  
  59. if position_target == nil then
  60. doPlayerSendCancel(cid, "Você não pode atravesar isso!")
  61. return false
  62. end
  63. local pos = position_target
  64. posTile1 = {{x=pos.x,y=pos.y,z=pos.z,stackpos=1}, 5579} -- embaixo do player
  65. posTile2 = {{x=pos.x+1,y=pos.y+1,z=pos.z,stackpos=1}, 5585}
  66. posTile3 = {{x=pos.x+1,y=pos.y,z=pos.z,stackpos=1}, 5580}
  67. posTile4 = {{x=pos.x+1,y=pos.y-1,z=pos.z,stackpos=1}, 5575}
  68. posTile5 = {{x=pos.x,y=pos.y-1,z=pos.z,stackpos=1}, 5574}
  69. posTile6 = {{x=pos.x-1,y=pos.y-1,z=pos.z,stackpos=1}, 5573}
  70. posTile7 = {{x=pos.x-1,y=pos.y,z=pos.z,stackpos=1}, 5578}
  71. posTile8 = {{x=pos.x-1,y=pos.y+1,z=pos.z,stackpos=1}, 5583}
  72. posTile9 = {{x=pos.x,y=pos.y+1,z=pos.z,stackpos=1}, 5584}
  73. posTile10 = {{x=pos.x,y=pos.y+2,z=pos.z,stackpos=1}, 5588}
  74. posTile11 = {{x=pos.x+1,y=pos.y+2,z=pos.z,stackpos=1}, 5589}
  75. posTile12 = {{x=pos.x+2,y=pos.y+1,z=pos.z,stackpos=1}, 5586}
  76. posTile13 = {{x=pos.x+2,y=pos.y,z=pos.z,stackpos=1}, 5581}
  77. posTile14 = {{x=pos.x+2,y=pos.y-1,z=pos.z,stackpos=1}, 5576}
  78. posTile15 = {{x=pos.x+1,y=pos.y-2,z=pos.z,stackpos=1}, 5571}
  79. posTile16 = {{x=pos.x,y=pos.y-2,z=pos.z,stackpos=1}, 5570}
  80. posTile17 = {{x=pos.x-1,y=pos.y-2,z=pos.z,stackpos=1}, 5569}
  81. posTile18 = {{x=pos.x-2,y=pos.y-1,z=pos.z,stackpos=1}, 5572}
  82. posTile19 = {{x=pos.x-2,y=pos.y,z=pos.z,stackpos=1}, 5577}
  83. posTile20 = {{x=pos.x-2,y=pos.y+1,z=pos.z,stackpos=1}, 5582}
  84. posTile21 = {{x=pos.x-1,y=pos.y+2,z=pos.z,stackpos=1}, 5587}
  85. posTile22 = {{x=pos.x,y=pos.y-3,z=pos.z,stackpos=1}, 5590}
  86. posTile23 = {{x=pos.x+2,y=pos.y-2,z=pos.z,stackpos=1}, 5592}
  87. posTile24 = {{x=pos.x-2,y=pos.y-2,z=pos.z,stackpos=1}, 5591}
  88. posTile25 = {{x=pos.x-3,y=pos.y,z=pos.z,stackpos=1}, 5593}
  89. posTile26 = {{x=pos.x-2,y=pos.y+2,z=pos.z,stackpos=1}, 5595}
  90. posTile27 = {{x=pos.x+3,y=pos.y,z=pos.z,stackpos=1}, 5594}
  91. posAllTeste = {posTile1,posTile2,posTile3,posTile4,posTile5,posTile6,posTile7,posTile8,posTile9,posTile10,posTile11,posTile12,posTile13,posTile14,posTile15,posTile16,posTile17,posTile18,posTile19,posTile20,posTile21,posTile22,posTile23,posTile24,posTile25,posTile26,posTile27}
  92. posAll = {}
  93. for i=1, #posAllTeste do
  94. if isWalkable2(posAllTeste[i][1]) then
  95. posAll[#posAll+1] = posAllTeste[i]
  96. end
  97. end
  98. if position_target ~= nil then
  99. doTeleportThing(cid, position_target)
  100. local tempo = 0
  101. while (tempo ~= quant_hit*(timeHit*1000)) do
  102. addEvent(sendEffect813, tempo, cid, target)
  103. tempo = tempo + 500
  104. end
  105. tempo = 0
  106. while (tempo ~= quant_hit*(timeHit*1000)) do
  107. addEvent(hitTarget35, tempo, cid, target)
  108. tempo = tempo + (timeHit*1000)
  109. end
  110. local temp = tempo
  111. while (tempo ~= temp+quant_sqm*(sqmTime*1000)) do
  112. addEvent(empurrar2Target, tempo, cid, target, tempo, posAll)
  113. tempo = tempo + (sqmTime*1000)
  114. end
  115. doAddCondition(cid, condition)
  116. doAddCondition(target, condition)
  117. local mana_hit = (getPlayerLevel(cid)*2 + getPlayerMagLevel(cid)*2 + 24700)
  118. doCreatureAddMana(target, -mana_hit)
  119. for o=1, #posAll do
  120. local check = true
  121. for j=0, 255 do
  122. pos_stack = {x=posAll[o][1].x,y=posAll[o][1].y,z=posAll[o][1].z,stackpos=j}
  123. removeTile = getThingfromPos(pos_stack)
  124. if isInArray(tiles_exception, removeTile.itemid) then
  125. check = false
  126. end
  127. end
  128. if check then
  129. if isWalkable2(posAll[o][1]) then
  130. doCreateItem(posAll[o][2], 1, posAll[o][1])
  131. end
  132. end
  133. end
  134. setGlobalStorageValue(45000, os.time() + 60)
  135. end
  136. return true
  137. else
  138. doPlayerSendTextMessage(cid, 27, "Esta em cooldown: " .. getGlobalStorageValue(45000) - os.time() .. ".")
  139. end
  140.  
  141. end
  142.  
  143.  
  144.  
  145.  
  146. function isWalkable(pos, creature, pz, proj)
  147. if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
  148. local creature = getTopCreature(pos)
  149. if creature.type > 0 then return false end
  150. if getTilePzInfo(pos) and not pz then return false end
  151. local n = not proj and 3 or 2
  152. for i = 0, 255 do
  153. pos.stackpos = i
  154. local tile = getTileThingByPos(pos)
  155. if tile.itemid ~= 0 and not isCreature(tile.uid) then
  156. if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
  157. return false
  158. end
  159. end
  160. end
  161. return true
  162. end
  163.  
  164. function isWalkable2(pos, creature, pz, proj)
  165. if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
  166. if getTilePzInfo(pos) and not pz then return false end
  167. local n = not proj and 3 or 2
  168. for i = 0, 255 do
  169. pos.stackpos = i
  170. local tile = getTileThingByPos(pos)
  171. if tile.itemid ~= 0 and not isCreature(tile.uid) then
  172. if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
  173. return false
  174. end
  175. end
  176. end
  177. return true
  178. end
  179.  
  180. function hitTarget35(cid, target)
  181. if isCreature(target) and isPlayer(cid) then
  182. local effect813 = 9 -- efeito do hit na creatura.
  183. doAddCondition(target, condition)
  184. doTargetCombatHealth(cid, target, COMBAT_PHYSICALDAMAGE, -getHit35(cid), -getHit35(cid), effect813)
  185. end
  186. end
  187.  
  188. function getHit35(cid)
  189. local hit35 = getPlayerLevel(cid)*1 + getPlayerMagLevel(cid)*1 + math.random(55000,56000)
  190. return hit35
  191. end
  192.  
  193. function empurrar2Target(cid, target, tempo, posAll)
  194. if isPlayer(cid) then
  195. doRemoveCondition(cid, CONDITION_PARALYZE)
  196. end
  197. if not isCreature(target) then
  198. for k=1, #posAll do
  199. for j=0, 255 do
  200. pos_stack = {x=posAll[k][1].x,y=posAll[k][1].y,z=posAll[k][1].z,stackpos=j}
  201. removeTile = getThingfromPos(pos_stack)
  202. if removeTile.itemid == posAll[k][2] then
  203. doRemoveItem(removeTile.uid)
  204. end
  205. end
  206. end
  207. end
  208. if isCreature(target) and isPlayer(cid) then
  209. local positions = nil
  210. doAddCondition(target, condition)
  211. if getPlayerLookDir(cid) == 0 then
  212. positions = {x=getCreaturePosition(target).x, y=getCreaturePosition(target).y-1, z=getCreaturePosition(target).z}
  213. elseif getPlayerLookDir(cid) == 1 then
  214. positions = {x=getCreaturePosition(target).x+1, y=getCreaturePosition(target).y, z=getCreaturePosition(target).z}
  215. elseif getPlayerLookDir(cid) == 2 then
  216. positions = {x=getCreaturePosition(target).x, y=getCreaturePosition(target).y+1, z=getCreaturePosition(target).z}
  217. elseif getPlayerLookDir(cid) == 3 then
  218. positions = {x=getCreaturePosition(target).x-1, y=getCreaturePosition(target).y, z=getCreaturePosition(target).z}
  219. end
  220. if positions ~= nil and isWalkable(positions) then
  221. doTeleportThing(target, positions)
  222. end
  223. local tp = sqmTime*1000*(quant_sqm-1)+quant_hit*timeHit*1000
  224. if tempo == tp then
  225. doRemoveCondition(target, CONDITION_PARALYZE)
  226. for k=1, #posAll do
  227. for j=0, 255 do
  228. pos_stack = {x=posAll[k][1].x,y=posAll[k][1].y,z=posAll[k][1].z,stackpos=j}
  229. removeTile = getThingfromPos(pos_stack)
  230. if removeTile.itemid == posAll[k][2] then
  231. doRemoveItem(removeTile.uid)
  232. end
  233. end
  234. end
  235. end
  236. end
  237. end
  238.  
  239. function sendEffect813(cid, target)
  240. local position1 = {x=getPlayerPosition(cid).x, y=getPlayerPosition(cid).y, z=getPlayerPosition(cid).z}
  241. if isCreature(target) and isPlayer(cid) then
  242. doSendMagicEffect(position1, playerEffect)
  243. end
  244. end
Advertisement
Add Comment
Please, Sign In to add comment