Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- text={}
- lang={}
- lang.en={hero="Hero",villain="Villain",portal="Sorry, you're putting the portal in the wrong place!",full="This team is full of players!"}
- lang.ar={hero="بطل",villain="شرير",portal="عذرًا، أنت تضع البوابة في المكان الخطأ!",full="هذا الفريق ممتلئ باللاعبين!"}
- blue,red=false,false
- play=false
- started=false
- portal=0
- data={}
- p={}
- toDespawn={}
- portals={}
- ob={}
- for _,v in pairs ({'disableAutoScore','disableAfkDeath','disablePhysicalConsumables','disableAutoNewGame','disableDebugCommand','disableMinimalistMode','disableMortCommand','disableAutoTimeLeft','disableAutoShaman'}) do
- tfm.exec[v](true)
- end
- teams={
- hero={title="Hero",super="",members={},inRoomMembers={},isWinner=false,color=0x2ED748,mn=0,ir=0,ig=0,hp=100,x=692,id=10,id2=9},
- villain={title="Villain",super="",members={},inRoomMembers={},isWinner=false,color=0xE6254E,mn=0,ir=0,ig=0,hp=100,x=10,id=7,id2=6}
- }
- maps={
- {code="@7442984",category="cheese",x={hero=780,villain=20},y={hero=205,villain=205}},
- {code="@7443039",category="hole",x={hero=770,villain=30},y={hero=104,villain=104}},
- {code="@7443691",category="hole",x={hero=580,villain=214},y={hero=174,villain=174}},
- {code="@7445773",category="hole",x={hero=700,villain=120},y={hero=175,villain=175}}
- }
- function table.random(list)
- return list[math.random(#list)]
- end
- function table.indexes(list)
- local out = {}
- for index in next, list do
- out[#out + 1] = index
- end
- return out
- end
- function math.rotate(x,y,centerx, centery, ang)
- ang = ang/(180/math.pi)
- return centerx + (x - centerx) * math.cos(ang) - (y - centery) * math.sin(ang) , centery + (x - centerx) * math.sin(ang) + (y - centery) * math.cos(ang)
- end
- function setLang(n)
- text[n]=lang[tfm.get.room.playerList[n].community] or lang.en
- end
- function newMap()
- map={}
- i=0
- for _,v in pairs(maps) do
- i=i+1
- map[i]=v.code
- end
- tfm.exec.newGame(map[math.random(#map)])
- end
- function newGame()
- if play then
- newMap()
- else
- tfm.exec.newGame("@6984945")
- end
- end
- function toStart()
- local i=0
- for n,p in pairs(tfm.get.room.playerList) do
- if not p.isDead then
- i=i+1
- end
- end
- if i==0 then
- teams["hero"].hp=100
- teams["villain"].hp=100
- newGame()
- end
- end
- function Win(team)
- teams[team].isWinner=true
- for n in pairs(teams[team].members) do
- p[n].isHolding=false
- for i,v in pairs(maps) do
- if v.code==map then
- if v.category=="cheese" then
- tfm.exec.playerVictory(n)
- else
- tfm.exec.giveCheese(n)
- end
- end
- end
- end
- removeBar(nil)
- end
- function Teams(n)
- ui.addTextArea(0, "", n, 309, 114, 182, 172, 0x47707d, 0x000000, 1, true)
- ui.addTextArea(1, "", n, 310, 115, 180, 170, 0x193542, 0x47707d, 1, true)
- ui.addTextArea(2, "<p align='center'><b><a href='event:hero'><font size='15' color='#2ED748'>"..text[n].hero, n, 343, 138, 114, 27, 0x38516b, 0x47707d, 1, true)
- ui.addTextArea(4, "<p align='center'><b><a href='event:villain'><font size='15' color='#E6254E'>"..text[n].villain, n, 343, 235, 114, 27, 0x38516b, 0x47707d, 1, true)
- end
- function HPBar(n)
- ui.addTextArea(5, "", n, 8, 27, 104, 29, 0x324650, 0x324650, 1, true)
- if teams["villain"].hp > 0 and not teams["villain"].isWinner then
- ui.addTextArea(6, "", n, 10, 29, teams["villain"].hp, 25, 0xE6254E, 0xE6254E, 1, true)
- end
- ui.addTextArea(7, teams["villain"].hp < 0 and "<p align='center'><b><font size='15'>0%" or "<p align='center'><b><font size='15'>"..teams["villain"].hp.."%", n, 10, 29, 100, 25, 0x324650, 0x000000, 0, true)
- ui.addTextArea(8, "", n, 690, 27, 104, 29, 0x324650, 0x324650, 1, true)
- if teams["hero"].hp > 0 and not teams["hero"].isWinner then
- ui.addTextArea(9, "", n, 692, 29, teams["hero"].hp, 25, 0x2ED748, 0x2ED748, 1, true)
- end
- ui.addTextArea(10, teams["hero"].hp < 0 and "<p align='center'><b><font size='15'>0%" or "<p align='center'><b><font size='15'>"..teams["hero"].hp.."%", n, 692, 29, 100, 29, 0x324650, 0x000000, 0, true)
- end
- function removeBar(n)
- for i=5,10 do
- ui.removeTextArea(i,n)
- end
- end
- function eventNewPlayer(n)
- setLang(n)
- if not data[n] then
- data[n]={team={false,"None",""},angle=90}
- end
- p[n]={right=false,isHolding=false,timetoshoot=os.time(),power=0,HPpower=0,objectid={0,0,0},chance=1}
- if not data[n].team[1] then
- Teams(n)
- else
- teams[data[n].team[3]].ir=teams[data[n].team[3]].ir+1
- teams[data[n].team[3]]["inRoomMembers"][n]=true
- end
- for k=0,100 do
- system.bindKeyboard(n,k,true,true)
- end
- system.bindKeyboard(n,32,false,true)
- system.bindMouse(n,true)
- if play and teams["hero"].hp > 0 and teams["villain"].hp > 0 then
- HPBar(n)
- end
- end
- function eventPlayerLeft(n)
- if data[n].team[1] then
- teams[data[n].team[3]].ir=teams[data[n].team[3]].ir-1
- teams[data[n].team[3]]["inRoomMembers"][n]=nil
- end
- end
- function eventPlayerDied(n)
- p[n].isHolding=false
- if play then
- if data[n].team[1] then
- teams[data[n].team[3]].hp=teams[data[n].team[3]].hp-math.ceil(100/teams[data[n].team[3]].ig)
- if not teams[data[n].team[3]].isWinner and teams[data[n].team[3]].hp <= 0 then
- HPBar(nil)
- end
- end
- local t={hero=0,villain=0}
- for n in pairs(tfm.get.room.playerList) do
- if not tfm.get.room.playerList[n].isDead and data[n].team[1] then
- t[data[n].team[3]]=t[data[n].team[3]]+1
- end
- end
- if t["hero"]==0 then
- Win("villain")
- tfm.exec.setGameTime(15)
- elseif t["villain"]==0 then
- Win("hero")
- tfm.exec.setGameTime(15)
- end
- end
- toStart()
- end
- function eventPlayerWon(n)
- p[n].isHolding=false
- toStart()
- end
- function eventPlayerGetCheese(n)
- for i,v in pairs(maps) do
- if v.code==map then
- if v.category=="cheese" and teams[data[n].team[3]].isWinner then
- tfm.exec.playerVictory(n)
- end
- end
- end
- end
- function eventNewGame()
- blue,red=false,false
- portal=0
- tfm.exec.setGameTime(180)
- map=tfm.get.room.currentMap
- started=false
- for o,i in pairs(teams) do
- i.hp=100
- i.isWinner=false
- i.ig=0
- end
- for i=5,10 do
- ui.removeTextArea(i,nil)
- end
- if play then
- teams["hero"].super = table.random(table.indexes(teams["hero"].members))
- teams["villain"].super = table.random(table.indexes(teams["villain"].members))
- HPBar(nil)
- for n in pairs(tfm.get.room.playerList) do
- p[n].isHolding=false
- p[n].power=0
- p[n].HPpower=0
- p[n].chance=1
- if data[n].team[1] then
- teams[data[n].team[3]].ig=teams[data[n].team[3]].ig+1
- tfm.exec.setNameColor(n,teams[data[n].team[3]].color)
- tfm.exec.setNameColor(teams["villain"].super,0x0522AA)
- tfm.exec.setNameColor(teams["hero"].super,0x0522AA)
- for i,v in pairs(maps) do
- if v.code==map then
- tfm.exec.movePlayer(n,v.x[data[n].team[3]],v.y[data[n].team[3]])
- end
- end
- else
- tfm.exec.killPlayer(n)
- end
- end
- end
- end
- function eventLoop(time,remaining)
- if teams["hero"].ir > 0 and teams["villain"].ir > 0 then
- play=true
- else
- play=false
- end
- for i,v in pairs(maps) do
- if v.code==map and time >= 3000 and not started then
- started=true
- end
- end
- if play and map=="@6984945" then
- newMap()
- end
- if remaining <=0 then
- teams["hero"].hp=100
- teams["villain"].hp=100
- newGame()
- end
- for i,cannon in ipairs(toDespawn) do
- if cannon[1] <= os.time()-1500 then
- tfm.exec.moveObject(cannon[2],2000,2000)
- tfm.exec.removeObject(cannon[2])
- table.remove(toDespawn,i)
- end
- end
- for i,portal in ipairs(portals) do
- if portal[1] <= os.time()-5000 then
- tfm.exec.addShamanObject(26,1500,1500)
- tfm.exec.addShamanObject(27,1500,1500)
- table.remove(portals,i)
- end
- end
- for n,k in pairs(tfm.get.room.playerList) do
- if data[n].team[3]=="hero" then
- if (k.x < 380 and k.x > 15) and started and play then
- for i,v in pairs(maps) do
- tfm.exec.movePlayer(n,v.x[data[n].team[3]],v.y[data[n].team[3]])
- end
- end
- end
- if p[n].isHolding then
- p[n].power=p[n].power+15
- p[n].HPpower=p[n].power/30
- local particles = {1,2,9,11,13}
- for i = 1, 4 do
- tfm.exec.displayParticle(particles[math.random(#particles)], k.x, k.y - math.random(5, 15), math.random(-2, 2), math.random(-2, 2))
- end
- end
- if data[n].team[1] and teams[data[n].team[3]].hp <= 0 and not teams[data[n].team[3]].isWinner then
- tfm.exec.killPlayer(n)
- removeBar(nil)
- end
- for v in pairs(tfm.get.room.playerList) do
- local i=p[v].objectid[1]
- local o=tfm.get.room.objectList[i]
- if o and p[n].objectid[1]~=i and (k.x-o.x)^2 + (k.y-o.y)^2 <= 55^2 and data[n].team[3]~=data[v].team[3] and not ob[i] then
- if data[n].team[1] and not ob[i] then
- teams[data[n].team[3]].hp=teams[data[n].team[3]].hp-math.floor(p[v].HPpower)
- ob[i]=true
- HPBar(nil)
- end
- end
- end
- end
- end
- --[[X ~> 88
- C ~> 67]]
- function eventKeyboard(n,k,d,x,y)
- if k==2 then
- p[n].right=true
- elseif k==0 then
- p[n].right=false
- elseif k==32 then--and not tfm.get.room.playerList[n].isDead and started and play and not teams[data[n].team[3]].isWinner and n~=teams["hero"].super then
- if not d then
- if p[n].power > 10 then
- local dir, angle = p[n].right and 1 or -1, data[n].angle-90
- p[n].objectid[1]=tfm.exec.addShamanObject(17,x+15*dir,y+3,angle*dir,0,0)
- tfm.exec.moveObject(p[n].objectid[1],0,0,true,p[n].power*math.cos(math.rad(angle))*dir,p[n].power*math.sin(math.rad(angle)),true)
- table.insert(toDespawn,{os.time(),p[n].objectid[1]})
- end
- end
- p[n].power=0
- p[n].isHolding=d
- elseif k==88 and started and play and (data[n].angle ~= 120) and not tfm.get.room.playerList[n].isDead and n~=teams["hero"].super then
- data[n].angle=data[n].angle+5
- local dir,angle=p[n].right and -1 or 1,180-data[n].angle
- tfm.exec.addShamanObject(0,x,y,angle*dir)
- elseif k==67 and started and play and (data[n].angle ~= 45) and not tfm.get.room.playerList[n].isDead and n~=teams["hero"].super then
- data[n].angle=data[n].angle-5
- local dir,angle=p[n].right and -1 or 1,180-data[n].angle
- tfm.exec.addShamanObject(0,x,y,angle*dir)
- end
- end
- function eventMouse(n,x,y)
- if n==teams["villain"].super and started and play and not teams["villain"].isWinner and not tfm.get.room.playerList[n].isDead then
- if (x < 380 and x > 15) and (y > 40 and y < 385) and p[n].chance > 0 and not tfm.get.room.objectList[26] and not blue then
- p[n].objectid[1]=tfm.exec.addShamanObject(26,x,y)
- blue=true
- portal=portal+1
- elseif (x > 420 and x < 785) and (y > 40 and y < 385) and p[n].chance > 0 and not tfm.get.room.objectList[27] and not red then
- p[n].objectid[2]=tfm.exec.addShamanObject(27,x,y)
- red=true
- portal=portal+1
- else
- tfm.exec.chatMessage(text[n].portal,n)
- end
- if portal==2 then
- p[n].chance=0
- table.insert(portals,{os.time(),p[n].objectid[1]})
- table.insert(portals,{os.time(),p[n].objectid[2]})
- end
- elseif n==teams["hero"].super and started and play and p[n].timetoshoot<os.time()-2000 and not teams["hero"].isWinner and not tfm.get.room.playerList[n].isDead then
- p[n].timetoshoot=os.time()
- p[n].HPpower=2
- local x0, y0 = tfm.get.room.playerList[n].x, tfm.get.room.playerList[n].y
- local d = math.sqrt((x-x0)^2 + (y-y0)^2)
- local angle = -math.deg(math.atan2(x0-x,y0-y))
- local x1, y1 = math.rotate(x0, y0 - 50,x0,y0,angle)
- p[n].objectid[1]=tfm.exec.addShamanObject(17,x1,y1,angle,0,0,false)
- tfm.exec.moveObject(p[n].objectid[1],0,0,true,(30/d)*(x-x0),(80/d)*(y-y0),true)
- table.insert(toDespawn,{os.time(),p[n].objectid[1]})
- end
- end
- team=""
- function eventTextAreaCallback(id,n,cb)
- if teams[cb] then
- if cb=="hero" then
- team="villain"
- else
- team="hero"
- end
- if teams[cb].ir-2==teams[team].ir then
- tfm.exec.chatMessage(text[n].full,n)
- else
- data[n].team[1]=true
- data[n].team[2]=teams[cb].title
- data[n].team[3]=cb
- teams[cb].mn=teams[cb].mn+1
- teams[cb].ir=teams[cb].ir+1
- teams[cb]["members"][n]=true
- teams[cb]["inRoomMembers"][n]=true
- for i=0,4 do
- ui.removeTextArea(i,n)
- end
- end
- end
- end
- local c={"map","angle"}
- function eventChatCommand(n,cmd)
- local c={}
- for i in cmd:gmatch('[^%s]+') do
- table.insert(c,i)
- end
- c[1]=c[1]:lower()
- if c[1]=="map" and n=="Bodykudo#0000" then
- newGame()
- elseif c[1]=="angle" then
- c[2]=tonumber(c[2])
- if c[2] >= 45 and c[2] <= 120 and started and play and not tfm.get.room.playerList[n].isDead then
- data[n].angle=c[2]
- local x,y,dir,angle=tfm.get.room.playerList[n].x,tfm.get.room.playerList[n].y,p[n].right and -1 or 1,180-data[n].angle
- tfm.exec.addShamanObject(0,x,y,angle*dir)
- end
- end
- end
- for i=1,#c do
- system.disableChatCommandDisplay(c[i],true)
- end
- newGame()
- table.foreach(tfm.get.room.playerList,eventNewPlayer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement