Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.84 KB | None | 0 0
  1.  
  2.  
  3. function getPlayersInRange(position, radiusx, radiusy)
  4. local creaturesList = {}
  5. for x = -radiusx, radiusx do
  6. for y = -radiusy, radiusy do
  7. if not (x == 0 and y == 0) then
  8. local creature = getTopCreature({x = position.x+x, y = position.y+y, z = position.z})
  9. if creature.type == 1 then
  10. table.insert(creaturesList, creature.uid)
  11. end
  12. end
  13. end
  14. end
  15.  
  16. local creature = getTopCreature(position)
  17. if creature.type == 1 then
  18. if not(table.find(creaturesList, creature.uid)) then
  19. table.insert(creaturesList, creature.uid)
  20. end
  21. end
  22. return creaturesList
  23. end
  24.  
  25. function isPositionInArray(haystack, needle)
  26. for i = 1, #haystack do
  27. if haystack[i].x == needle.x and haystack[i].y == needle.y and haystack[i].z == needle.z then
  28. return true
  29. end
  30. end
  31. return false
  32. end
  33.  
  34. local t = {
  35. from = {x=825, y=1171, z=7},
  36. to = {x=839, y=1181, z=7},
  37. storage = {
  38. placed = 10001,
  39. max = 10002,
  40. radius = 10003
  41. },
  42. delay = 3000,
  43. bombID = 9468,
  44. effect = CONST_ME_FIREAREA,
  45. blockID = 10744,
  46. text = "BOOOOM!",
  47. temple = {x=160, y=51, z=7},
  48. exceptions = {
  49. {x=826, y=1171, z=7},
  50. {x=825, y=1171, z=7},
  51. {x=825, y=1172, z=7},
  52.  
  53. {x=825, y=1180, z=7},
  54. {x=825, y=1181, z=7},
  55. {x=826, y=1181, z=7},
  56.  
  57. {x=838, y=1181, z=7},
  58. {x=839, y=1181, z=7},
  59. {x=839, y=1180, z=7},
  60.  
  61. {x=839, y=1172, z=7},
  62. {x=839, y=1171, z=7},
  63. {x=838, y=1171, z=7}
  64. }
  65. }
  66. function reset()
  67. local dummy = doCreateItem(10744, 1, {x=832,y=1176,z=7})
  68. for x = t.from.x, t.to.x do
  69. for y = t.from.y, t.to.y do
  70. local pos = {x=x,y=y,z=t.from.z}
  71. local i1, i2, i3 = getTileItemById(pos, 8304).uid, getTileItemById(pos, 2644).uid, getTileItemById(pos, 8046).uid, getTileItemById(pos, 8310).uid
  72. if i1 > 0 then
  73. doRemoveItem(i1)
  74. end
  75. if i2 > 0 then
  76. doRemoveItem(i2)
  77. end
  78. if i3 > 0 then
  79. doRemoveItem(i3)
  80. end
  81. if queryTileAddThing(dummy, pos, 4) == RETURNVALUE_NOERROR and not isPositionInArray(t.exceptions, pos) then
  82. doCreateItem(t.blockID, 1, pos)
  83. end
  84. end
  85. end
  86. doRemoveItem(dummy)
  87. end
  88.  
  89. local sto = 800990
  90. local speedchange = 50
  91. local oldspeed = getPlayerStorageValue(cid, sto) == -1 and getCreatureBaseSpeed(cid) or getPlayerStorageValue(cid, sto)
  92. local function boom(pos, cid)
  93. local v = getTileItemById(pos, t.bombID).uid
  94. if isPlayer(cid) and isInRange(getThingPos(cid), t.from, t.to) then
  95. setPlayerStorageValue(cid, t.storage.placed, getPlayerStorageValue(cid, t.storage.placed) - 1)
  96. doCreatureSay(cid, t.text, TALKTYPE_ORANGE_2, false, nil, pos)
  97. doSendMagicEffect(pos, t.effect)
  98. local c = getTopCreature(pos).uid
  99. if isPlayer(c) and isInRange(getThingPos(c), t.from, t.to) then
  100. doSendMagicEffect(pos, CONST_ME_GIFT_WRAPS)
  101. doTeleportThing(c, t.temple)
  102. doChangeSpeed(c, oldspeed)
  103. doSendMagicEffect(t.temple, CONST_ME_MORTAREA)
  104. local n1, n2 = getPlayerName(c), getPlayerName(cid)
  105. doBroadcastMessage(n1==n2 and n1 .. " killed " .. (getPlayerSex(c) == 0 and "her" or "him") .. "self![Bomberman]" or n1 .. " was killed by " .. n2 .. "![Bomberman]", MESSAGE_STATUS_WARNING)
  106. local a = getPlayersInRange({x=832, y=1176, z=7}, 7, 5)
  107. local sto = 800990
  108. local speedchange = 50
  109. local abc = getPlayerName(a[1])
  110. local oldspeed = getPlayerStorageValue(cid, sto) == -1 and getCreatureBaseSpeed(cid) or getPlayerStorageValue(cid, sto)
  111. if #a < 2 then
  112. doBroadcastMessage(getPlayerName(a[1]) .. " has won the match![Bomberman]", MESSAGE_STATUS_WARNING)
  113. doTeleportThing(a[1], t.temple)
  114. doChangeSpeed(abc, oldspeed)
  115. doSendMagicEffect(t.temple, CONST_ME_FIREWORK_RED)
  116. reset()
  117. reset()
  118. end
  119. else
  120. local b = getTileItemById(pos, t.blockID).uid
  121. if b > 0 or getTileItemById(pos, 10756).uid > 0 then
  122. doSendMagicEffect(pos, CONST_ME_BLOCKHIT)
  123. doRemoveItem(b)
  124. local r = math.random(10)
  125. if r < 4 then
  126. doCreateItem(r==1 and 8304 or r==2 and 2644 or r==3 and 8310, 1, _pos)
  127. end
  128. end
  129. end
  130. local N, E, W, S, l = 1, 1, 1, 1, getPlayerStorageValue(cid, t.storage.radius)
  131. function loopDir(dir)
  132. local _pos = {x=pos.x+(dir=="E" and E or dir=="W" and -W or 0), y=pos.y+(dir=="N" and -N or dir=="S" and S or 0), z=pos.z}
  133. if queryTileAddThing(v, _pos, 4) == RETURNVALUE_NOERROR or getTileItemById(_pos, t.blockID).uid > 0 then
  134. doSendMagicEffect(_pos, t.effect)
  135. local c = getTopCreature(_pos).uid
  136. local sto = 800990
  137. local speedchange = 50
  138. local oldspeed = getPlayerStorageValue(cid, sto) == -1 and getCreatureBaseSpeed(cid) or getPlayerStorageValue(cid, sto)
  139. if isPlayer(c) and isInRange(getThingPos(c), t.from, t.to) then
  140. doSendMagicEffect(_pos, CONST_ME_GIFT_WRAPS)
  141. doTeleportThing(c, t.temple)
  142. doChangeSpeed(c, oldspeed)
  143. doSendMagicEffect(t.temple, CONST_ME_MORTAREA)
  144. local n1, n2 = getPlayerName(c), getPlayerName(cid)
  145. doBroadcastMessage(n1==n2 and n1 .. " killed " .. (getPlayerSex(c) == 0 and "her" or "him") .. "self![Bomberman]" or n1 .. " was killed by " .. n2 .. "![Bomberman]", MESSAGE_STATUS_WARNING)
  146. local a = getPlayersInRange({x=832, y=1176, z=7}, 7, 5)
  147. local sto = 800990
  148. local speedchange = 50
  149. local oldspeed = getPlayerStorageValue(a[1], sto) == -1 and getCreatureBaseSpeed(a[1]) or getPlayerStorageValue(a[1], sto)
  150. if #a < 2 then
  151. doBroadcastMessage(getPlayerName(a[1]) .. " has won the match![Bomberman]", MESSAGE_STATUS_WARNING)
  152. doTeleportThing(a[1], t.temple)
  153. doChangeSpeed(a[1], oldspeed)
  154. doSendMagicEffect(t.temple, CONST_ME_FIREWORK_RED)
  155. reset()
  156. reset()
  157. return "endgame"
  158. end
  159. else
  160. local b = getTileItemById(_pos, t.blockID).uid
  161. if b > 0 then
  162. doSendMagicEffect(_pos, CONST_ME_BLOCKHIT)
  163. doRemoveItem(b)
  164. local r = math.random(10)
  165. if r < 4 then
  166. doCreateItem(r==1 and 8304 or r==2 and 2644 or r==3 and 8310, 1, _pos)
  167. end
  168. return false
  169. end
  170. end
  171. elseif queryTileAddThing(v, _pos, 4) == 3 then
  172. return false
  173. end
  174. return true
  175. end
  176. while N <= l do
  177. local q = loopDir("N")
  178. if q == "endgame" then
  179. return doRemoveItem(v, 1)
  180. elseif not q then
  181. break
  182. else
  183. N = N + 1
  184. end
  185. end
  186. while E <= l do
  187. local q = loopDir("E")
  188. if q == "endgame" then
  189. return doRemoveItem(v, 1)
  190. elseif not q then
  191. break
  192. else
  193. E = E + 1
  194. end
  195. end
  196. while W <= l do
  197. local q = loopDir("W")
  198. if q == "endgame" then
  199. return doRemoveItem(v, 1)
  200. elseif not q then
  201. break
  202. else
  203. W = W + 1
  204. end
  205. end
  206. while S <= l do
  207. local q = loopDir("S")
  208. if q == "endgame" then
  209. return doRemoveItem(v, 1)
  210. elseif not q then
  211. break
  212. else
  213. S = S + 1
  214. end
  215. end
  216. end
  217. doRemoveItem(v, 1)
  218. end
  219. function onSay(cid, words, param, channel)
  220. if isInRange(getThingPos(cid), t.from, t.to) then
  221. setPlayerStorageValue(cid, t.storage.placed, math.max(getPlayerStorageValue(cid, t.storage.placed), 0))
  222. setPlayerStorageValue(cid, t.storage.max, math.max(getPlayerStorageValue(cid, t.storage.max), 1))
  223. setPlayerStorageValue(cid, t.storage.radius, math.max(getPlayerStorageValue(cid, t.storage.radius), 1))
  224. if getPlayerStorageValue(cid, t.storage.placed) < getPlayerStorageValue(cid, t.storage.max) then
  225. doCreateItem(t.bombID, 1, getThingPos(cid))
  226. addEvent(boom, t.delay, getThingPos(cid), cid)
  227. setPlayerStorageValue(cid, t.storage.placed, getPlayerStorageValue(cid, t.storage.placed) + 1)
  228. end
  229. return true
  230. end
  231. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement