Advertisement
Soristl

Pega gelo

Jul 7th, 2018 (edited)
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.46 KB | None | 0 0
  1. --------------
  2. -- Settings --
  3. --------------
  4. OUTPUT_MODE = 2
  5. -- 0 = silent mode (only visible to the one who loaded the script)
  6. -- 1 = chat box mode (will not work in tribehouse)
  7. -- 2 = tribe mode (will work in tribehouse; outputs through a textbox)
  8. KILL_RADIUS = 75
  9. -- The radius (in pixels) around the ice mouse that is considered in-range to freeze another mouse
  10. COOLDOWN = 2.5;
  11. -- The time (in seconds) of delay between when the ice mouse can freeze again after attacking and when a mouse can revive another mouse (only increments of 0.5)
  12. RESCUE_RADIUS = 100
  13. -- The radius (in pixels) around every other mouse that is considered in-ranged to unfreeze an ice block
  14. OUTPUT_NAME_COLOR = '<V>'
  15. OUTPUT_MESSAGE_COLOR = '<J>'
  16. -- Color tags to be used during output
  17. MAPS = {'@4000002'}
  18. -- Add more, separate with commas and use quotes, will be chosen randomly(e.g MAPS = {'@111111', '@222222', '@333333'})
  19.  
  20. --------------
  21. --------------
  22. tfm.exec.disableAfkDeath(true)
  23. tfm.exec.disableAutoNewGame(true)
  24. tfm.exec.disableAutoScore(true)
  25. tfm.exec.disableAutoShaman(true)
  26. tfm.exec.disableAutoTimeLeft(true)
  27. tfm.exec.disableAllShamanSkills(true)
  28.  
  29. if OUTPUT_MODE == 2 then
  30. ui.addTextArea(0, '', nil, 5, 5)
  31. end
  32. ui.addTextArea(1, '', nil, 5, 375)
  33.  
  34. all_players = {}
  35. ice_blocks = {}
  36. cooldowns = {}
  37. ice_mouse = '';
  38. countdown = 1
  39. second_mark = false
  40. all_dead = false
  41. can_attack = false
  42. time_to_clear_ttt = 3
  43. time_to_clear_ctt = 3
  44. mk_for_reset = false
  45. ttt = ''
  46. ctt = ''
  47. player_life = {}
  48.  
  49.  
  50. function output_msg(msg)
  51. if OUTPUT_MODE == 0 then
  52. print(msg)
  53. elseif OUTPUT_MODE == 1 then
  54. tfm.exec.chatMessage(msg)
  55. elseif OUTPUT_MODE == 2 then
  56. ttt = ttt .. '\n' .. msg
  57. ui.updateTextArea(0, ttt)
  58. time_to_clear_ttt = 3
  59. end
  60. end
  61.  
  62. function countdown_msg(msg)
  63. ctt = ctt .. ' ' .. msg
  64. ui.updateTextArea(1, ctt)
  65. time_to_clear_ctt = 3
  66. end
  67.  
  68. for name,player in pairs(tfm.get.room.playerList) do
  69. table.insert(all_players, name)
  70. tfm.exec.setPlayerScore(name, 0, false)
  71. end
  72.  
  73. function start_new_game()
  74. all_players = {}
  75. ice_blocks = {}
  76. can_attack = false
  77. tfm.exec.newGame(MAPS[math.random(#MAPS)])
  78.  
  79. for name,player in pairs(tfm.get.room.playerList) do
  80. tfm.exec.bindKeyboard(name, 32, true, true)
  81. table.insert(all_players, name)
  82. cooldowns[name] = 0
  83. tfm.exec.setNameColor(name, 0xB5B5B5)
  84. player_life[name] = 1
  85. end
  86.  
  87. ice_mouse = all_players[math.random(#all_players)]
  88. tfm.exec.setNameColor(ice_mouse, 0x009DFF)
  89.  
  90. output_msg(OUTPUT_NAME_COLOR .. ice_mouse .. OUTPUT_MESSAGE_COLOR .. ' is the Ice Mouse!')
  91. output_msg(OUTPUT_MESSAGE_COLOR .. 'The game will start in 10 seconds!')
  92. countdown = 10
  93. end
  94.  
  95. function set_new_game_countdown(num)
  96. countdown = 20 + num
  97. end
  98.  
  99. function eventLoop(current_time, time_remaining)
  100. second_mark = not second_mark
  101. if second_mark then
  102. if countdown > 0 and countdown < 20 then
  103. countdown_msg(OUTPUT_MESSAGE_COLOR .. countdown)
  104. countdown = countdown - 1
  105. elseif countdown == 0 then
  106. countdown_msg(OUTPUT_MESSAGE_COLOR .. 'Go!')
  107. countdown = -1
  108. can_attack = true
  109. elseif countdown == 20 then
  110. output_msg(OUTPUT_MESSAGE_COLOR .. 'Starting next game!')
  111. start_new_game()
  112. elseif countdown > 20 then
  113. countdown = countdown - 1
  114. end
  115. if time_to_clear_ttt == 0 and OUTPUT_MODE == 2 then
  116. if mk_for_reset then
  117. ui.removeTextArea(0)
  118. ui.addTextArea(0, '', nil, 5, 5)
  119. else
  120. ttt = ''
  121. ui.updateTextArea(0, ttt)
  122. end
  123. end
  124. if time_to_clear_ctt == 0 and OUTPUT_MODE == 2 then
  125. if mk_for_reset then
  126. ui.removeTextArea(1)
  127. ui.addTextArea(1, '', nil, 5, 375)
  128. mk_for_reset = false
  129. else
  130. ctt = ''
  131. ui.updateTextArea(1, ctt)
  132. end
  133. end
  134. time_to_clear_ttt = time_to_clear_ttt - 1
  135. time_to_clear_ctt = time_to_clear_ctt - 1
  136. end
  137. if time_remaining <= 1 then
  138. for name,player in pairs(tfm.get.room.playerList) do
  139. if (name ~= ice_mouse) and not (tfm.get.room.playerList[name].isDead) then
  140. all_dead = false
  141. end
  142. end
  143. output_msg(OUTPUT_MESSAGE_COLOR .. 'Oh no! The Ice Mouse ' .. OUTPUT_NAME_COLOR .. ice_mouse .. OUTPUT_MESSAGE_COLOR .. ' has failed to freeze all the mice!')
  144. output_msg(OUTPUT_MESSAGE_COLOR .. 'New game starting now!')
  145. start_new_game()
  146. end
  147. for num,name in pairs(all_players) do
  148. if cooldowns[name] > 0 then
  149. cooldowns[name] = cooldowns[name] - 1
  150. end
  151. end
  152. end
  153.  
  154. function check_alive()
  155. all_dead = true
  156. for name,player in pairs(tfm.get.room.playerList) do
  157. if (name ~= ice_mouse) and not (tfm.get.room.playerList[name].isDead) then
  158. all_dead = false
  159. end
  160. end
  161. if all_dead then
  162. tfm.exec.setPlayerScore(ice_mouse, 1, true)
  163. output_msg(OUTPUT_NAME_COLOR .. ice_mouse .. OUTPUT_MESSAGE_COLOR .. ' has frozen all of the mice!')
  164. output_msg(OUTPUT_NAME_COLOR .. ice_mouse .. OUTPUT_MESSAGE_COLOR .. ' wins!')
  165. output_msg(OUTPUT_MESSAGE_COLOR .. 'The next game will start in 5 seconds')
  166. set_new_game_countdown(5)
  167. end
  168. end
  169.  
  170. function eventPlayerDied(name)
  171. if name == ice_mouse then
  172. for namme,player in pairs(tfm.get.room.playerList) do
  173. if namme ~= ice_mouse and not tfm.get.room.playerList[namme].isDead then
  174. tfm.exec.setPlayerScore(namme, 1, true)
  175. end
  176. end
  177. output_msg(OUTPUT_MESSAGE_COLOR .. 'The Ice Mouse ' .. OUTPUT_NAME_COLOR .. ice_mouse .. OUTPUT_MESSAGE_COLOR .. ' has died!')
  178. output_msg(OUTPUT_MESSAGE_COLOR .. 'The next game will start in 5 seconds')
  179. set_new_game_countdown(5)
  180. else
  181. output_msg(OUTPUT_NAME_COLOR .. name .. OUTPUT_MESSAGE_COLOR .. ' has been frozen!')
  182. ice_blocks[tfm.exec.addShamanObject(54, tfm.get.room.playerList[name].x, tfm.get.room.playerList[name].y, 0, 0, 0, false)] = name
  183. check_alive()
  184. end
  185. end
  186.  
  187. --[[-- Somewhat useful; enable if you want
  188. function eventChatCommand(name, cmd)
  189. if cmd == 'newgame' then
  190. start_new_game()
  191. elseif cmd == 'gg' then
  192. tfm.exec.killPlayer(ice_mouse)
  193. elseif cmd == 'ff' then
  194. tfm.exec.killPlayer(name)
  195. end
  196. end
  197. --]]--
  198. function search_and_kill()
  199. for name,player in pairs(tfm.get.room.playerList) do
  200. if (name ~= ice_mouse) and (not tfm.get.room.playerList[name].isDead) and (math.abs(tfm.get.room.playerList[name].x - tfm.get.room.playerList[ice_mouse].x) <= KILL_RADIUS) and (math.abs(tfm.get.room.playerList[name].y - tfm.get.room.playerList[ice_mouse].y) <= KILL_RADIUS) then
  201. tfm.exec.killPlayer(name)
  202. player_life[name] = player_life[name] - 1
  203. return
  204. end
  205. end
  206. end
  207.  
  208. function search_and_rescue(rescuee)
  209. for id in pairs(ice_blocks) do
  210. if (math.abs(tfm.get.room.objectList[id].x - tfm.get.room.playerList[rescuee].x) <= RESCUE_RADIUS) and (math.abs(tfm.get.room.objectList[id].y - tfm.get.room.playerList[rescuee].y) <= RESCUE_RADIUS and player_life[name] >= 1) then
  211. output_msg(OUTPUT_NAME_COLOR .. ice_blocks[id] .. OUTPUT_MESSAGE_COLOR .. ' has been thawed by ' .. OUTPUT_NAME_COLOR .. rescuee)
  212. tfm.exec.respawnPlayer(ice_blocks[id])
  213. tfm.exec.movePlayer(ice_blocks[id], tfm.get.room.objectList[id].x, tfm.get.room.objectList[id].y, false, 0, 0, false)
  214. tfm.exec.removeObject(id)
  215. ice_blocks[id] = nil
  216. return
  217. end
  218. end
  219.  
  220. end
  221.  
  222. function eventKeyboard(name, key, down, x, y)
  223. if not tfm.get.room.playerList[name].isDead and can_attack and key == 32 and cooldowns[name] == 0 and player_life[name] == 1 then
  224. if name == ice_mouse then
  225. search_and_kill()
  226. else
  227.  
  228. search_and_rescue(name)
  229. end
  230.  
  231. cooldowns[name] = COOLDOWN * 2
  232. end
  233. end
  234.  
  235. function eventNewPlayer(name)
  236. mk_for_reset = true
  237. end
  238.  
  239. start_new_game()
  240. ui.setMapName("<v>Pega gelo<n>")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement