Script bloble.io

Vários scripts em um.

目前为 2019-02-02 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Script bloble.io
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.6
  5. // @description Vários scripts em um.
  6. // @author Stamer
  7. // @match http://bloble.io/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Your code here...
  15. })();addEventListener("keydown", function(a) {
  16. if (a.keyCode ==75) {//
  17. socket.emit("1",1.00,245,3);
  18. socket.emit("1",1.30,245,3);
  19. socket.emit("1",1.60,245,3);
  20. socket.emit("1",1.90,245,3);
  21. socket.emit("1",2.20,245,3);
  22. socket.emit("1",2.50,245,3);
  23. socket.emit("1",2.80,245,3);
  24. socket.emit("1",3.10,245,3);
  25. socket.emit("1",3.40,245,3);
  26. socket.emit("1",3.70,245,3);
  27. socket.emit("1",4.00,245,3);
  28. socket.emit("1",4.30,245,3);
  29. socket.emit("1",4.60,245,3);
  30. socket.emit("1",4.90,245,3);
  31. socket.emit("1",5.20,245,3);
  32. socket.emit("1",5.50,245,3);
  33. socket.emit("1",5.80,245,3);
  34. socket.emit("1",6.10,245,3);
  35. socket.emit("1",6.40,245,3);
  36. socket.emit("1",6.70,245,3);
  37. socket.emit("1",6.99,245,3);
  38. socket.emit("1",1.44,180,3);
  39. socket.emit("1",1.73,132,3);
  40. socket.emit("1",2.00,182,3);
  41. socket.emit("1",2.29,132,3);
  42. socket.emit("1",2.58,182,3);
  43. socket.emit("1",2.88,132,3);
  44. socket.emit("1",3.18,182,3);
  45. socket.emit("1",3.46,132,3);
  46. socket.emit("1",3.78,182,3);
  47. socket.emit("1",4.09,182,3);
  48. socket.emit("1",4.05,132,3);
  49. socket.emit("1",4.37,180,3);
  50. socket.emit("1",4.67,132,3);
  51. socket.emit("1",4.98,180,3);
  52. socket.emit("1",5.30,132,3);
  53. socket.emit("1",5.59,180,3);
  54. socket.emit("1",5.90,132,3);
  55. socket.emit("1",6.19,181,3);
  56. socket.emit("1",6.48,132,3);
  57. socket.emit("1",6.77,181,3);
  58. socket.emit("1",7.05,132,3);
  59. socket.emit("1",7.36,180,3);
  60. }
  61. });addEventListener("keydown", function(a) {
  62. if (a.keyCode == 97){
  63. for(i=-3.14;i<=3.14;i+=0.5233){
  64. socket.emit("1",i,132,3);
  65. }
  66. }
  67. if (a.keyCode == 100){
  68. for(i=-2.965;i<=3.14;i+=0.3488){
  69. socket.emit("1",i,243.85,3);
  70. }
  71. }
  72. if (a.keyCode == 103){
  73. for(i=0;i<units.length;++i){
  74. if(0===units[i].type&&"hexagon"==units[i].shape&&units[i].owner==player.sid){
  75. socket.emit("4",units[i].id,0);
  76. }
  77. }
  78. }
  79. if (a.keyCode == 98){
  80. for(i=-3.14;i<=3.14;i+=0.3488){
  81. socket.emit("1",i,194,2);
  82. }
  83. }
  84. if (a.keyCode == 101){
  85. for(i=0;i<units.length;++i){
  86. if(0===units[i].type&&1==units[i].turretIndex&&"circle"==units[i].shape&&units[i].owner==player.sid){
  87. socket.emit("4",units[i].id,1);
  88. }
  89. }
  90. }
  91. if (a.keyCode == 104){
  92. for(i=0;i<units.length;++i){
  93. if(0===units[i].type&&3==units[i].turretIndex&&"circle"==units[i].shape&&units[i].owner==player.sid){
  94. socket.emit("4",units[i].id,0);
  95. }
  96. }
  97. }
  98. if (a.keyCode == 99){
  99. for(i=-3.14;i<3.14;i+=0.216){
  100. socket.emit("1",i,1e3,1);
  101. }
  102. }
  103. if (a.keyCode == 102){
  104. for(i=0;i<units.length;++i){
  105. if(3==units[i].type&&"circle"==units[i].shape&&units[i].owner==player.sid){
  106. socket.emit("4",units[i].id,0);
  107. }
  108. }
  109. }
  110. if (a.keyCode == 105){
  111. for(i=0;i<units.length;++i){
  112. if(3==units[i].type&&"hexagon"==units[i].shape&&units[i].owner==player.sid){
  113. socket.emit("4",units[i].id,0);
  114. }
  115. }
  116. }
  117. if (a.keyCode == 67){
  118. for(i=0;i<units.length;++i){
  119. if(1==units[i].type&&"star"==units[i].shape&&units[i].owner==player.sid){
  120. camX = units[i].x-player.x;
  121. camY = units[i].y-player.y;
  122. }
  123. }
  124. }
  125. });var scroll=0;
  126. mainCanvas["addEventListener"]?(window["addEventListener"]("mousewheel",zoom,!1),mainCanvas["addEventListener"]("DOMMouseScroll",zoom,!1)):window["attachEvent"]("onmousewheel",zoom);function zoom(a)
  127. {
  128. a= window["event"]|| a;a["preventDefault"]();a["stopPropagation"]();scroll= Math["max"](-1,Math["min"](1,a["wheelDelta"]|| -a["detail"]));if(scroll== -1)
  129. {
  130. if(maxScreenHeight< 10000)
  131. {
  132. (maxScreenHeight+= 250,maxScreenWidth+= 250,resize());scroll= 0
  133. }
  134. }
  135. if(scroll== 1)
  136. {
  137. if(maxScreenHeight> 1000)
  138. {
  139. (maxScreenHeight-= 250,maxScreenWidth-= 250,resize());scroll= 0
  140. }
  141. }
  142. }
  143. mainCanvas["onkeydown"]= function(event)
  144. {
  145. var k=event["keyCode"]?event["keyCode"]:event["which"];
  146. if(k== 70)
  147. {
  148. if(maxScreenHeight< 10000)
  149. {
  150. (maxScreenHeight+= 250,maxScreenWidth+= 250,resize())
  151. }
  152. }
  153. if(k== 67)
  154. {
  155. if(maxScreenHeight> 1000)
  156. {
  157. (maxScreenHeight-= 250,maxScreenWidth-= 250,resize())
  158. }
  159. }
  160. {
  161. if(65== a|| 37== a)
  162. {
  163. cameraKeys["l"]= 0,updateCameraInput()
  164. }
  165. if(68== a|| 39== a)
  166. {
  167. cameraKeys["r"]= 0,updateCameraInput()
  168. }
  169. if(87== a|| 38== a)
  170. {
  171. cameraKeys["u"]= 0,updateCameraInput()
  172. }
  173. if(83== a|| 40== a)
  174. {
  175. cameraKeys["d"]= 0,updateCameraInput()
  176. }
  177. if(32== a)
  178. {
  179. var d=unitList["indexOf"](activeUnit);
  180. sendUnit(d)
  181. }
  182. void(0)!= upgrInputsToIndex["k"+ a]&& toggleActiveUnit(upgrInputsToIndex["k"+ a]);46== a&& selUnits["length"]&& sellSelUnits();84== a&& toggleChat("none"== chatListWrapper["style"]["display"]);27== a&& (toggleActiveUnit(),disableSelUnit(),showSelector= !1);82== a&& (camY= camX= 0)
  183. }
  184. }
  185. ;mainCanvas["onkeydown"]= function(a)
  186. {
  187. a= a["keyCode"]?a["keyCode"]:a["which"];socket&& player&& !player["dead"]&& (65!= a&& 37!= a|| cameraKeys["l"]|| (cameraKeys["l"]= -1,cameraKeys["r"]= 0,updateCameraInput()),68!= a&& 39!= a|| cameraKeys["r"]|| (cameraKeys["r"]= 1,cameraKeys["l"]= 0,updateCameraInput()),87!= a&& 38!= a|| cameraKeys["u"]|| (cameraKeys["u"]= -1,cameraKeys["d"]= 0,updateCameraInput()),83!= a&& 40!= a|| cameraKeys["d"]|| (cameraKeys["d"]= 1,cameraKeys["u"]= 0,updateCameraInput()))
  188. }
  189.  
  190.  
  191.  
  192.  
  193. addEventListener("keydown", function(a) {
  194. if (a.keyCode == 51) { //Generators
  195. for(i=-3.14;i<=2.36;i+=0.050){
  196. socket.emit("1",i,132,3);
  197. }
  198. }
  199. if (a.keyCode == 54) { //Armory
  200. socket.emit("1",UTILS.roundToTwo(2.75),UTILS.roundToTwo(175),7);
  201. }
  202. if (a.keyCode == 52) { //Houses
  203. for(i=-3.134;i<=2.492;i+=0.04620){
  204. socket.emit("1",i,194,4);
  205. }
  206. }
  207.  
  208. if (a.keyCode == 50) {//Turrets
  209. socket.emit("1",2.75,245.75,2);socket.emit("1",2.50,245,2);socket.emit("1",3,245,2);
  210. for(i=-2.98;i<=2.2;i+=0.3235){
  211. socket.emit("1",i,245,2);
  212. }
  213. }
  214. if (a.keyCode == 49) {//Walls
  215. for(i=-3.14;i<3.14;i+=0.216){
  216. socket.emit("1",i,1e3,1);
  217. }
  218. }
  219. if (a.keyCode == 55) {//Barracks
  220. socket.emit("1",0.32,310,8);
  221. socket.emit("1",-0.98,310,8);
  222. socket.emit("1",1.61,310,8);
  223. socket.emit("1",-2.27,310,8);
  224. }
  225. });
  226.  
  227. addEventListener("keydown", function(a) {
  228. if (a.keyCode == 77){
  229. for(i=0;i<users.length;++i){
  230. if(users[i].name.startsWith("[G]")&&users[i].name !== player.name){
  231. camX = users[i].x-player.x;
  232. camY = users[i].y-player.y;
  233. }
  234. }
  235. }
  236. });
  237.  
  238.  
  239.  
  240. 1
  241. 2
  242. 3
  243. 4
  244. 5
  245. 6
  246. 7
  247. 8
  248. 9
  249. 10
  250. 11
  251. 12
  252. 13
  253. 14
  254. 15
  255.  
  256.  
  257. setInterval(updatePlayer,90000);
  258. function updatePlayer(){
  259. socket.emit("2",0,0);
  260. socket.emit("2",Math.round(camX),Math.round(camY));
  261. }
  262.  
  263.  
  264.  
  265. 1
  266. 2
  267. 3
  268. 4
  269. 5
  270. 6
  271. 7
  272. 8
  273.  
  274.  
  275. var headAppend=document.getElementsByTagName("head")[0],style=document.createElement("div");style.innerHTML="<style>#upgradeScriptCont,.buttonClass{background-color:rgba(40,40,40,.5);margin-left: 3px;border-radius:4px;pointer-events:all}#upgradeScriptCont{top: -138px;transition: 1s;margin-left:10px;position:absolute;padding-left:24px;margin-top:9px;padding-top:15px;width:530px;height:128px;font-family:arial;left:28%}#upgradeScriptCont:hover{top:0px}.buttonClass{color:#fff;padding:7px;height:19px;display:inline-block;cursor:pointer;font-size:15px}.hoverMessage{color: white;font-size: 14px;position: relative;left: 457px;bottom: 2px;pointer-events: none;}</style>",headAppend.appendChild(style);var contAppend=document.getElementById("gameUiContainer"),menuA=document.createElement("div");menuA.innerHTML="<div id=upgradeScriptCont><div id=layer1><div id=walls class=buttonClass onclick=walls()>Buy Walls</div><div id=upgradeBoulders class=buttonClass onclick=boulders()>Upgrade Boulders</div><div id=upgradeSpikes class=buttonClass onclick=spikes()>Upgrade Spikes</div><div id=upgradeGen class=buttonClass onclick=powerPlants()>Upgrade Power Plants</div></div><div id=layer2 style=margin-top:7px;margin-left:7px><div id=walls class=buttonClass onclick=generators()>Buy Generators</div><div id=upgradeBoulders class=buttonClass onclick=rapid()>Upgrade Rapid</div><div id=upgradeSpikes class=buttonClass onclick=ranged()>Upgrade Ranged</div><div id=upgradeGen class=buttonClass onclick=antiTank()>Upgrade anti-tank</div></div><div id=layer3 style=margin-top:7px;margin-left:-16px><div id=walls class=buttonClass onclick=gatlins()>Upgrade Gatlins</div><div id=upgradeBoulders class=buttonClass onclick=spotter()>Upgrade spotter</div><div id=upgradeMicro class=buttonClass onclick=microGenerators()>Upgrade Micro-Gen</div><div id=upgradeSpikes class=buttonClass onclick=semiAuto()>Upgrade Semi-auto</div></div><span class=hoverMessage>Hover over</span></div>",contAppend.insertBefore(menuA,contAppend.firstChild),window.walls=function(){for(i=-3.14;i<3.14;i+=.108)socket.emit("1",i,1e3,1)},window.generators=function(){for(i=-3.14;i<3.14;i+=.075)socket.emit("1",i,132,3)},window.boulders=function(){for(i=0;i<units.length;++i)3==units[i].type&&"circle"==units[i].shape&&units[i].owner==player.sid&&socket.emit("4",units[i].id,0)},window.microGenerators=function(){for(i=0;i<units.length;++i)3==units[i].type&&"circle"==units[i].shape&&units[i].owner==player.sid&&socket.emit("4",units[i].id,1)},window.spikes=function(){for(i=0;i<units.length;++i)3==units[i].type&&"hexagon"==units[i].shape&&units[i].owner==player.sid&&socket.emit("4",units[i].id,0)},window.powerPlants=function(){for(i=0;i<units.length;++i)0==units[i].type&&"hexagon"==units[i].shape&&units[i].owner==player.sid&&socket.emit("4",units[i].id,0)},window.rapid=function(){for(i=0;i<units.length;++i)0==units[i].type&&1==units[i].turretIndex&&"circle"==units[i].shape&&units[i].owner==player.sid&&socket.emit("4",units[i].id,0)},window.ranged=function(){for(i=0;i<units.length;++i)0==units[i].type&&1==units[i].turretIndex&&"circle"==units[i].shape&&units[i].owner==player.sid&&socket.emit("4",units[i].id,1)},window.antiTank=function(){for(i=0;i<units.length;++i)0==units[i].type&&4==units[i].turretIndex&&"circle"==units[i].shape&&units[i].owner==player.sid&&socket.emit("4",units[i].id,1)},window.semiAuto=function(){for(i=0;i<units.length;++i)0==units[i].type&&4==units[i].turretIndex&&"circle"==units[i].shape&&units[i].owner==player.sid&&socket.emit("4",units[i].id,0)},window.gatlins=function(){for(i=0;i<units.length;++i)0==units[i].type&&2==units[i].turretIndex&&"circle"==units[i].shape&&units[i].owner==player.sid&&socket.emit("4",units[i].id,0)},window.spotter=function(){for(i=0;i<units.length;++i)0==units[i].type&&3==units[i].turretIndex&&"circle"==units[i].shape&&units[i].owner==player.sid&&socket.emit("4",units[i].id,0)};
  276.  
  277. var correct = `<div class="correctness incorrect">Errado</div>`;
  278. //document.body.style.backgroundImage = "url('http://eskipaper.com/images/blue-background-2.jpg')";
  279.  
  280.  
  281. function clickelementbyname(elementname){
  282. document.getElementsByName(elementname)[0].click();
  283. }
  284. /*
  285. function clickelementbyclassname(elementclassname){
  286. document.getElementsByClassName(elementclassname)[0].click();
  287. }
  288. */
  289.  
  290. if(window.location.href.indexOf("nead.pro.br/mod/quiz/attempt.php?") > -1){
  291. console.log("Questionary page detected.");
  292. //var id = document.getElementsByName('questionids')[0].value;
  293. var s1 = document.getElementsByClassName('submit btn')[0].getAttribute('onclick').split(`'`)[1];
  294. var id = s1.split('q')[1];
  295. var questionID = document.getElementsByName('questionids')[0].value;
  296. var questioncode = document.getElementById(`q${id}`).innerHTML;
  297. var correctness = document.getElementsByClassName("correctness correct")[0];
  298. console.log("Checking question grading.");
  299. if(correctness !== undefined){
  300. console.log("Question is right, saving data.");
  301. localStorage.setItem('que'+ id, questioncode);
  302. if(document.getElementsByClassName("next")[0] !== undefined){
  303. console.log("Going to next page.");
  304. document.getElementsByClassName("next")[0].click();
  305. }
  306. if(document.getElementsByClassName("next")[0] === undefined){
  307. console.log("Questionary is finished.");
  308. alert("Questionary is finished.");
  309. }
  310. }
  311. if(correctness === undefined){
  312. console.log("Question isn't right, looking for question data");
  313. if(localStorage.getItem('que' + id) === null){
  314. alert("No data found, you must answer this question");
  315. console.log("No data found, human must answer");
  316. }
  317. if(localStorage.getItem('que' + id) !== null){
  318. document.getElementById(`q${id}`).innerHTML = localStorage.getItem('que' + id);
  319. setTimeout(clickelementbyname, 250, 'resp' + id + '_submit');
  320. console.log("Data found, changing page.");
  321. }
  322. }
  323. }
  324.  
  325.  
  326.  
  327.  
  328. //CHAT IS SELECTED OR NO
  329. chatInput.onfocus=function(){chatInput.isFocused=true;};
  330. chatInput.onblur=function(){chatInput.isFocused=false;};
  331.  
  332. //DELETE PLAYER
  333. addEventListener("keydown", function(a) {
  334. if(chatInput.isFocused===false&&a.keyCode==46){
  335. if(selUnits.length!==0){
  336. local.emit('del',selUnits[0].owner);
  337. }
  338. }
  339. });
  340.  
  341. //AGROUP UNITS
  342. addEventListener("keydown", function(a) {
  343. if(chatInput.isFocused===false&&a.keyCode==16){
  344. if(selUnits.length==4&&selUnits.length!==0){
  345. var center = selUnitsMidPoint();
  346. var points = [];
  347. points.push({x:center[0],y:center[1],moving:false});
  348. points.push({x:center[0]+275,y:center[1]+275,moving:false});
  349. points.push({x:center[0]+275,y:center[1],moving:false});
  350. points.push({x:center[0],y:center[1]+275,moving:false});
  351. for(o=0,e=selUnits;o<e.length;++o){
  352. var closest = 1000000000;
  353. for(i=0,e=points;i<points.length;++i){
  354. var d=UTILS.getDistance(e[i].x,e[i].y,selUnits[o].x,selUnits[o].y);
  355. if(i!==4){
  356. if(e[i].moving===false&&d<closest){
  357. closest=d;
  358. local.emit("5",points[i].x,points[i].y,[selUnits[o].id],0,0);
  359. if(selUnits[o].owner==player.sid){socket.emit("5",UTILS.roundToTwo(points[i].x),UTILS.roundToTwo(points[i].y),[selUnits[o].id],0,0);}
  360. }
  361. }
  362. else{
  363. closest=d;
  364. if(selUnits[o].owner==player.sid){socket.emit("5",UTILS.roundToTwo(points[i].x),UTILS.roundToTwo(points[i].y),[selUnits[o].id],0,0);}
  365. local.emit("5",points[i].x,points[i].y,[selUnits[o].id],0,0);
  366. }
  367. }
  368. }
  369. }
  370. }
  371. });
  372.  
  373.  
  374. //CONNECT TO BOTS
  375. var local = connectLocal();
  376. function connectLocal(){
  377. const locallIo = io;
  378. return locallIo.connect('http://localhost:8080');
  379. }
  380.  
  381.  
  382. //MID POS BETWEN UNITS
  383. function selUnitsMidPoint(){
  384. x=0;
  385. y=0;
  386. for(i=0,a=selUnits;i<a.length;++i){
  387. y=selUnits[i].y+y;
  388. x=selUnits[i].x+x;
  389. }
  390. return [x/a.length,y/a.length];
  391. }
  392.  
  393. //CREATE NEW SOLDIER
  394. addEventListener("keydown", function(a) {
  395. if (chatInput.isFocused===false&&a.keyCode == 107) {
  396. local.emit("create");
  397. }
  398. });
  399.  
  400.  
  401. //GET BOTS CODE
  402. addEventListener("keydown", function(a) {
  403. if (chatInput.isFocused===false&&a.keyCode == 9) {
  404. alert('node . '+socket.io.uri+' '+player.sid+' '+[KM]+'SOLDIER'+' 0');
  405. }
  406. });var scroll=0;
  407. mainCanvas["addEventListener"]?(window["addEventListener"]("mousewheel",zoom,!1),mainCanvas["addEventListener"]("DOMMouseScroll",zoom,!1)):window["attachEvent"]("onmousewheel",zoom);function zoom(a)
  408. {
  409. a= window["event"]|| a;a["preventDefault"]();a["stopPropagation"]();scroll= Math["max"](-1,Math["min"](1,a["wheelDelta"]|| -a["detail"]));if(scroll== -1)
  410. {
  411. if(maxScreenHeight< 10000)
  412. {
  413. (maxScreenHeight+= 250,maxScreenWidth+= 250,resize());scroll= 0
  414. }
  415. }
  416. if(scroll== 1)
  417. {
  418. if(maxScreenHeight> 1000)
  419. {
  420. (maxScreenHeight-= 250,maxScreenWidth-= 250,resize());scroll= 0
  421. }
  422. }
  423. }
  424. mainCanvas["onkeydown"]= function(event)
  425. {
  426. var k=event["keyCode"]?event["keyCode"]:event["which"];
  427. if(k== 70)
  428. {
  429. if(maxScreenHeight< 10000)
  430. {
  431. (maxScreenHeight+= 250,maxScreenWidth+= 250,resize())
  432. }
  433. }
  434. if(k== 67)
  435. {
  436. if(maxScreenHeight> 1000)
  437. {
  438. (maxScreenHeight-= 250,maxScreenWidth-= 250,resize())
  439. }
  440. }
  441. {
  442. if(65== a|| 37== a)
  443. {
  444. cameraKeys["l"]= 0,updateCameraInput()
  445. }
  446. if(68== a|| 39== a)
  447. {
  448. cameraKeys["r"]= 0,updateCameraInput()
  449. }
  450. if(87== a|| 38== a)
  451. {
  452. cameraKeys["u"]= 0,updateCameraInput()
  453. }
  454. if(83== a|| 40== a)
  455. {
  456. cameraKeys["d"]= 0,updateCameraInput()
  457. }
  458. if(32== a)
  459. {
  460. var d=unitList["indexOf"](activeUnit);
  461. sendUnit(d)
  462. }
  463. void(0)!= upgrInputsToIndex["k"+ a]&& toggleActiveUnit(upgrInputsToIndex["k"+ a]);46== a&& selUnits["length"]&& sellSelUnits();84== a&& toggleChat("none"== chatListWrapper["style"]["display"]);27== a&& (toggleActiveUnit(),disableSelUnit(),showSelector= !1);82== a&& (camY= camX= 0)
  464. }
  465. }
  466. ;mainCanvas["onkeydown"]= function(a)
  467. {
  468. a= a["keyCode"]?a["keyCode"]:a["which"];socket&& player&& !player["dead"]&& (65!= a&& 37!= a|| cameraKeys["l"]|| (cameraKeys["l"]= -1,cameraKeys["r"]= 0,updateCameraInput()),68!= a&& 39!= a|| cameraKeys["r"]|| (cameraKeys["r"]= 1,cameraKeys["l"]= 0,updateCameraInput()),87!= a&& 38!= a|| cameraKeys["u"]|| (cameraKeys["u"]= -1,cameraKeys["d"]= 0,updateCameraInput()),83!= a&& 40!= a|| cameraKeys["d"]|| (cameraKeys["d"]= 1,cameraKeys["u"]= 0,updateCameraInput()))
  469. }
  470.  
  471.  
  472.  
  473.  
  474. addEventListener("keydown", function(a) {
  475. if (a.keyCode == 51) { //Generators
  476. for(i=-3.14;i<=2.36;i+=0.050){
  477. socket.emit("1",i,132,3);
  478. }
  479. }
  480. if (a.keyCode == 54) { //Armory
  481. socket.emit("1",UTILS.roundToTwo(2.75),UTILS.roundToTwo(175),7);
  482. }
  483. if (a.keyCode == 52) { //Houses
  484. for(i=-3.134;i<=2.492;i+=0.04620){
  485. socket.emit("1",i,194,4);
  486. }
  487. }
  488.  
  489. if (a.keyCode == 50) {//Turrets
  490. socket.emit("1",2.75,245.75,2);socket.emit("1",2.50,245,2);socket.emit("1",3,245,2);
  491. for(i=-2.98;i<=2.2;i+=0.3235){
  492. socket.emit("1",i,245,2);
  493. }
  494. }
  495. if (a.keyCode == 49) {//Walls
  496. for(i=-3.14;i<3.14;i+=0.216){
  497. socket.emit("1",i,1e3,1);
  498. }
  499. }
  500. if (a.keyCode == 55) {//Barracks
  501. socket.emit("1",0.32,310,8);
  502. socket.emit("1",-0.98,310,8);
  503. socket.emit("1",1.61,310,8);
  504. socket.emit("1",-2.27,310,8);
  505. }
  506. });
  507.  
  508. addEventListener("keydown", function(a) {
  509. if (a.keyCode == 77){
  510. for(i=0;i<users.length;++i){
  511. if(users[i].name.startsWith("[G]")&&users[i].name !== player.name){
  512. camX = users[i].x-player.x;
  513. camY = users[i].y-player.y;
  514. }
  515. }
  516. }
  517. });
  518.  
  519.  
  520.  
  521. 1
  522. 2
  523. 3
  524. 4
  525. 5
  526. 6
  527. 7
  528. 8
  529. 9
  530. 10
  531. 11
  532. 12
  533. 13
  534. 14
  535. 15
  536.  
  537.  
  538. setInterval(updatePlayer,90000);
  539. function updatePlayer(){
  540. socket.emit("2",0,0);
  541. socket.emit("2",Math.round(camX),Math.round(camY));
  542. }
  543.  
  544.  
  545.  
  546. 1
  547. 2
  548. 3
  549. 4
  550. 5
  551. 6
  552. 7
  553. 8
  554.  
  555.  
  556. var headAppend=document.getElementsByTagName("head")[0],style=document.createElement("div");style.innerHTML="<style>#upgradeScriptCont,.buttonClass{background-color:rgba(40,40,40,.5);margin-left: 3px;border-radius:4px;pointer-events:all}#upgradeScriptCont{top: -138px;transition: 1s;margin-left:10px;position:absolute;padding-left:24px;margin-top:9px;padding-top:15px;width:530px;height:128px;font-family:arial;left:28%}#upgradeScriptCont:hover{top:0px}.buttonClass{color:#fff;padding:7px;height:19px;display:inline-block;cursor:pointer;font-size:15px}.hoverMessage{color: white;font-size: 14px;position: relative;left: 457px;bottom: 2px;pointer-events: none;}</style>",headAppend.appendChild(style);var contAppend=document.getElementById("gameUiContainer"),menuA=document.createElement("div");menuA.innerHTML="<div id=upgradeScriptCont><div id=layer1><div id=walls class=buttonClass onclick=walls()>Buy Walls</div><div id=upgradeBoulders class=buttonClass onclick=boulders()>Upgrade Boulders</div><div id=upgradeSpikes class=buttonClass onclick=spikes()>Upgrade Spikes</div><div id=upgradeGen class=buttonClass onclick=powerPlants()>Upgrade Power Plants</div></div><div id=layer2 style=margin-top:7px;margin-left:7px><div id=walls class=buttonClass onclick=generators()>Buy Generators</div><div id=upgradeBoulders class=buttonClass onclick=rapid()>Upgrade Rapid</div><div id=upgradeSpikes class=buttonClass onclick=ranged()>Upgrade Ranged</div><div id=upgradeGen class=buttonClass onclick=antiTank()>Upgrade anti-tank</div></div><div id=layer3 style=margin-top:7px;margin-left:-16px><div id=walls class=buttonClass onclick=gatlins()>Upgrade Gatlins</div><div id=upgradeBoulders class=buttonClass onclick=spotter()>Upgrade spotter</div><div id=upgradeMicro class=buttonClass onclick=microGenerators()>Upgrade Micro-Gen</div><div id=upgradeSpikes class=buttonClass onclick=semiAuto()>Upgrade Semi-auto</div></div><span class=hoverMessage>Hover over</span></div>",contAppend.insertBefore(menuA,contAppend.firstChild),window.walls=function(){for(i=-3.14;i<3.14;i+=.108)socket.emit("1",i,1e3,1)},window.generators=function(){for(i=-3.14;i<3.14;i+=.075)socket.emit("1",i,132,3)},window.boulders=function(){for(i=0;i<units.length;++i)3==units[i].type&&"circle"==units[i].shape&&units[i].owner==player.sid&&socket.emit("4",units[i].id,0)},window.microGenerators=function(){for(i=0;i<units.length;++i)3==units[i].type&&"circle"==units[i].shape&&units[i].owner==player.sid&&socket.emit("4",units[i].id,1)},window.spikes=function(){for(i=0;i<units.length;++i)3==units[i].type&&"hexagon"==units[i].shape&&units[i].owner==player.sid&&socket.emit("4",units[i].id,0)},window.powerPlants=function(){for(i=0;i<units.length;++i)0==units[i].type&&"hexagon"==units[i].shape&&units[i].owner==player.sid&&socket.emit("4",units[i].id,0)},window.rapid=function(){for(i=0;i<units.length;++i)0==units[i].type&&1==units[i].turretIndex&&"circle"==units[i].shape&&units[i].owner==player.sid&&socket.emit("4",units[i].id,0)},window.ranged=function(){for(i=0;i<units.length;++i)0==units[i].type&&1==units[i].turretIndex&&"circle"==units[i].shape&&units[i].owner==player.sid&&socket.emit("4",units[i].id,1)},window.antiTank=function(){for(i=0;i<units.length;++i)0==units[i].type&&4==units[i].turretIndex&&"circle"==units[i].shape&&units[i].owner==player.sid&&socket.emit("4",units[i].id,1)},window.semiAuto=function(){for(i=0;i<units.length;++i)0==units[i].type&&4==units[i].turretIndex&&"circle"==units[i].shape&&units[i].owner==player.sid&&socket.emit("4",units[i].id,0)},window.gatlins=function(){for(i=0;i<units.length;++i)0==units[i].type&&2==units[i].turretIndex&&"circle"==units[i].shape&&units[i].owner==player.sid&&socket.emit("4",units[i].id,0)},window.spotter=function(){for(i=0;i<units.length;++i)0==units[i].type&&3==units[i].turretIndex&&"circle"==units[i].shape&&units[i].owner==player.sid&&socket.emit("4",units[i].id,0)};
  557.  
  558. var correct = `<div class="correctness incorrect">Errado</div>`;
  559. //document.body.style.backgroundImage = "url('http://eskipaper.com/images/blue-background-2.jpg')";
  560.  
  561.  
  562. function clickelementbyname(elementname){
  563. document.getElementsByName(elementname)[0].click();
  564. }
  565. /*
  566. function clickelementbyclassname(elementclassname){
  567. document.getElementsByClassName(elementclassname)[0].click();
  568. }
  569. */
  570.  
  571. if(window.location.href.indexOf("nead.pro.br/mod/quiz/attempt.php?") > -1){
  572. console.log("Questionary page detected.");
  573. //var id = document.getElementsByName('questionids')[0].value;
  574. var s1 = document.getElementsByClassName('submit btn')[0].getAttribute('onclick').split(`'`)[1];
  575. var id = s1.split('q')[1];
  576. var questionID = document.getElementsByName('questionids')[0].value;
  577. var questioncode = document.getElementById(`q${id}`).innerHTML;
  578. var correctness = document.getElementsByClassName("correctness correct")[0];
  579. console.log("Checking question grading.");
  580. if(correctness !== undefined){
  581. console.log("Question is right, saving data.");
  582. localStorage.setItem('que'+ id, questioncode);
  583. if(document.getElementsByClassName("next")[0] !== undefined){
  584. console.log("Going to next page.");
  585. document.getElementsByClassName("next")[0].click();
  586. }
  587. if(document.getElementsByClassName("next")[0] === undefined){
  588. console.log("Questionary is finished.");
  589. alert("Questionary is finished.");
  590. }
  591. }
  592. if(correctness === undefined){
  593. console.log("Question isn't right, looking for question data");
  594. if(localStorage.getItem('que' + id) === null){
  595. alert("No data found, you must answer this question");
  596. console.log("No data found, human must answer");
  597. }
  598. if(localStorage.getItem('que' + id) !== null){
  599. document.getElementById(`q${id}`).innerHTML = localStorage.getItem('que' + id);
  600. setTimeout(clickelementbyname, 250, 'resp' + id + '_submit');
  601. console.log("Data found, changing page.");
  602. }
  603. }
  604. }
  605.  
  606.  
  607.  
  608.  
  609. //CHAT IS SELECTED OR NO
  610. chatInput.onfocus=function(){chatInput.isFocused=true;};
  611. chatInput.onblur=function(){chatInput.isFocused=false;};
  612.  
  613. //DELETE PLAYER
  614. addEventListener("keydown", function(a) {
  615. if(chatInput.isFocused===false&&a.keyCode==46){
  616. if(selUnits.length!==0){
  617. local.emit('del',selUnits[0].owner);
  618. }
  619. }
  620. });
  621.  
  622. //AGROUP UNITS
  623. addEventListener("keydown", function(a) {
  624. if(chatInput.isFocused===false&&a.keyCode==16){
  625. if(selUnits.length==4&&selUnits.length!==0){
  626. var center = selUnitsMidPoint();
  627. var points = [];
  628. points.push({x:center[0],y:center[1],moving:false});
  629. points.push({x:center[0]+275,y:center[1]+275,moving:false});
  630. points.push({x:center[0]+275,y:center[1],moving:false});
  631. points.push({x:center[0],y:center[1]+275,moving:false});
  632. for(o=0,e=selUnits;o<e.length;++o){
  633. var closest = 1000000000;
  634. for(i=0,e=points;i<points.length;++i){
  635. var d=UTILS.getDistance(e[i].x,e[i].y,selUnits[o].x,selUnits[o].y);
  636. if(i!==4){
  637. if(e[i].moving===false&&d<closest){
  638. closest=d;
  639. local.emit("5",points[i].x,points[i].y,[selUnits[o].id],0,0);
  640. if(selUnits[o].owner==player.sid){socket.emit("5",UTILS.roundToTwo(points[i].x),UTILS.roundToTwo(points[i].y),[selUnits[o].id],0,0);}
  641. }
  642. }
  643. else{
  644. closest=d;
  645. if(selUnits[o].owner==player.sid){socket.emit("5",UTILS.roundToTwo(points[i].x),UTILS.roundToTwo(points[i].y),[selUnits[o].id],0,0);}
  646. local.emit("5",points[i].x,points[i].y,[selUnits[o].id],0,0);
  647. }
  648. }
  649. }
  650. }
  651. }
  652. });
  653.  
  654.  
  655. //CONNECT TO BOTS
  656. var local = connectLocal();
  657. function connectLocal(){
  658. const locallIo = io;
  659. return locallIo.connect('http://localhost:8080');
  660. }
  661.  
  662.  
  663. //MID POS BETWEN UNITS
  664. function selUnitsMidPoint(){
  665. x=0;
  666. y=0;
  667. for(i=0,a=selUnits;i<a.length;++i){
  668. y=selUnits[i].y+y;
  669. x=selUnits[i].x+x;
  670. }
  671. return [x/a.length,y/a.length];
  672. }
  673.  
  674. //CREATE NEW SOLDIER
  675. addEventListener("keydown", function(a) {
  676. if (chatInput.isFocused===false&&a.keyCode == 107) {
  677. local.emit("create");
  678. }
  679. });
  680.  
  681.  
  682. //GET BOTS CODE
  683. addEventListener("keydown", function(a) {
  684. if (chatInput.isFocused===false&&a.keyCode == 9) {
  685. alert('node . '+socket.io.uri+' '+player.sid+' '+[KM]+'SOLDIER'+' 0');
  686. }
  687. });
  688.  
  689. window.addEventListener("keyup", function(a) {
  690. a = a.keyCode ? a.keyCode : a.which;
  691.  
  692. if (a === 81) { // All troops except commander
  693. selUnits = [];
  694. units.forEach((unit) => {
  695. if (unit.owner === player.sid && unit.type === 1) {
  696. if (!unit.info) unit.info = getUnitFromPath(unit.uPath);
  697. unit.info.name !== 'Commander' && selUnits.push(unit)
  698.  
  699. }
  700. });
  701. selUnitType = "Unit";
  702. } else if (a === 69) { // Everything
  703. selUnits = [];
  704. units.forEach((unit) => {
  705. if (unit.owner === player.sid && unit.type === 1) {
  706. if (!unit.info) unit.info = getUnitFromPath(unit.uPath);
  707. selUnits.push(unit)
  708. }
  709. });
  710. selUnitType = "Unit";
  711. } else if (a === 67) { // Commander
  712. selUnits = [];
  713. units.every((unit) => {
  714. if (unit.owner === player.sid && unit.type === 1) {
  715. if (!unit.info) unit.info = getUnitFromPath(unit.uPath);
  716. if (unit.info.name === 'Commander') {
  717. selUnits.push(unit)
  718. return false;
  719. }
  720. }
  721. return true;
  722. });
  723. selUnitType = "Unit";
  724. }
  725. });
  726.  
  727. var gotoUsers = [];
  728. var gotoIndex = 0;
  729. window.overrideSocketEvents = window.overrideSocketEvents || [];
  730. window.chatCommands = window.chatCommands || {};
  731.  
  732. window.chatCommands.find = function(split) {
  733. var name = split.slice(1).join(' ');
  734. if (name == '') {
  735. addChat('Please specify a username', 'Client')
  736. return;
  737. }
  738. window.goto(name)
  739. }
  740. window.overrideSocketEvents.push({
  741. name: "l",
  742. description: "Leaderboard Insta Find override",
  743. func: function(a) {
  744. var d = "",
  745. c = 1,
  746. b = 0;
  747. for (; b < a.length;) {
  748. d += "<div class='leaderboardItem' onclick=goto2(" + a[b] + ");><div style='display:inline-block;float:left;' class='whiteText'>" + c + ".</div> <div class='" + (player && a[b] == player.sid ? "leaderYou" : "leader") + "'>" + a[b + 1] + "</div><div class='scoreText'>" + a[b + 2] + "</div></div>", c++, b += 3;
  749. }
  750. leaderboardList.innerHTML = d;
  751. }
  752. })
  753. leaderboardList.style.pointerEvents = 'auto';
  754. chatListWrapper.style.pointerEvents = 'auto';
  755.  
  756. window.goto = function(username) {
  757. gotoUsers = users.filter((user) => {
  758. return user.name === username
  759. });
  760. gotoIndex = 0;
  761. if (gotoUsers[0]) {
  762. camX = gotoUsers[0].x - player.x;
  763. camY = gotoUsers[0].y - player.y;
  764. }
  765. addChat(gotoUsers.length + ' users found with the name ' + username, 'Client');
  766. return gotoUsers.length;
  767. }
  768. window.goto2 = function(id, go) {
  769. gotoUsers = users.filter((user) => {
  770. return user.sid === id;
  771. });
  772. gotoIndex = 0;
  773. if (!go && gotoUsers[0]) {
  774. camX = gotoUsers[0].x - player.x;
  775. camY = gotoUsers[0].y - player.y;
  776. }
  777. return gotoUsers.length;
  778. }
  779.  
  780. window.gotoLeft = function() {
  781. if (!gotoUsers.length) return;
  782.  
  783. if (camX == gotoUsers[gotoIndex].x - player.x && camY == gotoUsers[gotoIndex].y - player.y) {
  784. if (gotoIndex <= 0) gotoIndex = gotoUsers.length;
  785. gotoIndex--;
  786. }
  787. camX = gotoUsers[gotoIndex].x - player.x;
  788. camY = gotoUsers[gotoIndex].y - player.y;
  789. }
  790.  
  791. window.gotoRight = function() {
  792. if (!gotoUsers.length) return;
  793.  
  794. if (camX == gotoUsers[gotoIndex].x - player.x && camY == gotoUsers[gotoIndex].y - player.y) {
  795. if (gotoIndex >= gotoUsers.length - 1) gotoIndex = -1;
  796. gotoIndex++;
  797. }
  798. camX = gotoUsers[gotoIndex].x - player.x;
  799. camY = gotoUsers[gotoIndex].y - player.y;
  800. }
  801.  
  802. window.addChat = function(msg, from, color) {
  803. color = color || "#fff";
  804. var b = document.createElement("li");
  805. b.className = "chatother";
  806. b.innerHTML = '<span style="color:' + color + '">[' + from + ']</span> <span class="chatText">' + msg + "</span>";
  807. 10 < chatList.childNodes.length && chatList.removeChild(chatList.childNodes[0]);
  808. chatList.appendChild(b)
  809. }
  810.  
  811. window.resetCamera = function() { // Override
  812. camX = camXS = camY = camYS = 0;
  813. cameraKeys = {
  814. l: 0,
  815. r: 0,
  816. u: 0,
  817. d: 0
  818. }
  819.  
  820. if (socket && window.overrideSocketEvents && window.overrideSocketEvents.length) {
  821. window.overrideSocketEvents.forEach((item) => {
  822. socket.removeAllListeners(item.name)
  823. socket.on(item.name, item.func);
  824.  
  825. });
  826.  
  827. }
  828. }
  829.  
  830.  
  831.  
  832. window.addChatLine = function(a, d, c) {
  833. if (player) {
  834. var b = getUserBySID(a);
  835. if (c || 0 <= b) {
  836. var g = c ? "SERVER" : users[b].name;
  837. c = c ? "#fff" : playerColors[users[b].color] ? playerColors[users[b].color] : playerColors[0];
  838. player.sid == a && (c = "#fff");
  839. b = document.createElement("li");
  840. b.className = player.sid == a ? "chatme" : "chatother";
  841.  
  842. b.innerHTML = '<span style="color:' + c + '" onclick=goto2(' + a + ');>[' + g + ']</span> <span class="chatText">' + d + "</span>";
  843. 10 < chatList.childNodes.length && chatList.removeChild(chatList.childNodes[0]);
  844. chatList.appendChild(b)
  845. }
  846. }
  847. }
  848.  
  849. window.addEventListener("keyup", function(a) {
  850. a = a.keyCode ? a.keyCode : a.which;
  851. if (a === 190) {
  852. window.gotoRight()
  853. } else if (a === 188) {
  854. window.gotoLeft();
  855. }
  856.  
  857. });
  858.  
  859. window.UIList = window.UIList || [];
  860. window.initFuncs = window.initFuncs || [];
  861. window.statusItems = window.statusItems || [];
  862.  
  863.  
  864. window.UIList.push({
  865. level: 0,
  866. x: 0,
  867. html: '<div onclick=buildGenerators()>Build Generators</div>'
  868. }, {
  869. level: 0,
  870. x: 1,
  871. html: '<div onclick=walls()>Build Walls</div>'
  872. }, {
  873. level: 0,
  874. x: 2,
  875. html: '<div onclick=buildHouses()>Build Offense</div>'
  876. }, {
  877. level: 0,
  878. x: 4,
  879. html: '<div onclick=buildHybrid()>Build Hybrid</div>'
  880. }, {
  881. level: 1,
  882. x: 0,
  883. html: '<div onclick=boulders()>Upgrade Boulders</div>'
  884. }, {
  885. level: 1,
  886. x: 1,
  887. html: '<div onclick=spikes()>Upgrade Spikes</div>'
  888. }, {
  889. level: 1,
  890. x: 2,
  891. html: '<div onclick=microGenerators()>Mico-Generators</div>'
  892. }, {
  893. level: 1,
  894. x: 3,
  895. html: '<div onclick=powerPlants()>Upgrade Power Plants</div>'
  896. }, {
  897. level: 2,
  898. x: 0,
  899. html: '<div onclick=sellGenerators()>Sell Generators</div>'
  900. }, {
  901. level: 2,
  902. x: 1,
  903. html: '<div onclick=sellall()>Sell all</div>'
  904. });
  905.  
  906. function emit2() {
  907. socket.emit.apply(socket, arguments);
  908. }
  909. window.walls = function () {
  910. for (i = -3.14; i < 3.14; i += .108) emit2("1", i, 1e3, 1)
  911. }
  912. window.sellGenerators = window.sellGenerators || function () {
  913. for (var a = [], d = 0; d < units.length; ++d) {
  914. if (units[d].type === 0 && units[d].owner == player.sid) {
  915. var name = getUnitFromPath(units[d].uPath).name;
  916. (name === 'Generator' || name === 'Power Plant') && a.push(units[d].id)
  917. }
  918. }
  919. socket.emit("3", a)
  920. }
  921. window.sellhouses = function () {
  922. for (var a = [], d = 0; d < units.length; ++d) units[d].type === 0 && units[d].owner == player.sid && getUnitFromPath(units[d].uPath).name === 'House' && a.push(units[d].id);
  923. socket.emit("3", a)
  924. }
  925. window.sellwalls = function () {
  926. for (var a = [], d = 0; d < units.length; ++d) units[d].type === 3 && units[d].owner == player.sid && getUnitFromPath(units[d].uPath).name === 'Wall' && a.push(units[d].id);
  927. socket.emit("3", a)
  928. }
  929. window.sellinner = function () {
  930. for (var a = [], d = 0; d < units.length; ++d) {
  931. if (units[d].type === 0 && units[d].owner == player.sid) {
  932. a.push(units[d].id)
  933. }
  934. }
  935. socket.emit("3", a)
  936. }
  937. window.sellall = function () {
  938. for (var a = [], d = 0; d < units.length; ++d)(units[d].type === 3 || units[d].type === 2 || units[d].type === 0) && units[d].owner == player.sid && a.push(units[d].id);
  939. socket.emit("3", a)
  940. }
  941. window.boulders = window.boulders || function () {
  942. for (var i = 0; i < units.length; ++i) 3 == units[i].type && "circle" == units[i].shape && units[i].owner == player.sid && socket.emit("4", units[i].id, 0)
  943. }
  944. window.microGenerators = window.microGenerators || function () {
  945. for (var i = 0; i < units.length; ++i) 3 == units[i].type && "circle" == units[i].shape && units[i].owner == player.sid && socket.emit("4", units[i].id, 1)
  946. }
  947. window.spikes = window.spikes || function () {
  948. for (var i = 0; i < units.length; ++i) 3 == units[i].type && "hexagon" == units[i].shape && units[i].owner == player.sid && socket.emit("4", units[i].id, 0)
  949. }
  950. window.powerPlants = window.powerPlants || function () {
  951. for (var i = 0; i < units.length; ++i) 0 == units[i].type && "hexagon" == units[i].shape && units[i].owner == player.sid && socket.emit("4", units[i].id, 0)
  952. }
  953. window.rapid = window.rapid || function () {
  954. for (var i = 0; i < units.length; ++i) 0 == units[i].type && 1 == units[i].turretIndex && "circle" == units[i].shape && units[i].owner == player.sid && socket.emit("4", units[i].id, 0)
  955. }
  956. window.ranged = window.ranged || function () {
  957. for (var i = 0; i < units.length; ++i) 0 == units[i].type && 1 == units[i].turretIndex && "circle" == units[i].shape && units[i].owner == player.sid && socket.emit("4", units[i].id, 1)
  958. }
  959. window.antiTank = window.antiTank || function () {
  960. for (var i = 0; i < units.length; ++i) 0 == units[i].type && 4 == units[i].turretIndex && "circle" == units[i].shape && units[i].owner == player.sid && socket.emit("4", units[i].id, 1)
  961. }
  962. window.semiAuto = window.semiAuto || function () {
  963. for (var i = 0; i < units.length; ++i) 0 == units[i].type && 4 == units[i].turretIndex && "circle" == units[i].shape && units[i].owner == player.sid && socket.emit("4", units[i].id, 0)
  964. }
  965. window.gatlins = window.gatlins || function () {
  966. for (var i = 0; i < units.length; ++i) 0 == units[i].type && 2 == units[i].turretIndex && "circle" == units[i].shape && units[i].owner == player.sid && socket.emit("4", units[i].id, 0)
  967. }
  968. window.spotter = window.spotter || function () {
  969. for (var i = 0; i < units.length; ++i) 0 == units[i].type && 3 == units[i].turretIndex && "circle" == units[i].shape && units[i].owner == player.sid && socket.emit("4", units[i].id, 0)
  970. };
  971. window.build = function (instr) {
  972. instr.forEach((ins) => {
  973. emit2.apply({}, ins);
  974. })
  975. }
  976. window.buildHybrid = function () {
  977. window.build([["1", 3.13, 243.85, 5], ["1", 2.87, 246.85, 2], ["1", 2.62, 243.85, 5], ["1", 2.37, 246.85, 2], ["1", 2.11, 243.85, 5], ["1", 1.86, 246.85, 2], ["1", 1.6, 243.85, 5], ["1", 1.34, 246.85, 2], ["1", 1.08, 243.85, 5], ["1", 0.82, 246.85, 2], ["1", 0.56, 243.85, 5], ["1", 0.3, 246.85, 2], ["1", 0.04, 243.85, 5], ["1", -0.21, 246.85, 2], ["1", -0.46, 243.85, 5], ["1", -0.72, 246.85, 2], ["1", -0.98, 243.85, 5], ["1", -1.23, 246.85, 2], ["1", -1.49, 243.85, 5], ["1", -1.74, 246.85, 2], ["1", -1.99, 243.85, 5], ["1", -2.25, 246.85, 2], ["1", -2.51, 243.85, 5], ["1", -2.77, 246.85, 2], ["1", 2.77, 190.49, 2], ["1", 2.43, 187.99, 2], ["1", 1.96, 188.53, 2], ["1", 2.76, 130, 4], ["1", 2.28, 130, 4], ["1", 1.79, 130, 4], ["1", 1.28, 130, 4], ["1", 0.79, 130, 4], ["1", 0.28, 130, 4], ["1", -0.19, 130, 4], ["1", -0.67, 130, 4], ["1", -1.17, 130, 4], ["1", -1.64, 130, 4], ["1", -2.13, 130, 4], ["1", -2.61, 130, 4], ["1", -3.06, 138.27, 4], ["1", -2.94, 195.69, 2], ["1", -2.4, 183.33, 2], ["1", -1.91, 180.8, 2], ["1", -1.41, 182.01, 2], ["1", -0.94, 182.52, 2], ["1", -0.45, 180.37, 2], ["1", 0.04, 178.74, 2], ["1", 0.53, 177.22, 2], ["1", 1.03, 181.72, 2], ["1", 1.49, 184.1, 2]]);
  978. }
  979. window.buildHouses = function () {
  980. window.build([["1", -0.09, 245.4, 1], ["1", 0.16, 243.15, 1], ["1", 0.41, 243.84, 1], ["1", 0.67, 244.57, 1], ["1", 0.04, 183.15, 5], ["1", 0.39, 184.96, 2], ["1", 0.72, 184.99, 4], ["1", 0.92, 245.85, 4], ["1", -0.34, 245.85, 4], ["1", -0.34, 140, 7], ["1", -0.6, 245.85, 4], ["1", 0.25, 130, 4], ["1", -0.88, 130, 4], ["1", -1.37, 130, 4], ["1", -1.86, 130, 4], ["1", -2.36, 130, 4], ["1", -2.88, 130, 4], ["1", 2.85, 130, 4], ["1", 2.36, 130, 4], ["1", 1.85, 130, 4], ["1", 1.38, 130, 4], ["1", 0.9, 130, 4], ["1", 1.19, 245.85, 4], ["1", 1.46, 245.85, 4], ["1", 1.73, 245.85, 4], ["1", 2, 245.85, 4], ["1", 2.26, 245.85, 4], ["1", 2.52, 245.85, 4], ["1", 2.78, 245.85, 4], ["1", 3.04, 245.85, 4], ["1", -2.99, 245.85, 4], ["1", -2.74, 245.85, 4], ["1", -2.49, 245.85, 4], ["1", -2.24, 245.85, 4], ["1", -1.99, 245.85, 4], ["1", -1.74, 245.85, 4], ["1", -1.48, 245.85, 4], ["1", -1.23, 245.85, 4], ["1", -0.94, 245.85, 4], ["1", -0.72, 187.11, 4], ["1", -1.06, 186.05, 4], ["1", -1.53, 186.15, 4], ["1", -1.87, 191.23, 4], ["1", -2.21, 185.53, 4], ["1", -2.55, 184.19, 4], ["1", 1.07, 186.28, 4], ["1", 1.61, 184.13, 4], ["1", 2.07, 185.66, 4], ["1", 2.39, 192.03, 4], ["1", 2.71, 186.8, 4], ["1", 3.06, 185.93, 4]])
  981. // window.build([["1", 0.24, 245.85, 4], ["1", 0.49, 245.85, 4], ["1", 0.74, 245.85, 4], ["1", -0.01, 245.85, 4], ["1", -0.26, 245.85, 4], ["1", -0.51, 245.85, 4], ["1", 1, 245.85, 4], ["1", 1.25, 245.85, 4], ["1", 1.5, 245.85, 4], ["1", 1.75, 245.85, 4], ["1", 2, 245.85, 4], ["1", 2.25, 245.85, 4], ["1", 2.5, 245.85, 4], ["1", 2.75, 245.85, 4], ["1", 3.01, 245.85, 4], ["1", -3.03, 245.85, 4], ["1", -3.01, 245.85, 4], ["1", -2.75, 245.85, 4], ["1", -2.49, 245.85, 4], ["1", -2.24, 245.85, 4], ["1", -1.98, 245.85, 4], ["1", -1.72, 245.85, 4], ["1", -1.46, 245.85, 4], ["1", -1.21, 245.85, 4], ["1", -0.96, 245.85, 4], ["1", -0.72, 203.14, 4], ["1", -0.39, 190.85, 4], ["1", -0.59, 130, 4], ["1", -0.05, 185.69, 4], ["1", 0.11, 130, 4], ["1", 0.31, 185.08, 5], ["1", 0.66, 187.02, 4], ["1", 1.02, 184.03, 4], ["1", 0.84, 130, 4], ["1", 1.36, 189.19, 4], ["1", 1.7, 186.55, 4], ["1", 1.44, 130, 4], ["1", 2.05, 186.48, 4], ["1", 1.92, 130, 4], ["1", 1.91, 130, 4], ["1", 2.38, 191.67, 4], ["1", 2.38, 130, 4], ["1", 2.71, 185.92, 4], ["1", 3.05, 185.84, 4], ["1", 2.87, 130, 4], ["1", -2.9, 188.9, 4], ["1", -2.57, 187.48, 4], ["1", -2.74, 130, 4], ["1", -2.24, 185.43, 4], ["1", -1.91, 186.44, 4], ["1", -2.07, 130, 4], ["1", -1.57, 190.81, 4], ["1", -1.58, 186.32, 4], ["1", -1.42, 130, 4], ["1", -1.24, 186.06, 4]]);
  982. }
  983. window.buildGenerators = function () {
  984. var arr = [["1", 3.11, 243.85, 3], ["1", -2.9, 243.85, 3], ["1", -2.63, 243.85, 3], ["1", -2.36, 243.85, 3], ["1", -2.06, 243.85, 3], ["1", -1.77, 243.85, 3], ["1", -1.5, 243.85, 3], ["1", -1.22, 243.85, 3], ["1", -0.94, 243.85, 3], ["1", -0.64, 243.85, 3], ["1", -0.36, 243.85, 3], ["1", -0.07, 243.85, 3], ["1", 0.2, 243.85, 3], ["1", 0.47, 243.85, 3], ["1", 0.76, 243.85, 3], ["1", 1.05, 243.85, 3], ["1", 1.35, 243.85, 3], ["1", 1.64, 243.85, 3], ["1", 1.92, 243.85, 3], ["1", 2.22, 243.85, 3], ["1", 2.49, 243.85, 3], ["1", 2.78, 243.85, 3], ["1", 3, 183.39, 3], ["1", -2.91, 178.82, 3], ["1", -2.5, 182.85, 3], ["1", -2.11, 178.92, 3], ["1", -1.72, 176.82, 3], ["1", -1.35, 177.59, 3], ["1", -0.98, 174.52, 3], ["1", -0.57, 179.76, 3], ["1", -0.19, 183.42, 3], ["1", 0.21, 176.37, 3], ["1", 0.63, 179.87, 3], ["1", 1.03, 175.57, 3], ["1", 1.43, 176.6, 3], ["1", 1.8, 181.19, 3], ["1", 2.19, 177.95, 3], ["1", 2.6, 178.66, 3]]
  985. window.build(arr);
  986. }
  987. window.makeUI = function () {
  988. if (window.hasMadeUI) return;
  989. window.hasMadeUI = true;
  990. window.statusItems.sort(function (a, b) {
  991. return a.order - b.order;
  992. })
  993. var levels = [];
  994. window.UIList.forEach((item) => {
  995. if (!levels[item.level]) levels[item.level] = [];
  996. levels[item.level].push(item)
  997. })
  998.  
  999. levels = levels.filter((a) => {
  1000. if (a) {
  1001. a.sort(function (a, b) {
  1002. return a.x - b.x;
  1003. })
  1004. return true;
  1005. } else {
  1006. return false;
  1007. }
  1008. })
  1009.  
  1010. var headAppend = document.getElementsByTagName("head")[0],
  1011. style = document.createElement("div");
  1012.  
  1013. var toast = document.createElement('div');
  1014. toast.id = "snackbar";
  1015. var css = document.createElement('div');
  1016.  
  1017. css.innerHTML = '<style>\n\
  1018. #snackbar {\n\
  1019. visibility: hidden;\n\
  1020. min-width: 250px;\n\
  1021. margin-left: -125px;\n\
  1022. background-color: rgba(40, 40, 40, 0.5);\n\
  1023. color: #fff;\n\
  1024. text-align: center;\n\
  1025. border-radius: 4px;\n\
  1026. padding: 10px;\n\
  1027. font-family: "regularF";\n\
  1028. font-size: 20px;\n\
  1029. position: fixed;\n\
  1030. z-index: 100;\n\
  1031. left: 50%;\n\
  1032. top: 30px;\n\
  1033. }\n\
  1034. #snackbar.show {\n\
  1035. visibility: visible;\n\
  1036. -webkit-animation: fadein 0.5s;\n\
  1037. animation: fadein 0.5s;\n\
  1038. }\n\
  1039. #snackbar.hide {\n\
  1040. visibility: visible;\n\
  1041. -webkit-animation: fadeout 0.5s;\n\
  1042. animation: fadeout 0.5s;\n\
  1043. }\n\
  1044. @-webkit-keyframes fadein {\n\
  1045. from {top: 0; opacity: 0;}\n\
  1046. to {top: 30px; opacity: 1;}\n\
  1047. }\n\
  1048. @keyframes fadein {\n\
  1049. from {top: 0; opacity: 0;}\n\
  1050. to {top: 30px; opacity: 1;}\n\
  1051. }\n\
  1052. @-webkit-keyframes fadeout {\n\
  1053. from {top: 30px; opacity: 1;}\n\
  1054. to {top: 0; opacity: 0;}\n\
  1055. }\n\
  1056. @keyframes fadeout {\n\
  1057. from {top: 30px; opacity: 1;}\n\
  1058. to {top: 0; opacity: 0;}\n\
  1059. }\n\
  1060. </style>'
  1061. var height = levels.length * (14 + 19) + (levels.length - 1) * 7 + 15;
  1062. style.innerHTML = "<style>\n\
  1063. #noobscriptUI, #noobscriptUI > div > div {\n\
  1064. background-color:rgba(40,40,40,.5);\n\
  1065. margin-left: 3px;\n\
  1066. border-radius:4px;\n\
  1067. pointer-events:all\n\
  1068. }\n\
  1069. #noobscriptUI {\n\
  1070. top: -" + (height + 12) + "px;\n\
  1071. transition: 1s;\n\
  1072. margin-left:10px;\n\
  1073. position:absolute;\n\
  1074. padding-left:24px;\n\
  1075. margin-top:9px;\n\
  1076. padding-top:15px;\n\
  1077. width:580px;\n\
  1078. height: " + height + "px;\n\
  1079. font-family:arial;\n\
  1080. left:25%\n\
  1081. }\n\
  1082. #noobscriptUI:hover{\n\
  1083. top:0px\n\
  1084. }\n\
  1085. #noobscriptUI > div > div {\n\
  1086. color:#fff;\n\
  1087. padding:7px;\n\
  1088. height:19px;\n\
  1089. display:inline-block;\n\
  1090. cursor:pointer;\n\
  1091. font-size:15px\n\
  1092. }\n\
  1093. </style>"
  1094.  
  1095. headAppend.appendChild(style);
  1096. headAppend.appendChild(css);
  1097.  
  1098.  
  1099. var contAppend = document.getElementById("gameUiContainer"),
  1100. menuA = document.createElement("div");
  1101.  
  1102. var code = ['<div id="noobscriptUI">\n'];
  1103.  
  1104. levels.forEach((items, i) => {
  1105. code.push(i === 0 ? ' <div>\n' : ' <div style="margin-top:7px;">\n');
  1106. items.forEach((el) => {
  1107. code.push(' ' + el.html + '\n');
  1108. })
  1109. code.push(' </div>\n');
  1110. })
  1111. code.push(' <div id="confinfo" style="margin-top:4px; color: white; text-align: center; font-size: 10px; white-space:pre"></div>')
  1112. code.push('</div>');
  1113.  
  1114. menuA.innerHTML = code.join("");
  1115. contAppend.insertBefore(menuA, contAppend.firstChild)
  1116. contAppend.appendChild(toast)
  1117. var toastTimeout = false;
  1118. window.showToast = function (msg) {
  1119. toast.textContent = msg;
  1120.  
  1121. if (toastTimeout) clearTimeout(toastTimeout);
  1122. else toast.className = "show";
  1123. toastTimeout = setTimeout(function () {
  1124. toast.className = 'hide'
  1125. setTimeout(function () {
  1126. toast.className = '';
  1127. }, 400);
  1128. toastTimeout = false;
  1129. }, 3000);
  1130. }
  1131. window.statusBar = function () {
  1132. var el = document.getElementById('confinfo');
  1133. var text = [];
  1134.  
  1135. window.statusItems.forEach((item, i) => {
  1136. if (i !== 0) text.push(' ');
  1137. if (item.name) text.push(item.name + ': ');
  1138. text.push(item.value());
  1139. })
  1140.  
  1141. el.textContent = text.join('');
  1142. }
  1143. window.statusBar();
  1144.  
  1145. window.initFuncs.forEach((func) => {
  1146. func();
  1147. })
  1148. }
  1149. setTimeout(() => {
  1150. window.makeUI();
  1151. }, 1000)(function() {
  1152. 'use strict';
  1153.  
  1154. // Your code here...
  1155. })();addEventListener("keydown", function(a) {
  1156. if (a.keyCode == 80) { //Generators
  1157. socket.emit("1",2.10,132,2);
  1158. socket.emit("1",2.62,132,2);
  1159. socket.emit("1",3.14,132,2);
  1160. socket.emit("1",3.66,132,2);
  1161. socket.emit("1",4.18,132,2);
  1162. socket.emit("1",4.70,132,5);
  1163. socket.emit("1",5.22,132,2);
  1164. socket.emit("1",5.74,132,2);
  1165. socket.emit("1",6.26,132,2);
  1166. socket.emit("1",6.78,132,2);
  1167. socket.emit("1",7.30,132,2);
  1168. socket.emit("1",2.35,132,2);
  1169. socket.emit("1",1.89,186,5);
  1170. socket.emit("1",2.35,184,5);
  1171. socket.emit("1",2.88,184,5);
  1172. socket.emit("1",3.41,184,5);
  1173. socket.emit("1",3.93,184,5);
  1174. socket.emit("1",4.45,184,5);
  1175. socket.emit("1",4.97,184,5);
  1176. socket.emit("1",5.47,184,5);
  1177. socket.emit("1",5.98,184,5);
  1178. socket.emit("1",6.51,184,5);
  1179. socket.emit("1",7.03,184,5);
  1180. socket.emit("1",7.50,186,5);
  1181. }
  1182. if (a.keyCode == 186) {//Walls
  1183. for(i=-3.14;i<3.14;i+=0.075){
  1184. socket.emit("1",i,1e3,1);
  1185. }
  1186. }
  1187. if (a.keyCode == 80) { //Armory
  1188. socket.emit("1",UTILS.roundToTwo(1.56),UTILS.roundToTwo(132),5);
  1189. }
  1190. if (a.keyCode == 76) { //Houses
  1191. socket.emit("1",2.54,245,3);
  1192. socket.emit("1",2.82,245,3);
  1193. socket.emit("1",3.09,245,3);
  1194. socket.emit("1",3.36,245,3);
  1195. socket.emit("1",3.62,245,3);
  1196. socket.emit("1",3.90,245,3);
  1197. socket.emit("1",4.17,245,3);
  1198. socket.emit("1",4.44,245,3);
  1199. socket.emit("1",5.02,245,3);
  1200. socket.emit("1",5.29,245,3);
  1201. socket.emit("1",5.56,245,3);
  1202. socket.emit("1",5.82,245,3);
  1203. socket.emit("1",6.08,245,3);
  1204. socket.emit("1",6.35,245,3);
  1205. socket.emit("1",6.62,245,3);
  1206. socket.emit("1",6.90,245,3);
  1207. socket.emit("1",7.44,245,3);
  1208. socket.emit("1",7.72,245,3);
  1209. socket.emit("1",8.00,245,3);
  1210. socket.emit("1",8.28,245,3);
  1211. socket.emit("1",7.44,245,3);
  1212. socket.emit("1",7.72,245,3);
  1213. socket.emit("1",8.00,245,3);
  1214. socket.emit("1",8.28,245,3);
  1215. socket.emit("1",4.72,245,3);
  1216. socket.emit("1",2.26,245,3);
  1217. socket.emit("1",7.19,245,3);
  1218. }
  1219. });addEventListener("keydown", function(a) {
  1220. if (a.keyCode == 73) { //
  1221. socket.emit("1",2.10,132,1);
  1222. socket.emit("1",2.62,132,1);
  1223. socket.emit("1",3.14,132,1);
  1224. socket.emit("1",3.66,132,1);
  1225. socket.emit("1",4.18,132,1);
  1226. socket.emit("1",4.70,132,1);
  1227. socket.emit("1",5.22,132,1);
  1228. socket.emit("1",5.74,132,1);
  1229. socket.emit("1",6.26,132,1);
  1230. socket.emit("1",6.78,132,1);
  1231. socket.emit("1",7.30,132,1);
  1232. socket.emit("1",2.35,132,1);
  1233. }
  1234. if (a.keyCode == 73) { //
  1235. socket.emit("1",UTILS.roundToTwo(1.56),UTILS.roundToTwo(132),1);
  1236. }
  1237. if (a.keyCode == 73) { //
  1238. socket.emit("1",2.54,245,1);
  1239. socket.emit("1",2.82,245,1);
  1240. socket.emit("1",3.09,245,1);
  1241. socket.emit("1",3.36,245,1);
  1242. socket.emit("1",3.62,245,1);
  1243. socket.emit("1",3.90,245,1);
  1244. socket.emit("1",4.17,245,1);
  1245. socket.emit("1",4.44,245,1);
  1246. socket.emit("1",5.02,245,1);
  1247. socket.emit("1",5.29,245,1);
  1248. socket.emit("1",5.56,245,1);
  1249. socket.emit("1",5.82,245,1);
  1250. socket.emit("1",6.08,245,1);
  1251. socket.emit("1",6.35,245,1);
  1252. socket.emit("1",6.62,245,1);
  1253. socket.emit("1",6.90,245,1);
  1254. socket.emit("1",1.89,186,1);
  1255. socket.emit("1",2.35,184,1);
  1256. socket.emit("1",2.88,184,1);
  1257. socket.emit("1",3.41,184,1);
  1258. socket.emit("1",3.93,184,1);
  1259. socket.emit("1",4.45,184,1);
  1260. socket.emit("1",4.97,184,1);
  1261. socket.emit("1",5.47,184,1);
  1262. socket.emit("1",5.98,184,1);
  1263. socket.emit("1",6.51,184,1);
  1264. socket.emit("1",7.03,184,1);
  1265. socket.emit("1",7.50,186,1);
  1266. socket.emit("1",7.44,245,1);
  1267. socket.emit("1",7.72,245,1);
  1268. socket.emit("1",8.00,245,1);
  1269. socket.emit("1",8.28,245,1);
  1270. socket.emit("1",7.44,245,1);
  1271. socket.emit("1",7.72,245,1);
  1272. socket.emit("1",8.00,245,1);
  1273. socket.emit("1",8.28,245,1);
  1274. socket.emit("1",4.72,245,1);
  1275. socket.emit("1",2.26,245,1);
  1276. socket.emit("1",7.19,245,1);
  1277. }
  1278. if (a.keyCode == 79){
  1279. for(i=0;i<units.length;++i){
  1280. if(0===units[i].type&&1==units[i].turretIndex&&"circle"==units[i].shape&&units[i].owner==player.sid){
  1281. socket.emit("4",units[i].id,1);
  1282. }
  1283. }
  1284. }
  1285. if (a.keyCode == 79){
  1286. for(i=0;i<units.length;++i){
  1287. if(0===units[i].type&&3==units[i].turretIndex&&"circle"==units[i].shape&&units[i].owner==player.sid){
  1288. socket.emit("4",units[i].id,0);
  1289. }
  1290. }
  1291. }
  1292. if (a.keyCode == 79){
  1293. for(i=0;i<units.length;++i){
  1294. if(3==units[i].type&&"circle"==units[i].shape&&units[i].owner==player.sid){
  1295. socket.emit("4",units[i].id,0);
  1296. }
  1297. }
  1298. }
  1299. if (a.keyCode == 79){
  1300. for(i=0;i<units.length;++i){
  1301. if(3==units[i].type&&"hexagon"==units[i].shape&&units[i].owner==player.sid){
  1302. socket.emit("4",units[i].id,0);
  1303. }
  1304. }
  1305. }
  1306. });