Advertisement
Guest User

Untitled

a guest
Nov 25th, 2015
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.01 KB | None | 0 0
  1. --21 en adelanet equip blanco
  2. local map = {'<C><P defilante="0,0,0,1" F="4" L="2500" /><Z><S><S L="144" H="157" X="323" Y="269" T="8" P="0,0,0.3,0.2,0,0,0,0" /><S lua="1" H="10" L="400" o="7895a4" X="540" c="2" Y="225" T="12" P="0,0,0.3,0.2,40,0,0,0" /><S L="306" X="543" H="53" Y="388" T="9" P="0,0,,,,0,0,0" /><S lua="2" P="0,0,0.3,0.2,0,0,0,0" L="109" o="48606c" H="94" Y="122" T="12" X="341" /><S lua="3" L="109" o="3e535e" H="94" X="341" Y="213" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S lua="4" P="0,0,0.3,0.2,0,0,0,0" L="109" o="48606c" X="341" Y="287" T="12" H="55" /><S lua="5" H="45" L="28" o="2a383f" X="341" c="2" Y="54" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S lua="6" P="0,0,0.3,0.2,0,0,0,0" L="28" o="2a383f" H="45" c="2" Y="54" T="12" X="382" /><S lua="7" L="141" o="3a4f59" X="324" H="40" Y="367" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S lua="8" L="75" o="3e535e" X="217" H="94" Y="236" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S lua="9" P="0,0,0.3,0.2,0,0,0,0" L="75" o="48606c" H="94" Y="329" T="12" X="216" /><S lua="10" P="0,0,0.3,0.2,0,0,0,0" L="109" o="3e535e" H="94" Y="328" T="12" X="125" /><S lua="11" L="109" o="48606c" H="94" X="125" Y="235" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S lua="12" P="0,0,0.3,0.2,90,0,0,0" L="109" o="3e535e" H="40" Y="242" T="12" X="51" /><S lua="13" L="109" o="48606c" H="40" X="51" Y="348" T="12" P="0,0,0.3,0.2,90,0,0,0" /><S lua="14" P="0,0,0.3,0.2,180,0,0,0" L="109" o="48606c" X="124" Y="395" T="12" H="40" /><S lua="15" L="109" o="3e535e" X="231" H="40" Y="394" T="12" P="0,0,0.3,0.2,180,0,0,0" /><S lua="16" P="0,0,0.3,0.2,0,0,0,0" L="302" o="2a383f" H="17" Y="356" T="12" X="545" /><S lua="17" P="0,0,0.3,0.2,0,0,0,0" L="112" o="48606c" H="16" Y="395" T="12" X="338" /><S lua="18" P="0,0,0.3,0.2,0,0,0,0" L="28" o="2a383f" X="300" c="2" Y="54" T="12" H="45" /><S lua="19" H="45" L="28" o="2a383f" X="341" c="2" Y="54" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S lua="20" H="45" L="28" o="2a383f" X="341" c="2" Y="54" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S L="141" H="147" X="2208" Y="269" T="8" P="0,0,0.3,0.2,0,0,0,0" /> <S lua="21" X="2233" L="28" o="2a383f" H="45" c="2" Y="54" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S lua="22" P="0,0,0.3,0.2,-40,0,0,0" L="400" o="7895a4" X="1994" c="2" Y="230" T="12" H="10" /><S L="306" H="53" X="1988" Y="382" T="9" P="0,0,,,,0,0,0" /> <S lua="23" H="45" L="28" o="2a383f" X="2152" c="2" Y="52" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S lua="24" L="109" o="48606c" H="94" X="2193" Y="122" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S lua="25" P="0,0,0.3,0.2,0,0,0,0" L="109" o="3e535e" X="2193" Y="213" T="12" H="94" /> <S lua="26" L="109" o="48606c" X="2193" H="55" Y="287" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S lua="27" P="0,0,0.3,0.2,0,0,0,0" L="141" o="3a4f59" H="40" Y="367" T="12" X="2207" /><S lua="28" L="302" o="2a383f" H="17" X="1986" Y="363" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S lua="29" L="112" o="48606c" H="16" X="2193" Y="389" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S lua="30" P="0,0,0.3,0.2,0,0,0,0" L="75" o="3e535e" H="94" Y="235" T="12" X="2315" /><S lua="31" P="0,0,0.3,0.2,0,0,0,0" L="109" o="48606c" X="2407" Y="235" T="12" H="94" /><S lua="32" L="109" o="3e535e" H="40" X="2481" Y="242" T="12" P="0,0,0.3,0.2,90,0,0,0" /><S lua="33" P="0,0,0.3,0.2,0,0,0,0" L="28" o="2a383f" X="2192" c="2" Y="52" T="12" H="45" /><S lua="34" P="0,0,0.3,0.2,90,0,0,0" L="109" o="48606c" X="2480" Y="348" T="12" H="40" /><S lua="35" L="109" o="3e535e" H="94" X="2407" Y="328" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S lua="36" L="109" o="48606c" X="2407" H="40" Y="394" T="12" P="0,0,0.3,0.2,180,0,0,0" /><S lua="37" P="0,0,0.3,0.2,180,0,0,0" L="109" o="3e535e" H="40" Y="394" T="12" X="2298" /><S lua="38" L="75" o="48606c" H="94" X="2315" Y="329" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S L="1000" H="52" X="1246" Y="374" T="6" P="0,0,0.3,0.2,0,0,0,0" /><S L="138" H="39" X="1040" Y="284" T="6" P="0,0,0.3,0.2,0,0,0,0" /><S L="138" X="1200" H="39" Y="208" T="6" P="0,0,0.3,0.2,0,0,0,0" /><S L="138" H="39" X="1593" Y="207" T="6" P="0,0,0.3,0.2,0,0,0,0" /><S L="138" X="1396" H="39" Y="274" T="6" P="0,0,0.3,0.2,0,0,0,0" /><S L="138" X="1041" H="39" Y="133" T="6" P="0,0,0.3,0.2,0,0,0,0" /><S L="138" X="1405" H="39" Y="143" T="6" P="0,0,0.3,0.2,0,0,0,0" /><S L="138" H="39" X="870" Y="207" T="6" P="0,0,0.3,0.2,0,0,0,0" /></S><D><DS Y="-79" X="1246" /><P P="1,0" Y="346" T="1" X="840" /><P P="0,0" Y="345" T="2" X="817" /><P P="0,0" Y="345" T="2" X="832" /><P P="0,0" Y="345" T="2" X="832" /><P P="0,0" Y="346" T="2" X="852" /><P P="0,0" Y="346" T="2" X="852" /><P P="0,0" Y="350" T="0" X="937" /><P P="0,0" Y="347" T="0" X="1046" /><P P="0,0" Y="348" T="0" X="1235" /><P X="1140" Y="348" T="0" P="0,0" /><P P="0,0" Y="348" T="0" X="1327" /><P X="1512" Y="349" T="0" P="0,0" /><P P="0,0" Y="349" T="0" X="1689" /><P P="0,0" Y="349" T="1" X="962" /><P P="0,0" Y="299" T="1" X="1137" /><P P="0,0" Y="256" T="1" X="932" /><P P="0,0" Y="256" T="1" X="889" /><P P="0,0" Y="254" T="1" X="1228" /><P P="0,0" Y="224" T="1" X="1005" /><P P="0,0" Y="275" T="1" X="1397" /><P P="0,0" Y="173" T="1" X="851" /><P P="0,0" Y="349" T="1" X="1567" /><P P="1,0" Y="349" T="1" X="1658" /><P P="0,0" Y="345" T="1" X="1462" /><P P="0,0" Y="348" T="1" X="1281" /><P P="1,0" Y="269" T="1" X="806" /><P P="0,0" Y="321" T="1" X="1042" /><P P="0,0" Y="345" T="1" X="1091" /><P P="0,0" Y="349" T="1" X="1146" /><P P="0,0" Y="341" T="1" X="1206" /><P P="0,0" Y="343" T="1" X="1324" /><P P="0,0" Y="343" T="1" X="1393" /><P P="1,0" Y="259" T="1" X="1091" /><P P="1,0" Y="241" T="1" X="1178" /><P P="0,0" Y="231" T="1" X="1326" /><P P="0,0" Y="238" T="1" X="1473" /><P P="0,0" Y="192" T="1" X="1536" /><P P="1,0" Y="272" T="1" X="1651" /><P P="1,0" Y="261" T="1" X="1555" /></D><O /></Z></C>'}
  3. local sp = {}
  4. local mice = {}
  5. local playerList = {}
  6. local teams = {{}, {}}
  7.  
  8. function main()
  9.     tfm.exec.disableAutoShaman(true)
  10.     tfm.exec.disableAutoTimeLeft(true)
  11.     tfm.exec.disableAutoNewGame(true)
  12.     tfm.exec.disableAfkDeath(true)
  13.     table.foreach(tfm.get.room.playerList, eventNewPlayer)
  14.     tfm.exec.newGame(map[1])
  15. end
  16.  
  17. function eventNewPlayer(name)
  18.     if not mice[name] then
  19.         mice[name] = {
  20.             inTeam = false,
  21.             shoots = 3,
  22.             -- Name, range, id, damage
  23.             weapon = {"Default", 200, 9, math.random(40,60)},
  24.             health = 300
  25.         }
  26.     end
  27.     system.bindMouse(name, true)
  28.     table.insert(playerList, name)
  29. end
  30.  
  31. function eventNewGame()
  32.     teams = {{}, {}}
  33.     playerList = {}
  34.     for name,_ in pairs(tfm.get.room.playerList) do table.insert(playerList, name) end
  35.     ui.addTextArea(100, "", nil, 1, 1, 1250, 30, 0x000001, 0x000001, 1, false)
  36.     ui.addTextArea(101, "", nil, 1250, 1, 1250, 30, 0xFFFFFF, 0xFFFFFF, 1, false)
  37.     local xml = tfm.get.room.xmlMapInfo.xml
  38.         for sup in xml:gmatch('(<S [^<]-lua="%d+"[^>]-/>)') do
  39.             xs = sup:match('X="(%d+)"')
  40.             ys = sup:match('Y="(%d+)"')
  41.             width = sup:match('L="(%d+)"')
  42.             height = sup:match('H="(%d+)"')
  43.             id = sup:match('lua="(%d+)"')
  44.             table.insert(sp, {ids=id,x=xs,y=ys,w=width,h=height,v=100})
  45.         end
  46.         for i=1,38 do
  47.             ui.addTextArea(i, sp[i].v.."%", nil, sp[i].x-15, sp[i].y-10, nil, nil, 0, 0, 0, false)
  48.         end
  49.     makeTeams()
  50. end
  51.  
  52. function makeTeams()
  53.     table.sort(playerList, function() return math.random() > 0.5 end)
  54.     for i, name in ipairs(playerList) do
  55.         if not mice[name].inTeam then
  56.             table.insert(teams[i%#teams+1], name)
  57.             mice[name].inTeam = true
  58.         end
  59.     end
  60.    
  61.     table.foreach(tfm.get.room.playerList,
  62.     function(k,v)
  63.         if table.find(teams[1], k) then
  64.             tfm.exec.setNameColor(k, 0xFFFFFF)
  65.         elseif table.find(teams[2], k) then
  66.             tfm.exec.setNameColor(k, 0x000001)
  67.         end
  68.     end)
  69.    
  70. end
  71.  
  72. function table.find(tbl, element)
  73.     for a,b in pairs(tbl) do
  74.         if b == element then
  75.             return true
  76.         end
  77.     end
  78.     return false
  79. end
  80.  
  81. function table.delete(tbl, element)
  82.     for a,b in pairs(tbl)do
  83.         if tbl[a] == element then
  84.             table.remove(tbl, a)
  85.             break
  86.         end
  87.     end
  88. end
  89.  
  90. function eventMouse(name,x,y)
  91.     px,pxi = tfm.get.room.playerList[name].x,tfm.get.room.playerList[name].x - x
  92.     py,pyi = tfm.get.room.playerList[name].y,tfm.get.room.playerList[name].y - y
  93.     Rsq = mice[name].weapon[2]^2
  94.     distance = pxi*pxi + pyi*pyi
  95.     if distance < Rsq then
  96.         --if mice[name].shoots > 0 then
  97.             tfm.exec.displayParticle(mice[name].weapon[3],x,y,0,0,0,0,nil)
  98.             mice[name].shoots = mice[name].shoots - 1
  99.             for i=1,38 do
  100.                 x4 = sp[i].x+(sp[i].w/2)
  101.                 x5 = sp[i].x-(sp[i].w/2)
  102.                 y4 = sp[i].y+(sp[i].h/2)
  103.                 y5 = sp[i].y-(sp[i].h/2)
  104.                 if x < x4 and x > x5 then
  105.                     if y < y4 and y > y5 then
  106.                         sp[i].v = sp[i].v - 10
  107.                         ui.addTextArea(i, sp[i].v.."%", nil, sp[i].x-15, sp[i].y-10, nil, nil, 0, 0, 0, false)
  108.                         if sp[i].v < 1 then
  109.                             tfm.exec.removePhysicObject (sp[i].ids)
  110.                             ui.addTextArea(i, "0%", nil, sp[i].x-15, sp[i].y-10, nil, nil, 0, 0, 0, false)
  111.                             sp[i].v = 0
  112.                         end
  113.                     end
  114.                 end
  115.             end
  116.         --end
  117.     end
  118.     for mouse, player in pairs(tfm.get.room.playerList) do
  119.         if pythag(x, y, player.x, player.y, 15) then
  120.             if mouse ~= name then
  121.                 print('hey')
  122.                 tfm.exec.displayParticle(mice[name].weapon[3],x,y,0,0,0,0,nil)
  123.             end
  124.         end
  125.     end
  126. end
  127.  
  128. function pythag(x1,y1,x2,y2,r)
  129.     local x=x2-x1
  130.     local y=y2-y1
  131.     local r=r+r
  132.     return x*x+y*y<r*r
  133. end
  134.  
  135. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement