Advertisement
Guest User

New Brofist.io Cheats 0.4.2

a guest
Dec 12th, 2017
9,560
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 36.08 KB | None | 0 0
  1. // ==UserScript==
  2. // @name New Brofistio Cheats
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.4.2
  5. // @description Brofist.io Hack
  6. // @author Troll
  7. // @match http://brofist.io/modes/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. /*
  12. * Authored by CuteLifeBot
  13. * Updated by Troll
  14. * 10 December 2017
  15. */
  16.  
  17. (function() {
  18.  
  19. var oldGravity = -9.77;
  20. var zoomCoeff = 1600;
  21. var verts = [];
  22. var imgURLText = "";
  23. var smallestDiff;
  24. var closestColour;
  25. window.denyNormalness = false;
  26.  
  27. // Minimap Coefficients
  28. var MC = {
  29. x: {
  30. p: [
  31. 41,
  32. 4110
  33. ],
  34. a: [
  35. -151.68,
  36. 930.08
  37. ]
  38. },
  39. y: {
  40. p: [
  41. 74,
  42. 691
  43. ],
  44. a: [
  45. 26.64,
  46. -137.46
  47. ]
  48. },
  49. width: 5168,
  50. height: 1016
  51. };
  52.  
  53. mode = false;
  54.  
  55. function waitForPlay() {
  56. if(!mode) {
  57. setTimeout(waitForPlay, 500);
  58. return;
  59. }
  60.  
  61. if(mode.player === undefined) {
  62. setTimeout(waitForPlay, 500);
  63. return;
  64. }
  65.  
  66. if(mode.player.gpData === undefined) {
  67. setTimeout(waitForPlay, 500);
  68. return;
  69. }
  70.  
  71. if(mode.player.gpData.p === undefined) {
  72. setTimeout(waitForPlay, 500);
  73. return;
  74. }
  75.  
  76. doCheats();
  77. }
  78.  
  79. function doCheats() {
  80. console.log("Added cheats!");
  81.  
  82. // Print in console the key name
  83. var keyNameDebug = false;
  84.  
  85. ////// LEFT
  86. (function() {
  87. var repeat = 0;
  88. var pastFirst = false;
  89.  
  90. window.keyboardJS.bind("num4", function(e) {
  91. if (keyNameDebug) console.log("Left Down");
  92. (repeat = 1);
  93. if (pastFirst) {
  94. mode.updateChatText(8, mode.player.gpData.chat);
  95. mode.player.gpData.chatBuffer = [8];
  96. }
  97. pastFirst = true;
  98. }, function(e) {
  99. if (keyNameDebug) console.log("Left Up");
  100. (repeat = 0, 1) && resetNormalness();
  101. mode.updateChatText(8, mode.player.gpData.chat);
  102. mode.player.gpData.chatBuffer = [8];
  103. pastFirst = false;
  104. });
  105.  
  106. setInterval(function() {
  107. if (!repeat) {
  108. return;
  109. };
  110. mode.player.gpData.p.world.gravity = [0, 0];
  111. mode.player.gpData.p.world.useFrictionGravityOnZeroGravity = false;
  112. mode.player.gpData.p.position[0] += -0.03;
  113. }, 10);
  114. })();
  115. ////// RIGHT
  116. (function() {
  117. var repeat = 0;
  118. var pastFirst = false;
  119.  
  120. window.keyboardJS.bind("num6", function(e) {
  121. if (keyNameDebug) console.log("Right Down");
  122. (repeat = 1);
  123. if (pastFirst) {
  124. mode.updateChatText(8, mode.player.gpData.chat);
  125. mode.player.gpData.chatBuffer = [8];
  126. }
  127. pastFirst = true;
  128. }, function(e) {
  129. if (keyNameDebug) console.log("Right Up");
  130. (repeat = 0, 1) && resetNormalness();
  131. mode.updateChatText(8, mode.player.gpData.chat);
  132. mode.player.gpData.chatBuffer = [8];
  133. pastFirst = false;
  134. });
  135.  
  136. setInterval(function() {
  137. if (!repeat) {
  138. return;
  139. };
  140. mode.player.gpData.p.world.gravity = [0, 0];
  141. mode.player.gpData.p.world.useFrictionGravityOnZeroGravity = false;
  142. mode.player.gpData.p.position[0] += 0.03;
  143. }, 10);
  144. })();
  145. ////// UP
  146. (function() {
  147. var repeat = 0;
  148. var pastFirst = false;
  149.  
  150. window.keyboardJS.bind("num8", function(e) {
  151. if (keyNameDebug) console.log("Up Down");
  152. (repeat = 1);
  153. if (pastFirst) {
  154. mode.updateChatText(8, mode.player.gpData.chat);
  155. mode.player.gpData.chatBuffer = [8];
  156. }
  157. pastFirst = true;
  158. }, function(e) {
  159. if (keyNameDebug) console.log("Up Up");
  160. (repeat = 0, 1) && resetNormalness();
  161. mode.updateChatText(8, mode.player.gpData.chat);
  162. mode.player.gpData.chatBuffer = [8];
  163. pastFirst = false;
  164. });
  165.  
  166. setInterval(function() {
  167. if (!repeat) {
  168. return;
  169. };
  170. mode.player.gpData.p.world.gravity = [0, 0];
  171. mode.player.gpData.p.world.useFrictionGravityOnZeroGravity = false;
  172. mode.player.gpData.p.position[1] += 0.03;
  173. }, 10);
  174. })();
  175. ////// DOWN
  176. (function() {
  177. var repeat = 0;
  178. var pastFirst = false;
  179.  
  180. window.keyboardJS.bind("num5", function(e) {
  181. if (keyNameDebug) console.log("Down Down");
  182. (repeat = 1);
  183. if (pastFirst) {
  184. mode.updateChatText(8, mode.player.gpData.chat);
  185. mode.player.gpData.chatBuffer = [8];
  186. }
  187. pastFirst = true;
  188. }, function(e) {
  189. if (keyNameDebug) console.log("Down Up");
  190. (repeat = 0, 1) && resetNormalness();
  191. mode.updateChatText(8, mode.player.gpData.chat);
  192. mode.player.gpData.chatBuffer = [8];
  193. pastFirst = false;
  194. });
  195.  
  196. setInterval(function() {
  197. if (!repeat) {
  198. return;
  199. };
  200. mode.player.gpData.p.world.gravity = [0, 0];
  201. mode.player.gpData.p.world.useFrictionGravityOnZeroGravity = false;
  202. mode.player.gpData.p.position[1] += -0.03;
  203. }, 10);
  204. })();
  205.  
  206.  
  207. ////// SUPER UP
  208. (function() {
  209. var repeat = 0;
  210. var pastFirst = false;
  211.  
  212. window.keyboardJS.bind("num/", function(e) {
  213. if (keyNameDebug) console.log("SuperUp Down");
  214. (repeat = 1);
  215. if (pastFirst) {
  216. mode.updateChatText(8, mode.player.gpData.chat);
  217. mode.player.gpData.chatBuffer = [8];
  218. }
  219. pastFirst = true;
  220. }, function(e) {
  221. if (keyNameDebug) console.log("SuperUp Up");
  222. (repeat = 0, 1) && resetNormalness();
  223. mode.updateChatText(8, mode.player.gpData.chat);
  224. mode.player.gpData.chatBuffer = [8];
  225. pastFirst = false;
  226. });
  227.  
  228. setInterval(function() {
  229. if (!repeat) {
  230. return;
  231. };
  232. mode.player.gpData.p.world.gravity = [0, 0];
  233. mode.player.gpData.p.world.useFrictionGravityOnZeroGravity = false;
  234. mode.player.gpData.p.position[1] += 0.15;
  235. }, 10);
  236. })();
  237. ////// SUPER DOWN
  238. (function() {
  239. var repeat = 0;
  240. var pastFirst = false;
  241.  
  242. window.keyboardJS.bind("num2", function(e) {
  243. if (keyNameDebug) console.log("SuperDown Down");
  244. (repeat = 1);
  245. if (pastFirst) {
  246. mode.updateChatText(8, mode.player.gpData.chat);
  247. mode.player.gpData.chatBuffer = [8];
  248. }
  249. pastFirst = true;
  250. }, function(e) {
  251. if (keyNameDebug) console.log("SuperDown Up");
  252. (repeat = 0, 1) && resetNormalness();
  253. mode.updateChatText(8, mode.player.gpData.chat);
  254. mode.player.gpData.chatBuffer = [8];
  255. pastFirst = false;
  256. });
  257.  
  258. setInterval(function() {
  259. if (!repeat) {
  260. return;
  261. };
  262. mode.player.gpData.p.world.gravity = [0, 0];
  263. mode.player.gpData.p.world.useFrictionGravityOnZeroGravity = false;
  264. mode.player.gpData.p.position[1] += -0.15;
  265. }, 10);
  266. })();
  267. ////// SUPER LEFT
  268. (function() {
  269. var repeat = 0;
  270. var pastFirst = false;
  271.  
  272. window.keyboardJS.bind("num1", function(e) {
  273. if (keyNameDebug) console.log("SuperLeft Down");
  274. (repeat = 1);
  275. if (pastFirst) {
  276. mode.updateChatText(8, mode.player.gpData.chat);
  277. mode.player.gpData.chatBuffer = [8];
  278. }
  279. pastFirst = true;
  280. }, function(e) {
  281. if (keyNameDebug) console.log("SuperLeft Up");
  282. (repeat = 0, 1) && resetNormalness();
  283. mode.updateChatText(8, mode.player.gpData.chat);
  284. mode.player.gpData.chatBuffer = [8];
  285. pastFirst = false;
  286. });
  287.  
  288. setInterval(function() {
  289. if (!repeat) {
  290. return;
  291. };
  292. mode.player.gpData.p.world.gravity = [0, 0];
  293. mode.player.gpData.p.world.useFrictionGravityOnZeroGravity = false;
  294. mode.player.gpData.p.position[0] += -0.15;
  295. }, 10);
  296. })();
  297. ////// SUPER RIGHT
  298. (function() {
  299. var repeat = 0;
  300. var pastFirst = false;
  301.  
  302. window.keyboardJS.bind("num3", function(e) {
  303. if (keyNameDebug) console.log("SuperRight Down");
  304. (repeat = 1);
  305. if (pastFirst) {
  306. mode.updateChatText(8, mode.player.gpData.chat);
  307. mode.player.gpData.chatBuffer = [8];
  308. }
  309. pastFirst = true;
  310. }, function(e) {
  311. if (keyNameDebug) console.log("SuperRight Up");
  312. (repeat = 0, 1) && resetNormalness();
  313. mode.updateChatText(8, mode.player.gpData.chat);
  314. mode.player.gpData.chatBuffer = [8];
  315. pastFirst = false;
  316. });
  317.  
  318. setInterval(function() {
  319. if (!repeat) {
  320. return;
  321. }
  322. mode.player.gpData.p.world.gravity = [0, 0];
  323. mode.player.gpData.p.world.useFrictionGravityOnZeroGravity = false;
  324. mode.player.gpData.p.position[0] += 0.15;
  325. }, 10);
  326. })();
  327.  
  328. // Text box functions
  329. (function() {
  330. // Prepend html
  331. // imgur / ptZVIHV alternative
  332. var textHtml="";
  333. textHtml += "<div id=\"cheats\" style=\"position: absolute; background-color: lightgrey; padding: 5px;\">";
  334. textHtml += " X: <input type=\"text\" id=\"positionX\" maxlength=\"8\" size=\"10\"><br\/>";
  335. textHtml += " Y: <input type=\"text\" id=\"positionY\" maxlength=\"8\" size=\"10\"><hr\/>";
  336. textHtml += " <input type=\"checkbox\" id=\"minimapcb\"> minimap<br\/>";
  337. textHtml += " <input type=\"checkbox\" id=\"gravitycb\"> gravity<br\/>";
  338. textHtml += " <input type=\"checkbox\" id=\"noclipcb\"> noclip<hr\/>";
  339. textHtml += " Say: <input type=\"text\" id=\"msgSay\" size=\"10\"><hr\/>";
  340. textHtml += " <input type=\"checkbox\" id=\"degrees\"> 180 degrees skin<br\/>";
  341. textHtml += " <input type=\"checkbox\" id=\"ghost\"> ghost<br\/>";
  342. textHtml += " NC: <input type=\"checkbox\" id=\"redNick\">R<input type=\"checkbox\" id=\"greenNick\">G<input type=\"checkbox\" id=\"blueNick\">B<input type=\"checkbox\" id=\"lightblueNick\">LB<input type=\"checkbox\" id=\"yellowNick\">Y<br\/>";
  343. textHtml += " CC: <input type=\"checkbox\" id=\"redChat\">R<input type=\"checkbox\" id=\"greenChat\">G<input type=\"checkbox\" id=\"blueChat\">B<input type=\"checkbox\" id=\"lightblueChat\">LB<input type=\"checkbox\" id=\"yellowChat\">Y<br\/>";
  344. textHtml += " NTA: <input type=\"checkbox\" id=\"A_ctfs\">45<input type=\"checkbox\" id=\"B_ctfs\">135<input type=\"checkbox\" id=\"C_ctfs\">180<br\/>";
  345. textHtml += " CTA: <input type=\"checkbox\" id=\"D_ctfs\">45<input type=\"checkbox\" id=\"E_ctfs\">135<input type=\"checkbox\" id=\"F_ctfs\">180<br\/>";
  346. textHtml += " NFS: <input type=\"checkbox\" id=\"Nck_A\">A<input type=\"checkbox\" id=\"Nck_B\">B<input type=\"checkbox\" id=\"Nck_C\">C<br\/>";
  347. textHtml += " CFS: <input type=\"checkbox\" id=\"Cht_A\">A<input type=\"checkbox\" id=\"Cht_B\">B<input type=\"checkbox\" id=\"Cht_C\">C<br\/>";;
  348. textHtml += " <a href=\"https:\/\/gist.github.com\/CuteLifeBot\/f509039ff6259baa32473a362fcda2cf\" style=\"position: relative; float: right; text-decoration: none;\">Help<\/a>";
  349. textHtml += "<\/div>";
  350. textHtml += "<div id=\"minimap\" style=\"position: fixed; top: 0; right: 0; width: 50%\">";
  351. textHtml += " <img id=\"minimapimg\" src=\"http:\/\/i.imgur.com\/fjM6WpB.png\" width=\"100%\" height=\"100%\" style=\"position: relative; top: 0; left: 0;\"\/>";
  352. textHtml += " <svg id=\"minimapsvg\" width=\"100%\" height=\"100%\" style=\"position: absolute; top: 0; left: 0; z-index: 1;\">";
  353. textHtml += " <circle id=\"posMarker\" cx=\"0\" cy=\"0\" r=\"3\" stroke=\"red\" stroke-width=\"2\" fill=\"black\"><\/circle>";
  354. textHtml += " <\/svg>";
  355. textHtml += "<\/div>";
  356. document.body.insertBefore(createFragment(textHtml), document.body.childNodes[0]);
  357. // Done prepending html
  358.  
  359. window.keyboardJS.bind("enter", function(e) {
  360. if(document.getElementById("positionX") === document.activeElement) {
  361. document.getElementById("positionY").focus();
  362. document.getElementById("positionY").select();
  363. } else if(document.getElementById("positionY") === document.activeElement) {
  364. document.getElementById("positionY").blur();
  365. mode.player.gpData.p.position = [
  366. parseFloat(document.getElementById("positionX").value) || -75,
  367. parseFloat(document.getElementById("positionY").value) || 0
  368. ];
  369. }
  370. });
  371.  
  372. window.keyboardJS.bind("esc", function(e) {
  373. document.getElementById("positionX").focus();
  374. document.getElementById("positionX").select();
  375. });
  376.  
  377. window.keyboardJS.bind("alt", function(e) {
  378. if(document.getElementById("msgSay") === document.activeElement) {
  379. document.getElementById("positionY").blur();
  380.  
  381. var text = document.getElementById("msgSay").value;
  382.  
  383. mode.updateChatText(text, mode.player.gpData.chat);
  384. mode.player.gpData.chatBuffer = [text];
  385. }
  386. });
  387.  
  388. setInterval(function() {
  389. if (!positionFocused()) {
  390. document.getElementById("positionX").value = mode.player.gpData.p.position[0].toFixed(2);
  391. document.getElementById("positionY").value = mode.player.gpData.p.position[1].toFixed(2);
  392. }
  393. }, 100);
  394. })();
  395.  
  396. // Minimap functions
  397. (function () {
  398. var pastFirst = false;
  399.  
  400. // Toggle minimap with "7" on numpad
  401. window.keyboardJS.bind("num7", function(e) {
  402. if (pastFirst) {
  403. mode.updateChatText(8, mode.player.gpData.chat);
  404. mode.player.gpData.chatBuffer = [8];
  405. }
  406. pastFirst = true;
  407. if (document.getElementById('minimapcb').checked) {
  408. document.getElementById("minimap").style.display = "none";
  409. document.getElementById("minimap").style.visibility = "hidden";
  410. } else {
  411. document.getElementById("minimap").style.display = "";
  412. document.getElementById("minimap").style.visibility = "visible";
  413. }
  414. document.getElementById('minimapcb').checked = !document.getElementById('minimapcb').checked;
  415. }, function(e) {
  416. mode.updateChatText(8, mode.player.gpData.chat);
  417. mode.player.gpData.chatBuffer = [8];
  418. pastFirst = false;
  419. });
  420.  
  421. document.getElementById("minimap").style.display = "none";
  422. document.getElementById("minimap").style.visibility = "hidden";
  423.  
  424. setInterval(function() {
  425. if (document.getElementById('minimapcb').checked) {
  426. updateMinimapPosition();
  427. }
  428. }, 100);
  429. })();
  430.  
  431. // Gravity toggle
  432. (function () {
  433. var pastFirst = false;
  434.  
  435. // Toggle gravity with "9" on numpad
  436. window.keyboardJS.bind("num9", function(e) {
  437. if (pastFirst) {
  438. mode.updateChatText(8, mode.player.gpData.chat);
  439. mode.player.gpData.chatBuffer = [8];
  440. }
  441. pastFirst = true;
  442.  
  443. enableGravity(document.getElementById('gravitycb').checked);
  444. document.getElementById('gravitycb').checked = !document.getElementById('gravitycb').checked;
  445. }, function(e) {
  446. mode.updateChatText(8, mode.player.gpData.chat);
  447. mode.player.gpData.chatBuffer = [8];
  448. pastFirst = false;
  449. });
  450.  
  451. document.getElementById('gravitycb').checked = true;
  452. })();
  453.  
  454. // Noclip toggle
  455. (function () {
  456. var pastFirst = false;
  457.  
  458. // Toggle noclip with "0" on numpad
  459. window.keyboardJS.bind("num0", function(e) {
  460. if (pastFirst) {
  461. mode.updateChatText(8, mode.player.gpData.chat);
  462. mode.player.gpData.chatBuffer = [8];
  463. }
  464. pastFirst = true;
  465.  
  466. enableNoclip(!document.getElementById('noclipcb').checked);
  467. document.getElementById('noclipcb').checked = !document.getElementById('noclipcb').checked;
  468. }, function(e) {
  469. mode.updateChatText(8, mode.player.gpData.chat);
  470. mode.player.gpData.chatBuffer = [8];
  471. pastFirst = false;
  472. });
  473.  
  474. document.getElementById('gravitycb').checked = true;
  475. })();
  476.  
  477. // Degrees toggle
  478. (function () {
  479. var pastFirst = false;
  480.  
  481. // Toggle degrees with "*" on numpad
  482. window.keyboardJS.bind("Insert", function(e) {
  483. if (pastFirst) {
  484. mode.updateChatText(8, mode.player.gpData.chat);
  485. mode.player.gpData.chatBuffer = [8];
  486. }
  487. pastFirst = true;
  488.  
  489. degrees(!document.getElementById('degrees').checked);
  490. document.getElementById('degrees').checked = !document.getElementById('degrees').checked;
  491. }, function(e) {
  492. mode.updateChatText(8, mode.player.gpData.chat);
  493. mode.player.gpData.chatBuffer = [8];
  494. pastFirst = false;
  495. });
  496.  
  497. document.getElementById('gravitycb').checked = true;
  498. })();
  499.  
  500. // Toggle minimap
  501. document.getElementById('minimapcb').onclick = function() {
  502. if (document.getElementById('minimapcb').checked) {
  503. document.getElementById("minimap").style.display = "";
  504. document.getElementById("minimap").style.visibility = "visible";
  505. document.getElementById('minimapcb').blur();
  506. } else {
  507. document.getElementById("minimap").style.display = "none";
  508. document.getElementById("minimap").style.visibility = "hidden";
  509. document.getElementById('minimapcb').blur();
  510. }
  511. };
  512.  
  513. // Toggle gravity
  514. document.getElementById('gravitycb').onclick = function() {
  515. enableGravity(!document.getElementById('gravitycb').checked);
  516. document.getElementById('gravitycb').blur();
  517. };
  518.  
  519. // Toggle noclip
  520. document.getElementById('noclipcb').onclick = function() {
  521. enableNoclip(document.getElementById('noclipcb').checked);
  522. document.getElementById('noclipcb').blur();
  523. };
  524.  
  525. // Toggle degrees
  526. document.getElementById('degrees').onclick = function() {
  527. degrees(document.getElementById('degrees').checked);
  528. document.getElementById('degrees').blur();
  529. };
  530.  
  531. // Toggle redNick
  532. document.getElementById('redNick').onclick = function() {
  533. redNick(document.getElementById('redNick').checked);
  534. document.getElementById('redNick').blur();
  535. };
  536.  
  537. // Toggle greenNick
  538. document.getElementById('greenNick').onclick = function() {
  539. greenNick(document.getElementById('greenNick').checked);
  540. document.getElementById('greenNick').blur();
  541. };
  542.  
  543. // Toggle blueNick
  544. document.getElementById('blueNick').onclick = function() {
  545. blueNick(document.getElementById('blueNick').checked);
  546. document.getElementById('blueNick').blur();
  547. };
  548.  
  549. // Toggle lightblueNick
  550. document.getElementById('lightblueNick').onclick = function() {
  551. lightblueNick(document.getElementById('lightblueNick').checked);
  552. document.getElementById('lightblueNick').blur();
  553. };
  554.  
  555. // Toggle yellowNick
  556. document.getElementById('yellowNick').onclick = function() {
  557. yellowNick(document.getElementById('yellowNick').checked);
  558. document.getElementById('yellowNick').blur();
  559. };
  560.  
  561. // Toggle redNick
  562. document.getElementById('redChat').onclick = function() {
  563. redChat(document.getElementById('redChat').checked);
  564. document.getElementById('redChat').blur();
  565. };
  566.  
  567. // Toggle greenNick
  568. document.getElementById('greenChat').onclick = function() {
  569. greenChat(document.getElementById('greenChat').checked);
  570. document.getElementById('greenChat').blur();
  571. };
  572.  
  573. // Toggle blueNick
  574. document.getElementById('blueChat').onclick = function() {
  575. blueChat(document.getElementById('blueChat').checked);
  576. document.getElementById('blueChat').blur();
  577. };
  578.  
  579. // Toggle lightblueNick
  580. document.getElementById('lightblueChat').onclick = function() {
  581. lightblueChat(document.getElementById('lightblueChat').checked);
  582. document.getElementById('lightblueChat').blur();
  583. };
  584.  
  585. // Toggle yellowNick
  586. document.getElementById('yellowChat').onclick = function() {
  587. yellowChat(document.getElementById('yellowChat').checked);
  588. document.getElementById('yellowChat').blur();
  589. };
  590.  
  591. // Toggle ctfs
  592. document.getElementById('A_ctfs').onclick = function() {
  593. A_ctfs(document.getElementById('A_ctfs').checked);
  594. document.getElementById('A_ctfs').blur();
  595. };
  596.  
  597. // Toggle ctfs
  598. document.getElementById('B_ctfs').onclick = function() {
  599. B_ctfs(document.getElementById('B_ctfs').checked);
  600. document.getElementById('B_ctfs').blur();
  601. };
  602.  
  603. // Toggle ctfs
  604. document.getElementById('C_ctfs').onclick = function() {
  605. C_ctfs(document.getElementById('C_ctfs').checked);
  606. document.getElementById('C_ctfs').blur();
  607. };
  608.  
  609. // Toggle ctfs
  610. document.getElementById('D_ctfs').onclick = function() {
  611. D_ctfs(document.getElementById('D_ctfs').checked);
  612. document.getElementById('D_ctfs').blur();
  613. };
  614.  
  615. // Toggle ctfs
  616. document.getElementById('E_ctfs').onclick = function() {
  617. E_ctfs(document.getElementById('E_ctfs').checked);
  618. document.getElementById('E_ctfs').blur();
  619. };
  620.  
  621. // Toggle ctfs
  622. document.getElementById('F_ctfs').onclick = function() {
  623. F_ctfs(document.getElementById('F_ctfs').checked);
  624. document.getElementById('F_ctfs').blur();
  625. };
  626.  
  627. // Toggle NCK
  628. document.getElementById('Nck_A').onclick = function() {
  629. Nck_A(document.getElementById('Nck_A').checked);
  630. document.getElementById('Nck_A').blur();
  631. };
  632.  
  633. // Toggle NCK2
  634. document.getElementById('Nck_B').onclick = function() {
  635. Nck_B(document.getElementById('Nck_B').checked);
  636. document.getElementById('Nck_B').blur();
  637. };
  638.  
  639. // Toggle NCK3
  640. document.getElementById('Nck_C').onclick = function() {
  641. Nck_C(document.getElementById('Nck_C').checked);
  642. document.getElementById('Nck_C').blur();
  643. };
  644.  
  645. // Toggle CHT1
  646. document.getElementById('Cht_A').onclick = function() {
  647. Cht_A(document.getElementById('Cht_A').checked);
  648. document.getElementById('Cht_A').blur();
  649. };
  650.  
  651. // Toggle CHT2
  652. document.getElementById('Cht_B').onclick = function() {
  653. Cht_B(document.getElementById('Cht_B').checked);
  654. document.getElementById('Cht_B').blur();
  655. };
  656.  
  657. // Toggle CHT3
  658. document.getElementById('Cht_C').onclick = function() {
  659. Cht_C(document.getElementById('Cht_C').checked);
  660. document.getElementById('Cht_C').blur();
  661. };
  662.  
  663. // Toggle ghost
  664. document.getElementById('ghost').onclick = function() {
  665. ghost(document.getElementById('ghost').checked);
  666. document.getElementById('ghost').blur();
  667. };
  668.  
  669.  
  670. // Minimap handle clicks
  671. document.getElementById('minimap').onmouseup = function(e) {
  672. var relative_pixel_pos = getRelativeXY(e, 'minimap');
  673. warpToLocation(relative_pixel_pos);
  674. };
  675.  
  676. }
  677.  
  678. function enableGravity(on) {
  679. if (on) {
  680. mode.player.gpData.p.world.gravity = [0, 0];
  681. mode.player.gpData.p.world.useFrictionGravityOnZeroGravity = false;
  682. mode.ghost = !0;
  683. window.denyNormalness = true;
  684. } else {
  685. if (mode.player.gpData.getAlpha() == 1) mode.ghost = !1;
  686. window.denyNormalness = false;
  687. resetNormalness();
  688. }
  689. }
  690.  
  691. function enableNoclip(on) {
  692. if (on) {
  693. mode.player.gpData.p.shapes[0].vertices = [0];
  694. } else {
  695. mode.player.gpData.p.shapes[0].vertices = [[-0.15000000596046448, -0.5], [0.15000000596046448, -0.5], [0.15000000596046448, 0.5], [-0.15000000596046448, 0.5]];
  696. }
  697. }
  698.  
  699. function degrees(on) {
  700. if (on) {
  701. mode.player.gpData.playerShape.refP.setAngle(180);
  702. } else {
  703. mode.player.gpData.playerShape.refP.setAngle(0);
  704. }
  705. }
  706.  
  707. function ghost(on) {
  708. if (on) {
  709. mode.onSpt();
  710. } else {
  711. mode.player.gpData.playerShape.refP.setAngle(0);
  712. }
  713. }
  714.  
  715. function redNick(on) {
  716. if (on) {
  717. mode.player.gpData.shapes[1].setColor("red");
  718. } else {
  719. mode.player.gpData.shapes[1].setColor("white");
  720. }
  721. }
  722.  
  723. function greenNick(on) {
  724. if (on) {
  725. mode.player.gpData.shapes[1].setColor("lime");
  726. } else {
  727. mode.player.gpData.shapes[1].setColor("white");
  728. }
  729. }
  730.  
  731. function blueNick(on) {
  732. if (on) {
  733. mode.player.gpData.shapes[1].setColor("blue");
  734. } else {
  735. mode.player.gpData.shapes[1].setColor("white");
  736. }
  737. }
  738.  
  739. function lightblueNick(on) {
  740. if (on) {
  741. mode.player.gpData.shapes[1].setColor("lightblue");
  742. } else {
  743. mode.player.gpData.shapes[1].setColor("white");
  744. }
  745. }
  746.  
  747. function yellowNick(on) {
  748. if (on) {
  749. mode.player.gpData.shapes[1].setColor("yellow");
  750. } else {
  751. mode.player.gpData.shapes[1].setColor("white");
  752. }
  753. }
  754.  
  755. function redChat(on) {
  756. if (on) {
  757. mode.player.gpData.shapes[0].setColor("red");
  758. } else {
  759. mode.player.gpData.shapes[0].setColor("black");
  760. }
  761. }
  762.  
  763. function greenChat(on) {
  764. if (on) {
  765. mode.player.gpData.shapes[0].setColor("lime");
  766. } else {
  767. mode.player.gpData.shapes[0].setColor("black");
  768. }
  769. }
  770.  
  771. function blueChat(on) {
  772. if (on) {
  773. mode.player.gpData.shapes[0].setColor("blue");
  774. } else {
  775. mode.player.gpData.shapes[0].setColor("black");
  776. }
  777. }
  778.  
  779. function lightblueChat(on) {
  780. if (on) {
  781. mode.player.gpData.shapes[0].setColor("lightblue");
  782. } else {
  783. mode.player.gpData.shapes[0].setColor("black");
  784. }
  785. }
  786.  
  787. function yellowChat(on) {
  788. if (on) {
  789. mode.player.gpData.shapes[0].setColor("yellow");
  790. } else {
  791. mode.player.gpData.shapes[0].setColor("black");
  792. }
  793. }
  794.  
  795. function A_ctfs(on) {
  796. if (on) {
  797. mode.player.gpData.p.ref.shapes[1].setAngle(45);
  798. } else {
  799. mode.player.gpData.p.ref.shapes[1].setAngle(0);
  800. }
  801. }
  802.  
  803. function B_ctfs(on) {
  804. if (on) {
  805. mode.player.gpData.p.ref.shapes[1].setAngle(135);
  806. } else {
  807. mode.player.gpData.p.ref.shapes[1].setAngle(0);
  808. }
  809. }
  810.  
  811. function C_ctfs(on) {
  812. if (on) {
  813. mode.player.gpData.p.ref.shapes[1].setAngle(180);
  814. } else {
  815. mode.player.gpData.p.ref.shapes[1].setAngle(0);
  816. }
  817. }
  818.  
  819. function D_ctfs(on) {
  820. if (on) {
  821. mode.player.gpData.p.ref.shapes[0].setAngle(45);
  822. } else {
  823. mode.player.gpData.p.ref.shapes[0].setAngle(0);
  824. }
  825. }
  826.  
  827. function E_ctfs(on) {
  828. if (on) {
  829. mode.player.gpData.p.ref.shapes[0].setAngle(135);
  830. } else {
  831. mode.player.gpData.p.ref.shapes[0].setAngle(0);
  832. }
  833. }
  834.  
  835. function F_ctfs(on) {
  836. if (on) {
  837. mode.player.gpData.p.ref.shapes[0].setAngle(180);
  838. } else {
  839. mode.player.gpData.p.ref.shapes[0].setAngle(0);
  840. }
  841. }
  842.  
  843. function Nck_A(on) {
  844. if (on) {
  845. mode.player.gpData.p.ref.shapes[1].setFontSize(23);
  846. } else {
  847. mode.player.gpData.p.ref.shapes[1].setFontSize(18);
  848. }
  849. }
  850.  
  851. function Nck_B(on) {
  852. if (on) {
  853. mode.player.gpData.p.ref.shapes[1].setFontSize(29);
  854. } else {
  855. mode.player.gpData.p.ref.shapes[1].setFontSize(18);
  856. }
  857. }
  858.  
  859. function Nck_C(on) {
  860. if (on) {
  861. mode.player.gpData.p.ref.shapes[1].setFontSize(35);
  862. } else {
  863. mode.player.gpData.p.ref.shapes[1].setFontSize(18);
  864. }
  865. }
  866.  
  867. function Cht_A(on) {
  868. if (on) {
  869. mode.player.gpData.p.ref.shapes[0].setFontSize(23);
  870. } else {
  871. mode.player.gpData.p.ref.shapes[0].setFontSize(18);
  872. }
  873. }
  874.  
  875. function Cht_B(on) {
  876. if (on) {
  877. mode.player.gpData.p.ref.shapes[0].setFontSize(29);
  878. } else {
  879. mode.player.gpData.p.ref.shapes[0].setFontSize(18);
  880. }
  881. }
  882.  
  883. function Cht_C(on) {
  884. if (on) {
  885. mode.player.gpData.p.ref.shapes[0].setFontSize(35);
  886. } else {
  887. mode.player.gpData.p.ref.shapes[0].setFontSize(18);
  888. }
  889. }
  890.  
  891. function resetNormalness() {
  892. if (!window.denyNormalness) {
  893. mode.player.gpData.p.world.gravity = [0, oldGravity];
  894. mode.player.gpData.p.world.useFrictionGravityOnZeroGravity = true;
  895. }
  896. return true;
  897. }
  898.  
  899. function positionFocused() {
  900. return (document.getElementById("positionX") === document.activeElement || document.getElementById("positionY") === document.activeElement);
  901. }
  902.  
  903. function createFragment(htmlStr) {
  904. var frag = document.createDocumentFragment(),
  905. temp = document.createElement('div');
  906. temp.innerHTML = htmlStr;
  907. while (temp.firstChild) {
  908. frag.appendChild(temp.firstChild);
  909. }
  910. return frag;
  911. }
  912.  
  913. // World location to pixel location on minimap
  914. function aToPminimap(a) {
  915. var mx = (MC.x.p[1] - MC.x.p[0])/(MC.x.a[1] - MC.x.a[0]);
  916. var my = (MC.y.p[1] - MC.y.p[0])/(MC.y.a[1] - MC.y.a[0]);
  917. var bx = MC.x.p[0] - mx*MC.x.a[0];
  918. var by = MC.y.p[0] - my*MC.y.a[0];
  919. return {
  920. x: mx*a.x + bx,
  921. y: my*a.y + by
  922. };
  923. }
  924.  
  925. // Pixel location on minimap to world location
  926. // (inverse of the above function)
  927. function pToAminimap(p) {
  928. var mx = (MC.x.a[1] - MC.x.a[0])/(MC.x.p[1] - MC.x.p[0]);
  929. var my = (MC.y.a[1] - MC.y.a[0])/(MC.y.p[1] - MC.y.p[0]);
  930. var bx = MC.x.a[0] - mx*MC.x.p[0];
  931. var by = MC.y.a[0] - my*MC.y.p[0];
  932. return {
  933. x: mx*p.x + bx,
  934. y: my*p.y + by
  935. };
  936. }
  937.  
  938. // Update minimap position
  939. function updateMinimapPosition() {
  940. var scale_x = document.getElementById("minimapimg").width / MC.width;
  941. var scale_y = document.getElementById("minimapimg").height / MC.height;
  942. var p = aToPminimap({
  943. x: mode.player.gpData.p.position[0],
  944. y: mode.player.gpData.p.position[1]
  945. });
  946. p.x = scale_x * p.x;
  947. p.y = scale_y * p.y;
  948.  
  949. document.getElementById("minimapsvg").remove();
  950. var textHtml = "";
  951. textHtml += "<svg id=\"minimapsvg\" width=\"100%\" height=\"100%\" style=\"position: absolute; top: 0; left: 0; z-index: 1;\">";
  952. textHtml += "<circle id=\"posMarker\" cx=\"" + p.x + "\" cy=\"" + p.y + "\" r=\"3\" stroke=\"red\" stroke-width=\"2\" fill=\"black\"><\/circle>";
  953. textHtml += "<\/svg>";
  954. document.getElementById("minimap").insertBefore(createFragment(textHtml), document.getElementById("minimap").childNodes[0]);
  955.  
  956. }
  957.  
  958. // Warp to position, given a pixel location on the minimap
  959. function warpToLocation(pos) {
  960. var scale_x = MC.width / document.getElementById("minimapimg").width;
  961. var scale_y = MC.height / document.getElementById("minimapimg").height;
  962. var p = {
  963. x: pos.x * scale_x,
  964. y: pos.y * scale_y
  965. };
  966. var a = pToAminimap(p);
  967. mode.player.gpData.p.position[0] = a.x;
  968. mode.player.gpData.p.position[1] = a.y;
  969. }
  970.  
  971. // Generic relative mouse clicks
  972. function getRelativeXY(evt, id) {
  973. var element = document.getElementById(id); //replace elementId with your element's Id.
  974. var rect = element.getBoundingClientRect();
  975. var scrollTop = document.documentElement.scrollTop?
  976. document.documentElement.scrollTop:document.body.scrollTop;
  977. var scrollLeft = document.documentElement.scrollLeft?
  978. document.documentElement.scrollLeft:document.body.scrollLeft;
  979. var elementLeft = rect.left+scrollLeft;
  980. var elementTop = rect.top+scrollTop;
  981.  
  982. if (document.all){ //detects using IE
  983. x = event.clientX+scrollLeft-elementLeft; //event not evt because of IE
  984. y = event.clientY+scrollTop-elementTop;
  985. }
  986. else{
  987. x = evt.pageX-elementLeft;
  988. y = evt.pageY-elementTop;
  989. }
  990. return {"x":x, "y":y};
  991. }
  992.  
  993. waitForPlay();
  994. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement