Mousetat

Ice Tag

Oct 14th, 2016
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.45 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 = {'@3372137', '@3193260', '@3854747', '@3850296', '@758179', '@3858131', '@3852671', '@3792682', '@3554921', '@953564', '@3360929', '@3441279', '@1032158', '@1106226', '@3301175', '@1517940'}
  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 = 3
  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.  
  48. function output_msg(msg)
  49. if OUTPUT_MODE == 0 then
  50.  
  51. elseif OUTPUT_MODE == 1 then
  52. tfm.exec.chatMessage(msg)
  53. elseif OUTPUT_MODE == 2 then
  54. ttt = ttt .. '\n' .. msg
  55. ui.updateTextArea(0, ttt)
  56. time_to_clear_ttt = 3
  57. end
  58. end
  59.  
  60. function countdown_msg(msg)
  61. ctt = ctt .. ' ' .. msg
  62. ui.updateTextArea(1, ctt)
  63. time_to_clear_ctt = 3
  64. end
  65.  
  66. for name,player in pairs(tfm.get.room.playerList) do
  67. print(name)
  68. table.insert(all_players, name)
  69. tfm.exec.setPlayerScore(name, 0, false)
  70. end
  71.  
  72. function start_new_game()
  73. all_players = {}
  74. ice_blocks = {}
  75. can_attack = false
  76. tfm.exec.newGame(MAPS[math.random(#MAPS)])
  77.  
  78. for name,player in pairs(tfm.get.room.playerList) do
  79. tfm.exec.bindKeyboard(name, 32, true, true)
  80. table.insert(all_players, name)
  81. cooldowns[name] = 0
  82. tfm.exec.setNameColor(name, 0xB5B5B5)
  83. end
  84.  
  85. ice_mouse = all_players[math.random(#all_players)]
  86. tfm.exec.setNameColor(ice_mouse, 0x009DFF)
  87.  
  88. output_msg(OUTPUT_NAME_COLOR .. ice_mouse .. OUTPUT_MESSAGE_COLOR .. ' is the Ice Mouse!')
  89. output_msg(OUTPUT_MESSAGE_COLOR .. 'The game will start in 10 seconds!')
  90. countdown = 10
  91. end
  92.  
  93. function set_new_game_countdown(num)
  94. countdown = 20 + num
  95. end
  96.  
  97. function eventLoop(current_time, time_remaining)
  98. second_mark = not second_mark
  99. if second_mark then
  100. if countdown > 0 and countdown < 20 then
  101. countdown_msg(OUTPUT_MESSAGE_COLOR .. countdown)
  102. countdown = countdown - 1
  103. elseif countdown == 0 then
  104. countdown_msg(OUTPUT_MESSAGE_COLOR .. 'Go!')
  105. countdown = -1
  106. can_attack = true
  107. elseif countdown == 20 then
  108. output_msg(OUTPUT_MESSAGE_COLOR .. 'Starting next game!')
  109. start_new_game()
  110. elseif countdown > 20 then
  111. countdown = countdown - 1
  112. end
  113. if time_to_clear_ttt == 0 and OUTPUT_MODE == 2 then
  114. if mk_for_reset then
  115. ui.removeTextArea(0)
  116. ui.addTextArea(0, '', nil, 5, 5)
  117. else
  118. ttt = ''
  119. ui.updateTextArea(0, ttt)
  120. end
  121. end
  122. if time_to_clear_ctt == 0 and OUTPUT_MODE == 2 then
  123. if mk_for_reset then
  124. ui.removeTextArea(1)
  125. ui.addTextArea(1, '', nil, 5, 375)
  126. mk_for_reset = false
  127. else
  128. ctt = ''
  129. ui.updateTextArea(1, ctt)
  130. end
  131. end
  132. time_to_clear_ttt = time_to_clear_ttt - 1
  133. time_to_clear_ctt = time_to_clear_ctt - 1
  134. end
  135. if time_remaining <= 1 then
  136. for name,player in pairs(tfm.get.room.playerList) do
  137. if (name ~= ice_mouse) and not (tfm.get.room.playerList[name].isDead) then
  138. all_dead = false
  139. end
  140. end
  141. 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!')
  142. output_msg(OUTPUT_MESSAGE_COLOR .. 'New game starting now!')
  143. start_new_game()
  144. end
  145. for num,name in pairs(all_players) do
  146. if cooldowns[name] > 0 then
  147. cooldowns[name] = cooldowns[name] - 1
  148. end
  149. end
  150. end
  151.  
  152. function check_alive()
  153. all_dead = true
  154. for name,player in pairs(tfm.get.room.playerList) do
  155. if (name ~= ice_mouse) and not (tfm.get.room.playerList[name].isDead) then
  156. all_dead = false
  157. end
  158. end
  159. if all_dead then
  160. tfm.exec.setPlayerScore(ice_mouse, 1, true)
  161. output_msg(OUTPUT_NAME_COLOR .. ice_mouse .. OUTPUT_MESSAGE_COLOR .. ' has frozen all of the mice!')
  162. output_msg(OUTPUT_NAME_COLOR .. ice_mouse .. OUTPUT_MESSAGE_COLOR .. ' wins!')
  163. output_msg(OUTPUT_MESSAGE_COLOR .. 'The next game will start in 5 seconds')
  164. set_new_game_countdown(5)
  165. end
  166. end
  167.  
  168. function eventPlayerDied(name)
  169. if name == ice_mouse then
  170. for namme,player in pairs(tfm.get.room.playerList) do
  171. if namme ~= ice_mouse and not tfm.get.room.playerList[namme].isDead then
  172. tfm.exec.setPlayerScore(namme, 1, true)
  173. end
  174. end
  175. output_msg(OUTPUT_MESSAGE_COLOR .. 'The Ice Mouse ' .. OUTPUT_NAME_COLOR .. ice_mouse .. OUTPUT_MESSAGE_COLOR .. ' has died!')
  176. output_msg(OUTPUT_MESSAGE_COLOR .. 'The next game will start in 5 seconds')
  177. set_new_game_countdown(5)
  178. else
  179. output_msg(OUTPUT_NAME_COLOR .. name .. OUTPUT_MESSAGE_COLOR .. ' has been frozen!')
  180. ice_blocks[tfm.exec.addShamanObject(54, tfm.get.room.playerList[name].x, tfm.get.room.playerList[name].y, 0, 0, 0, false)] = name
  181. check_alive()
  182. end
  183. end
  184.  
  185. --[[-- Somewhat useful; enable if you want
  186. function eventChatCommand(name, cmd)
  187. if cmd == 'newgame' then
  188. start_new_game()
  189. elseif cmd == 'gg' then
  190. tfm.exec.killPlayer(ice_mouse)
  191. elseif cmd == 'ff' then
  192. tfm.exec.killPlayer(name)
  193. end
  194. end
  195. --]]--
  196. function search_and_kill()
  197. for name,player in pairs(tfm.get.room.playerList) do
  198. 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
  199. tfm.exec.killPlayer(name)
  200. return
  201. end
  202. end
  203. end
  204.  
  205. function search_and_rescue(rescuee)
  206. for id in pairs(ice_blocks) do
  207. 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) then
  208. output_msg(OUTPUT_NAME_COLOR .. ice_blocks[id] .. OUTPUT_MESSAGE_COLOR .. ' has been thawed by ' .. OUTPUT_NAME_COLOR .. rescuee)
  209. tfm.exec.respawnPlayer(ice_blocks[id])
  210. tfm.exec.movePlayer(ice_blocks[id], tfm.get.room.objectList[id].x, tfm.get.room.objectList[id].y, false, 0, 0, false)
  211. tfm.exec.removeObject(id)
  212. ice_blocks[id] = nil
  213. return
  214. end
  215. end
  216.  
  217. end
  218.  
  219. function eventKeyboard(name, key, down, x, y)
  220. if not tfm.get.room.playerList[name].isDead and can_attack and key == 32 and cooldowns[name] == 0 then
  221. if name == ice_mouse then
  222. search_and_kill()
  223. else
  224. search_and_rescue(name)
  225. end
  226. cooldowns[name] = COOLDOWN * 2
  227. end
  228. end
  229.  
  230. function eventNewPlayer(name)
  231. print(name)
  232. mk_for_reset = true
  233. end
  234.  
  235. start_new_game()
Advertisement
Add Comment
Please, Sign In to add comment