Advertisement
zigwin

#heavyrain 1.2

Jun 1st, 2019
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 32.82 KB | None | 0 0
  1. --[[
  2. transformice lua by zigwin
  3. #heavyrain
  4. v1.2
  5. --]]
  6.  
  7.  
  8. do
  9.     local _,name = pcall(nil)
  10.     admin = string.match(name, "(.-)%.")
  11. end
  12.  
  13. local playerData = {}
  14.  
  15. --[[ Новый игрок--]]
  16.  
  17. function eventNewPlayer(playerName)
  18.     system.bindKeyboard(playerName, 0, true, true)  -- Left
  19.     system.bindKeyboard(playerName, 2, true, true)  -- Right
  20.     system.bindKeyboard(playerName, 3, true, true)  -- Down
  21.     system.bindKeyboard(playerName, 32, true, true) -- Space
  22.     system.bindKeyboard(playerName, 69, true, true) -- E
  23.     system.bindKeyboard(playerName, 72, true, true) -- H
  24.     system.bindMouse(playerName, true)
  25.  
  26.     playerData[playerName] = {
  27.         cannons = 0,
  28.         hasTeleported = false,
  29.         hasCheese = false,
  30.         isHelpVisible = false,
  31.         power = 0,
  32.         nextPower = 0,
  33.         powerUsable = true,
  34.         facingRight = true,
  35.         powerList = {true,true,true,true,true,true},
  36.         powersShopPage = 1,
  37.         coin = 0,
  38.     }
  39. end
  40.  
  41. table.foreach(tfm.get.room.playerList, eventNewPlayer)
  42.  
  43. --[[ Переводы--]]
  44.  
  45. -- 0 - Nothing
  46. -- 1 - Free jump   - Every round ; Usable
  47. -- 2 - Boost        - Every 20 seconds ; Usable
  48. -- 3 - Free cheese - Every round
  49. -- 4 - Free cannon - Every even round
  50. -- 5 - Explode     - Every round ; Usable
  51.  
  52. local text = {
  53.     ru = {
  54.         round = 'Раунд',
  55.         winner = 'победитель',
  56.         help1 = '<u><b>Управление</b>______________________________</u>\n\n● <b>↓</b> or <b>E</b> or <b>Space</b> - Подобрать бонус\n● <b>H</b> - Помощь\n● <b>Mouse Left Button</b> - Использовать предмет\n\n<u><b>Бонусы</b>__________________________________ </u>\n\n● <b><j>Звезда</j></b> - Ядро\n● <b><v>+1</v></b> - +1 К счету\n● <b><j>Сыр</j></b> - Телепорт - Только раз за раунд\n\n<u><b>События</b>__________________________________</u>\n\n● <b><r>Авиаудар</r></b> - Появляется линия ядер с местом для укрытия ● \n● <b><r>Наковальни</r></b> - Появляется много наковален\n● <b><r>Бонусная лихорадка</r></b> - Частота появления бонусов увеличивается в 10 раз\n● <b><r>Удвоенная скорость</r></b> - 4 Ядра появляются каждую секунду',
  57.         help2 = "<u><b>Силы</b>_____________________________</u>\n<i><g>Используемый - нажми <b>↓</b> чтобы использовать.</g></i>\n\n<b><bv><u>Прыжок</u></bv></b>\n▫ Каждый раунд\n▫ Используемый\n\n<b><bv><u>Ускорение</u></bv></b>\n▫ Каждый раунд и каждые 10 сек\n▫ Используемый\n\n<b><bv><u>Сыр</u></bv></b>\n▫ Каждый раунд\n\n<b><bv><u>Ядро</u></bv></b>\n▫ Каждый четный раунд\n\n<b><bv><u>Взоваться</u></bv></b>\n▫ Каждый раунд\n▫ Используемый",
  58.         event = {
  59.             "Авиаудар",
  60.             "Наковальни",
  61.             "Удвоенная скорость",
  62.             "Бонусная лихорадка",
  63.         },
  64.         powers = {
  65.             "Прыжок",
  66.             "Ускорение",
  67.             "Сыр",
  68.             "Ядро",
  69.             "Взоваться"
  70.         },
  71.         buy = "Купить",
  72.         equip = "Экипировать",
  73.         equipped = "Экипированно",
  74.         willbeeqippedinnextround = "Будет экипированно в следующем раунде",
  75.         close = "Закрыть",
  76.         coins = "Монеты"
  77.     },
  78.     en = {
  79.         round = 'Round',
  80.         winner = 'winner',
  81.         help1 = '<u><b>Controls</b>__________________________________</u>\n\n● <b>↓</b> or <b>E</b> or <b>Space</b> - Take bonus\n● <b>H</b> - Help message\n● <b>Mouse Left Button</b> - Use item\n\n<u><b>Bonuses</b>__________________________________ </u>\n\n● <b><j>Star</j></b> - Cannon\n● <b><v>+1</v></b> - +1 To score\n● <b><j>Cheese</j></b> - Teleport - Only one in round\n\n<u><b>Events</b>___________________________________</u>\n\n● <b><r>Airstrike</r></b> - A line of cannons spawn with ● place to hide\n● <b><r>Anvils</r></b> - Alot anvils spawn\n● <b><r>Bonus Madness</r></b> - Bonus spawn rate multiplies by 10\n● <b><r>Double Speed</r></b> - 4 Cannons spawn each second',
  82.         help2 = "<u><b>Powers</b>_____________________________</u>\n<i><g>Usable - press <b>↓</b> to use.</g></i>\n\n<b><bv><u>Free jump</u></bv></b>\n▫ Every round\n▫ Usable\n\n<b><bv><u>Boost</u></bv></b>\n▫ Every 20 seconds\n▫ Usable\n\n<b><bv><u>Free cheese</u></bv></b>\n▫ Every round\n\n<b><bv><u>Free cannon</u></bv></b>\n▫ Every even round\n\n<b><bv><u>Explode</u></bv></b>\n▫ Every round\n▫ Usable",
  83.         event = {
  84.             "Airstrike",
  85.             "Anvils",
  86.             "Double Speed",
  87.             "Bonus Madness",
  88.         },
  89.         powers = {
  90.             "Jump",
  91.             "Boost",
  92.             "Cheese",
  93.             "Cannon",
  94.             "Explode"
  95.         },
  96.         buy = "Buy",
  97.         equip = "Equip",
  98.         equipped = "Equipped",
  99.         willbeeqippedinnextround = "Will be eqipped in next round",
  100.         close = "Close",
  101.         coins = "Coins"
  102.     },
  103.     tr = {
  104.         round = 'Tur',
  105.         winner = 'kazanan',
  106.         help1 = '<u><b>Kontroller</b>_________________________________</u>\n\n● <b>↓</b> ya da <b>E</b> ya da <b>Space</b> - Bonusu almak için\n● <b>H</b> - Yardım mesajı\n● <b>Sol tık</b> - Eşya kullanmak için\n\n<u><b>Bonuslar</b>__________________________________ </u>\n\n● <b><j>Yıldız</j></b> - top\n● <b><v>+1</v></b> - skora +1 puan ekler\n● <b><j>Peynir</j></b> - Işınlanmak - Her tur da sadece 1 kere\n\n<u><b>Etkinlikler</b>________________________________</u>\n\n● <b><r>Airstrike</r></b> - 1 sırada tüm toplar ● Gizlemek için\n● <b><r>Örsler</r></b> - Birsürü örs yaratır\n● <b><r>Bonus delilik</r></b> - Bonus yaratma oranı 10 ile çarpıyor\n● <b><r>2 kat hız</r></b> - Her saniye 4 top yaratır',
  107.         help2 = "<u><b>Powers</b>_____________________________</u>\n<i><g>Usable - press <b>↓</b> to use.</g></i>\n\n<b><bv><u>Free jump</u></bv></b>\n▫ Every round\n▫ Usable\n\n<b><bv><u>Boost</u></bv></b>\n▫ Every 20 seconds\n▫ Usable\n\n<b><bv><u>Free cheese</u></bv></b>\n▫ Every round\n\n<b><bv><u>Free cannon</u></bv></b>\n▫ Every even round\n\n<b><bv><u>Explode</u></bv></b>\n▫ Every round\n▫ Usable",
  108.         event = {
  109.             "Airstrike",
  110.             "Örsler",
  111.             "2 kat hız",
  112.             "Bonus Delilik",
  113.         },
  114.         powers = {
  115.             "Jump",
  116.             "Boost",
  117.             "Cheese",
  118.             "Cannon",
  119.             "Explode"
  120.         },
  121.         buy = "Buy",
  122.         equip = "Equip",
  123.         equipped = "Equipped",
  124.         willbeeqippedinnextround = "Will be eqipped in next round",
  125.         close = "Close",
  126.         coins = "Coins"
  127.     },
  128. }
  129.  
  130. text.e2 = text.en
  131.  
  132. local language = tfm.get.room.community or "en"
  133. if language == "xx" then
  134.     language = tfm.get.room.playerList[admin].community
  135. end
  136. if not text[language] then
  137.     language = 'en'
  138. end
  139.  
  140.  
  141. --[[ Карты--]]
  142.  
  143. local mapList = {
  144.     {
  145.         code = [[<C><P Ca='' /><Z><S><S L="200" H="40" X="100" Y="380" T="9" P="0,0,,,,0,0,0" /><S L="200" X="700" H="40" Y="380" T="9" P="0,0,,,,0,0,0" /><S L="50" H="20" X="225" Y="370" T="1" P="0,0,0,0.2,0,0,0,0" /><S L="50" X="575" H="20" Y="370" T="1" P="0,0,0,0.2,0,0,0,0" /><S L="300" H="40" X="400" Y="360" T="9" P="0,0,,,,0,0,0" /></S><D><DS Y="340" X="400" /><F Y="100" X="400" /></D><O /></Z></C>]],
  146.         bonusSpawn = function()
  147.             return math.random(15, 785), math.random(325, 375)
  148.         end
  149.     },
  150.  
  151.     {
  152.         code = [[<C><P Ca='' /><Z><S><S L="200" H="80" X="400" Y="380" T="9" P="0,0,,,,0,0,0" /><S P="0,0,0,0.2,0,0,0,0" L="20" H="20" c="3" Y="290" T="1" X="220" /><S P="0,0,0.3,0.2,0,0,0,0" L="10" o="6a7495" X="220" c="4" Y="290" T="12" H="10" /><S X="580" L="20" H="20" c="3" Y="290" T="1" P="0,0,0,0.2,0,0,0,0" /><S H="10" L="10" o="6a7495" X="580" c="4" Y="290" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S L="200" X="400" H="60" Y="250" T="9" P="0,0,,,,0,0,0" /><S X="220" L="20" H="20" c="3" Y="210" T="1" P="0,0,0,0.2,0,0,0,0" /><S H="10" L="10" o="6a7495" X="220" c="4" Y="210" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0,0.2,0,0,0,0" L="20" X="580" c="3" Y="210" T="1" H="20" /><S P="0,0,0.3,0.2,0,0,0,0" L="10" o="6a7495" X="580" c="4" Y="211" T="12" H="10" /><S L="40" X="700" H="220" Y="310" T="9" P="0,0,,,,0,0,0" /><S L="40" H="220" X="100" Y="310" T="9" P="0,0,,,,0,0,0" /><S L="180" H="20" X="210" Y="370" T="9" P="0,0,,,,0,0,0" /><S L="180" X="590" H="20" Y="370" T="9" P="0,0,,,,0,0,0" /></S><D><DS Y="340" X="400" /><F Y="100" X="400" /></D><O /></Z></C>]],
  153.         bonusSpawn = function()
  154.             local coordinates = {
  155.                 {100,250},
  156.                 {220,250},
  157.                 {580,250},
  158.                 {700,250},
  159.                 {220,355},
  160.                 {580,355}
  161.             }
  162.             local out = math.random(1, 6)
  163.             return coordinates[out][1], coordinates[out][2]
  164.         end
  165.     },
  166.  
  167.     {
  168.         code = [[<C><P Ca='' /><Z><S><S L="50" H="80" X="400" Y="200" T="9" P="0,0,,,,0,0,0" /><S L="50" X="440" H="80" Y="220" T="9" P="0,0,,,,0,0,0" /><S L="50" H="80" X="480" Y="240" T="9" P="0,0,,,,0,0,0" /><S L="50" X="560" H="80" Y="280" T="9" P="0,0,,,,0,0,0" /><S L="50" X="520" H="80" Y="260" T="9" P="0,0,,,,0,0,0" /><S L="50" H="80" X="600" Y="300" T="9" P="0,0,,,,0,0,0" /><S L="50" X="640" H="80" Y="320" T="9" P="0,0,,,,0,0,0" /><S L="50" H="80" X="680" Y="340" T="9" P="0,0,,,,0,0,0" /><S L="50" X="720" H="80" Y="360" T="9" P="0,0,,,,0,0,0" /><S L="50" H="80" X="760" Y="380" T="9" P="0,0,,,,0,0,0" /><S L="50" X="280" H="80" Y="260" T="9" P="0,0,,,,0,0,0" /><S L="50" X="360" H="80" Y="220" T="9" P="0,0,,,,0,0,0" /><S L="50" H="80" X="320" Y="240" T="9" P="0,0,,,,0,0,0" /><S L="50" H="80" X="240" Y="280" T="9" P="0,0,,,,0,0,0" /><S L="50" X="200" H="80" Y="300" T="9" P="0,0,,,,0,0,0" /><S L="50" H="80" X="160" Y="320" T="9" P="0,0,,,,0,0,0" /><S L="50" X="120" H="80" Y="340" T="9" P="0,0,,,,0,0,0" /><S L="50" H="80" X="80" Y="360" T="9" P="0,0,,,,0,0,0" /><S L="50" X="40" H="80" Y="380" T="9" P="0,0,,,,0,0,0" /><S L="20" H="20" X="400" Y="370" T="1" P="0,0,0,0.2,0,0,0,0" /></S><D /><O /></Z></C>]],
  169.         bonusSpawn = function()
  170.             local coordinates = {
  171.                 {300,365},
  172.                 {500,365},
  173.                 {150,150},
  174.                 {650,150},
  175.                 {400,345},
  176.                 {400,60}
  177.             }
  178.             local out = math.random(1, 6)
  179.             return coordinates[out][1], coordinates[out][2]
  180.         end
  181.     },
  182.  
  183.     {
  184.         code = [[<C><P Ca='' /><Z><S><S L="200" H="100" X="400" Y="200" T="9" P="0,0,,,,0,0,0" /><S L="60" H="250" X="50" Y="275" T="9" P="0,0,,,,0,0,0" /><S L="60" X="750" H="250" Y="275" T="9" P="0,0,,,,0,0,0" /><S L="500" X="400" H="40" Y="400" T="9" P="0,0,,,,0,0,0" /><S L="40" H="40" X="650" Y="380" T="9" P="0,0,,,,0,0,0" /><S L="40" X="150" H="40" Y="380" T="9" P="0,0,,,,0,0,0" /><S L="100" H="20" X="190" Y="160" T="9" P="0,0,,,,0,0,0" /><S L="100" X="610" H="20" Y="160" T="9" P="0,0,,,,0,0,0" /></S><D><F Y="179" D="" X="49" /><F Y="209" D="" X="49" /><F Y="389" D="" X="49" /><F Y="359" D="" X="49" /><F Y="329" D="" X="29" /><F Y="299" D="" X="29" /><F Y="269" D="" X="29" /><F Y="239" D="" X="29" /><F Y="179" D="" X="749" /><F Y="209" D="" X="749" /><F Y="239" D="" X="769" /><F Y="269" D="" X="769" /><F Y="299" D="" X="769" /><F Y="329" D="" X="769" /><F Y="359" D="" X="749" /><F Y="389" D="" X="749" /><DS Y="140" X="400" /></D><O /></Z></C>]],
  185.         bonusSpawn = function()
  186.             return math.random(100, 700), math.random(140, 340)
  187.         end
  188.     },
  189.  
  190.     {
  191.         code = [[<C><P DS="m;100,385,700,385" Ca="" /><Z><S><S H="300" L="20" X="200" c="3" Y="250" T="1" P="0,0,0,0.2,0,0,0,0" /><S X="200" L="20" H="440" c="3" Y="-180" T="1" P="0,0,0,0.2,0,0,0,0" /><S X="600" L="20" H="300" c="3" Y="250" T="1" P="0,0,0,0.2,0,0,0,0" /><S H="440" L="20" X="600" c="3" Y="-180" T="1" P="0,0,0,0.2,0,0,0,0" /><S H="290" L="10" o="6a7495" X="200" c="4" Y="250" 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="10" o="6a7495" X="600" c="4" Y="250" T="12" H="290" /><S H="40" L="10" o="6a7495" X="600" c="4" Y="10" 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="10" o="6a7495" X="200" c="4" Y="10" T="12" H="40" /><S L="300" H="60" X="400" Y="130" T="9" P="0,0,,,,0,0,0" /><S L="300" X="400" H="40" Y="360" T="9" P="0,0,,,,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="10" H="30" c="3" Y="385" T="15" X="100" /><S L="45" H="30" X="72" Y="385" T="9" P="0,0,,,,0,0,0" /><S L="45" X="127" H="30" Y="385" T="9" P="0,0,,,,0,0,0" /><S L="45" H="30" X="672" Y="385" T="9" P="0,0,,,,0,0,0" /><S L="45" X="727" H="30" Y="385" T="9" P="0,0,,,,0,0,0" /><S X="700" L="10" H="30" c="3" Y="385" T="15" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0,0.2,0,0,0,0" L="1600" X="400" c="3" Y="-10" T="1" H="20" /><S L="100" X="700" H="160" Y="130" T="9" P="0,0,,,,0,0,0" /><S L="100" H="100" X="700" Y="290" T="9" P="0,0,,,,0,0,0" /><S L="100" X="100" H="100" Y="290" T="9" P="0,0,,,,0,0,0" /><S L="100" H="160" X="100" Y="130" T="9" P="0,0,,,,0,0,0" /></S><D><F Y="255" D="" X="130" /><F Y="125" D="" X="70" /><F Y="145" D="" X="80" /><F Y="165" D="" X="83" /><F Y="185" D="" X="79" /><F Y="205" D="" X="69" /><F Y="275" D="" X="120" /><F Y="295" D="" X="116" /><F Y="315" D="" X="120" /><F Y="335" D="" X="130" /><F Y="335" D="" X="669" /><F Y="315" D="" X="679" /><F Y="295" D="" X="683" /><F Y="275" D="" X="680" /><F Y="255" D="" X="670" /><F Y="205" D="" X="730" /><F Y="185" D="" X="720" /><F Y="165" D="" X="716" /><F Y="145" D="" X="720" /><F Y="125" D="" X="730" /><F Y="110" D="" X="400" /><F Y="110" D="" X="530" /><F Y="110" D="" X="270" /><F Y="100" D="" X="410" /><F Y="100" D="" X="390" /><F Y="90" D="" X="400" /><F Y="100" D="" X="280" /><F Y="100" D="" X="260" /><F Y="90" D="" X="270" /><F Y="100" D="" X="520" /><F Y="100" D="" X="540" /><F Y="90" D="" X="530" /></D><O /></Z></C>]],
  192.         bonusSpawn = function()
  193.             local coordinates = {
  194.                 {335,130},
  195.                 {465,130},
  196.                 {100,225},
  197.                 {700,225},
  198.                 {400,50},
  199.                 {400,255}
  200.             }
  201.             local out = math.random(1, 6)
  202.             return coordinates[out][1], coordinates[out][2]
  203.         end
  204.     },
  205.  
  206. }
  207.  
  208. local currentMap = math.random(1, #mapList)
  209.  
  210. --[[ Основное--]]
  211.  
  212. local isEvent = false
  213. local currentEvent = 1
  214. local bonus, bonusAmount = {}, 0
  215. local objectList, objects = {}, 0
  216. local timer = 0
  217. local round = 0
  218. local bonusRate = 20
  219. local CannonsPairsPerSecond = 1
  220. local canUsePowers = false
  221.  
  222. function eventLoop(currentTime, timeRemaining)
  223.  
  224.     timer = timer + 1
  225.  
  226.     if timer % 20 == 0 then
  227.         for playerName, Data in next, playerData do
  228.             if Data.power == 2 then
  229.                 Data.powerUsable = true
  230.             end
  231.         end
  232.     end
  233.  
  234.     if timer % bonusRate == 0 then
  235.         --[[ Add bonus--]]
  236.         --[[
  237.         0 - + 1 Score
  238.         1 - Cannon
  239.         --]]
  240.         bonusAmount = bonusAmount + 1
  241.         local x, y = mapList[currentMap].bonusSpawn()
  242.         bonus[bonusAmount] = {x = x, y = y, type = math.random(0,1)}
  243.     end
  244.  
  245.         --[[ Show bonus--]]
  246.     for _, bonusData in next, bonus do
  247.         if bonusData.type == 0 then
  248.             tfm.exec.displayParticle(15, bonusData.x, bonusData.y)
  249.         else
  250.             tfm.exec.displayParticle(29, bonusData.x, bonusData.y)
  251.         end
  252.     end
  253.  
  254.  
  255.         --[[ Spawn cannon--]]
  256.     if currentTime > 5000 then
  257.        
  258.         canUsePowers = true
  259.  
  260.         for i = 1, CannonsPairsPerSecond do
  261.             local newObjectId
  262.             local id = math.random(0,11)
  263.             local x = math.random(15,785)
  264.    
  265.             if id < 10 then
  266.                 id = "0"..id
  267.             end
  268.             if id == "00" then
  269.                 newObjectId = tfm.exec.addShamanObject(17, x, -200)
  270.             else
  271.                 newObjectId = tfm.exec.addShamanObject("17"..id, x, -200)
  272.             end
  273.             tfm.exec.addShamanObject(0, x, 50)
  274.    
  275.             objects = objects + 1
  276.             objectList[objects] = newObjectId
  277.    
  278.             if currentTime > 8500 then
  279.                 tfm.exec.removeObject(objectList[1])
  280.                 table.remove(objectList, 1)
  281.                 objects = objects - 1
  282.             end
  283.         end
  284.     end
  285.  
  286.     --[[ Reset Game --]]
  287.  
  288.     if timeRemaining <= 0 then
  289.         for playerName, playerData in next, tfm.get.room.playerList do
  290.             if not playerData.isDead then
  291.                 tfm.exec.displayParticle(15, playerData.x, playerData.y, math.random(-100,100)/100, -3, 0, 0.1)
  292.                 tfm.exec.displayParticle(15, playerData.x, playerData.y, math.random(-100,100)/100, -3, 0, 0.1)
  293.                 tfm.exec.displayParticle(15, playerData.x, playerData.y, math.random(-100,100)/100, -3, 0, 0.1)
  294.                 tfm.exec.setPlayerScore(playerName, 3, true)
  295.             end
  296.         end
  297.         bonus = {}
  298.         bonusAmount = 0
  299.         objectList = {}
  300.         objects = 0
  301.  
  302.         if round == 10 then
  303.             --[[ End --]]
  304.             local winner
  305.             for playerName, playerData in next, tfm.get.room.playerList do
  306.                 winner = playerName
  307.                 break
  308.             end
  309.  
  310.             for playerName, Data in next, tfm.get.room.playerList do
  311.                 if Data.score > tfm.get.room.playerList[winner].score then
  312.                     winner = playerName
  313.                 end
  314.  
  315.                 tfm.exec.setPlayerScore(playerName, 0)
  316.  
  317.                 if Data.score >= 30 then
  318.                     playerData[playerName].coin = playerData[playerName].coin + 1
  319.                 end
  320.             end
  321.  
  322.             for playerName, Data in next, playerData do
  323.                 Data = {
  324.                     cannons = 0,
  325.                     hasTeleported = false,
  326.                     hasCheese = false,
  327.                 }
  328.             end
  329.  
  330.             tfm.exec.newGame([[<C><P DS="y;350" /><Z><S><S L="800" H="40" X="400" Y="380" T="9" P="0,0,,,,0,0,0" /><S H="200" L="100" o="ddac2a" X="400" c="3" Y="300" 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="10" o="a3790e" X="401" c="3" Y="300" T="12" H="200" /><S X="441" L="10" o="342604" H="200" c="3" Y="300" 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="10" o="ca9a1d" X="399" c="3" Y="300" T="12" H="200" /><S X="439" L="10" o="a3790e" H="200" c="3" Y="300" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S H="200" L="10" o="a3790e" X="361" c="3" Y="300" 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="10" o="eabe4b" H="200" c="3" Y="300" T="12" X="359" /><S P="0,0,0.3,0.2,0,0,0,0" L="140" o="eabe4b" X="400" c="3" Y="210" T="12" H="20" /><S H="10" L="20" o="eabe4b" X="470" c="3" Y="220" T="13" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="20" o="eabe4b" X="330" c="3" Y="220" T="13" H="10" /></S><D /><O /></Z></C>]])
  331.             tfm.exec.setGameTime(600)
  332.             tfm.exec.setUIMapName("#heavyrain - <bl>Zigwin<bl>   <g>|<g>   <v>"..winner.."</v> <n>- "..(text[language].winner).."</n>")
  333.             round = -1
  334.  
  335.             tfm.exec.movePlayer(winner, 400, 100)
  336.  
  337.             for playerName, playerData in next, tfm.get.room.playerList do
  338.                 if playerName ~= winner then
  339.                     tfm.exec.playEmote(playerName, 1)
  340.                 else
  341.                     tfm.exec.playEmote(playerName, 0)
  342.                 end
  343.             end
  344.         else
  345.             --[[ Next Round --]]
  346.             local newMap = math.random(1, #mapList)
  347.             while newMap == currentMap do
  348.                 newMap = math.random(1, #mapList)
  349.             end
  350.  
  351.             currentMap = newMap
  352.  
  353.             -- Remember if player has cheese
  354.             for playerName, Data in next, tfm.get.room.playerList do
  355.                 if not Data.isDead and Data.hasCheese then
  356.                     playerData[playerName].hasCheese = true
  357.                 end
  358.             end
  359.  
  360.             tfm.exec.newGame(mapList[currentMap].code)
  361.         end
  362.     end
  363.  
  364.     --[[ Events --]]
  365.     if isEvent then
  366.         if currentEvent == 2 and timer % 20 == 0 then
  367.             --[[ Spawn anvils --]]
  368.             for i = 1, 10 do
  369.                 local x = math.random(0, 1) == 0 and i*80-40 or i*80-80
  370.                 tfm.exec.addShamanObject(10, x, -200, 90, 0, 0)
  371.                 tfm.exec.addShamanObject(0, x, 50)
  372.             end
  373.         elseif currentEvent == 1 then
  374.             --[[ Airstrike--]]
  375.             if timer % 60 == 0 or (currentTime > 10000 and currentTime < 10500) then
  376.                 local randomPos = math.random(40, 760)
  377.                 tfm.exec.addPhysicObject(0, randomPos, 100, {type = 8,
  378.                     width = 80,
  379.                     height = 20,
  380.                     miceCollision = false,
  381.                     groundCollision = true
  382.                 })
  383.                 tfm.exec.displayParticle(33, randomPos, 200)
  384.                 tfm.exec.displayParticle(33, randomPos+10, 200)
  385.                 tfm.exec.displayParticle(33, randomPos-10, 200)
  386.                 for i = 1, 28 do
  387.                     local x = i * 30 - 50
  388.                     tfm.exec.addShamanObject(17, x, -500)
  389.                     tfm.exec.addShamanObject(0, x, 50)
  390.                 end
  391.             elseif timer % 64 == 0 or (currentTime >= 12000 and currentTime < 12500)then
  392.                 tfm.exec.removePhysicObject(0)
  393.             end
  394.         end
  395.     end
  396. end
  397.  
  398. function eventNewGame()
  399.     canUsePowers = false
  400.  
  401.     timer = 0
  402.  
  403.     for playerName, Data in next, playerData do
  404.         Data.hasTeleported = false
  405.         if Data.hasCheese then
  406.             tfm.exec.giveCheese(playerName)
  407.         end
  408.         updateItem(playerName)
  409.  
  410.         --[[ Change power--]]
  411.  
  412.         Data.power = Data.nextPower
  413.  
  414.         --[[ Recharge powers --]]
  415.  
  416.         local power = Data.power
  417.  
  418.         if power ~= 0 then
  419.             if power == 1 or power == 2 or power == 5 then
  420.                 Data.powerUsable = true
  421.             elseif power == 4 and round % 2 == 0 then
  422.                 Data.cannons = Data.cannons + 1
  423.                 updateItem(playerName)
  424.             elseif power == 3 then
  425.                 tfm.exec.giveCheese(playerName)
  426.             end
  427.         end
  428.     end
  429.  
  430.     round = round + 1
  431.  
  432.     if round == 10 or round == 5 then
  433.     --if round > 0 then         -- DEBUG
  434.         --[[ Event --]]
  435.         local newEvent = math.random(1, 4)
  436.         while newEvent == currentEvent do
  437.             newEvent = math.random(1, 4)
  438.         end
  439.  
  440.         currentEvent = newEvent
  441.         --currentEvent = 3      -- DEBUG
  442.  
  443.         --[[
  444.             Airstrike
  445.             Falling balls
  446.             Cannons Double Speed
  447.             Bonus Madness
  448.         --]]
  449.  
  450.         --if currentEvent == 1 then
  451.         --elseif currentEvent == 2 then        
  452.         if currentEvent == 3 then
  453.             CannonsPairsPerSecond = 2
  454.         elseif currentEvent == 4 then
  455.             bonusRate = 2
  456.         end
  457.  
  458.         updateText(true)
  459.  
  460.         isEvent = true
  461.  
  462.     end
  463.  
  464.     if round <= 1 or round == 6 then
  465.        
  466.         --if currentEvent == 1 then
  467.  
  468.         --elseif currentEvent == 2 then
  469.  
  470.         if currentEvent == 3 then
  471.             CannonsPairsPerSecond = 1
  472.         elseif currentEvent == 4 then
  473.             bonusRate = 20
  474.         end            
  475.         updateText(false)
  476.  
  477.         isEvent = false
  478.     end
  479.     tfm.exec.setUIMapName("#heavyrain - <bl>Zigwin<bl>   <g>|<g>   <n>"..(text[language].round).." : </n><v>"..round.." / 10</v>")
  480. end
  481.  
  482. function eventMouse(playerName, xMousePosition, yMousePosition)
  483.     local Data = tfm.get.room.playerList[playerName]
  484.     if not Data.isDead then
  485.         if Data.hasCheese and not playerData[playerName].hasTeleported and xMousePosition > -10 and xMousePosition < 810 and yMousePosition > -10 then
  486.             playerData[playerName].hasTeleported = true
  487.             playerData[playerName].hasCheese = false
  488.  
  489.             tfm.exec.displayParticle(36, Data.x, Data.x)
  490.             tfm.exec.movePlayer(playerName, xMousePosition, yMousePosition)
  491.             tfm.exec.displayParticle(37, xMousePosition, yMousePosition)
  492.             tfm.exec.removeCheese(playerName)
  493.  
  494.             --[[ Update Item Display--]]
  495.             local Cannons = playerData[playerName].cannons
  496.             if Cannons > 0 then
  497.                 if Cannons == 1 then
  498.                     ui.updateTextArea(2, "<n><b>Cannon", playerName)
  499.                     ui.updateTextArea(3, "<font color='#000000'><b>Cannon", playerName)
  500.                 else
  501.                     ui.updateTextArea(2, "<n><b>Cannons x "..Cannons, playerName)
  502.                     ui.updateTextArea(3, "<font color='#000000'><b>Cannons x "..Cannons, playerName)
  503.                 end
  504.             else
  505.                 ui.updateTextArea(2, "", playerName)
  506.                 ui.updateTextArea(3, "", playerName)
  507.             end
  508.  
  509.             return
  510.         end
  511.  
  512.         if playerData[playerName].cannons > 0 then
  513.             playerData[playerName].cannons = playerData[playerName].cannons - 1
  514.  
  515.             tfm.exec.addShamanObject(17, xMousePosition, -200, 180)
  516.  
  517.             updateItem(playerName)
  518.             return
  519.         end
  520.     end
  521. end
  522.  
  523. function eventKeyboard(playerName, keyCode, down, xPlayerPosition, yPlayerPosition)
  524.     local Data = playerData[playerName]
  525.     if keyCode == 0 then
  526.         Data.facingRight = false
  527.     elseif keyCode == 2 then
  528.         Data.facingRight = true
  529.     end
  530.  
  531.     if keyCode == 72 then
  532.         updateHelp(playerName)
  533.     end
  534.  
  535.     local playerPower = Data.power
  536.  
  537.     if playerPower ~= 0 and keyCode == 3 and canUsePowers then
  538.         local powerUsable = Data.powerUsable
  539.  
  540.         if powerUsable then
  541.             -- 1 - Jump Boost       - Every round ; Usable
  542.             -- 2 - Speed Boost      - Every 20 seconds ; Usable
  543.             -- 5 - Explode          - Every round ; Usable
  544.             if playerPower == 1 then
  545.                 tfm.exec.movePlayer(playerName, 0, 0, 0, 0, -150)
  546.             elseif playerPower == 2 then
  547.                 local facingRight = Data.facingRight
  548.                 if facingRight then
  549.                     tfm.exec.movePlayer(playerName, 0, 0, 0, 150)
  550.                 else
  551.                     tfm.exec.movePlayer(playerName, 0, 0, 0, -150)
  552.                 end
  553.             elseif playerPower == 5 then
  554.                 drawExplosionParticles(xPlayerPosition, yPlayerPosition)
  555.                 tfm.exec.explosion(xPlayerPosition, yPlayerPosition, 50, 100, false)
  556.                 tfm.exec.killPlayer(playerName)
  557.             end
  558.             Data.powerUsable = false
  559.         end
  560.     end
  561.  
  562.     --[[ Bonus check--]]
  563.     if not tfm.get.room.playerList[playerName].isDead then
  564.         for bonusId, bonusData in next, bonus do
  565.             if xPlayerPosition >= bonusData.x - 15 and xPlayerPosition <= bonusData.x + 15 and yPlayerPosition >= bonusData.y - 15 and yPlayerPosition <= bonusData.y + 15 then
  566.  
  567.                 if bonusData.type == 0 then
  568.                     tfm.exec.setPlayerScore(playerName, 1, true)
  569.                     tfm.exec.displayParticle(15, xPlayerPosition, yPlayerPosition, 0, -2, 0, 0.1)
  570.                 else
  571.                     Data.cannons = Data.cannons + 1
  572.                     tfm.exec.displayParticle(29, xPlayerPosition, yPlayerPosition, 0, -2, 0, 0.1)
  573.  
  574.                     updateItem(playerName)
  575.                 end
  576.                 table.remove(bonus, bonusId)
  577.                 bonusAmount = bonusAmount - 1
  578.                 return
  579.             end
  580.         end
  581.     end
  582. end
  583.  
  584. function eventTextAreaCallback(textAreaId, playerName, callback)
  585.     if callback == 'pageleft' then
  586.         if playerData[playerName].powersShopPage > 1 then
  587.             playerData[playerName].powersShopPage = playerData[playerName].powersShopPage - 1
  588.             drawPowersShop(playerName)
  589.         end
  590.     elseif callback == 'pageright' then
  591.         if playerData[playerName].powersShopPage < 2 then
  592.             playerData[playerName].powersShopPage = playerData[playerName].powersShopPage + 1
  593.             drawPowersShop(playerName)
  594.         end
  595.     elseif callback == 'close' then
  596.         for i = 1, 13 do
  597.             ui.removeTextArea('2'..tostring(i), playerName)
  598.         end
  599.     elseif callback:sub(1,5) == 'equip' then
  600.         playerData[playerName].nextPower = tonumber(callback:sub(6,6))
  601.         drawPowersShop(playerName)
  602.     elseif callback:sub(1,3) == 'buy' then
  603.         local number = tonumber(callback:sub(4,4))
  604.         playerData[playerName].powerList[number] = true
  605.         playerData[playerName].nextPower = number
  606.         drawPowersShop(playerName)
  607.     end
  608. end
  609.  
  610. function eventPlayerDied(playerName)
  611.     playerData[playerName].hasCheese = false
  612.  
  613.     tfm.exec.setPlayerScore(playerName, 1, true)
  614.  
  615.     -- If one player left set time to 5
  616.     local alive = false
  617.     for playerName, playerData in next, tfm.get.room.playerList do
  618.         if not playerData.isDead then
  619.             if alive then
  620.                 return
  621.             else
  622.                 alive = true
  623.             end
  624.         end
  625.     end
  626.     tfm.exec.setGameTime(5)
  627. end
  628.  
  629. function eventChatCommand(playerName, message)
  630.     --[[ Help message--]]
  631.     if message == 'help' then
  632.         updateHelp(playerName)
  633.     elseif message == 'shop' then
  634.         drawPowersShop(playerName)
  635.     end
  636. end
  637.  
  638. function eventPlayerGetCheese(playerName)
  639.     updateItem(playerName)
  640. end
  641.  
  642. function drawExplosionParticles(x, y)
  643.     local draw = tfm.exec.displayParticle
  644.     -- Clouds
  645.     draw(3, x, y, 10, 0, -0.5, -0.1)
  646.     draw(3, x, y, -10, 0, 0.5, -0.1)
  647.     draw(3, x, y, 12, 1, -0.5, -0.1)
  648.     draw(3, x, y, -12, 1, 0.5, -0.1)
  649.     draw(3, x, y, 0.5, -12, -0.1, 0.5)
  650.     draw(3, x, y, -0.5, -12, 0.1, 0.5)
  651.     draw(3, x, y, 1, -11.3, -0.2, 0.6)
  652.     draw(3, x, y, -1, -11.3, 0.2, 0.6)
  653.     draw(3, x, y, 0, -12.5, 0, 0.5)
  654.     -- Spirit
  655.     draw(10, x, y, 0, 0, 0, 0)
  656.     -- Confetti
  657.     draw(math.random(21,24), x, y, 11 + math.random(-1,1), 0 + math.random(-1,1), -0.5, 0)
  658.     draw(math.random(21,24), x, y, -11 + math.random(-1,1), 0 + math.random(-1,1), 0.5, 0)
  659.     draw(math.random(21,24), x, y, 10.8 + math.random(-1,1), 2 + math.random(-1,1), -0.5, -0.1)
  660.     draw(math.random(21,24), x, y, -10.8 + math.random(-1,1), 2 + math.random(-1,1), 0.5, -0.1)
  661.     draw(math.random(21,24), x, y, 10.8 + math.random(-1,1), -2 + math.random(-1,1), -0.5, 0.1)
  662.     draw(math.random(21,24), x, y, -10.8 + math.random(-1,1), -2 + math.random(-1,1), 0.5, 0.1)
  663.     draw(math.random(21,24), x, y, 10.5 + math.random(-1,1), -4 + math.random(-1,1), -0.5, 0.2)
  664.     draw(math.random(21,24), x, y, -10.5 + math.random(-1,1), -4 + math.random(-1,1), 0.5, 0.2)
  665.     draw(math.random(21,24), x, y, 10 + math.random(-1,1), -5.8 + math.random(-1,1), -0.5, 0.3)
  666.     draw(math.random(21,24), x, y, -10 + math.random(-1,1), -5.8 + math.random(-1,1), 0.5, 0.3)
  667.     draw(math.random(21,24), x, y, 9 + math.random(-1,1), -7.5 + math.random(-1,1), -0.5, 0.35)
  668.     draw(math.random(21,24), x, y, -9 + math.random(-1,1), -7.5 + math.random(-1,1), 0.5, 0.35)
  669.     draw(math.random(21,24), x, y, 8 + math.random(-1,1), -8 + math.random(-1,1), -0.5, 0.3)
  670.     draw(math.random(21,24), x, y, -8 + math.random(-1,1), -8 + math.random(-1,1), 0.5, 0.3)
  671.     draw(math.random(21,24), x, y, 7 + math.random(-1,1), -8.5 + math.random(-1,1), -0.5, 0.2)
  672.     draw(math.random(21,24), x, y, -7 + math.random(-1,1), -8.5 + math.random(-1,1), 0.5, 0.2)
  673.     draw(math.random(21,24), x, y, 6 + math.random(-1,1), -8.8 + math.random(-1,1), -0.5, 0.1)
  674.     draw(math.random(21,24), x, y, -6 + math.random(-1,1), -8.8 + math.random(-1,1), 0.5, 0.1)
  675. end
  676.  
  677. function updateText(show)
  678.     if show then
  679.         for playerName, playerData in next, tfm.get.room.playerList do
  680.             -- Get Langugae
  681.             local language = playerData.community
  682.             if not text[language] then language = "en" end
  683.  
  684.             -- Update Text
  685.             ui.updateTextArea(0, "<font color='#000000' size='20' ><p align='center'><b>"..(text[language].event[currentEvent]))
  686.             ui.updateTextArea(1, "<font size='20' ><j><p align='center'><b>"..(text[language].event[currentEvent]))
  687.         end
  688.     else
  689.         ui.updateTextArea(0, "")
  690.         ui.updateTextArea(1, "")
  691.     end
  692. end
  693.  
  694. function updateItem(playerName)
  695.     local Cannons = playerData[playerName].cannons
  696.     if tfm.get.room.playerList[playerName].hasCheese then
  697.         ui.updateTextArea(2, "<font color='#000000'><b>Teleport", playerName)
  698.         ui.updateTextArea(3, "<bv><b>Teleport", playerName)
  699.     elseif Cannons > 0 then
  700.         if Cannons == 1 then
  701.             ui.updateTextArea(2, "<n><b>Cannon", playerName)
  702.             ui.updateTextArea(3, "<font color='#000000'><b>Cannon", playerName)
  703.         else
  704.             ui.updateTextArea(2, "<n><b>Cannons x "..Cannons, playerName)
  705.             ui.updateTextArea(3, "<font color='#000000'><b>Cannons x "..Cannons, playerName)
  706.         end
  707.     else
  708.         ui.updateTextArea(2, "", playerName)
  709.         ui.updateTextArea(3, "", playerName)
  710.     end
  711. end
  712.  
  713. function updateHelp(playerName)
  714.     -- Get language
  715.     local language = tfm.get.room.playerList[playerName].community
  716.     if not text[language] then
  717.         language = 'en'
  718.     end
  719.  
  720.     -- Show help
  721.     playerData[playerName].isHelpVisible = not playerData[playerName].isHelpVisible
  722.     if playerData[playerName].isHelpVisible then
  723.         ui.addTextArea(10, "", playerName, 100, 50, 600, 300, 0x3f3f3f, 0x3f3f3f, 1, true)
  724.         ui.addTextArea(11, text[language].help1, playerName, 110, 60, 300, 280, 0x151515, 0x151515, 1, true)
  725.         ui.addTextArea(12, "", playerName, 101, 51, 1, 1, 0x8f8f8f, 0x8f8f8f, 1, true)
  726.         ui.addTextArea(13, "", playerName, 101, 348, 1, 1, 0x8f8f8f, 0x8f8f8f, 1, true)
  727.         ui.addTextArea(14, "", playerName, 698, 348, 1, 1, 0x8f8f8f, 0x8f8f8f, 1, true)
  728.         ui.addTextArea(15, "", playerName, 698, 51, 1, 1, 0x8f8f8f, 0x8f8f8f, 1, true)
  729.         ui.addTextArea(16, text[language].help2, playerName, 430, 60, 260, 280, 0x151515, 0x151515, 1, true)
  730.     else
  731.         for i = 10, 16 do
  732.             ui.removeTextArea(i, playerName)
  733.         end
  734.     end
  735. end
  736.  
  737. function drawPowersShop(playerName)
  738.     ui.addTextArea(27, "", playerName, 330, 275, 140, 30, 0x3f3f3f, 0x3f3f3f, 1, true)
  739.     ui.addTextArea(28, "", playerName, 220, 150, 360, 120, 0x3f3f3f, 0x3f3f3f, 1, true)
  740.     ui.addTextArea(29, "", playerName, 221, 151, 1, 1, 0x8f8f8f, 0x8f8f8f, 1, true)
  741.     ui.addTextArea(210, "", playerName, 221, 268, 1, 1, 0x8f8f8f, 0x8f8f8f, 1, true)
  742.     ui.addTextArea(211, "", playerName, 578, 268, 1, 1, 0x8f8f8f, 0x8f8f8f, 1, true)
  743.     ui.addTextArea(212, "", playerName, 579, 151, 1, 1, 0x8f8f8f, 0x8f8f8f, 1, true)
  744.  
  745.     local language = tfm.get.room.playerList[playerName].community
  746.     if not text[language] then language = 'en' end
  747.  
  748.     ui.addTextArea(213, text[language].coins.." : "..playerData[playerName].coin, playerName, 5, 25, 0, 0, nil, nil, 0, true)
  749.  
  750.     for i = 1, 3 do
  751.         local desc
  752.         local page = playerData[playerName].powersShopPage
  753.         local powerId = i+(page*3-3)
  754.  
  755.         if powerId > 5 then
  756.             break
  757.         end
  758.  
  759.         local isAvailable = playerData[playerName].powerList[powerId]
  760.  
  761.         if isAvailable then
  762.             if powerId == playerData[playerName].power then
  763.                 desc = text[language].equipped
  764.             elseif powerId == playerData[playerName].nextPower then
  765.                 desc = text[language].willbeeqippedinnextround
  766.             else
  767.                 desc = isAvailable and "<p align='center'><a href='event:equip"..powerId.."'>"..text[language].equip.."</a>" or ""
  768.             end
  769.         else
  770.             desc = "<p align='center'><a href='event:buy"..tostring(powerId).."'>"..text[language].buy.."</a>"
  771.         end
  772.  
  773.         ui.addTextArea(20 + i, "<bv><p align='center'><font size='14'><u>"..(text[language].powers[powerId]).."</u></p></bv>\n\n"..desc, playerName, 110 + i * 120, 160, 100, 100, 0x151515, 0x151515, 1, true)
  774.     end
  775.  
  776.     ui.addTextArea(24, "<p align='center'><font size='14'><a href='event:pageleft'>‹", playerName, 335, 280, 20, 20, 0x151515, 0x151515, 1, true)
  777.     ui.addTextArea(25, "<p align='center'><font size='14'><a href='event:pageright'>›", playerName, 445, 280, 20, 20, 0x151515, 0x151515, 1, true)
  778.     ui.addTextArea(26, "<p align='center'><a href='event:close'>"..text[language].close, playerName, 370, 280, 60, 20, 0x151515, 0x151515, 1, true)
  779. end
  780.  
  781. ui.addTextArea(0, "", nil, 0, 42, 802, 0, nil, nil, 0)
  782. ui.addTextArea(1, "", nil, 0, 40, 800, 0, nil, nil, 0)
  783.  
  784. ui.addTextArea(2, "", nil, 26, 366, 201, 0, nil, nil, 0)
  785. ui.addTextArea(3, "", nil, 25, 365, 200, 0, nil, nil, 0)
  786.  
  787. tfm.exec.disableAutoShaman(true)
  788. tfm.exec.disableAutoScore(true)
  789. tfm.exec.disableAutoNewGame(true)
  790. tfm.exec.disableAutoTimeLeft(true)
  791. tfm.exec.newGame(mapList[currentMap].code)
  792. tfm.exec.setUIMapName("#Module - <bl>Zigwin<bl>   <g>|<g>   <n>"..(text[language].round).." : </n><v>"..round.." / 10</v>")
  793.  
  794. do
  795.     for playerName in next, tfm.get.room.playerList do
  796.         tfm.exec.setPlayerScore(playerName, 0, false)
  797.     end
  798. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement