Advertisement
zigwin

#miceindaylight

Jul 14th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 25.91 KB | None | 0 0
  1. xml = [[]]
  2.  
  3. tfm.exec.disableAutoTimeLeft(true)
  4. tfm.exec.disableAutoNewGame(true)
  5. tfm.exec.disableAutoScore(true)
  6. tfm.exec.disableAfkDeath(true)
  7. tfm.exec.disableAutoShaman(true)
  8. tfm.exec.disableMortCommand(true)
  9. tfm.exec.disableMinimalistMode(true)
  10. tfm.exec.newGame('7446134')
  11.  
  12. admin = "Zigwin#0000"
  13. playerData = {}
  14. map = 1
  15. killer = ""
  16. killerStartPos = {}
  17. exitPos = {}
  18. gameStarted = false
  19.  
  20. function eventChatCommand(playerName, message)
  21.     if playerName == admin then
  22.         if message:sub(1,9) == 'selectMap' then
  23.             map = message:sub(11)
  24.         end
  25.         if message == 'startGame' and not gameStarted then
  26.             do
  27.                 local players = 0
  28.                 for _ in next, tfm.get.room.playerList do
  29.                     players = players + 1
  30.                 end
  31.                 if players <= 1 then
  32.                     print("<r>Need at least 2 players to start!</r>")
  33.                     return
  34.                 end
  35.             end
  36.  
  37.             -- Загрузить данные о карте (генераторы, хмл и т.д.)
  38.             setMapData(map)
  39.             local playerList = {} -- Список имен игроков
  40.  
  41.             for name, data in next,playerData do
  42.                 data.isAlive = true -- Сделать всех живими
  43.                 table.insert(playerList, name)
  44.             end
  45.  
  46.             tfm.exec.newGame(xml)
  47.  
  48.             -- Убийца    
  49.             killer = playerList[math.random(1,#playerList)]
  50.             playerData[killer].respawnCooldown = 60
  51.             tfm.exec.setNameColor(killer, 0xff0000)
  52.             tfm.exec.killPlayer(killer)
  53.  
  54.             gameStarted = true
  55.             map = nil
  56.         end
  57.         if message == 'endGame' and gameStarted then
  58.             gameStarted = false
  59.             map = 1
  60.             playerData[killer].respawnCooldown = 0
  61.             killer = ""
  62.             killerStartPos = {}
  63.             exitPos = {}
  64.             generatorsInfo = {}
  65.             hooksList = {}
  66.             xml = [[]]     
  67.  
  68.             for name, data in next,playerData do
  69.                 data.isAlive = false -- Сделать всех живими
  70.                 ui.removeTextArea(0, name)
  71.                 ui.removeTextArea(1, name)
  72.                 ui.removeTextArea(2, name)
  73.                 ui.removeTextArea(3, name)
  74.                 ui.removeTextArea(5, name)
  75.             end        
  76.  
  77.             tfm.exec.newGame('7446134')
  78.         end
  79.     end
  80. end
  81.  
  82. function eventNewPlayer(playerName)
  83.     tfm.exec.bindKeyboard(playerName, 32, true, true)
  84.     tfm.exec.bindKeyboard(playerName, 32, false, true)
  85.  
  86.     system.bindKeyboard(playerName, 65, true, true)
  87.     system.bindKeyboard(playerName, 68, true, true)
  88.     system.bindKeyboard(playerName, 37, true, true)
  89.     system.bindKeyboard(playerName, 39, true, true)
  90.  
  91.     playerData[playerName]={
  92.         isAlive = false,
  93.         isOnHook = false, -- Висит ли на крюке
  94.  
  95.         isFacingRight = true,
  96.  
  97.         swapTimer = false, -- я уже сам не знаю что это
  98.         item = "",
  99.        
  100.         isHoldingSpace=false,
  101.         activity="",
  102.  
  103.         generatorId=0,
  104.         hookId = 0,
  105.         isWon = false
  106.     }
  107. end
  108.  
  109. for name, data in next, tfm.get.room.playerList do
  110.     eventNewPlayer(name)
  111.     tfm.exec.setPlayerScore(name, 0)
  112. end
  113.  
  114. local generatorsInfo = {}
  115. local hooksList = {}
  116.  
  117. function setMapData(mapId)
  118.     local mapsData =
  119.     {
  120.         {-- 1 Map
  121.             generatorsInfo = {
  122.                 {x1=425,x2=475,y1=85,y2=125,progress=0,isRepaired=false,},
  123.                 {x1=935,x2=985,y1=25,y2=65,progress=0,isRepaired=false,},
  124.                 {x1=1425,x2=1475,y1=85,y2=125,progress=0,isRepaired=false,},
  125.                 {x1=1515,x2=1565,y1=250,y2=290,progress=0,isRepaired=false,},
  126.             },
  127.             hooksList = {
  128.                 {x1 = 530,x2 = 570,y1 = 315,y2 = 355,item = "",isBroken = false,timer = 60,breakProgress = 0,},
  129.                 {x1 = 830,x2 = 870,y1 = 315,y2 = 355,item = "",isBroken = false,timer = 60,breakProgress = 0,},
  130.                 {x1 = 1855,x2 = 1895,y1 = 315,y2 = 355,item = "",isImmortal = true,timer = 60,breakProgress = 0,},
  131.                 {x1 = 1925,x2 = 1965,y1 = 315,y2 = 355,item = "",isImmortal = true,timer = 60,breakProgress = 0,},
  132.             },
  133.             xml = [[<C><P Ca="" L="2400" /><Z><S><S P="0,0,0.3,0,0,0,0,0" L="80" X="1310" c="4" Y="270" T="10" H="60" /><S X="1272" L="241" H="80" c="4" Y="248" T="10" P="0,0,0.3,0,-45,0,0,0" /><S P="0,0,0.3,0,-180,0,0,0" L="300" X="1865" c="4" Y="260" T="10" H="200" /><S H="350" L="210" o="6a7495" X="895" c="4" Y="175" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0.3,0,-180,0,0,0" L="280" X="1172" c="4" Y="364" T="10" H="90" /><S H="60" L="70" X="1595" c="3" Y="346" T="10" P="0,0,0.3,0,45,0,0,0" /><S L="50" X="425" H="50" Y="-25" T="14" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0.3,0,-45,0,0,0" L="140" H="80" c="3" Y="380" T="10" X="1310" /><S X="1795" L="410" H="50" c="4" Y="375" T="5" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0,0,0,0,0,0" L="400" o="0" X="2200" c="3" N="" Y="200" T="12" H="400" /><S X="1795" L="410" H="10" c="3" Y="355" T="14" P="0,0,0.3,0.2,0,0,0,0" /><S L="10" H="50" X="455" Y="-25" T="14" P="0,0,0.3,0.2,0,0,0,0" /><S L="100" H="100" X="650" Y="371" T="6" P="0,0,0.3,0.2,-45,0,0,0" /><S L="50" X="475" H="10" Y="-45" T="14" P="0,0,0.3,0.2,0,0,0,0" /><S L="10" X="495" H="50" Y="-25" T="14" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0.3,0,-45,0,0,0" L="70" H="40" c="3" Y="338" T="10" X="990" /><S X="1010" L="20" H="100" c="3" Y="350" T="10" P="0,0,0.3,0,0,0,0,0" /><S L="100" X="750" H="100" Y="371" T="6" P="0,0,0.3,0.2,45,0,0,0" /><S L="50" H="10" X="475" Y="-5" T="14" P="0,0,0.3,0.2,0,0,0,0" /><S X="695" L="610" H="50" c="4" Y="375" T="6" P="0,0,0.3,0.2,0,0,0,0" /><S H="400" L="400" o="0" X="200" c="3" N="" Y="200" T="12" P="0,0,0,0,0,0,0,0" /><S H="20" L="590" X="1295" c="4" N="" Y="310" T="10" P="0,0,0.3,0,0,0,0,0" /><S X="1575" L="25" H="140" c="2" Y="72" T="1" P="0,0,0,0.2,180,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="260" X="1130" c="3" Y="310" T="14" H="20" /><S H="20" L="260" X="1460" c="3" Y="310" T="14" P="0,0,0.3,0.2,0,0,0,0" /><S X="1460" L="260" H="90" c="4" Y="365" T="10" P="0,0,0.3,0,-180,0,0,0" /><S H="60" L="10" X="1020" c="3" Y="106" T="1" P="0,0,0,0.2,0,0,0,0" /><S P="0,0,0,0.2,180,0,0,0" L="25" H="140" c="2" Y="75" T="1" X="1014" /><S P="0,0,0.3,0.2,0,0,0,0" L="310" X="1175" c="1" Y="390" T="5" H="20" /><S H="60" L="20" X="1030" c="1" Y="350" T="5" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0.3,0,0,0,0,0" L="20" X="1340" c="3" Y="195" T="10" H="120" /><S H="180" L="20" X="1010" c="3" Y="165" T="10" P="0,0,0.3,0,0,0,0,0" /><S H="120" L="20" X="1580" c="3" Y="195" T="10" P="0,0,0.3,0,0,0,0,0" /><S P="0,0,0.3,0,0,0,0,0" L="550" H="50" c="2" N="" Y="160" T="10" X="1295" /><S P="0,0,0.3,0,0,0,0,0" L="590" H="20" c="1" Y="10" T="10" X="1295" /><S H="10" L="1600" X="1175" c="3" Y="-5" T="14" P="0,0,0.3,0.2,0,0,0,0" /><S X="1775" L="120" H="44" c="1" Y="258" T="5" P="0,0,0,0,0,0,0,0" /><S P="0,0,0,0,20,0,0,0" L="120" H="250" c="1" Y="139" T="5" X="1815" /><S H="200" L="200" X="1900" c="1" Y="100" T="5" P="0,0,0,0,0,0,0,0" /><S P="0,0,0.3,0.2,20,0,0,0" L="30" o="6a7495" X="1714" c="4" Y="197" T="12" H="100" /><S H="10" L="170" X="1273" c="3" Y="200" T="14" P="0,0,1,0.2,-45,0,0,0" /><S P="0,0,0.3,0.2,-0,0,0,0" L="220" H="10" c="3" Y="140" T="14" X="1130" /><S X="1450" L="240" H="10" c="3" Y="140" T="14" P="0,0,0.3,0.2,-0,0,0,0" /><S P="0,0,0.3,0.2,-0,0,0,0" L="240" X="1450" c="3" Y="180" T="14" H="10" /><S H="10" L="50" X="1374" c="3" Y="230" T="14" P="0,0,0.3,0.2,-0,0,0,0" /><S L="100" X="700" H="100" Y="350" T="6" P="0,0,0.3,0.2,0,0,0,0" /><S L="60" H="10" X="700" Y="200" T="14" P="0,0,0.3,0.2,0,0,0,0" /><S L="10" X="730" H="70" Y="170" T="14" P="0,0,0.3,0.2,0,0,0,0" /><S L="10" H="70" X="675" Y="170" T="14" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0.3,0.2,-15,0,0,0" L="200" H="40" c="4" Y="191" T="5" X="457" /><S H="50" L="170" X="475" c="3" Y="160" T="6" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0.3,0,0,0,0,0" L="70" X="965" c="3" Y="95" T="10" H="40" /><S L="20" X="746" H="10" Y="140" T="14" P="0,0,0.3,0.2,0,0,0,0" /><S L="20" H="10" X="660" Y="140" T="14" P="0,0,0.3,0.2,0,0,0,0" /><S L="10" X="530" H="50" Y="375" T="14" P="0,0,0.3,0.2,0,0,0,0" /><S L="10" H="50" X="570" Y="375" T="14" P="0,0,0.3,0.2,0,0,0,0" /><S L="610" X="695" H="10" Y="355" T="14" P="0,0,0.3,0.2,0,0,0,0" /><S L="50" H="10" X="550" Y="395" T="14" P="0,0,0.3,0.2,0,0,0,0" /><S L="10" X="870" H="50" Y="375" T="14" P="0,0,0.3,0.2,0,0,0,0" /><S L="10" H="50" X="830" Y="375" T="14" P="0,0,0.3,0.2,0,0,0,0" /><S L="50" X="850" H="10" Y="395" T="14" P="0,0,0.3,0.2,0,0,0,0" /><S L="10" H="50" X="1855" Y="375" T="14" P="0,0,0.3,0.2,0,0,0,0" /><S L="10" X="1895" H="50" Y="375" T="14" P="0,0,0.3,0.2,0,0,0,0" /><S L="10" X="1965" H="50" Y="375" T="14" P="0,0,0.3,0.2,0,0,0,0" /><S L="10" X="1925" H="50" Y="375" T="14" P="0,0,0.3,0.2,0,0,0,0" /><S L="50" H="10" X="1875" Y="395" T="14" P="0,0,0.3,0.2,0,0,0,0" /><S L="50" X="1945" H="10" Y="396" T="14" P="0,0,0.3,0.2,0,0,0,0" /><S H="10" L="50" o="948616" X="450" c="4" Y="90" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S H="10" L="10" o="1f1f1f" X="430" c="4" Y="130" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="12" o="1f1f1f" X="470" Y="123" T="13" c="4" H="10" /><S P="0,0,0.3,0.2,0,0,0,0" L="50" o="1f1f1f" X="450" c="4" Y="110" T="12" H="30" /><S L="10" o="948616" X="470" H="10" Y="123" T="13" c="4" P="0,0,0.3,0.2,0,0,0,0" /><S H="10" L="50" o="948616" X="1450" c="4" Y="90" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="50" o="1f1f1f" X="1450" c="4" Y="110" T="12" H="30" /><S P="0,0,0.3,0.2,0,0,0,0" L="12" o="1f1f1f" H="10" Y="123" T="13" c="4" X="1470" /><S H="10" L="10" o="1f1f1f" X="1430" c="4" Y="130" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S L="10" o="948616" H="10" X="1470" Y="123" T="13" c="4" P="0,0,0.3,0.2,0,0,0,0" /><S H="30" L="50" o="1f1f1f" X="1540" c="4" Y="275" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="50" o="948616" X="1540" c="4" Y="255" T="12" H="10" /><S P="0,0,0.3,0.2,0,0,0,0" L="10" o="1f1f1f" X="1520" c="4" Y="295" T="12" H="10" /><S L="12" o="1f1f1f" H="10" X="1560" Y="288" T="13" c="4" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="10" o="948616" X="1560" Y="288" T="13" c="4" H="10" /><S P="0,0,0.3,0.2,0,0,0,0" L="12" o="1f1f1f" X="980" Y="63" T="13" c="4" H="10" /><S P="0,0,0.3,0.2,0,0,0,0" L="50" o="1f1f1f" X="960" c="4" Y="50" T="12" H="30" /><S H="10" L="10" o="1f1f1f" X="940" c="4" Y="70" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S L="10" o="948616" X="980" H="10" Y="63" T="13" c="4" P="0,0,0.3,0.2,0,0,0,0" /><S H="10" L="50" o="948616" X="960" c="4" Y="30" T="12" P="0,0,0.3,0.2,0,0,0,0" /></S><D><P X="460" Y="110" T="37" P="0,0" /><P X="435" Y="105" T="126" P="0,1" /><P X="1460" Y="110" T="37" P="0,0" /><P X="1435" Y="108" T="126" P="0,1" /><P P="0,0" Y="275" T="37" X="1550" /><P P="0,1" Y="270" T="126" X="1525" /><P X="970" Y="50" T="37" P="0,0" /><P C="2f2f2f" Y="0" T="34" X="790" P="0,0" /><DS Y="335" X="590" /><P C="545454,0" Y="135" T="117" P="0,0" X="790" /><P C="2f2f2f,1b1d1c,1c1c1c" Y="300" T="129" X="1375" P="0,0" /><P C="545454,1c1c1c,0" Y="235" T="128" X="1374" P="1,0" /><P X="1051" Y="381" T="106" P="1,0" /><P X="1039" Y="320" T="107" P="1,0" /><P X="1099" Y="242" T="112" P="0,0" /><P P="0,0" Y="252" T="121" X="1469" /><P C="545454,1c1c1c,0" Y="300" T="128" P="0,0" X="1474" /><P C="2f2f2f,1b1d1c,1c1c1c" Y="300" T="129" P="0,0" X="1425" /><P P="0,0" Y="201" T="123" X="1433" /><P P="0,0" Y="348" T="118" X="1707" /><P X="1875" Y="350" T="116" P="1,0" /><P P="1,0" Y="350" T="116" X="1945" /><P X="550" Y="350" T="116" P="1,0" /><P P="1,0" Y="350" T="116" X="850" /><P X="700" Y="300" T="1" P="1,0" /></D><O><O C="1" Y="121" X="1183" P="0" /></O></Z></C>]],
  134.             killerStartPos = {1850,330},
  135.             exitPos = {x1 = 400,x2 = 500,y1 = 200,y2 = 400}
  136.         },
  137.     }
  138.  
  139.     generatorsInfo = mapsData[mapId].generatorsInfo
  140.     hooksList = mapsData[mapId].hooksList
  141.     xml = mapsData[mapId].xml
  142.     exitPos = mapsData[mapId].exitPos
  143.     killerStartPos = mapsData[mapId].killerStartPos
  144. end
  145.  
  146. function showProgress(playerName, remove)
  147.     print("Showing Progress...")
  148.     local y = tfm.get.room.playerList[playerName].y
  149.     if not remove then
  150.         if playerData[playerName].activity == "repairGenerator" then
  151.             ui.addTextArea(-10, '',playerName, 360, y - 100, 80, 10, nil, nil, 0.7, true)
  152.             ui.addTextArea(-11, '',playerName, 360, y - 100, generatorsInfo[playerData[playerName].generatorId].progress, 10, nil, nil, 0.7, true)
  153.         elseif playerData[playerName].activity == "breakHook" then
  154.             ui.addTextArea(-10, '',playerName, 360, y - 100, 80, 10, nil, nil, 0.7, true)
  155.             ui.addTextArea(-11, '',playerName, 360, y - 100, hooksList[playerData[playerName].hookId].breakProgress*4, 10, nil, nil, 0.7, true)
  156.         end
  157.     else
  158.         ui.removeTextArea(-10, playerName)
  159.         ui.removeTextArea(-11, playerName)
  160.     end
  161. end
  162.  
  163. function eventPlayerRespawn(playerName)
  164.     -- Если при респавне игрок на крюке то телепорт к крюку
  165.     if playerData[playerName].isOnHook then
  166.         local hook = hooksList[playerData[playerName].hookId]
  167.         tfm.exec.movePlayer(playerName, hook.x1 + 25, hook.y2 + 25)
  168.     end
  169.     print(playerName.." respawned")
  170. end
  171.  
  172. function checkKillersPos(isFacingRight, x1, y1, x2, y2)
  173.     -- 5px вперед - дальность захвата (в ту сторону в которую смотрит игрок)
  174.     if isFacingRight then
  175.         return x1 + 5 > x2 and x1 < x2 and y1 - 20 < y2 and y1 + 20 > y2
  176.     else
  177.         return x1 - 5 < x2 and x1 > x2 and y1 - 20 < y2 and y1 + 20 > y2
  178.     end
  179. end
  180.  
  181. function checkGenerators()
  182.     local a = 0
  183.     for _, data in next,generatorsInfo do
  184.         if data.isRepaired then a = a + 1 end
  185.     end
  186.     print(a)
  187.     return a == #generatorsInfo
  188. end
  189.  
  190. function eventKeyboard(playerName, keyCode, down, xPlayerPosition, yPlayerPosition)
  191.     -- Если жив
  192.     if playerData[playerName].isAlive then
  193.         -- Нажатие Влево
  194.         if keyCode==65 or keyCode==37 then
  195.             playerData[playerName].isFacingRight = false
  196.             playerData[playerName].swapTimer = true
  197.             -- Если у убийцы нет ничего в руках то ускорение
  198.             if playerName == killer and playerData[killer].item == "" then
  199.                 tfm.exec.movePlayer(playerName, 0, 0, nil, -50)
  200.             end
  201.         -- Нажатие Вправо
  202.         elseif keyCode==68 or keyCode==39 then
  203.             playerData[playerName].isFacingRight = true
  204.             playerData[playerName].swapTimer = true
  205.             -- Если у убийцы нет ничего в руках то ускорение
  206.             if playerName == killer and playerData[killer].item == "" then
  207.                 tfm.exec.movePlayer(playerName, 0, 0, nil, 50)
  208.             end
  209.         end
  210.     end
  211.  
  212.     -- Пробел (убийца)
  213.     if keyCode == 32 then
  214.         if playerName == killer then
  215.             if playerData[playerName].item == "" then      
  216.                 -- Ловля игроков
  217.                 local playersCatched = {}
  218.                 local playerTaken = ""
  219.                 if playerData[playerName].isFacingRight then           
  220.                     for name, data in next,tfm.get.room.playerList do
  221.                         if name ~= playerName then
  222.                             if checkKillersPos(true, xPlayerPosition, yPlayerPosition, data.x, data.y) then
  223.                                 table.insert(playersCatched, name)
  224.                             end
  225.                         end
  226.                     end
  227.                 else
  228.                     for name, data in next,tfm.get.room.playerList do
  229.                         if name ~= playerName then
  230.                             if checkKillersPos(false, xPlayerPosition, yPlayerPosition, data.x, data.y) then
  231.                                 table.insert(playersCatched, name)
  232.                             end
  233.                         end
  234.                     end
  235.                 end
  236.        
  237.                 -- Если поймано больше чем 1 то ловится случайный
  238.                 if #playersCatched == 1 then
  239.                     playerTaken = playersCatched[1]
  240.                     playerData[playerName].item = playerTaken
  241.                     tfm.exec.killPlayer(playerTaken)
  242.                 elseif #playersCatched > 1 then
  243.                     playerTaken = playersCatched[math.random(1,#playersCatched)]
  244.                     playerData[playerName].item = playerTaken
  245.                     tfm.exec.killPlayer(playerTaken)
  246.                 end
  247.             else
  248.                 -- Если уже есть предмет (игрок пойман)
  249.                 -- то проверка на вешание на крюк
  250.                 for id, data in next, hooksList do
  251.                     if data.item == "" and not data.isBroken and playerData[killer].item ~= "" then
  252.                         if xPlayerPosition - 50 < data.x1 and xPlayerPosition + 50 > data.x1 and yPlayerPosition > data.y1 and yPlayerPosition < data.y2 then
  253.                             data.item = playerData[killer].item
  254.                             local player = playerData[killer].item
  255.        
  256.                             playerData[player].isOnHook = true
  257.                             playerData[player].hookId = id
  258.                             tfm.exec.respawnPlayer(player)
  259.        
  260.                             playerData[killer].item = ""
  261.                         end
  262.                     end
  263.                 end
  264.             end
  265.         elseif  playerData[playerName].isAlive then
  266.             -- Пробел игрок
  267.             if down then
  268.                 -- При нажатии на пробел и если видна подсказка
  269.                 playerData[playerName].isHoldingSpace = true
  270.                 tfm.exec.playEmote(playerName, 27)
  271.             else
  272.                 -- Когда отпустили пробел
  273.                 playerData[playerName].isHoldingSpace = false
  274.                 showProgress(playerName, true) 
  275.             end
  276.         end
  277.     end
  278. end
  279.  
  280. function eventLoop(currentTime, timeRemaining)
  281. if gameStarted then
  282.     if checkGenerators() then
  283.         for i=1,10 do
  284.             tfm.exec.displayParticle(2, math.random(exitPos.x1, exitPos.x2), math.random(exitPos.y1, exitPos.y2))
  285.         end
  286.     end
  287.     for playerName, data in next, playerData do
  288.         if playerName ~= killer then
  289.             if not data.isWon then
  290.                 if checkGenerators() then
  291.                     if tfm.get.room.playerList[playerName].x > exitPos.x1 and tfm.get.room.playerList[playerName].x < exitPos.x2 and tfm.get.room.playerList[playerName].y > exitPos.y1 and tfm.get.room.playerList[playerName].y < exitPos.y2 then
  292.                         tfm.exec.giveCheese(playerName)
  293.                         tfm.exec.playerVictory(playerName)
  294.                         tfm.exec.setPlayerScore(playerName, 1, true)
  295.                         data.isWon = true
  296.                     end
  297.                 end
  298.             end
  299.         end
  300.         -- Если определено что игрок возле объекта с котором возможно взаимодействие то другие не проверяются
  301.         -- (Не может быть два таких объекта в одном месте)
  302.         local checkDone = false
  303.         -- Генератор
  304.         for genId, genData in next, generatorsInfo do
  305.             -- Проверка координат
  306.             if tfm.get.room.playerList[playerName].x > genData.x1 and tfm.get.room.playerList[playerName].x < genData.x2 and tfm.get.room.playerList[playerName].y > genData.y1 and tfm.get.room.playerList[playerName].y < genData.y2 then
  307.                 -- Если не починен
  308.                 if not genData.isRepaired then
  309.                     data.generatorId = genId
  310.                     data.activity = "repairGenerator"
  311.                     checkDone = true
  312.                 else
  313.                 -- Если починен то появление частиц
  314.                 tfm.exec.displayParticle(0, math.random(genData.x1,genData.x2), math.random(300,350), nil, nil, nil, nil, playerName)
  315.                 end
  316.             end
  317.         end
  318.         -- Крюк
  319.         if not checkDone then
  320.             for hookId, hookData in next, hooksList do
  321.                 if not hookData.isImmortal then
  322.                     if not hookData.isBroken then
  323.                         if tfm.get.room.playerList[playerName].x > hookData.x1 and tfm.get.room.playerList[playerName].x < hookData.x2 and tfm.get.room.playerList[playerName].y > hookData.y1 and tfm.get.room.playerList[playerName].y < hookData.y2 then
  324.                             data.hookId = hookId
  325.                             data.activity = "breakHook"
  326.                         end
  327.                     end
  328.                 end
  329.             end
  330.         end
  331.         -- Игрок совершает действие (Держит пробел)  
  332.         if data.isHoldingSpace then
  333.             if data.activity == "repairGenerator" then
  334.                 -- Генератор не починен
  335.                 if not generatorsInfo[data.generatorId].isRepaired then
  336.                     -- Проверка координт
  337.                     if tfm.get.room.playerList[playerName].x > generatorsInfo[playerData[playerName].generatorId].x1 and tfm.get.room.playerList[playerName].x < generatorsInfo[playerData[playerName].generatorId].x2 and tfm.get.room.playerList[playerName].y > generatorsInfo[playerData[playerName].generatorId].y1 and tfm.get.room.playerList[playerName].y < generatorsInfo[playerData[playerName].generatorId].y2 then
  338.                         -- Увеличение прогресса
  339.                         generatorsInfo[data.generatorId].progress = generatorsInfo[data.generatorId].progress + 4
  340.                         -- Если прогресс достигнут то генератор починен
  341.                         if generatorsInfo[data.generatorId].progress >= 80 then
  342.                             generatorsInfo[data.generatorId].isRepaired = true
  343.                             generatorsInfo[playerData[playerName].generatorId].progress = 80
  344.                             showProgress(playerName, true)
  345.                         end
  346.                         tfm.exec.playEmote(playerName, 27)
  347.  
  348.                         showProgress(playerName)
  349.                     else
  350.                         -- Убрать прогресс
  351.                         showProgress(playerName, true)
  352.                     end
  353.                 end
  354.             elseif data.activity == "breakHook" then
  355.                 if not hooksList[data.hookId].isBroken then
  356.                     if tfm.get.room.playerList[playerName].x > hooksList[data.hookId].x1 and tfm.get.room.playerList[playerName].x < hooksList[data.hookId].x2 and tfm.get.room.playerList[playerName].y > hooksList[data.hookId].y1 and tfm.get.room.playerList[playerName].y < hooksList[data.hookId].y2 then
  357.    
  358.                         hooksList[data.hookId].breakProgress = hooksList[data.hookId].breakProgress + 2
  359.                         if hooksList[data.hookId].breakProgress >= 20 then
  360.                             hooksList[data.hookId].isBroken = true
  361.                             hooksList[playerData[playerName].hookId].breakProgress = 20
  362.  
  363.                             -- Если был повешан игрок то его освобождение
  364.                             if hooksList[data.hookId].item ~= "" then
  365.                                 playerData[hooksList[data.hookId].item].isOnHook = false
  366.                                 tfm.exec.respawnPlayer(hooksList[data.hookId].item)
  367.                                 tfm.exec.movePlayer(hooksList[data.hookId].item, hooksList[data.hookId].x1 + 25, hooksList[data.hookId].y1)
  368.                                 showProgress(playerName, true)
  369.                             end
  370.  
  371.                         end
  372.                         showProgress(playerName)
  373.                     else
  374.                         showProgress(playerName, true)
  375.                     end
  376.                 end
  377.             end
  378.         end
  379.  
  380.         -- Область видимости
  381.         if data.isAlive then
  382.             -- При повороте промежуток времени для изменения области видимости
  383.             if data.swapTimer == true then
  384.                 data.swapTimer = false
  385.    
  386.                 if data.isFacingRight then
  387.                     ui.removeTextArea(0, playerName)
  388.                     ui.removeTextArea(1, playerName)
  389.                     -- Left
  390.                     ui.addTextArea(0, "", playerName, 0, 0, 250, 400, 0x000001, 0x000001, 1, true) 
  391.                     -- Right
  392.                     if data.isOnHook then
  393.                         ui.addTextArea(1, "", playerName, 550, 0, 250, 400, 0x000001, 0x000001, 1, true)
  394.                     else
  395.                         ui.addTextArea(1, "", playerName, 700, 0, 100, 400, 0x000001, 0x000001, 1, true)
  396.                     end
  397.                 else
  398.                     ui.removeTextArea(0, playerName)
  399.                     ui.removeTextArea(1, playerName)
  400.                     -- Right
  401.                     ui.addTextArea(0, "", playerName, 550, 0, 250, 400, 0x000001, 0x000001, 1, true)
  402.                     -- Left
  403.                     if data.isOnHook then
  404.                         ui.addTextArea(1, "", playerName, 0, 0, 250, 400, 0x000001, 0x000001, 1, true)
  405.                     else
  406.                         ui.addTextArea(1, "", playerName, 0, 0, 100, 400, 0x000001, 0x000001, 1, true)
  407.                     end
  408.                 end
  409.  
  410.                 -- Сверху и снизу
  411.                 if tfm.get.room.playerList[playerName].y > 260 then
  412.                     ui.addTextArea(2, "", playerName, 0, tfm.get.room.playerList[playerName].y-350, 800, 200, 0x000001, 0x000001, 1, true)
  413.                     ui.addTextArea(3, "", playerName, 0, tfm.get.room.playerList[playerName].y+20, 800, 200, 0x000001, 0x000001, 1, true)
  414.                 elseif tfm.get.room.playerList[playerName].y < 180 then
  415.                     ui.addTextArea(2, "", playerName, 0, tfm.get.room.playerList[playerName].y-350, 800, 200, 0x000001, 0x000001, 1, true)
  416.                     ui.addTextArea(3, "", playerName, 0, tfm.get.room.playerList[playerName].y+20, 800, 400, 0x000001, 0x000001, 1, true)
  417.                 else
  418.                     -- Посередине
  419.                     ui.removeTextArea(0, playerName)
  420.                     ui.removeTextArea(3, playerName)
  421.                     ui.addTextArea(1, "", playerName, 500, 0, 300, 400, 0x000001, 0x000001, 1, true)
  422.                     ui.addTextArea(2, "", playerName, 0, 0, 300, 400, 0x000001, 0x000001, 1, true)
  423.                 end
  424.             else
  425.                 if playerName == killer and playerData[playerName].respawnCooldown > 0 then
  426.                     ui.addTextArea(5, "", playerName, -5,-5,820,420, 0x000001, 0x000001, 1, true)
  427.                 else
  428.                     ui.removeTextArea(5, playerName)
  429.                 end
  430.                 -- Сверху и снизу
  431.                 if tfm.get.room.playerList[playerName].y > 260 then
  432.                     ui.addTextArea(2, "", playerName, 0, tfm.get.room.playerList[playerName].y-350, 800, 200, 0x000001, 0x000001, 1, true)
  433.                     ui.addTextArea(3, "", playerName, 0, tfm.get.room.playerList[playerName].y+20, 800, 200, 0x000001, 0x000001, 1, true)
  434.                 elseif tfm.get.room.playerList[playerName].y < 180 then
  435.                     ui.addTextArea(2, "", playerName, 0, tfm.get.room.playerList[playerName].y-350, 800, 200, 0x000001, 0x000001, 1, true)
  436.                     ui.addTextArea(3, "", playerName, 0, tfm.get.room.playerList[playerName].y+20, 800, 400, 0x000001, 0x000001, 1, true)
  437.                 else
  438.                     -- Посередине
  439.                     ui.removeTextArea(0, playerName)
  440.                     ui.removeTextArea(3, playerName)
  441.                     ui.addTextArea(1, "", playerName, 500, 0, 300, 400, 0x000001, 0x000001, 1, true)
  442.                     ui.addTextArea(2, "", playerName, 0, 0, 300, 400, 0x000001, 0x000001, 1, true)
  443.                 end
  444.             end
  445.         else
  446.             ui.removeTextArea(0, playerName)
  447.             ui.removeTextArea(1, playerName)
  448.             ui.removeTextArea(2, playerName)
  449.             ui.removeTextArea(3, playerName)
  450.         end
  451.         -- Пойманный игрок
  452.         if playerName == killer then
  453.             if playerData[killer].respawnCooldown > 0 then
  454.                 playerData[killer].respawnCooldown = playerData[killer].respawnCooldown - 1
  455.                 if playerData[killer].respawnCooldown == 0 then
  456.                     tfm.exec.respawnPlayer(playerName)
  457.                     tfm.exec.movePlayer(playerName, killerStartPos[1], killerStartPos[2])
  458.                     tfm.exec.setNameColor(playerName, 0xff0000)
  459.                     killerStartPos = nil
  460.                 end
  461.             end
  462.             ui.addTextArea(-1000, "<p align='center'><font color='#dd0000'>"..data.item, nil, tfm.get.room.playerList[killer].x-100, tfm.get.room.playerList[killer].y-50, 200, 0, nil, nil, 0)
  463.         end
  464.  
  465.         -- Если на крюке
  466.         if data.isOnHook then
  467.             hooksList[data.hookId].timer = hooksList[data.hookId].timer - 1
  468.  
  469.             if hooksList[data.hookId].timer == 0 then
  470.                 data.isOnHook = false
  471.                 hooksList[data.hookId].isBroken = true
  472.                 tfm.exec.killPlayer(playerName)
  473.                 playerData[playerName].isAlive = false
  474.  
  475.                 local deadPlayers = 0
  476.                 for name, data in next, playerData do
  477.                     if name ~= killer then
  478.                         if not data.isAlive then
  479.                             deadPlayers = deadPlayers + 1
  480.                         end
  481.                     end
  482.                 end
  483.                 if deadPlayers >= math.ceil(#playerData/2) then
  484.                     tfm.exec.giveCheese(killer)
  485.                     tfm.exec.playerVictory(killer)
  486.                 end
  487.             elseif hooksList[data.hookId].timer == 10 then
  488.                 tfm.exec.setNameColor(playerName, 0xAC0300)
  489.             elseif hooksList[data.hookId].timer == 20 then
  490.                 tfm.exec.setNameColor(playerName, 0xCC7E1A)
  491.             end
  492.         end
  493.     end
  494. end
  495. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement