Advertisement
Guest User

Untitled

a guest
Jul 4th, 2015
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.55 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. doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
  139.  
  140. else
  141.  
  142. doPlayerSendTextMessage(cid, 27, "Esta em cooldown: " .. getGlobalStorageValue(45000) - os.time() .. ".")
  143.  
  144. end
  145. end
  146.  
  147.  
  148.  
  149. function isWalkable(pos, creature, pz, proj)
  150. if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
  151. local creature = getTopCreature(pos)
  152. if creature.type > 0 then return false end
  153. if getTilePzInfo(pos) and not pz then return false end
  154. local n = not proj and 3 or 2
  155. for i = 0, 255 do
  156. pos.stackpos = i
  157. local tile = getTileThingByPos(pos)
  158. if tile.itemid ~= 0 and not isCreature(tile.uid) then
  159. if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
  160. return false
  161. end
  162. end
  163. end
  164. return true
  165. end
  166.  
  167. function isWalkable2(pos, creature, pz, proj)
  168. if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
  169. if getTilePzInfo(pos) and not pz then return false end
  170. local n = not proj and 3 or 2
  171. for i = 0, 255 do
  172. pos.stackpos = i
  173. local tile = getTileThingByPos(pos)
  174. if tile.itemid ~= 0 and not isCreature(tile.uid) then
  175. if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
  176. return false
  177. end
  178. end
  179. end
  180. return true
  181. end
  182.  
  183. function hitTarget35(cid, target)
  184. if isCreature(target) and isPlayer(cid) then
  185. local effect813 = 9 -- efeito do hit na creatura.
  186. doAddCondition(target, condition)
  187. doTargetCombatHealth(cid, target, COMBAT_PHYSICALDAMAGE, -getHit35(cid), -getHit35(cid), effect813)
  188. end
  189. end
  190.  
  191. function getHit35(cid)
  192. local hit35 = getPlayerLevel(cid)*1 + getPlayerMagLevel(cid)*1 + math.random(55000,56000)
  193. return hit35
  194. end
  195.  
  196. function empurrar2Target(cid, target, tempo, posAll)
  197. if isPlayer(cid) then
  198. doRemoveCondition(cid, CONDITION_PARALYZE)
  199. end
  200. if not isCreature(target) then
  201. for k=1, #posAll do
  202. for j=0, 255 do
  203. pos_stack = {x=posAll[k][1].x,y=posAll[k][1].y,z=posAll[k][1].z,stackpos=j}
  204. removeTile = getThingfromPos(pos_stack)
  205. if removeTile.itemid == posAll[k][2] then
  206. doRemoveItem(removeTile.uid)
  207. end
  208. end
  209. end
  210. end
  211. if isCreature(target) and isPlayer(cid) then
  212. local positions = nil
  213. doAddCondition(target, condition)
  214. if getPlayerLookDir(cid) == 0 then
  215. positions = {x=getCreaturePosition(target).x, y=getCreaturePosition(target).y-1, z=getCreaturePosition(target).z}
  216. elseif getPlayerLookDir(cid) == 1 then
  217. positions = {x=getCreaturePosition(target).x+1, y=getCreaturePosition(target).y, z=getCreaturePosition(target).z}
  218. elseif getPlayerLookDir(cid) == 2 then
  219. positions = {x=getCreaturePosition(target).x, y=getCreaturePosition(target).y+1, z=getCreaturePosition(target).z}
  220. elseif getPlayerLookDir(cid) == 3 then
  221. positions = {x=getCreaturePosition(target).x-1, y=getCreaturePosition(target).y, z=getCreaturePosition(target).z}
  222. end
  223. if positions ~= nil and isWalkable(positions) then
  224. doTeleportThing(target, positions)
  225. end
  226. local tp = sqmTime*1000*(quant_sqm-1)+quant_hit*timeHit*1000
  227. if tempo == tp then
  228. doRemoveCondition(target, CONDITION_PARALYZE)
  229. for k=1, #posAll do
  230. for j=0, 255 do
  231. pos_stack = {x=posAll[k][1].x,y=posAll[k][1].y,z=posAll[k][1].z,stackpos=j}
  232. removeTile = getThingfromPos(pos_stack)
  233. if removeTile.itemid == posAll[k][2] then
  234. doRemoveItem(removeTile.uid)
  235. end
  236. end
  237. end
  238. end
  239. end
  240. end
  241.  
  242. function sendEffect813(cid, target)
  243. local position1 = {x=getPlayerPosition(cid).x, y=getPlayerPosition(cid).y, z=getPlayerPosition(cid).z}
  244. if isCreature(target) and isPlayer(cid) then
  245. doSendMagicEffect(position1, playerEffect)
  246. end
  247. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement