Advertisement
Guest User

Untitled

a guest
Jul 4th, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.52 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. if target > 0 then
  27. local position_target = nil
  28. local cont = 0
  29. for i=-1, 1 do
  30. for j=-1,1 do
  31. position_target = {x=getCreaturePosition(target).x+i, y=getCreaturePosition(target).y+j, z=getCreaturePosition(target).z}
  32. if isWalkable(position_target) then
  33. cont = cont+1
  34. break
  35. end
  36. end
  37. if cont > 0 then
  38. break
  39. end
  40. position_target = nil
  41. end
  42.  
  43. local px = math.random(-1,1)
  44. local py = 0
  45. if px == -1 or px == 1 then
  46. py = 0
  47. elseif px == 0 then
  48. local n = {1,-1}
  49. py = n[math.random(1,#n)]
  50. end
  51. local poscentral = {x=getCreaturePosition(target).x+px, y=getCreaturePosition(target).y+py, z=getCreaturePosition(target).z}
  52. if isWalkable(poscentral) then
  53. position_target = poscentral
  54. end
  55.  
  56. if getDistanceBetween(getCreaturePosition(cid), getCreaturePosition(target)) <= 1 then
  57. position_target = getCreaturePosition(cid)
  58. end
  59.  
  60. if position_target == nil then
  61. doPlayerSendCancel(cid, "Você não pode atravesar isso!")
  62. return false
  63. end
  64. local pos = position_target
  65. posTile1 = {{x=pos.x,y=pos.y,z=pos.z,stackpos=1}, 5579} -- embaixo do player
  66. posTile2 = {{x=pos.x+1,y=pos.y+1,z=pos.z,stackpos=1}, 5585}
  67. posTile3 = {{x=pos.x+1,y=pos.y,z=pos.z,stackpos=1}, 5580}
  68. posTile4 = {{x=pos.x+1,y=pos.y-1,z=pos.z,stackpos=1}, 5575}
  69. posTile5 = {{x=pos.x,y=pos.y-1,z=pos.z,stackpos=1}, 5574}
  70. posTile6 = {{x=pos.x-1,y=pos.y-1,z=pos.z,stackpos=1}, 5573}
  71. posTile7 = {{x=pos.x-1,y=pos.y,z=pos.z,stackpos=1}, 5578}
  72. posTile8 = {{x=pos.x-1,y=pos.y+1,z=pos.z,stackpos=1}, 5583}
  73. posTile9 = {{x=pos.x,y=pos.y+1,z=pos.z,stackpos=1}, 5584}
  74. posTile10 = {{x=pos.x,y=pos.y+2,z=pos.z,stackpos=1}, 5588}
  75. posTile11 = {{x=pos.x+1,y=pos.y+2,z=pos.z,stackpos=1}, 5589}
  76. posTile12 = {{x=pos.x+2,y=pos.y+1,z=pos.z,stackpos=1}, 5586}
  77. posTile13 = {{x=pos.x+2,y=pos.y,z=pos.z,stackpos=1}, 5581}
  78. posTile14 = {{x=pos.x+2,y=pos.y-1,z=pos.z,stackpos=1}, 5576}
  79. posTile15 = {{x=pos.x+1,y=pos.y-2,z=pos.z,stackpos=1}, 5571}
  80. posTile16 = {{x=pos.x,y=pos.y-2,z=pos.z,stackpos=1}, 5570}
  81. posTile17 = {{x=pos.x-1,y=pos.y-2,z=pos.z,stackpos=1}, 5569}
  82. posTile18 = {{x=pos.x-2,y=pos.y-1,z=pos.z,stackpos=1}, 5572}
  83. posTile19 = {{x=pos.x-2,y=pos.y,z=pos.z,stackpos=1}, 5577}
  84. posTile20 = {{x=pos.x-2,y=pos.y+1,z=pos.z,stackpos=1}, 5582}
  85. posTile21 = {{x=pos.x-1,y=pos.y+2,z=pos.z,stackpos=1}, 5587}
  86. posTile22 = {{x=pos.x,y=pos.y-3,z=pos.z,stackpos=1}, 5590}
  87. posTile23 = {{x=pos.x+2,y=pos.y-2,z=pos.z,stackpos=1}, 5592}
  88. posTile24 = {{x=pos.x-2,y=pos.y-2,z=pos.z,stackpos=1}, 5591}
  89. posTile25 = {{x=pos.x-3,y=pos.y,z=pos.z,stackpos=1}, 5593}
  90. posTile26 = {{x=pos.x-2,y=pos.y+2,z=pos.z,stackpos=1}, 5595}
  91. posTile27 = {{x=pos.x+3,y=pos.y,z=pos.z,stackpos=1}, 5594}
  92. 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}
  93. posAll = {}
  94. for i=1, #posAllTeste do
  95. if isWalkable2(posAllTeste[i][1]) then
  96. posAll[#posAll+1] = posAllTeste[i]
  97. end
  98. end
  99. if position_target ~= nil then
  100. doTeleportThing(cid, position_target)
  101. local tempo = 0
  102. while (tempo ~= quant_hit*(timeHit*1000)) do
  103. addEvent(sendEffect813, tempo, cid, target)
  104. tempo = tempo + 500
  105. end
  106. tempo = 0
  107. while (tempo ~= quant_hit*(timeHit*1000)) do
  108. addEvent(hitTarget35, tempo, cid, target)
  109. tempo = tempo + (timeHit*1000)
  110. end
  111. local temp = tempo
  112. while (tempo ~= temp+quant_sqm*(sqmTime*1000)) do
  113. addEvent(empurrar2Target, tempo, cid, target, tempo, posAll)
  114. tempo = tempo + (sqmTime*1000)
  115. end
  116. doAddCondition(cid, condition)
  117. doAddCondition(target, condition)
  118. local mana_hit = (getPlayerLevel(cid)*2 + getPlayerMagLevel(cid)*2 + 24700)
  119. doCreatureAddMana(target, -mana_hit)
  120. for o=1, #posAll do
  121. local check = true
  122. for j=0, 255 do
  123. pos_stack = {x=posAll[o][1].x,y=posAll[o][1].y,z=posAll[o][1].z,stackpos=j}
  124. removeTile = getThingfromPos(pos_stack)
  125. if isInArray(tiles_exception, removeTile.itemid) then
  126. check = false
  127. end
  128. end
  129. if check then
  130. if isWalkable2(posAll[o][1]) then
  131. doCreateItem(posAll[o][2], 1, posAll[o][1])
  132. end
  133. end
  134. end
  135. setGlobalStorageValue(45000, os.time() + 60)
  136. end
  137. return true
  138. else
  139. doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
  140. end
  141. else
  142. doPlayerSendCancel(cid, "Você precisa de um target!")
  143. end
  144. end
  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
Advertisement