Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local map = '<C><P Ca="" L="2000" /><Z><S><S P="0,0,0.3,0.2,-40,0,0,0" L="218" o="8c303b" X="320" Y="353" T="12" H="32" /><S P="0,0,0.3,0.2,0,0,0,0" L="319" o="8c303b" X="160" Y="388" T="12" H="29" /><S P="0,0,0.3,0.2,,0,0,0" L="218" o="8c303b" H="32" Y="295" T="12" X="84" /><S L="218" o="8c303b" X="267" H="32" Y="229" T="12" P="0,0,0.3,0.2,-40,0,0,0" /><S L="800" o="afc1cb" X="15" H="29" Y="0" T="12" P="0,0,0,0.2,90,0,0,0" /><S L="145" o="8c303b" H="32" X="492" Y="208" T="12" P="0,0,0.3,0.2,-45,0,0,0" /><S P="0,0,0,0.2,,0,0,0" L="2100" o="afc1cb" H="29" Y="10" T="12" X="1050" /><S L="399" o="20941f" H="32" X="1072" Y="385" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S L="211" o="20941f" X="1333" H="32" Y="315" T="12" P="0,0,0.3,0.2,-45,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="399" o="20941f" X="939" Y="385" T="12" H="32" /><S L="211" o="20941f" H="32" X="751" Y="231" T="12" P="0,0,0.3,0.2,-45,0,0,0" /><S L="82" H="10" X="1919" Y="370" T="2" P="0,0,0,0.6,0,0,0,0" /><S L="211" o="20941f" X="982" H="32" Y="237" T="12" P="0,0,0.3,0.2,30,0,0,0" /><S P="0,0,0,0.2,90,0,0,0" L="800" o="afc1cb" H="29" Y="0" T="12" X="1985" /><S L="258" o="1070a1" H="32" X="1841" Y="384" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0.3,0.2,45,0,0,0" L="200" o="1070a1" X="1763" Y="224" T="12" H="32" /><S L="120" o="1070a1" X="1536" H="32" Y="321" T="12" P="0,0,0.3,0.2,45,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="270" o="1070a1" X="1497" Y="128" T="12" H="32" /><S L="270" o="20941f" X="1106" H="32" Y="128" T="12" P="0,0,0.3,0.2,0,0,0,0" /></S><D><DS Y="362" X="38" /></D><O /></Z></C>'
- local mice = {}
- local attack,deff,healer,leader = 1,2,3,4,5
- local red = {}
- local blue = {}
- function table_foreach(tab, func) for i,v in pairs(tab) do func(i,v) end end
- function main()
- tfm.exec.disableAutoShaman(true)
- tfm.exec.disableAutoNewGame(true)
- tfm.exec.disableAutoTimeLeft(true)
- tfm.exec.newGame(map)
- table_foreach(tfm.get.room.playerList, _G["eventNewPlayer"])
- started = false
- end
- _G["eventNewPlayer"]=function(name)
- if not mice[name] then
- mice[name] = {
- class = attack,
- hp = 100,
- attack_bonus = math.random(5,10),
- deff_bonus = math.random(3, 5),
- cur_bonus = 0,
- attack_countdown = 2.5,
- cur_countdown = 2.5
- }
- end
- tfm.exec.bindKeyboard(name, string.byte(" "), true, true)
- end
- function eventNewGame()
- blue = {}
- red = {}
- started = true
- for name,_ in pairs(tfm.get.room.playerList) do
- setUp(name)
- end
- makeTeams()
- end
- function setUp(name)
- mice[name].attack_countdown = 2.5
- mice[name].cur_countdown = 2.5
- if mice[name].class == 1 then
- mice[name].attack_bonus = math.random(10, 15)
- mice[name].deff_bonus = math.random(4, 6)
- elseif mice[name].class == 2 then
- mice[name].attack_bonus = math.random(4, 6)
- mice[name].deff_bonus = math.random(10, 15)
- elseif mice[name].class == 3 then
- mice[name].cur_bonus = math.random(7,14)
- mice[name].attack_bonus = 0
- mice[name].deff_bonus = 0
- elseif mice[name].class == 4 then
- mice[name].attack_bonus = math.random(13, 17)
- mice[name].deff_bonus = math.random(3, 5)
- end
- end
- function wizzard(wizzard_type, x, y, mice1, mice2)
- player = tfm.get.room.playerList[mice2]
- if table.find(red, mice1) then
- value = blue
- elseif table.find(blue, mice1) then
- value = red
- end
- if wizzard_type == 1 and mice[mice1].attack_countdown <= 0 and table.find(value, mice2) then
- op = mice[mice1].attack_bonus - mice[mice2].deff_bonus
- mice[mice2].hp = mice[mice2].hp - op
- setUp(mice1)
- print(mice2.." - "..mice[mice2].hp)
- particles(30, player.x, player.y)
- if mice[mice2].hp <= 0 then
- mice[mice2].hp = 0
- tfm.exec.killPlayer(mice2)
- end
- elseif wizzard_type == 2 and mice[mice1].cur_countdown <= 0 and table.find(value, mice2) then
- if mice[mice2].hp <= 100 then
- mice[mice2].hp = mice[mice2].hp + mice[mice1].cur_bonus
- particles(35, player.x, player.y)
- setUp(mice1)
- else
- mice[mice2].hp = 100
- end
- end
- end
- function particles(id, x, y)
- for i=1,3 do
- tfm.exec.displayParticle(id, x, y, math.random(-3,3), -9, 0,math.random(8,15)/10, nil)
- end
- end
- function eventLoop()
- for name,_ in pairs(tfm.get.room.playerList) do
- if started then
- ui.addTextArea(0, "<r><b>HP</b>: "..mice[name].hp.."<n> | <bv><b>Attack B</b>: "..mice[name].attack_bonus.."</b><n> | <ch><b>Deff B</b>: "..mice[name].deff_bonus.."<n> | <v><b>Cur B</b>: "..mice[name].cur_bonus, name, 400, 380, 395, 20, 0x191919, 0x191919, 0.6, true)
- mice[name].attack_countdown = mice[name].attack_countdown - 0.5
- mice[name].cur_countdown = mice[name].cur_countdown - 0.5
- end
- end
- end
- function eventKeyboard(name, key, down, x, y)
- if key == string.byte(" ") then
- for playerName, player in pairs(tfm.get.room.playerList) do
- if pythag(x, y, player.x, player.y, 25) and name ~= playerName and not player.isDead then
- if mice[name].class == 1 or mice[name].class == 2 or mice[name].class == 4 then
- wizzard(1, player.x, player.y, name, playerName)
- elseif mice[name].class == 3 then
- wizzard(2, player.x, player.y, name, playerName)
- end
- end
- end
- end
- end
- function makeTeams()
- local playerList={}
- for name, player in pairs(tfm.get.room.playerList) do
- table.insert(playerList, name)
- end
- for i=1,#playerList,1 do
- local index = math.random(#playerList)
- local name = playerList[index]
- if i%2==0 then
- table.insert(red, name)
- tfm.exec.setNameColor(name, 0x8c303b)
- else
- table.insert(blue, name)
- tfm.exec.setNameColor(name, 0x1070a1)
- end
- table.remove(playerList,index)
- end
- end
- function table.find(tab, elmt)
- for key, val in pairs(tab) do
- if val==elmt then return true, key end
- end
- return false
- end
- function pythag(x1,y1,x2,y2,r)
- local x=x2-x1
- local y=y2-y1
- local r=r+r
- return x*x+y*y<r*r
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement