Advertisement
Guest User

Untitled

a guest
May 27th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.65 KB | None | 0 0
  1. text={}
  2. lang={}
  3. lang.en={hero="Hero",villain="Villain",portal="Sorry, you're putting the portal in the wrong place!",full="This team is full of players!"}
  4. lang.ar={hero="بطل",villain="شرير",portal="عذرًا، أنت تضع البوابة في المكان الخطأ!",full="هذا الفريق ممتلئ باللاعبين!"}
  5.  
  6. blue,red=false,false
  7. play=false
  8. started=false
  9. portal=0
  10. data={}
  11. p={}
  12. toDespawn={}
  13. portals={}
  14. ob={}
  15.  
  16. for _,v in pairs ({'disableAutoScore','disableAfkDeath','disablePhysicalConsumables','disableAutoNewGame','disableDebugCommand','disableMinimalistMode','disableMortCommand','disableAutoTimeLeft','disableAutoShaman'}) do
  17. tfm.exec[v](true)
  18. end
  19.  
  20. teams={
  21. hero={title="Hero",super="",members={},inRoomMembers={},isWinner=false,color=0x2ED748,mn=0,ir=0,ig=0,hp=100,x=692,id=10,id2=9},
  22. villain={title="Villain",super="",members={},inRoomMembers={},isWinner=false,color=0xE6254E,mn=0,ir=0,ig=0,hp=100,x=10,id=7,id2=6}
  23. }
  24.  
  25. maps={
  26. {code="@7442984",category="cheese",x={hero=780,villain=20},y={hero=205,villain=205}},
  27. {code="@7443039",category="hole",x={hero=770,villain=30},y={hero=104,villain=104}},
  28. {code="@7443691",category="hole",x={hero=580,villain=214},y={hero=174,villain=174}},
  29. {code="@7445773",category="hole",x={hero=700,villain=120},y={hero=175,villain=175}}
  30. }
  31.  
  32. function table.random(list)
  33. return list[math.random(#list)]
  34. end
  35.  
  36. function table.indexes(list)
  37. local out = {}
  38. for index in next, list do
  39. out[#out + 1] = index
  40. end
  41. return out
  42. end
  43.  
  44. function math.rotate(x,y,centerx, centery, ang)
  45. ang = ang/(180/math.pi)
  46. return centerx + (x - centerx) * math.cos(ang) - (y - centery) * math.sin(ang) , centery + (x - centerx) * math.sin(ang) + (y - centery) * math.cos(ang)
  47. end
  48.  
  49.  
  50. function setLang(n)
  51. text[n]=lang[tfm.get.room.playerList[n].community] or lang.en
  52. end
  53.  
  54. function newMap()
  55. map={}
  56. i=0
  57. for _,v in pairs(maps) do
  58. i=i+1
  59. map[i]=v.code
  60. end
  61. tfm.exec.newGame(map[math.random(#map)])
  62. end
  63.  
  64. function newGame()
  65. if play then
  66. newMap()
  67. else
  68. tfm.exec.newGame("@6984945")
  69. end
  70. end
  71.  
  72. function toStart()
  73. local i=0
  74. for n,p in pairs(tfm.get.room.playerList) do
  75. if not p.isDead then
  76. i=i+1
  77. end
  78. end
  79. if i==0 then
  80. teams["hero"].hp=100
  81. teams["villain"].hp=100
  82. newGame()
  83. end
  84. end
  85.  
  86. function Win(team)
  87. teams[team].isWinner=true
  88. for n in pairs(teams[team].members) do
  89. p[n].isHolding=false
  90. for i,v in pairs(maps) do
  91. if v.code==map then
  92. if v.category=="cheese" then
  93. tfm.exec.playerVictory(n)
  94. else
  95. tfm.exec.giveCheese(n)
  96. end
  97. end
  98. end
  99. end
  100. removeBar(nil)
  101. end
  102.  
  103. function Teams(n)
  104. ui.addTextArea(0, "", n, 309, 114, 182, 172, 0x47707d, 0x000000, 1, true)
  105. ui.addTextArea(1, "", n, 310, 115, 180, 170, 0x193542, 0x47707d, 1, true)
  106. 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)
  107. 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)
  108. end
  109.  
  110. function HPBar(n)
  111. ui.addTextArea(5, "", n, 8, 27, 104, 29, 0x324650, 0x324650, 1, true)
  112. if teams["villain"].hp > 0 and not teams["villain"].isWinner then
  113. ui.addTextArea(6, "", n, 10, 29, teams["villain"].hp, 25, 0xE6254E, 0xE6254E, 1, true)
  114. end
  115. 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)
  116. ui.addTextArea(8, "", n, 690, 27, 104, 29, 0x324650, 0x324650, 1, true)
  117. if teams["hero"].hp > 0 and not teams["hero"].isWinner then
  118. ui.addTextArea(9, "", n, 692, 29, teams["hero"].hp, 25, 0x2ED748, 0x2ED748, 1, true)
  119. end
  120. 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)
  121. end
  122.  
  123. function removeBar(n)
  124. for i=5,10 do
  125. ui.removeTextArea(i,n)
  126. end
  127. end
  128.  
  129. function eventNewPlayer(n)
  130. setLang(n)
  131. if not data[n] then
  132. data[n]={team={false,"None",""},angle=90}
  133. end
  134. p[n]={right=false,isHolding=false,timetoshoot=os.time(),power=0,HPpower=0,objectid={0,0,0},chance=1}
  135. if not data[n].team[1] then
  136. Teams(n)
  137. else
  138. teams[data[n].team[3]].ir=teams[data[n].team[3]].ir+1
  139. teams[data[n].team[3]]["inRoomMembers"][n]=true
  140. end
  141. for k=0,100 do
  142. system.bindKeyboard(n,k,true,true)
  143. end
  144. system.bindKeyboard(n,32,false,true)
  145. system.bindMouse(n,true)
  146. if play and teams["hero"].hp > 0 and teams["villain"].hp > 0 then
  147. HPBar(n)
  148. end
  149. end
  150.  
  151. function eventPlayerLeft(n)
  152. if data[n].team[1] then
  153. teams[data[n].team[3]].ir=teams[data[n].team[3]].ir-1
  154. teams[data[n].team[3]]["inRoomMembers"][n]=nil
  155. end
  156. end
  157.  
  158. function eventPlayerDied(n)
  159. p[n].isHolding=false
  160. if play then
  161. if data[n].team[1] then
  162. teams[data[n].team[3]].hp=teams[data[n].team[3]].hp-math.ceil(100/teams[data[n].team[3]].ig)
  163. if not teams[data[n].team[3]].isWinner and teams[data[n].team[3]].hp <= 0 then
  164. HPBar(nil)
  165. end
  166. end
  167. local t={hero=0,villain=0}
  168. for n in pairs(tfm.get.room.playerList) do
  169. if not tfm.get.room.playerList[n].isDead and data[n].team[1] then
  170. t[data[n].team[3]]=t[data[n].team[3]]+1
  171. end
  172. end
  173. if t["hero"]==0 then
  174. Win("villain")
  175. tfm.exec.setGameTime(15)
  176. elseif t["villain"]==0 then
  177. Win("hero")
  178. tfm.exec.setGameTime(15)
  179. end
  180. end
  181. toStart()
  182. end
  183.  
  184. function eventPlayerWon(n)
  185. p[n].isHolding=false
  186. toStart()
  187. end
  188.  
  189. function eventPlayerGetCheese(n)
  190. for i,v in pairs(maps) do
  191. if v.code==map then
  192. if v.category=="cheese" and teams[data[n].team[3]].isWinner then
  193. tfm.exec.playerVictory(n)
  194. end
  195. end
  196. end
  197. end
  198.  
  199. function eventNewGame()
  200. blue,red=false,false
  201. portal=0
  202. tfm.exec.setGameTime(180)
  203. map=tfm.get.room.currentMap
  204. started=false
  205. for o,i in pairs(teams) do
  206. i.hp=100
  207. i.isWinner=false
  208. i.ig=0
  209. end
  210. for i=5,10 do
  211. ui.removeTextArea(i,nil)
  212. end
  213. if play then
  214. teams["hero"].super = table.random(table.indexes(teams["hero"].members))
  215. teams["villain"].super = table.random(table.indexes(teams["villain"].members))
  216. HPBar(nil)
  217. for n in pairs(tfm.get.room.playerList) do
  218. p[n].isHolding=false
  219. p[n].power=0
  220. p[n].HPpower=0
  221. p[n].chance=1
  222. if data[n].team[1] then
  223. teams[data[n].team[3]].ig=teams[data[n].team[3]].ig+1
  224. tfm.exec.setNameColor(n,teams[data[n].team[3]].color)
  225. tfm.exec.setNameColor(teams["villain"].super,0x0522AA)
  226. tfm.exec.setNameColor(teams["hero"].super,0x0522AA)
  227. for i,v in pairs(maps) do
  228. if v.code==map then
  229. tfm.exec.movePlayer(n,v.x[data[n].team[3]],v.y[data[n].team[3]])
  230. end
  231. end
  232. else
  233. tfm.exec.killPlayer(n)
  234. end
  235. end
  236. end
  237. end
  238.  
  239. function eventLoop(time,remaining)
  240. if teams["hero"].ir > 0 and teams["villain"].ir > 0 then
  241. play=true
  242. else
  243. play=false
  244. end
  245. for i,v in pairs(maps) do
  246. if v.code==map and time >= 3000 and not started then
  247. started=true
  248. end
  249. end
  250. if play and map=="@6984945" then
  251. newMap()
  252. end
  253. if remaining <=0 then
  254. teams["hero"].hp=100
  255. teams["villain"].hp=100
  256. newGame()
  257. end
  258. for i,cannon in ipairs(toDespawn) do
  259. if cannon[1] <= os.time()-1500 then
  260. tfm.exec.moveObject(cannon[2],2000,2000)
  261. tfm.exec.removeObject(cannon[2])
  262. table.remove(toDespawn,i)
  263. end
  264. end
  265. for i,portal in ipairs(portals) do
  266. if portal[1] <= os.time()-5000 then
  267. tfm.exec.addShamanObject(26,1500,1500)
  268. tfm.exec.addShamanObject(27,1500,1500)
  269. table.remove(portals,i)
  270. end
  271. end
  272. for n,k in pairs(tfm.get.room.playerList) do
  273. if data[n].team[3]=="hero" then
  274. if (k.x < 380 and k.x > 15) and started and play then
  275. for i,v in pairs(maps) do
  276. tfm.exec.movePlayer(n,v.x[data[n].team[3]],v.y[data[n].team[3]])
  277. end
  278. end
  279. end
  280. if p[n].isHolding then
  281. p[n].power=p[n].power+15
  282. p[n].HPpower=p[n].power/30
  283. local particles = {1,2,9,11,13}
  284. for i = 1, 4 do
  285. tfm.exec.displayParticle(particles[math.random(#particles)], k.x, k.y - math.random(5, 15), math.random(-2, 2), math.random(-2, 2))
  286. end
  287. end
  288. if data[n].team[1] and teams[data[n].team[3]].hp <= 0 and not teams[data[n].team[3]].isWinner then
  289. tfm.exec.killPlayer(n)
  290. removeBar(nil)
  291. end
  292. for v in pairs(tfm.get.room.playerList) do
  293. local i=p[v].objectid[1]
  294. local o=tfm.get.room.objectList[i]
  295. 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
  296. if data[n].team[1] and not ob[i] then
  297. teams[data[n].team[3]].hp=teams[data[n].team[3]].hp-math.floor(p[v].HPpower)
  298. ob[i]=true
  299. HPBar(nil)
  300. end
  301. end
  302. end
  303. end
  304. end
  305.  
  306. --[[X ~> 88
  307. C ~> 67]]
  308. function eventKeyboard(n,k,d,x,y)
  309. if k==2 then
  310. p[n].right=true
  311. elseif k==0 then
  312. p[n].right=false
  313. 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
  314. if not d then
  315. if p[n].power > 10 then
  316. local dir, angle = p[n].right and 1 or -1, data[n].angle-90
  317. p[n].objectid[1]=tfm.exec.addShamanObject(17,x+15*dir,y+3,angle*dir,0,0)
  318. 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)
  319. table.insert(toDespawn,{os.time(),p[n].objectid[1]})
  320. end
  321. end
  322. p[n].power=0
  323. p[n].isHolding=d
  324. 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
  325. data[n].angle=data[n].angle+5
  326. local dir,angle=p[n].right and -1 or 1,180-data[n].angle
  327. tfm.exec.addShamanObject(0,x,y,angle*dir)
  328. 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
  329. data[n].angle=data[n].angle-5
  330. local dir,angle=p[n].right and -1 or 1,180-data[n].angle
  331. tfm.exec.addShamanObject(0,x,y,angle*dir)
  332. end
  333. end
  334.  
  335.  
  336. function eventMouse(n,x,y)
  337. if n==teams["villain"].super and started and play and not teams["villain"].isWinner and not tfm.get.room.playerList[n].isDead then
  338. 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
  339. p[n].objectid[1]=tfm.exec.addShamanObject(26,x,y)
  340. blue=true
  341. portal=portal+1
  342. 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
  343. p[n].objectid[2]=tfm.exec.addShamanObject(27,x,y)
  344. red=true
  345. portal=portal+1
  346. else
  347. tfm.exec.chatMessage(text[n].portal,n)
  348. end
  349. if portal==2 then
  350. p[n].chance=0
  351. table.insert(portals,{os.time(),p[n].objectid[1]})
  352. table.insert(portals,{os.time(),p[n].objectid[2]})
  353. end
  354. 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
  355. p[n].timetoshoot=os.time()
  356. p[n].HPpower=2
  357. local x0, y0 = tfm.get.room.playerList[n].x, tfm.get.room.playerList[n].y
  358. local d = math.sqrt((x-x0)^2 + (y-y0)^2)
  359. local angle = -math.deg(math.atan2(x0-x,y0-y))
  360. local x1, y1 = math.rotate(x0, y0 - 50,x0,y0,angle)
  361. p[n].objectid[1]=tfm.exec.addShamanObject(17,x1,y1,angle,0,0,false)
  362. tfm.exec.moveObject(p[n].objectid[1],0,0,true,(30/d)*(x-x0),(80/d)*(y-y0),true)
  363. table.insert(toDespawn,{os.time(),p[n].objectid[1]})
  364. end
  365. end
  366.  
  367. team=""
  368. function eventTextAreaCallback(id,n,cb)
  369. if teams[cb] then
  370. if cb=="hero" then
  371. team="villain"
  372. else
  373. team="hero"
  374. end
  375. if teams[cb].ir-2==teams[team].ir then
  376. tfm.exec.chatMessage(text[n].full,n)
  377. else
  378. data[n].team[1]=true
  379. data[n].team[2]=teams[cb].title
  380. data[n].team[3]=cb
  381. teams[cb].mn=teams[cb].mn+1
  382. teams[cb].ir=teams[cb].ir+1
  383. teams[cb]["members"][n]=true
  384. teams[cb]["inRoomMembers"][n]=true
  385. for i=0,4 do
  386. ui.removeTextArea(i,n)
  387. end
  388. end
  389. end
  390. end
  391.  
  392. local c={"map","angle"}
  393. function eventChatCommand(n,cmd)
  394. local c={}
  395. for i in cmd:gmatch('[^%s]+') do
  396. table.insert(c,i)
  397. end
  398. c[1]=c[1]:lower()
  399. if c[1]=="map" and n=="Bodykudo#0000" then
  400. newGame()
  401. elseif c[1]=="angle" then
  402. c[2]=tonumber(c[2])
  403. if c[2] >= 45 and c[2] <= 120 and started and play and not tfm.get.room.playerList[n].isDead then
  404. data[n].angle=c[2]
  405. 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
  406. tfm.exec.addShamanObject(0,x,y,angle*dir)
  407. end
  408. end
  409. end
  410.  
  411. for i=1,#c do
  412. system.disableChatCommandDisplay(c[i],true)
  413. end
  414.  
  415. newGame()
  416. table.foreach(tfm.get.room.playerList,eventNewPlayer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement