Advertisement
Guest User

Untitled

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