Guest User

Untitled

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