Bonk Commands

Adds lots of commands to bonk.io. Type /? or /help in bonk chat to get started.

当前为 2023-05-29 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Bonk Commands
  3. // @namespace https://gf.qytechs.cn/en/scripts/451341-bonk-commands
  4. // @version 15.6
  5. // @description Adds lots of commands to bonk.io. Type /? or /help in bonk chat to get started.
  6. // @author LEGENDBOSS123 + left paren + mastery3
  7. // @match https://bonk.io/*
  8. // @run-at document-idle
  9. // @grant none
  10. // @unwrap
  11. // ==/UserScript==
  12. function BonkCommandsScriptInjector(f){
  13. if(window.location == window.parent.location){
  14. if(document.readyState == "complete"){f();}
  15. else{document.addEventListener('readystatechange',function(){setTimeout(f,1500);});}
  16. }
  17. }
  18.  
  19. BonkCommandsScriptInjector(function(){
  20. var scope = window;
  21. scope.scope = scope;
  22. scope.Gwindow = document.getElementById("maingameframe").contentWindow;
  23. scope.Gdocument = document.getElementById("maingameframe").contentDocument;
  24. Gwindow.Gwindow = window;
  25. Gwindow.Gdocument = document;
  26.  
  27. scope.link2pastebin = "https://pastebin.com/2b8XqqYu";
  28. scope.link2greasyfork = "https://gf.qytechs.cn/en/scripts/451341-bonk-commands";
  29.  
  30. if(typeof(scope.injectedBonkCommandsScript)=='undefined'){
  31. scope.injectedBonkCommandsScript = true;
  32. }
  33. else{
  34. clearInterval(injectedBonkCommandsScript);
  35. }
  36. scope.GENERATE_COPRIME_NUMBER = function(mini = 0,maxi = 0,coprimewith = 0,choices = []){
  37. if(choices.length == 0){
  38. for(var i = mini;i<maxi+1;i++){
  39. choices.push(i);
  40. }
  41. }
  42. firstTry = choices[Math.floor(Math.random()*choices.length)];
  43. for(var i = 2; i<firstTry+1;i++){
  44. if(firstTry%i == 0 && coprimewith%i == 0){
  45. choices.splice(choices.indexOf(firstTry),1);
  46. if(choices.length == 0){
  47. return 0;
  48. }
  49. return GENERATE_COPRIME_NUMBER(mini,maxi,coprimewith,choices);
  50. }
  51. }
  52. return firstTry;
  53. };
  54. scope.GENERATE_PRIME_NUMBER = function(mini = 0,maxi = 0,choices = []){
  55. if(choices.length == 0){
  56. for(var i = mini;i<maxi+1;i++){
  57. choices.push(i);
  58. }
  59. }
  60. firstTry = choices[Math.floor(Math.random()*choices.length)];
  61. for(var i = 2; i<Math.floor(Math.sqrt(firstTry)+1);i++){
  62. if(i!=firstTry){
  63. if(firstTry%i == 0){
  64. choices.splice(choices.indexOf(firstTry),1);
  65. if(choices.length == 0){
  66. return 0;
  67. }
  68. return GENERATE_PRIME_NUMBER(mini,maxi,choices);
  69. }
  70. }
  71. }
  72. return firstTry;
  73. };
  74. scope.SHUFFLE_LIST = function(x){
  75. var nl = x.slice();
  76. for(var i = nl.length - 1;i>0;i--){
  77. var r = Math.floor(Math.random()*(i+1));
  78. var t = nl[i];
  79. nl[i] = nl[r];
  80. nl[r] = t;
  81. }
  82. return nl;
  83. };
  84. scope.GENERATE_KEYS = function(){
  85. interval = [];
  86. for(var i = 100;i<301;i++){
  87. interval.push(i);
  88. }
  89. random_prime = [GENERATE_PRIME_NUMBER(0,0,choices = interval),0];
  90. interval.splice(interval.indexOf(random_prime[0]),1);
  91. random_prime[1] = GENERATE_PRIME_NUMBER(0,0,choices = interval);
  92.  
  93. n = random_prime[0]*random_prime[1];
  94. n2 = (random_prime[0]-1)*(random_prime[1]-1);
  95.  
  96. e = GENERATE_COPRIME_NUMBER(2,n2-1,n2);
  97. d = 0;
  98. redo = true;
  99. for(var i = 0;i<1000000;i++){
  100. if((e*i-1)%n2 == 0 && i!=e){
  101. d = i;
  102. redo = false;
  103. break;
  104. }
  105. }
  106. if(redo){
  107. return GENERATE_KEYS();
  108. }
  109. else{
  110. return [[n,e],[n,d]];
  111. }
  112.  
  113. };
  114. scope.CRYPT_NUMBER = function(key, data){
  115.  
  116. result = 1;
  117.  
  118. for(var i = 0;i<key[1];i++){
  119. result*=data;
  120. result = result%key[0];
  121. }
  122. return result%key[0];
  123.  
  124. };
  125.  
  126. scope.CRYPT_MESSAGE = function(key,data){
  127. var resulttext = [];
  128. for(var i = 0;i<data.length;i++){
  129. resulttext.push(CRYPT_NUMBER(key,data[i]));
  130. }
  131. return resulttext;
  132.  
  133. };
  134. if(typeof(scope.textdecoder)=='undefined'){scope.textdecoder = new Gwindow.TextDecoder;}
  135. if(typeof(scope.textencoder)=='undefined'){scope.textencoder = new Gwindow.TextEncoder;}
  136.  
  137. class bytebuffer2 {
  138. constructor() {
  139. var g1d = [arguments];
  140. this.index = 0;
  141. this.buffer = new ArrayBuffer(100*1024);
  142. this.view = new DataView(this.buffer);
  143. this.implicitClassAliasArray = [];
  144. this.implicitStringArray = [];
  145. this.bodgeCaptureZoneDataIdentifierArray = [];
  146. }
  147. readByte() {
  148. var N0H = [arguments];
  149. N0H[4] = this.view.getUint8(this.index);
  150. this.index += 1;
  151. return N0H[4];
  152. }
  153. writeByte(z0w) {
  154. var v8$ = [arguments];
  155. this.view.setUint8(this.index, v8$[0][0]);
  156. this.index += 1;
  157. }
  158. readInt() {
  159. var A71 = [arguments];
  160. A71[6] = this.view.getInt32(this.index);
  161. this.index += 4;
  162. return A71[6];
  163. }
  164. writeInt(W6i) {
  165. var p5u = [arguments];
  166. this.view.setInt32(this.index, p5u[0][0]);
  167. this.index += 4;
  168. }
  169. readShort() {
  170. var R1R = [arguments];
  171. R1R[9] = this.view.getInt16(this.index);
  172. this.index += 2;
  173. return R1R[9];
  174. }
  175. writeShort(H8B) {
  176. var d_3 = [arguments];
  177. this.view.setInt16(this.index, d_3[0][0]);
  178. this.index += 2;
  179. }
  180. readUint() {
  181. var W2$ = [arguments];
  182. W2$[8] = this.view.getUint32(this.index);
  183. this.index += 4;
  184. return W2$[8];
  185. }
  186. writeUint(B2X) {
  187. var f8B = [arguments];
  188. this.view.setUint32(this.index, f8B[0][0]);
  189. this.index += 4;
  190. }
  191. readBoolean() {
  192. var h6P = [arguments];
  193. h6P[6] = this.readByte();
  194. return h6P[6] == 1;
  195. }
  196. writeBoolean(Y3I) {
  197. var l79 = [arguments];
  198. if (l79[0][0]) {
  199. this.writeByte(1);
  200. } else {
  201. this.writeByte(0);
  202. }
  203. }
  204. readDouble() {
  205. var V60 = [arguments];
  206. V60[4] = this.view.getFloat64(this.index);
  207. this.index += 8;
  208. return V60[4];
  209. }
  210. writeDouble(z4Z) {
  211. var O41 = [arguments];
  212. this.view.setFloat64(this.index, O41[0][0]);
  213. this.index += 8;
  214. }
  215. readFloat() {
  216. var I0l = [arguments];
  217. I0l[5] = this.view.getFloat32(this.index);
  218. this.index += 4;
  219. return I0l[5];
  220. }
  221. writeFloat(y4B) {
  222. var B0v = [arguments];
  223. this.view.setFloat32(this.index, B0v[0][0]);
  224. this.index += 4;
  225. }
  226. readUTF() {
  227. var d6I = [arguments];
  228. d6I[8] = this.readByte();
  229. d6I[7] = this.readByte();
  230. d6I[9] = d6I[8] * 256 + d6I[7];
  231. d6I[1] = new Uint8Array(d6I[9]);
  232. for (d6I[6] = 0; d6I[6] < d6I[9]; d6I[6]++) {
  233. d6I[1][d6I[6]] = this.readByte();
  234. }
  235. return textdecoder.decode(d6I[1]);
  236. }
  237. writeUTF(L3Z) {
  238. var Z75 = [arguments];
  239. Z75[4] = textencoder.encode(Z75[0][0]);
  240. Z75[3] = Z75[4].length;
  241. Z75[5] = Math.floor(Z75[3]/256);
  242. Z75[8] = Z75[3] % 256;
  243. this.writeByte(Z75[5]);
  244. this.writeByte(Z75[8]);
  245. Z75[7] = this;
  246. Z75[4].forEach(I_O);
  247. function I_O(s0Q, H4K, j$o) {
  248. var N0o = [arguments];
  249. Z75[7].writeByte(N0o[0][0]);
  250. }
  251. }
  252. toBase64() {
  253. var P4$ = [arguments];
  254. P4$[4] = "";
  255. P4$[9] = new Uint8Array(this.buffer);
  256. P4$[8] = this.index;
  257. for (P4$[7] = 0; P4$[7] < P4$[8]; P4$[7]++) {
  258. P4$[4] += String.fromCharCode(P4$[9][P4$[7]]);
  259. }
  260. return Gwindow.btoa(P4$[4]);
  261. }
  262. fromBase64(W69, A8Q) {
  263. var o0n = [arguments];
  264. o0n[8] = Gwindow.pako;
  265. o0n[6] = Gwindow.atob(o0n[0][0]);
  266. o0n[9] = o0n[6].length;
  267. o0n[4] = new Uint8Array(o0n[9]);
  268. for (o0n[1] = 0; o0n[1] < o0n[9]; o0n[1]++) {
  269. o0n[4][o0n[1]] = o0n[6].charCodeAt(o0n[1]);
  270. }
  271. if (o0n[0][1] === true) {
  272. o0n[5] = o0n[8].inflate(o0n[4]);
  273. o0n[4] = o0n[5];
  274. }
  275. this.buffer = o0n[4].buffer.slice(
  276. o0n[4].byteOffset,
  277. o0n[4].byteLength + o0n[4].byteOffset
  278. );
  279. this.view = new DataView(this.buffer);
  280. this.index = 0;
  281. }
  282. };
  283.  
  284. if(typeof(scope.originalSend)=='undefined'){scope.originalSend = Gwindow.WebSocket.prototype.send;}
  285. if(typeof(scope.originalXMLOpen)=='undefined'){scope.originalXMLOpen = Gwindow.XMLHttpRequest.prototype.open;}
  286. if(typeof(scope.originalXMLSend)=='undefined'){scope.originalXMLSend = Gwindow.XMLHttpRequest.prototype.send;}
  287. if(typeof(scope.searchrequested)=='undefined'){scope.searchrequested = false;}
  288. if(typeof(scope.originalDrawCircle)=='undefined'){scope.originalDrawCircle = Gwindow.PIXI.Graphics.prototype.drawCircle;}
  289. if(typeof(scope.parentDraw)=='undefined'){scope.parentDraw = 0;}
  290. if(typeof(scope.pixiCircle)=='undefined'){scope.pixiCircle = new Gwindow.PIXI.Graphics();}
  291. if(typeof(scope.container)=='undefined'){scope.container = new Gwindow.PIXI.Container();container.addChild(pixiCircle);}
  292. if(typeof(scope.canvasWidth)=='undefined'){scope.canvasWidth = -1;}
  293.  
  294.  
  295. if(typeof(scope.requestAnimationFrameOriginal)=='undefined'){scope.requestAnimationFrameOriginal = Gwindow.requestAnimationFrame;}
  296.  
  297.  
  298. if(typeof(scope.bonkwss)=='undefined'){scope.bonkwss = 0;}
  299. if(typeof(scope.bonkwssextra)=='undefined'){scope.bonkwssextra = [];}
  300. if(typeof(scope.chatlog)=='undefined'){scope.chatlog = ["ROOM START"];}
  301. if(typeof(scope.wsssendrecievelog)=='undefined'){scope.wsssendrecievelog = [];}
  302. if(typeof(scope.wsssendlog)=='undefined'){scope.wsssendlog = [];}
  303. if(typeof(scope.wssrecievelog)=='undefined'){scope.wssrecievelog = [];}
  304. if(typeof(scope.wsslogpaused)=='undefined'){scope.wsslogpaused = false;}
  305. if(typeof(scope.debuggeropen)=='undefined'){scope.debuggeropen = false;}
  306. if(typeof(scope.debuggercount)=='undefined'){scope.debuggercount = true;}
  307. if(typeof(scope.packetcount)=='undefined'){scope.packetcount = 0;}
  308. if(typeof(scope.requestedmaps)=='undefined'){scope.requestedmaps = [];}
  309. if(typeof(scope.maponclick)=='undefined'){scope.maponclick = 0;}
  310. if(typeof(scope.LZString)=='undefined'){scope.LZString = Gwindow.LZString;}
  311. if(typeof(scope.PSON)=='undefined'){scope.PSON = Gwindow.dcodeIO.PSON;}
  312. if(typeof(scope.bytebuffer)=='undefined'){scope.bytebuffer = Gwindow.dcodeIO.ByteBuffer;}
  313. if(typeof(scope.speech)=='undefined'){scope.speech = new SpeechSynthesisUtterance();speech.pitch = 0.75;}
  314. if(typeof(scope.sayer)=='undefined'){scope.sayer = speechSynthesis;sayer.volume = 0.5;sayer.rate = 1.25;}
  315. if(typeof(scope.pollactive)=='undefined'){scope.pollactive = [false,0,0,[]];}
  316. if(typeof(scope.pollactive2)=='undefined'){scope.pollactive2 = [false,0,[]];}
  317. if(typeof(scope.mode)=='undefined'){scope.mode = '';}
  318. if(typeof(scope.FFA)=='undefined'){scope.FFA = true;}
  319.  
  320. if(typeof(scope.ISpsonpair)=='undefined'){scope.ISpsonpair = new Gwindow.dcodeIO.PSON.StaticPair(["physics", "shapes", "fixtures", "bodies", "bro", "joints", "ppm", "lights", "spawns", "lasers", "capZones", "type", "w", "h", "c", "a", "v", "l", "s", "sh", "fr", "re", "de", "sn", "fc", "fm", "f", "d", "n", "bg", "lv", "av", "ld", "ad", "fr", "bu", "cf", "rv", "p", "d", "bf", "ba", "bb", "aa", "ab", "axa", "dr", "em", "mmt", "mms", "ms", "ut", "lt", "New body", "Box Shape", "Circle Shape", "Polygon Shape", "EdgeChain Shape", "priority", "Light", "Laser", "Cap Zone", "BG Shape", "Background Layer", "Rotate Joint", "Slider Joint", "Rod Joint", "Gear Joint", 65535, 16777215]);}
  321. if(typeof(scope.sandboxon)=='undefined'){scope.sandboxon = false;}
  322. if(typeof(scope.sandboxid)=='undefined'){scope.sandboxid = 200;}
  323. if(typeof(scope.playerids)=='undefined'){scope.playerids = {};}
  324. if(typeof(scope.delplayerids)=='undefined'){scope.delplayerids = {};}
  325. if(typeof(scope.myid)=='undefined'){scope.myid = -1;}
  326. if(typeof(scope.hostid)=='undefined'){scope.hostid = -1;}
  327. if(typeof(scope.sandboxplayerids)=='undefined'){scope.sandboxplayerids = {};}
  328. if(typeof(scope.originalMapLoad)=='undefined'){scope.originalMapLoad = Gdocument.getElementById("maploadwindowmapscontainer").appendChild;}
  329. if(typeof(scope.originalLobbyChat)=='undefined'){scope.originalLobbyChat = Gdocument.getElementById("newbonklobby_chat_content").appendChild;}
  330. if(typeof(scope.originalIngameChat)=='undefined'){scope.originalIngameChat = Gdocument.getElementById("ingamechatcontent").appendChild;}
  331. if(typeof(scope.private_chat_keys)=='undefined'){scope.private_chat_keys = GENERATE_KEYS();scope.private_key = private_chat_keys[0];scope.public_key = private_chat_keys[1];}
  332. if(Gdocument.getElementById("maploadtypedropdowntitlerequested") == null){
  333. scope.clearmaprequests = Gdocument.createElement("div");
  334. clearmaprequests.id = "clearmaprequests";
  335. clearmaprequests.classList.value = "brownButton brownButton_classic buttonShadow";
  336. clearmaprequests.textContent = "Clear";
  337. clearmaprequests.style["position"] = "absolute";
  338. clearmaprequests.style["display"] = "none";
  339. if(typeof(ishost)!='undefined'){
  340. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  341. clearmaprequests.style["display"] = "block";
  342. }
  343. }
  344. clearmaprequests.style["right"] = "306px";
  345. clearmaprequests.style["top"] = "57px";
  346. clearmaprequests.style["height"] = "23px";
  347. clearmaprequests.style["width"] = "47px";
  348. clearmaprequests.style["line-height"] = "23px";
  349. clearmaprequests.style["font-size"] = "14px";
  350. clearmaprequests.addEventListener("click",function(){
  351. requestedmaps = [];
  352. Gdocument.getElementById("maploadwindowstatustext").style["visibility"] = "inherit";
  353. Gdocument.getElementById("maploadwindowstatustext").textContent = "No Maps";
  354. while(Gdocument.getElementById("maploadwindowmapscontainer").children.length>0){
  355. Gdocument.getElementById("maploadwindowmapscontainer").removeChild(Gdocument.getElementById("maploadwindowmapscontainer").firstChild);
  356. }
  357. });
  358. Gdocument.getElementById("maploadwindow").insertBefore(clearmaprequests,Gdocument.getElementById("maploadwindowsearchinput"));
  359. scope.refreshmaprequests = Gdocument.createElement("div");
  360. refreshmaprequests.id = "refreshmaprequests";
  361. refreshmaprequests.classList.value = "brownButton brownButton_classic buttonShadow";
  362. refreshmaprequests.textContent = "Refresh";
  363. refreshmaprequests.style["position"] = "absolute";
  364. refreshmaprequests.style["display"] = "none";
  365. if(typeof(ishost)!='undefined'){
  366. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  367. refreshmaprequests.style["display"] = "block";
  368. }
  369. }
  370. refreshmaprequests.style["right"] = "357px";
  371. refreshmaprequests.style["top"] = "57px";
  372. refreshmaprequests.style["height"] = "23px";
  373. refreshmaprequests.style["width"] = "47px";
  374. refreshmaprequests.style["line-height"] = "23px";
  375. refreshmaprequests.style["font-size"] = "14px";
  376. refreshmaprequests.addEventListener("click",function(){
  377. Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdownrequested.textContent;
  378. Gdocument.getElementById("maploadwindowsearchinput").value = "";
  379. dropdownrequested.style["display"] = "none";
  380. clearmaprequests.style["display"] = "block";
  381. refreshmaprequests.style["display"] = "block";
  382. Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
  383. Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
  384. searchrequested = true;
  385. Gdocument.getElementById("maploadwindowsearchbutton").click();
  386.  
  387. Gdocument.getElementById("maploadtypedropdowntitle").textContent = "MAP REQUESTS";
  388. });
  389. Gdocument.getElementById("maploadwindow").insertBefore(refreshmaprequests,Gdocument.getElementById("maploadwindowsearchinput"));
  390.  
  391. scope.dropdownrequested = Gdocument.createElement("div");
  392. dropdownrequested.classList = "dropdown-option dropdown_classic";
  393. dropdownrequested.style["display"] = "none";
  394. dropdownrequested.id = "maploadtypedropdowntitlerequested";
  395.  
  396. if(Gdocument.getElementById("maploadtypedropdownoption10").style["display"] == "block"){
  397. dropdownrequested.style["display"] = "block";
  398. }
  399. dropdownrequested.textContent = "MAP REQUESTS";
  400. dropdownrequested.onclick = function(){
  401. Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdownrequested.textContent;
  402. Gdocument.getElementById("maploadwindowsearchinput").value = "";
  403. dropdownrequested.style["display"] = "none";
  404. clearmaprequests.style["display"] = "block";
  405. refreshmaprequests.style["display"] = "block";
  406. Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
  407. Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
  408. searchrequested = true;
  409. Gdocument.getElementById("maploadwindowsearchbutton").click();
  410.  
  411. Gdocument.getElementById("maploadtypedropdowntitle").textContent = "MAP REQUESTS";
  412. };
  413. (new MutationObserver(function(){if(Gdocument.getElementById("maploadtypedropdownoption10").style["display"] == "none"){ dropdownrequested.style["display"] = "none"; clearmaprequests.style["display"] = "none";refreshmaprequests.style["display"] = "none"; } else{ dropdownrequested.style["display"] = "block";}})).observe(Gdocument.getElementById("maploadtypedropdownoption10"),{attributes:true,childList:true});
  414. Gdocument.getElementById("maploadtypedropdown").insertBefore(dropdownrequested,Gdocument.getElementById("maploadtypedropdownoption1"));
  415. Gdocument.getElementById("maploadwindowmapscontainer").__defineGetter__("clientHeight",function(){if(Gdocument.getElementById("maploadtypedropdowntitle").textContent != "MAP REQUESTS"){return Gdocument.getElementById("maploadwindowmapscontainer").getClientRects()[0].height;}else{return 0;}});
  416.  
  417. };
  418. scope.sandboxonclick = function(){
  419. Gdocument.getElementById("roomlistrefreshbutton").click();
  420. Gdocument.getElementById("roomlistcreatebutton").click();
  421. sandboxon = true;
  422. };
  423. scope.checkboxclearbuttononclick = function(){
  424. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  425. var e = true;
  426. for(var i = 0; i<classes.length;i++){
  427. if(classes[i].checked == true){
  428. e = false
  429. }
  430. classes[i].checked = false;
  431. }
  432. if(e){
  433. for(var i = 0; i<classes.length;i++){
  434. classes[i].checked = true;
  435. }
  436. }
  437. };
  438. Gdocument.getElementById("ingamechatcontent").__defineGetter__("childElementCount",function(){return this.children.length/50;});
  439. if(Gdocument.getElementById("classic_mid_sandbox")==null){
  440. Gdocument.getElementById("roomlistrefreshbutton").click();
  441. scope.sandboxbutton = Gdocument.createElement("div");
  442. sandboxbutton.id = "classic_mid_sandbox";
  443. sandboxbutton.classList.value = "brownButton brownButton_classic classic_mid_buttons";
  444. sandboxbutton.textContent = "Sandbox";
  445. sandboxbutton.addEventListener("click",sandboxonclick);
  446. Gdocument.getElementById("classic_mid").insertBefore(sandboxbutton,Gdocument.getElementById("classic_mid_news"));
  447.  
  448. }
  449. if(Gdocument.getElementById("clearallcheckboxes")==null){
  450. scope.checkboxclearbutton = Gdocument.createElement("div");
  451. checkboxclearbutton.id = "clearallcheckboxes";
  452. checkboxclearbutton.classList.value = "brownButton brownButton_classic buttonShadow";
  453. checkboxclearbutton.textContent = "On/Off";
  454. checkboxclearbutton.style["position"] = "absolute";
  455. checkboxclearbutton.style["display"] = "none";
  456. if(typeof(ishost)!='undefined'){
  457. if(ishost && stopquickplay == 0){
  458. checkboxclearbutton.style["display"] = "block";
  459. }
  460. }
  461. checkboxclearbutton.style["right"] = "255px";
  462. checkboxclearbutton.style["top"] = "57px";
  463. checkboxclearbutton.style["height"] = "23px";
  464. checkboxclearbutton.style["width"] = "47px";
  465. checkboxclearbutton.style["line-height"] = "23px";
  466. checkboxclearbutton.style["font-size"] = "13px";
  467. checkboxclearbutton.addEventListener("click",checkboxclearbuttononclick);
  468. Gdocument.getElementById("maploadwindow").insertBefore(checkboxclearbutton,Gdocument.getElementById("maploadwindowsearchinput"));
  469.  
  470. }
  471. scope.holdloadbuttonTimeout = [];
  472. scope.holdloadbutton = function(){
  473. var scrollcount = 0;
  474. var mapwindow = Gdocument.getElementById("maploadwindowmapscontainer");
  475. mapwindow.scroll(0,mapwindow.scrollHeight);
  476. };
  477.  
  478. if(Gdocument.getElementById("mapwindowloadall")==null){
  479. scope.loadall = Gdocument.createElement("div");
  480. loadall.id = "mapwindowloadall";
  481. loadall.classList.value = "brownButton brownButton_classic buttonShadow";
  482. loadall.textContent = "Load";
  483. loadall.style["position"] = "absolute";
  484. loadall.style["display"] = "block";
  485. loadall.style["left"] = "204px";
  486. loadall.style["top"] = "57px";
  487. loadall.style["height"] = "23px";
  488. loadall.style["width"] = "34px";
  489. loadall.style["line-height"] = "23px";
  490. loadall.style["font-size"] = "12px";
  491. var repeat = function(){holdloadbutton();holdloadbuttonTimeout.push(setTimeout(repeat,25));};
  492. loadall.onmousedown = function(){repeat();};
  493. loadall.onmouseup = function(){for(var i = 0; i<holdloadbuttonTimeout.length; i++){clearTimeout(holdloadbuttonTimeout[i]);}};
  494. loadall.onmouseout = function(){for(var i = 0; i<holdloadbuttonTimeout.length; i++){clearTimeout(holdloadbuttonTimeout[i]);}};
  495.  
  496. Gdocument.getElementById("maploadwindow").insertBefore(loadall,Gdocument.getElementById("maploadwindowsearchinput"));
  497.  
  498. }
  499. if(Gdocument.getElementById("BonkCommandsDebuggerContainer")==null){
  500. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=3;
  501. scope.debuggermenu = Gdocument.createElement("div");
  502. debuggermenu.id = "BonkCommandsDebuggerContainer";
  503. debuggermenu.style["position"] = "absolute";
  504. debuggermenu.style["display"] = "none";
  505. if(typeof(debuggeropen)!='undefined'){
  506. if(debuggeropen){
  507. debuggermenu.style["display"] = "block";
  508. }
  509. }
  510. debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
  511. debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
  512.  
  513. debuggermenu.style["background"] = "rgb(26, 39, 51)";
  514.  
  515. scope.width = parseInt(Gdocument.getElementById("bonkiocontainer").style["width"])-20;
  516. scope.height = parseInt(Gdocument.getElementById("bonkiocontainer").style["height"])-210;
  517.  
  518. scope.logmenu = Gdocument.createElement("div");
  519. logmenu.id = "BonkCommandsWebSocketLog";
  520. logmenu.style["position"] = "absolute";
  521. logmenu.style["width"] = width.toString()+"px";
  522. logmenu.style["height"] = height.toString()+"px";
  523. logmenu.style["top"] = "80px";
  524. logmenu.style["left"] = "10px";
  525. logmenu.style["background"] = "rgb(207, 216, 220)";
  526. scope.logmenutopleft = Gdocument.createElement("div");
  527. logmenutopleft.id = "BonkCommandsWebSocketLog";
  528. logmenutopleft.style["position"] = "absolute";
  529. logmenutopleft.textContent = "Sending";
  530. logmenutopleft.classList = "newbonklobby_boxtop newbonklobby_boxtop_classic";
  531. logmenutopleft.style["width"] = (width/2).toString()+"px";
  532. logmenutopleft.style["height"] = "30px";
  533. logmenutopleft.style["top"] = "-30px";
  534. logmenutopleft.style["background"] = "rgb(0, 150, 136)";
  535. logmenu.appendChild(logmenutopleft);
  536. scope.logmenutopright = Gdocument.createElement("div");
  537. logmenutopright.id = "BonkCommandsWebSocketLog";
  538. logmenutopright.style["position"] = "absolute";
  539. logmenutopright.textContent = "Recieving";
  540. logmenutopright.classList = "newbonklobby_boxtop newbonklobby_boxtop_classic";
  541. logmenutopright.style["width"] = (width/2).toString()+"px";
  542. logmenutopright.style["height"] = "30px";
  543. logmenutopright.style["left"] = (width/2).toString()+"px";
  544. logmenutopright.style["top"] = "-30px";
  545. logmenutopright.style["background"] = "rgb(0, 150, 136)";
  546. logmenu.appendChild(logmenutopright);
  547. scope.logmenutable = Gdocument.createElement("table");
  548. logmenutable.id = "BonkCommandsWebSocketTable";
  549. logmenutable.style["position"] = "absolute";
  550. logmenutable.style["border-spacing"] = "0px";
  551. logmenutable.style["font-size"] = "12px";
  552. logmenutable.style["display"] = "table-cell";
  553. logmenutable.style["width"] = "50%";
  554. logmenutable.style["height"] = "100%";
  555. logmenutable.style["table-layout"] = "fixed";
  556. logmenutable.style["overflow-y"] = "scroll";
  557.  
  558. scope.logmenutable2 = Gdocument.createElement("table");
  559. logmenutable2.id = "BonkCommandsWebSocketTable2";
  560. logmenutable2.style["position"] = "absolute";
  561. logmenutable2.style["width"] = "50%";
  562. logmenutable2.style["left"] = "50%";
  563. logmenutable2.style["font-size"] = "12px";
  564. logmenutable2.style["display"] = "table-cell";
  565. logmenutable2.style["height"] = "100%";
  566. logmenutable2.style["table-layout"] = "fixed";
  567. logmenutable2.style["overflow-y"] = "scroll";
  568. logmenutable2.style["border-spacing"] = "0px";
  569. scope.leftsync = false;
  570. scope.rightsync = false;
  571. logmenutable2.onscroll = function(){
  572. if(!leftsync){
  573. rightsync = true;
  574. logmenutable.scrollTop = this.scrollTop;
  575. }
  576. else{
  577. leftsync = false;
  578. }
  579. };
  580. logmenutable.onscroll = function(){
  581. if(!rightsync){
  582. leftsync = true;
  583. logmenutable2.scrollTop = this.scrollTop;
  584. }
  585. else{
  586. rightsync = false
  587. }
  588. };
  589. logmenu.appendChild(logmenutable);
  590. logmenu.appendChild(logmenutable2);
  591. debuggermenu.appendChild(logmenu);
  592. scope.debuggermenuclose = Gdocument.createElement("div");
  593. debuggermenuclose.id = "debuggerclose";
  594. debuggermenuclose.classList = "windowCloseButton brownButton brownButton_classic buttonShadow";
  595. debuggermenuclose.style["position"] = "absolute";
  596. debuggermenuclose.style["top"] = "40px";
  597. debuggermenuclose.style["right"] = "5px";
  598. debuggermenuclose.onclick = function(){debuggeropen = false;debuggermenu.style["display"] = "none";Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  599. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";};
  600. debuggermenu.appendChild(debuggermenuclose);
  601. scope.debuggerform = Gdocument.createElement("form");
  602. debuggerform.autocomplete = "off";
  603. scope.debuggerinput = Gdocument.createElement("input");
  604. debuggerinput.style["position"] = "absolute";
  605. debuggerinput.style["width"] = width.toString()+"px";
  606. debuggerinput.style["left"] = "10px";
  607. debuggerinput.style["top"] = (height+90).toString()+"px";
  608. debuggerinput.style["font-size"] = "12px";
  609. debuggerinput.style["height"] = "20px";
  610. debuggerform.appendChild(debuggerinput);
  611. scope.debuggersendrecieve = Gdocument.createElement("div");
  612. debuggersendrecieve.style["position"] = "absolute";
  613. debuggersendrecieve.style["width"] = "140px";
  614. debuggersendrecieve.style["left"] = "10px";
  615. debuggersendrecieve.style["top"] = (height+120).toString()+"px";
  616. debuggersendrecieve.style["font-size"] = "15px";
  617. debuggersendrecieve.style["height"] = "20px";
  618. debuggersendrecieve.classList = "brownButton brownButton_classic buttonShadow";
  619. debuggersendrecieve.textContent = "Send";
  620. debuggersendrecieve.value = 0;
  621. debuggersendrecieve.onclick = function(){if(this.value == 0){this.textContent = "Recieve";this.value = 1;}else{this.textContent = "Send";this.value = 0;}};
  622.  
  623. debuggermenu.appendChild(debuggersendrecieve);
  624. scope.debuggerpausebutton = Gdocument.createElement("div");
  625. debuggerpausebutton.style["position"] = "absolute";
  626. debuggerpausebutton.style["width"] = "140px";
  627. debuggerpausebutton.style["left"] = "10px";
  628. debuggerpausebutton.style["top"] = (height+150).toString()+"px";
  629. debuggerpausebutton.style["font-size"] = "15px";
  630. debuggerpausebutton.style["height"] = "20px";
  631. debuggerpausebutton.classList = "brownButton brownButton_classic buttonShadow";
  632. debuggerpausebutton.textContent = "Pause";
  633. debuggerpausebutton.value = 0;
  634. debuggerpausebutton.onclick = function(){if(this.value == 0){this.textContent = "Play";this.value = 1;wsslogpaused = true}else{this.textContent = "Pause";this.value = 0;wsslogpaused = false;}};
  635.  
  636. debuggermenu.appendChild(debuggerpausebutton);
  637. scope.debuggereval = Gdocument.createElement("input");
  638. debuggereval.style["position"] = "absolute";
  639. debuggereval.style["width"] = (width-150).toString()+"px";
  640. debuggereval.style["right"] = "10px";
  641. debuggereval.style["top"] = (height+120).toString()+"px";
  642. debuggereval.style["font-size"] = "12px";
  643. debuggereval.style["height"] = "20px";
  644. debuggereval.addEventListener("keypress",function(e){if(e.repeat){return;}if(e.code == "Enter" && this.value.length>0){if(debuggersendrecieve.value == 0){SEND(this.value);}else{RECIEVE(this.value);}}});
  645. debuggerform.appendChild(debuggereval);
  646. debuggermenu.appendChild(debuggerform);
  647. Gdocument.getElementById("newbonkgamecontainer").appendChild(debuggermenu);
  648.  
  649. }
  650. scope.ISdecode = function(rawdata) {
  651. rawdata_caseflipped = "";
  652. for (i = 0; i < rawdata.length; i++) {
  653. if (i <= 100 && rawdata.charAt(i) === rawdata.charAt(i).toLowerCase()) {
  654. rawdata_caseflipped += rawdata.charAt(i).toUpperCase();
  655. } else if (i <= 100 && rawdata.charAt(i) === rawdata.charAt(i).toUpperCase()) {
  656. rawdata_caseflipped += rawdata.charAt(i).toLowerCase();
  657. } else {
  658. rawdata_caseflipped += rawdata.charAt(i);
  659. }
  660. }
  661.  
  662. data_deLZd = LZString.decompressFromEncodedURIComponent(rawdata_caseflipped);
  663. databuffer = bytebuffer.fromBase64(data_deLZd);
  664. data = ISpsonpair.decode(databuffer.buffer);
  665. return data;
  666. };
  667. scope.ISencode = function(obj) {
  668. data = ISpsonpair.encode(obj);
  669. b64 = data.toBase64();
  670. lzd = LZString.compressToEncodedURIComponent(b64);
  671.  
  672. caseflipped = "";
  673. for (i = 0; i < lzd.length; i++) {
  674. if (i <= 100 && lzd.charAt(i) === lzd.charAt(i).toLowerCase()) {
  675. caseflipped += lzd.charAt(i).toUpperCase();
  676. } else if (i <= 100 && lzd.charAt(i) === lzd.charAt(i).toUpperCase()) {
  677. caseflipped += lzd.charAt(i).toLowerCase();
  678. } else {
  679. caseflipped += lzd.charAt(i);
  680. }
  681. }
  682.  
  683.  
  684. return caseflipped;
  685. };
  686. scope.decodeIS = function(x){
  687. return ISdecode(x);
  688. };
  689. scope.encodeIS = function(x){
  690. return ISencode(x);
  691. };
  692. scope.encodeToDatabase = function (W2A) {
  693. var M3n = [arguments];
  694. M3n[1] = new bytebuffer2;
  695. M3n[9] = M3n[0][0].physics;
  696. M3n[0][0].v = 14;
  697. M3n[1].writeShort(M3n[0][0].v);
  698. M3n[1].writeBoolean(M3n[0][0].s.re);
  699. M3n[1].writeBoolean(M3n[0][0].s.nc);
  700. M3n[1].writeShort(M3n[0][0].s.pq);
  701. M3n[1].writeFloat(M3n[0][0].s.gd);
  702. M3n[1].writeBoolean(M3n[0][0].s.fl);
  703. M3n[1].writeUTF(M3n[0][0].m.rxn);
  704. M3n[1].writeUTF(M3n[0][0].m.rxa);
  705. M3n[1].writeUint(M3n[0][0].m.rxid);
  706. M3n[1].writeShort(M3n[0][0].m.rxdb);
  707. M3n[1].writeUTF(M3n[0][0].m.n);
  708. M3n[1].writeUTF(M3n[0][0].m.a);
  709. M3n[1].writeUint(M3n[0][0].m.vu);
  710. M3n[1].writeUint(M3n[0][0].m.vd);
  711. M3n[1].writeShort(M3n[0][0].m.cr.length);
  712. for (
  713. M3n[84] = 0;
  714. M3n[84] < M3n[0][0].m.cr.length;
  715. M3n[84]++
  716. ) {
  717. M3n[1].writeUTF(M3n[0][0].m.cr[M3n[84]]);
  718. }
  719. M3n[1].writeUTF(M3n[0][0].m.mo);
  720. M3n[1].writeInt(M3n[0][0].m.dbid);
  721. M3n[1].writeBoolean(M3n[0][0].m.pub);
  722. M3n[1].writeInt(M3n[0][0].m.dbv);
  723. M3n[1].writeShort(M3n[9].ppm);
  724. M3n[1].writeShort(M3n[9].bro.length);
  725. for (M3n[17] = 0; M3n[17] < M3n[9].bro.length; M3n[17]++) {
  726. M3n[1].writeShort(M3n[9].bro[M3n[17]]);
  727. }
  728. M3n[1].writeShort(M3n[9].shapes.length);
  729. for (M3n[80] = 0; M3n[80] < M3n[9].shapes.length; M3n[80]++) {
  730. M3n[2] = M3n[9].shapes[M3n[80]];
  731. if (M3n[2].type == "bx") {
  732. M3n[1].writeShort(1);
  733. M3n[1].writeDouble(M3n[2].w);
  734. M3n[1].writeDouble(M3n[2].h);
  735. M3n[1].writeDouble(M3n[2].c[0]);
  736. M3n[1].writeDouble(M3n[2].c[1]);
  737. M3n[1].writeDouble(M3n[2].a);
  738. M3n[1].writeBoolean(M3n[2].sk);
  739. }
  740. if (M3n[2].type == "ci") {
  741. M3n[1].writeShort(2);
  742. M3n[1].writeDouble(M3n[2].r);
  743. M3n[1].writeDouble(M3n[2].c[0]);
  744. M3n[1].writeDouble(M3n[2].c[1]);
  745. M3n[1].writeBoolean(M3n[2].sk);
  746. }
  747. if (M3n[2].type == "po") {
  748. M3n[1].writeShort(3);
  749. M3n[1].writeDouble(M3n[2].s);
  750. M3n[1].writeDouble(M3n[2].a);
  751. M3n[1].writeDouble(M3n[2].c[0]);
  752. M3n[1].writeDouble(M3n[2].c[1]);
  753. M3n[1].writeShort(M3n[2].v.length);
  754. for (M3n[61] = 0; M3n[61] < M3n[2].v.length; M3n[61]++) {
  755. M3n[1].writeDouble(M3n[2].v[M3n[61]][0]);
  756. M3n[1].writeDouble(M3n[2].v[M3n[61]][1]);
  757. }
  758. }
  759. }
  760. M3n[1].writeShort(M3n[9].fixtures.length);
  761. for (M3n[20] = 0; M3n[20] < M3n[9].fixtures.length; M3n[20]++) {
  762. M3n[7] = M3n[9].fixtures[M3n[20]];
  763. M3n[1].writeShort(M3n[7].sh);
  764. M3n[1].writeUTF(M3n[7].n);
  765. if (M3n[7].fr === null) {
  766. M3n[1].writeDouble(Number.MAX_VALUE);
  767. } else {
  768. M3n[1].writeDouble(M3n[7].fr);
  769. }
  770. if (M3n[7].fp === null) {
  771. M3n[1].writeShort(0);
  772. }
  773. if (M3n[7].fp === false) {
  774. M3n[1].writeShort(1);
  775. }
  776. if (M3n[7].fp === true) {
  777. M3n[1].writeShort(2);
  778. }
  779. if (M3n[7].re === null) {
  780. M3n[1].writeDouble(Number.MAX_VALUE);
  781. } else {
  782. M3n[1].writeDouble(M3n[7].re);
  783. }
  784. if (M3n[7].de === null) {
  785. M3n[1].writeDouble(Number.MAX_VALUE);
  786. } else {
  787. M3n[1].writeDouble(M3n[7].de);
  788. }
  789. M3n[1].writeUint(M3n[7].f);
  790. M3n[1].writeBoolean(M3n[7].d);
  791. M3n[1].writeBoolean(M3n[7].np);
  792. M3n[1].writeBoolean(M3n[7].ng);
  793. M3n[1].writeBoolean(M3n[7].ig);
  794. }
  795. M3n[1].writeShort(M3n[9].bodies.length);
  796. for (M3n[37] = 0; M3n[37] < M3n[9].bodies.length; M3n[37]++) {
  797. M3n[4] = M3n[9].bodies[M3n[37]];
  798. M3n[1].writeUTF(M3n[4].type);
  799. M3n[1].writeUTF(M3n[4].n);
  800. M3n[1].writeDouble(M3n[4].p[0]);
  801. M3n[1].writeDouble(M3n[4].p[1]);
  802. M3n[1].writeDouble(M3n[4].a);
  803. M3n[1].writeDouble(M3n[4].fric);
  804. M3n[1].writeBoolean(M3n[4].fricp);
  805. M3n[1].writeDouble(M3n[4].re);
  806. M3n[1].writeDouble(M3n[4].de);
  807. M3n[1].writeDouble(M3n[4].lv[0]);
  808. M3n[1].writeDouble(M3n[4].lv[1]);
  809. M3n[1].writeDouble(M3n[4].av);
  810. M3n[1].writeDouble(M3n[4].ld);
  811. M3n[1].writeDouble(M3n[4].ad);
  812. M3n[1].writeBoolean(M3n[4].fr);
  813. M3n[1].writeBoolean(M3n[4].bu);
  814. M3n[1].writeDouble(M3n[4].cf.x);
  815. M3n[1].writeDouble(M3n[4].cf.y);
  816. M3n[1].writeDouble(M3n[4].cf.ct);
  817. M3n[1].writeBoolean(M3n[4].cf.w);
  818. M3n[1].writeShort(M3n[4].f_c);
  819. M3n[1].writeBoolean(M3n[4].f_1);
  820. M3n[1].writeBoolean(M3n[4].f_2);
  821. M3n[1].writeBoolean(M3n[4].f_3);
  822. M3n[1].writeBoolean(M3n[4].f_4);
  823. M3n[1].writeBoolean(M3n[4].f_p);
  824. M3n[1].writeBoolean(M3n[4].fz.on);
  825. if (M3n[4].fz.on) {
  826. M3n[1].writeDouble(M3n[4].fz.x);
  827. M3n[1].writeDouble(M3n[4].fz.y);
  828. M3n[1].writeBoolean(M3n[4].fz.d);
  829. M3n[1].writeBoolean(M3n[4].fz.p);
  830. M3n[1].writeBoolean(M3n[4].fz.a);
  831. }
  832. M3n[1].writeShort(M3n[4].fx.length);
  833. for (M3n[28] = 0; M3n[28] < M3n[4].fx.length; M3n[28]++) {
  834. M3n[1].writeShort(M3n[4].fx[M3n[28]]);
  835. }
  836. }
  837. M3n[1].writeShort(M3n[0][0].spawns.length);
  838. for (
  839. M3n[30] = 0;
  840. M3n[30] < M3n[0][0].spawns.length;
  841. M3n[30]++
  842. ) {
  843. M3n[6] = M3n[0][0].spawns[M3n[30]];
  844. M3n[1].writeDouble(M3n[6].x);
  845. M3n[1].writeDouble(M3n[6].y);
  846. M3n[1].writeDouble(M3n[6].xv);
  847. M3n[1].writeDouble(M3n[6].yv);
  848. M3n[1].writeShort(M3n[6].priority);
  849. M3n[1].writeBoolean(M3n[6].r);
  850. M3n[1].writeBoolean(M3n[6].f);
  851. M3n[1].writeBoolean(M3n[6].b);
  852. M3n[1].writeBoolean(M3n[6].gr);
  853. M3n[1].writeBoolean(M3n[6].ye);
  854. M3n[1].writeUTF(M3n[6].n);
  855. }
  856. M3n[1].writeShort(M3n[0][0].capZones.length);
  857. for (
  858. M3n[74] = 0;
  859. M3n[74] < M3n[0][0].capZones.length;
  860. M3n[74]++
  861. ) {
  862. M3n[3] = M3n[0][0].capZones[M3n[74]];
  863. M3n[1].writeUTF(M3n[3].n);
  864. M3n[1].writeDouble(M3n[3].l);
  865. M3n[1].writeShort(M3n[3].i);
  866. M3n[1].writeShort(M3n[3].ty);
  867. }
  868. M3n[1].writeShort(M3n[9].joints.length);
  869. for (M3n[89] = 0; M3n[89] < M3n[9].joints.length; M3n[89]++) {
  870. M3n[5] = M3n[9].joints[M3n[89]];
  871. if (M3n[5].type == "rv") {
  872. M3n[1].writeShort(1);
  873. M3n[1].writeDouble(M3n[5].d.la);
  874. M3n[1].writeDouble(M3n[5].d.ua);
  875. M3n[1].writeDouble(M3n[5].d.mmt);
  876. M3n[1].writeDouble(M3n[5].d.ms);
  877. M3n[1].writeBoolean(M3n[5].d.el);
  878. M3n[1].writeBoolean(M3n[5].d.em);
  879. M3n[1].writeDouble(M3n[5].aa[0]);
  880. M3n[1].writeDouble(M3n[5].aa[1]);
  881. }
  882. if (M3n[5].type == "d") {
  883. M3n[1].writeShort(2);
  884. M3n[1].writeDouble(M3n[5].d.fh);
  885. M3n[1].writeDouble(M3n[5].d.dr);
  886. M3n[1].writeDouble(M3n[5].aa[0]);
  887. M3n[1].writeDouble(M3n[5].aa[1]);
  888. M3n[1].writeDouble(M3n[5].ab[0]);
  889. M3n[1].writeDouble(M3n[5].ab[1]);
  890. }
  891. if (M3n[5].type == "lpj") {
  892. M3n[1].writeShort(3);
  893. M3n[1].writeDouble(M3n[5].pax);
  894. M3n[1].writeDouble(M3n[5].pay);
  895. M3n[1].writeDouble(M3n[5].pa);
  896. M3n[1].writeDouble(M3n[5].pf);
  897. M3n[1].writeDouble(M3n[5].pl);
  898. M3n[1].writeDouble(M3n[5].pu);
  899. M3n[1].writeDouble(M3n[5].plen);
  900. M3n[1].writeDouble(M3n[5].pms);
  901. }
  902. if (M3n[5].type == "lsj") {
  903. M3n[1].writeShort(4);
  904. M3n[1].writeDouble(M3n[5].sax);
  905. M3n[1].writeDouble(M3n[5].say);
  906. M3n[1].writeDouble(M3n[5].sf);
  907. M3n[1].writeDouble(M3n[5].slen);
  908. }
  909. M3n[1].writeShort(M3n[5].ba);
  910. M3n[1].writeShort(M3n[5].bb);
  911. M3n[1].writeBoolean(M3n[5].d.cc);
  912. M3n[1].writeDouble(M3n[5].d.bf);
  913. M3n[1].writeBoolean(M3n[5].d.dl);
  914. }
  915. M3n[32] = M3n[1].toBase64();
  916. M3n[77] = LZString.compressToEncodedURIComponent(M3n[32]);
  917. return M3n[77];
  918. };
  919. scope.decodeFromDatabase = function (map) {
  920. var F5W = [arguments];
  921. var b64mapdata = LZString.decompressFromEncodedURIComponent(map);
  922. var binaryReader = new bytebuffer2;
  923. binaryReader.fromBase64(b64mapdata, false);
  924. map = { v: 1, s: { re: false, nc: false, pq: 1, gd: 25, fl: false }, physics: { shapes: [], fixtures: [], bodies: [], bro: [], joints: [], ppm: 12, }, spawns: [], capZones: [], m: { a: "noauthor", n: "noname", dbv: 2, dbid: -1, authid: -1, date: "", rxid: 0, rxn: "", rxa: "", rxdb: 1, cr: [], pub: false, mo: "", }};
  925. map.physics = map.physics;
  926. map.v = binaryReader.readShort();
  927. if (map.v > 14) {
  928. throw new Error("Future map version, please refresh page");
  929. }
  930. map.s.re = binaryReader.readBoolean();
  931. map.s.nc = binaryReader.readBoolean();
  932. if (map.v >= 3) {
  933. map.s.pq = binaryReader.readShort();
  934. }
  935. if (map.v >= 4 && map.v <= 12) {
  936. map.s.gd = binaryReader.readShort();
  937. } else if (map.v >= 13) {
  938. map.s.gd = binaryReader.readFloat();
  939. }
  940. if (map.v >= 9) {
  941. map.s.fl = binaryReader.readBoolean();
  942. }
  943. map.m.rxn = binaryReader.readUTF();
  944. map.m.rxa = binaryReader.readUTF();
  945. map.m.rxid = binaryReader.readUint();
  946. map.m.rxdb = binaryReader.readShort();
  947. map.m.n = binaryReader.readUTF();
  948. map.m.a = binaryReader.readUTF();
  949. if (map.v >= 10) {
  950. map.m.vu = binaryReader.readUint();
  951. map.m.vd = binaryReader.readUint();
  952. }
  953. if (map.v >= 4) {
  954. F5W[7] = binaryReader.readShort();
  955. for (F5W[83] = 0; F5W[83] < F5W[7]; F5W[83]++) {
  956. map.m.cr.push(binaryReader.readUTF());
  957. }
  958. }
  959. if (map.v >= 5) {
  960. map.m.mo = binaryReader.readUTF();
  961. map.m.dbid = binaryReader.readInt();
  962. }
  963. if (map.v >= 7) {
  964. map.m.pub = binaryReader.readBoolean();
  965. }
  966. if (map.v >= 8) {
  967. map.m.dbv = binaryReader.readInt();
  968. }
  969. map.physics.ppm = binaryReader.readShort();
  970. F5W[4] = binaryReader.readShort();
  971. for (F5W[15] = 0; F5W[15] < F5W[4]; F5W[15]++) {
  972. map.physics.bro[F5W[15]] = binaryReader.readShort();
  973. }
  974. F5W[6] = binaryReader.readShort();
  975. for (F5W[28] = 0; F5W[28] < F5W[6]; F5W[28]++) {
  976. F5W[5] = binaryReader.readShort();
  977. if (F5W[5] == 1) {
  978. map.physics.shapes[F5W[28]] = { type: "bx", w: 10, h: 40, c: [0, 0], a: 0.0, sk: false };
  979. map.physics.shapes[F5W[28]].w = binaryReader.readDouble();
  980. map.physics.shapes[F5W[28]].h = binaryReader.readDouble();
  981. map.physics.shapes[F5W[28]].c = [
  982. binaryReader.readDouble(),
  983. binaryReader.readDouble(),
  984. ];
  985. map.physics.shapes[F5W[28]].a = binaryReader.readDouble();
  986. map.physics.shapes[F5W[28]].sk = binaryReader.readBoolean();
  987. }
  988. if (F5W[5] == 2) {
  989. map.physics.shapes[F5W[28]] = { type: "ci", r: 25, c: [0, 0], sk: false };
  990. map.physics.shapes[F5W[28]].r = binaryReader.readDouble();
  991. map.physics.shapes[F5W[28]].c = [
  992. binaryReader.readDouble(),
  993. binaryReader.readDouble(),
  994. ];
  995. map.physics.shapes[F5W[28]].sk = binaryReader.readBoolean();
  996. }
  997. if (F5W[5] == 3) {
  998. map.physics.shapes[F5W[28]] = { type: "po", v: [], s: 1, a: 0, c: [0, 0] };
  999. map.physics.shapes[F5W[28]].s = binaryReader.readDouble();
  1000. map.physics.shapes[F5W[28]].a = binaryReader.readDouble();
  1001. map.physics.shapes[F5W[28]].c = [
  1002. binaryReader.readDouble(),
  1003. binaryReader.readDouble(),
  1004. ];
  1005. F5W[74] = binaryReader.readShort();
  1006. map.physics.shapes[F5W[28]].v = [];
  1007. for (F5W[27] = 0; F5W[27] < F5W[74]; F5W[27]++) {
  1008. map.physics.shapes[F5W[28]].v.push([
  1009. binaryReader.readDouble(),
  1010. binaryReader.readDouble(),
  1011. ]);
  1012. }
  1013. }
  1014. }
  1015. F5W[71] = binaryReader.readShort();
  1016. for (F5W[17] = 0; F5W[17] < F5W[71]; F5W[17]++) {
  1017. map.physics.fixtures[F5W[17]] = { sh: 0, n: "Def Fix", fr: 0.3, fp: null, re: 0.8, de: 0.3, f: 0x4f7cac, d: false, np: false, ng: false };
  1018. map.physics.fixtures[F5W[17]].sh = binaryReader.readShort();
  1019. map.physics.fixtures[F5W[17]].n = binaryReader.readUTF();
  1020. map.physics.fixtures[F5W[17]].fr = binaryReader.readDouble();
  1021. if (map.physics.fixtures[F5W[17]].fr == Number.MAX_VALUE) {
  1022. map.physics.fixtures[F5W[17]].fr = null;
  1023. }
  1024. F5W[12] = binaryReader.readShort();
  1025. if (F5W[12] == 0) {
  1026. map.physics.fixtures[F5W[17]].fp = null;
  1027. }
  1028. if (F5W[12] == 1) {
  1029. map.physics.fixtures[F5W[17]].fp = false;
  1030. }
  1031. if (F5W[12] == 2) {
  1032. map.physics.fixtures[F5W[17]].fp = true;
  1033. }
  1034. map.physics.fixtures[F5W[17]].re = binaryReader.readDouble();
  1035. if (map.physics.fixtures[F5W[17]].re == Number.MAX_VALUE) {
  1036. map.physics.fixtures[F5W[17]].re = null;
  1037. }
  1038. map.physics.fixtures[F5W[17]].de = binaryReader.readDouble();
  1039. if (map.physics.fixtures[F5W[17]].de == Number.MAX_VALUE) {
  1040. map.physics.fixtures[F5W[17]].de = null;
  1041. }
  1042. map.physics.fixtures[F5W[17]].f = binaryReader.readUint();
  1043. map.physics.fixtures[F5W[17]].d = binaryReader.readBoolean();
  1044. map.physics.fixtures[F5W[17]].np = binaryReader.readBoolean();
  1045. if (map.v >= 11) {
  1046. map.physics.fixtures[F5W[17]].ng = binaryReader.readBoolean();
  1047. }
  1048. if (map.v >= 12) {
  1049. map.physics.fixtures[F5W[17]].ig = binaryReader.readBoolean();
  1050. }
  1051. }
  1052. F5W[63] = binaryReader.readShort();
  1053. for (F5W[52] = 0; F5W[52] < F5W[63]; F5W[52]++) {
  1054. map.physics.bodies[F5W[52]] ={ type: "s", n: "Unnamed", p: [0, 0], a: 0, fric: 0.3, fricp: false, re: 0.8, de: 0.3, lv: [0, 0], av: 0, ld: 0, ad: 0, fr: false, bu: false, cf: { x: 0, y: 0, w: true, ct: 0 }, fx: [], f_c: 1, f_p: true, f_1: true, f_2: true, f_3: true, f_4: true, fz: { on: false, x: 0, y: 0, d: true, p: true, a: true }};
  1055. map.physics.bodies[F5W[52]].type = binaryReader.readUTF();
  1056. map.physics.bodies[F5W[52]].n = binaryReader.readUTF();
  1057. map.physics.bodies[F5W[52]].p = [binaryReader.readDouble(), binaryReader.readDouble()];
  1058. map.physics.bodies[F5W[52]].a = binaryReader.readDouble();
  1059. map.physics.bodies[F5W[52]].fric = binaryReader.readDouble();
  1060. map.physics.bodies[F5W[52]].fricp = binaryReader.readBoolean();
  1061. map.physics.bodies[F5W[52]].re = binaryReader.readDouble();
  1062. map.physics.bodies[F5W[52]].de = binaryReader.readDouble();
  1063. map.physics.bodies[F5W[52]].lv = [
  1064. binaryReader.readDouble(),
  1065. binaryReader.readDouble(),
  1066. ];
  1067. map.physics.bodies[F5W[52]].av = binaryReader.readDouble();
  1068. map.physics.bodies[F5W[52]].ld = binaryReader.readDouble();
  1069. map.physics.bodies[F5W[52]].ad = binaryReader.readDouble();
  1070. map.physics.bodies[F5W[52]].fr = binaryReader.readBoolean();
  1071. map.physics.bodies[F5W[52]].bu = binaryReader.readBoolean();
  1072. map.physics.bodies[F5W[52]].cf.x = binaryReader.readDouble();
  1073. map.physics.bodies[F5W[52]].cf.y = binaryReader.readDouble();
  1074. map.physics.bodies[F5W[52]].cf.ct = binaryReader.readDouble();
  1075. map.physics.bodies[F5W[52]].cf.w = binaryReader.readBoolean();
  1076. map.physics.bodies[F5W[52]].f_c = binaryReader.readShort();
  1077. map.physics.bodies[F5W[52]].f_1 = binaryReader.readBoolean();
  1078. map.physics.bodies[F5W[52]].f_2 = binaryReader.readBoolean();
  1079. map.physics.bodies[F5W[52]].f_3 = binaryReader.readBoolean();
  1080. map.physics.bodies[F5W[52]].f_4 = binaryReader.readBoolean();
  1081. if (map.v >= 2) {
  1082. map.physics.bodies[F5W[52]].f_p = binaryReader.readBoolean();
  1083. }
  1084. if (map.v >= 14) {
  1085. map.physics.bodies[F5W[52]].fz.on = binaryReader.readBoolean();
  1086. if (map.physics.bodies[F5W[52]].fz.on) {
  1087. map.physics.bodies[F5W[52]].fz.x = binaryReader.readDouble();
  1088. map.physics.bodies[F5W[52]].fz.y = binaryReader.readDouble();
  1089. map.physics.bodies[F5W[52]].fz.d = binaryReader.readBoolean();
  1090. map.physics.bodies[F5W[52]].fz.p = binaryReader.readBoolean();
  1091. map.physics.bodies[F5W[52]].fz.a = binaryReader.readBoolean();
  1092. }
  1093. }
  1094. F5W[88] = binaryReader.readShort();
  1095. for (F5W[65] = 0; F5W[65] < F5W[88]; F5W[65]++) {
  1096. map.physics.bodies[F5W[52]].fx.push(binaryReader.readShort());
  1097. }
  1098. }
  1099. F5W[97] = binaryReader.readShort();
  1100. for (F5W[41] = 0; F5W[41] < F5W[97]; F5W[41]++) {
  1101. map.spawns[F5W[41]] = {"x":400,"y":300,"xv":0,"yv":0,"priority":5,"r":true,"f":true,"b":true,"gr":false,"ye":false,"n":"Spawn"};
  1102. F5W[35] = map.spawns[F5W[41]];
  1103. F5W[35].x = binaryReader.readDouble();
  1104. F5W[35].y = binaryReader.readDouble();
  1105. F5W[35].xv = binaryReader.readDouble();
  1106. F5W[35].yv = binaryReader.readDouble();
  1107. F5W[35].priority = binaryReader.readShort();
  1108. F5W[35].r = binaryReader.readBoolean();
  1109. F5W[35].f = binaryReader.readBoolean();
  1110. F5W[35].b = binaryReader.readBoolean();
  1111. F5W[35].gr = binaryReader.readBoolean();
  1112. F5W[35].ye = binaryReader.readBoolean();
  1113. F5W[35].n = binaryReader.readUTF();
  1114. }
  1115. F5W[16] = binaryReader.readShort();
  1116. for (F5W[25] = 0; F5W[25] < F5W[16]; F5W[25]++) {
  1117. map.capZones[F5W[25]] = {"n":"Cap Zone","ty":1,"l":10,"i":-1};
  1118. map.capZones[F5W[25]].n = binaryReader.readUTF();
  1119. map.capZones[F5W[25]].l = binaryReader.readDouble();
  1120. map.capZones[F5W[25]].i = binaryReader.readShort();
  1121. if (map.v >= 6) {
  1122. map.capZones[F5W[25]].ty = binaryReader.readShort();
  1123. }
  1124. }
  1125. F5W[98] = binaryReader.readShort();
  1126. for (F5W[19] = 0; F5W[19] < F5W[98]; F5W[19]++) {
  1127. F5W[31] = binaryReader.readShort();
  1128. if (F5W[31] == 1) {
  1129. map.physics.joints[F5W[19]] = {"type":"rv","d":{"la":0,"ua":0,"mmt":0,"ms":0,"el":false,"em":false,"cc":false,"bf":0,"dl":true},"aa":[0,0]};
  1130. F5W[20] = map.physics.joints[F5W[19]];
  1131. F5W[20].d.la = binaryReader.readDouble();
  1132. F5W[20].d.ua = binaryReader.readDouble();
  1133. F5W[20].d.mmt = binaryReader.readDouble();
  1134. F5W[20].d.ms = binaryReader.readDouble();
  1135. F5W[20].d.el = binaryReader.readBoolean();
  1136. F5W[20].d.em = binaryReader.readBoolean();
  1137. F5W[20].aa = [binaryReader.readDouble(), binaryReader.readDouble()];
  1138. }
  1139. if (F5W[31] == 2) {
  1140. map.physics.joints[F5W[19]] = {"type":"d","d":{"fh":0,"dr":0,"cc":false,"bf":0,"dl":true},"aa":[0,0],"ab":[0,0]};
  1141. F5W[87] = map.physics.joints[F5W[19]];
  1142. F5W[87].d.fh = binaryReader.readDouble();
  1143. F5W[87].d.dr = binaryReader.readDouble();
  1144. F5W[87].aa = [binaryReader.readDouble(), binaryReader.readDouble()];
  1145. F5W[87].ab = [binaryReader.readDouble(), binaryReader.readDouble()];
  1146. }
  1147. if (F5W[31] == 3) {
  1148. map.physics.joints[F5W[19]] = {"type":"lpj","d":{"cc":false,"bf":0,"dl":true},"pax":0,"pay":0,"pa":0,"pf":0,"pl":0,"pu":0,"plen":0,"pms":0};
  1149. F5W[90] = map.physics.joints[F5W[19]];
  1150. F5W[90].pax = binaryReader.readDouble();
  1151. F5W[90].pay = binaryReader.readDouble();
  1152. F5W[90].pa = binaryReader.readDouble();
  1153. F5W[90].pf = binaryReader.readDouble();
  1154. F5W[90].pl = binaryReader.readDouble();
  1155. F5W[90].pu = binaryReader.readDouble();
  1156. F5W[90].plen = binaryReader.readDouble();
  1157. F5W[90].pms = binaryReader.readDouble();
  1158. }
  1159. if (F5W[31] == 4) {
  1160. map.physics.joints[F5W[19]] = {"type":"lsj","d":{"cc":false,"bf":0,"dl":true},"sax":0,"say":0,"sf":0,"slen":0};
  1161. F5W[44] = map.physics.joints[F5W[19]];
  1162. F5W[44].sax = binaryReader.readDouble();
  1163. F5W[44].say = binaryReader.readDouble();
  1164. F5W[44].sf = binaryReader.readDouble();
  1165. F5W[44].slen = binaryReader.readDouble();
  1166. }
  1167. map.physics.joints[F5W[19]].ba = binaryReader.readShort();
  1168. map.physics.joints[F5W[19]].bb = binaryReader.readShort();
  1169. map.physics.joints[F5W[19]].d.cc = binaryReader.readBoolean();
  1170. map.physics.joints[F5W[19]].d.bf = binaryReader.readDouble();
  1171. map.physics.joints[F5W[19]].d.dl = binaryReader.readBoolean();
  1172. }
  1173. return map;
  1174. };
  1175. scope.updateWssLog = function(){
  1176. if(!wsslogpaused){
  1177. if(logmenutable.children.length < wsssendrecievelog.length){
  1178. var bottomscroll = logmenutable.clientHeight + logmenutable.scrollTop >= logmenutable.scrollHeight-1;
  1179. while (logmenutable.children.length>1000) {
  1180. logmenutable.removeChild(logmenutable.firstChild);
  1181. logmenutable2.removeChild(logmenutable2.firstChild);
  1182. }
  1183. var loopthro = wsssendrecievelog.slice(packetcount);
  1184. for(var i = 0; i < loopthro.length;i++){
  1185. packetcount++;
  1186. var row = document.createElement("tr");
  1187. var row2 = document.createElement("tr");
  1188.  
  1189. var cell1 = document.createElement("td");
  1190. cell1.style["overflow-x"] = "scroll";
  1191. cell1.style["padding"] = "0px";
  1192. cell1.style["width"] = "100000px";
  1193.  
  1194. var cell2 = document.createElement("td");
  1195. cell2.style["overflow-x"] = "scroll";
  1196. cell2.style["padding"] = "0px";
  1197. cell2.style["width"] = "100000px";
  1198. if(debuggercount){
  1199. cell1.style["background"] = "rgb(178, 185, 189)";
  1200. debuggercount = false;
  1201. }
  1202. else{
  1203. cell2.style["background"] = "rgb(178, 185, 189)";
  1204. debuggercount = true;
  1205. }
  1206. cell1.textContent = loopthro[i][1];
  1207. cell2.textContent = loopthro[i][1];
  1208. if(loopthro[i][0] == 0){
  1209. cell2.style["color"] = "transparent";
  1210. cell1.onclick = function(){debuggerinput.value = this.textContent};
  1211. }
  1212. else{
  1213. cell1.style["color"] = "transparent";
  1214. cell2.onclick = function(){debuggerinput.value = this.textContent};
  1215. }
  1216. row.appendChild(cell1);
  1217. row2.appendChild(cell2);
  1218. logmenutable.appendChild(row);
  1219. logmenutable2.appendChild(row2);
  1220. }
  1221. while (logmenutable.children.length>1000) {
  1222. logmenutable.removeChild(logmenutable.firstChild);
  1223. logmenutable2.removeChild(logmenutable2.firstChild);
  1224. }
  1225. if(bottomscroll){
  1226. logmenutable.scrollTop = logmenutable.scrollHeight;
  1227. logmenutable2.scrollTop = logmenutable.scrollHeight;
  1228. }
  1229. }
  1230. }
  1231. };
  1232. Gdocument.getElementById("maploadwindowmapscontainer").appendChild = function(args){
  1233.  
  1234. var checkbox = Gdocument.createElement("input");
  1235. checkbox.type = "checkbox";
  1236. checkbox.style["position"]="absolute";
  1237. checkbox.style["margin-top"] = "135px";
  1238. checkbox.style["margin-left"] = "140px";
  1239. checkbox.style["scale"] = "2";
  1240. checkbox.style["display"] = "none";
  1241. checkbox.className = "quickplaycheckbox quickplayunchecked";
  1242. if(ishost && stopquickplay==0){
  1243. checkbox.style["display"] = "block";
  1244. checkbox.className = "quickplaycheckbox quickplaychecked";
  1245. }
  1246. checkbox.checked = true;
  1247. checkbox.onclick = function(e){e.stopPropagation();};
  1248. args.appendChild(checkbox);
  1249. originalMapLoad.call(this,args);
  1250. };
  1251. Gdocument.getElementById("newbonklobby_chat_content").appendChild = function(args){
  1252. if(beenKickedTimeStamp+100>Date.now() && args.children.length>0){
  1253. if(args.children[0].textContent.endsWith(" has left the game ") && args.children[0].textContent.startsWith("* ")){
  1254. var kickedorbanned = "banned";
  1255. if(onlykicked){
  1256. kickedorbanned = "kicked";
  1257. }
  1258. args.children[0].textContent = args.children[0].textContent.substring(0,args.children[0].textContent.length-19)+" has been "+kickedorbanned+" from the game ";
  1259. }
  1260. }
  1261. setTimeout(function(){
  1262. if(args.textContent.startsWith("* ") && args.children.length>=5){
  1263. var newarg = args.cloneNode();
  1264. for(var i = 0;i<args.children.length;i++){
  1265. var newarg2 = args.children[i].cloneNode();
  1266. newarg2.textContent = args.children[i].textContent;
  1267. newarg2.style.color = '#ffffffd6';
  1268. newarg2.onclick = args.children[i].onclick;
  1269. newarg2.suggestID = args.children[i].suggestID;
  1270. newarg.appendChild(newarg2);
  1271. }
  1272. Gdocument.getElementById("ingamechatcontent").appendChild(newarg);
  1273. Gdocument.getElementById("ingamechatcontent").scrollTop = Number.MAX_SAFE_INTEGER;
  1274. }},0);
  1275. originalLobbyChat.call(this,args);
  1276. };
  1277. Gdocument.getElementById("ingamechatcontent").appendChild = function(args){
  1278. if(beenKickedTimeStamp+100>Date.now() && args.children.length>0){
  1279. if(args.children[0].textContent.endsWith(" has left the game.") && args.children[0].textContent.startsWith("* ")){
  1280. var kickedorbanned = "banned";
  1281. if(onlykicked){
  1282. kickedorbanned = "kicked";
  1283. }
  1284. args.children[0].textContent = args.children[0].textContent.substring(0,args.children[0].textContent.length-19)+" has been "+kickedorbanned+" from the game.";
  1285. }
  1286. }
  1287. if(recordedTimeStamp+100>Date.now() && args.children.length>0){
  1288. if(args.children[0].textContent.includes("seconds") && args.children[0].textContent.startsWith("* ")){
  1289. args.children[0].textContent = args.children[0].textContent + " - " + playerids[recordedId].userName;
  1290. }
  1291. }
  1292. originalIngameChat.call(this,args);
  1293. };
  1294. Gwindow.XMLHttpRequest.prototype.open = function(_, url) {
  1295. if (url.includes("scripts/map_get") || url.includes("scripts/map_b1_get") || url.includes("scripts/hotmaps/")) {
  1296. this.isSearchMap = true;
  1297. }
  1298. originalXMLOpen.call(this, ...arguments);
  1299. };
  1300. Gwindow.XMLHttpRequest.prototype.send = function(data) {
  1301. if (this.isSearchMap) {
  1302. this.onreadystatechange = function () {
  1303. if (this.readyState == 4 && searchrequested && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS") {
  1304. searchrequested = false;
  1305. var jsonargs = {r:"success",maps:[],more:true};
  1306. for(var i = 0; i<requestedmaps.length; i++){
  1307. var dec = requestedmaps[i][0];
  1308. var undec = requestedmaps[i][1];
  1309. var map = {};
  1310. map.id = dec["m"]["dbid"];
  1311. map.name = dec["m"]["n"];
  1312. map.authorname = dec["m"]["a"];
  1313. map.leveldata = undec;
  1314. map.publisheddate = dec["m"]["date"];
  1315. map.remixauthor = dec["m"]["rxa"];
  1316. map.remixdb = dec["m"]["rxdb"];
  1317. map.remixid = dec["m"]["rxid"];
  1318. map.remixname = dec["m"]["rxn"];
  1319. map.vd = dec["m"]["vd"];
  1320. map.vu = dec["m"]["vu"];
  1321. jsonargs.maps.push(map);
  1322. }
  1323. jsonargs2 = JSON.stringify(jsonargs);
  1324. function stringifyjsonargs(){
  1325. return jsonargs2;
  1326. }
  1327. this.__defineGetter__("responseText", stringifyjsonargs);
  1328. this.__defineGetter__("response", stringifyjsonargs);
  1329. }
  1330. }
  1331. }
  1332. originalXMLSend.call(this, ...arguments);
  1333. };
  1334. scope.STB = function(x){
  1335. if(x == "0"){
  1336. return 0;
  1337. }
  1338. else{
  1339. return 1;
  1340. }
  1341. };
  1342. scope.BTS = function(x){
  1343. if(x == 0){
  1344. return "0";
  1345. }
  1346. else{
  1347. return "1";
  1348. }
  1349. };
  1350. scope.GET_KEYS = function(x){
  1351. var x2 = ((x+64)>>>0).toString(2).substring(1).split("");
  1352. return {"left":STB(x2[5]),"right":STB(x2[4]),"up":STB(x2[3]),"down":STB(x2[2]),"heavy":STB(x2[1]),"special":STB(x2[0])}
  1353. };
  1354. scope.MAKE_KEYS = function(x){
  1355. return x.special*32+x.heavy*16+x.down*8+x.up*4+x.right*2+x.left
  1356. };
  1357.  
  1358. Gwindow.PIXI.Graphics.prototype.drawCircle = function(...args){
  1359. var This = this;
  1360. var Args = [...args];
  1361. setTimeout(function(){
  1362. if(This.parent){
  1363. var childs = This.parent.children;
  1364. var user = 0;
  1365. for(var i = 0;i<childs.length;i++){
  1366. if(childs[i]._text){
  1367. user = childs[i]._text;
  1368. }
  1369. if(i==2 && childs[i]!=This){
  1370. return;
  1371. }
  1372. }
  1373. var keys = Object.keys(playerids);
  1374. for(var i = 0;i<keys.length;i++){
  1375. if(playerids[keys[i]].userName == user){
  1376. playerids[keys[i]].playerData = This.parent;
  1377. if(!playerids[keys[i]].playerData2){
  1378. playerids[keys[i]].playerData2 = {alive:true,radius:12,timeStamp:0,timeStamp2:0,px:0,py:0,pvx:0,pvy:0,xacc:0,yacc:0,xvel:0,yvel:0,balance:0};
  1379. }
  1380. playerids[keys[i]].playerData2.radius = Args[2];
  1381. parentDraw = This.parent;
  1382. while(parentDraw.parent){
  1383. parentDraw = parentDraw.parent;
  1384. }
  1385. }
  1386. }
  1387. }
  1388. },0);
  1389. return originalDrawCircle.call(this,...args);
  1390. };
  1391. Gwindow.requestAnimationFrame = function(...args){
  1392. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  1393. while(parentDraw.parent){
  1394. parentDraw = parentDraw.parent;
  1395. }
  1396. var canv = 0;
  1397. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  1398. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  1399. canv = Gdocument.getElementById("gamerenderer").children[i];
  1400. break;
  1401. }
  1402. }
  1403. var width = parseInt(canv.style["width"]);
  1404. var height = parseInt(canv.style["height"]);
  1405. scale = (parseInt(canv.style["width"])/730);
  1406. var now = Date.now();
  1407. var keys = Object.keys(playerids);
  1408. addto = {"children":[]};
  1409. for(var i = 0;i<parentDraw.children.length;i++){
  1410. if(parentDraw.children[i].constructor.name == "e"){
  1411. addto = parentDraw.children[i];
  1412. break;
  1413. }
  1414. }
  1415. if(autocam){
  1416. var autocamx = 365*scale;
  1417. var autocamy = 250*scale;
  1418. if(FollowCam && playerids[myid].playerData?.transform){
  1419. autocamx = playerids[myid].playerData.transform.position.x;
  1420. autocamy = playerids[myid].playerData.transform.position.y;
  1421. }
  1422. var distances = {};
  1423. for(var i = 0;i<keys.length;i++){
  1424. if(playerids[keys[i]].playerData && playerids[keys[i]].playerData2){
  1425. if(playerids[keys[i]].playerData.transform){
  1426. var ypos = playerids[keys[i]].playerData.transform.position.y;
  1427. if(ypos>460*scale && ypos< 500 * scale){
  1428. ypos = scale * 460;
  1429. }
  1430. distances[keys[i]] = [playerids[keys[i]].playerData.transform.position.x-autocamx,ypos-autocamy];
  1431. }
  1432. }
  1433. }
  1434. distances["topleft"] = [autocamx-40,autocamy-40];
  1435. distances["topright"] = [690*scale-autocamx,autocamy-40];
  1436. distances["bottomleft"] = [autocamx-40,460*scale-autocamy];
  1437. distances["bottomright"] = [690*scale-autocamx,460*scale-autocamy];
  1438. var lowestD = [-1,-1];
  1439. var keys2 = Object.keys(distances);
  1440. for(var i = 0;i<keys2.length;i++){
  1441. if(Math.abs(distances[keys2[i]][0]/scale)>lowestD[0]){
  1442. lowestD[0] = Math.abs(distances[keys2[i]][0]/scale);
  1443. }
  1444. if(Math.abs(distances[keys2[i]][1]/scale)>lowestD[1]){
  1445. lowestD[1] = Math.abs(distances[keys2[i]][1]/scale);
  1446. }
  1447. }
  1448. var horizontal = (lowestD[0])/345;
  1449. var vertical = (lowestD[1])/230;
  1450. newzoom = Math.min(Math.abs(1/Math.max(horizontal,vertical)),1);
  1451. }
  1452. else{
  1453. newzoom = 1;
  1454. }
  1455.  
  1456. newzoom2 = newzoom2 + 0.15*(newzoom-newzoom2);
  1457. zoom2 = zoom2 + 0.15*(zoom-zoom2);
  1458. addto.scale.x = newzoom2 * zoom2;
  1459. addto.scale.y = newzoom2 * zoom2;
  1460. if(holdheavy>0){
  1461. if(holdheavy==1){
  1462. holdheavy = -1;
  1463. }
  1464. else{
  1465. holdheavy-=1;
  1466. }
  1467. }
  1468. if(playerids[myid].playerData?.children){
  1469. for(var i = 0;i<playerids[myid].playerData.children.length;i++){
  1470. if(playerids[myid].playerData.children[i].alpha!=1){
  1471. heavyid = i;
  1472. }
  1473. if(playerids[myid].playerData.children[i].vertextData){
  1474. if(playerids[myid].playerData.children[i].vertextData.length == 0){
  1475. specialid = i;
  1476. }
  1477. }
  1478. }
  1479. }
  1480. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  1481. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  1482. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  1483. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  1484. if(canvasWidth!=width){
  1485. canvasWidth = width;
  1486. pixiCircle.clear();
  1487. pixiCircle.x = parseInt(canv.style["width"])/2;
  1488. pixiCircle.y = parseInt(canv.style["height"])/2;
  1489. pixiCircle.lineStyle(3, 0x8B8000);
  1490. pixiCircle.drawRect(-parseInt(canv.style["width"])/2,-parseInt(canv.style["height"])/2,parseInt(canv.style["width"]),parseInt(canv.style["height"]));
  1491. pixiCircle.lineStyle(3, 0xFF0000);
  1492. pixiCircle.arc(0, 0, 850*scale,Math.atan2(250,-100*Math.sqrt(66)),Math.atan2(250,100*Math.sqrt(66)));
  1493. pixiCircle.lineTo(-100*Math.sqrt(66)*scale,250*scale);
  1494. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  1495. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  1496. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  1497. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  1498. }
  1499.  
  1500. if(!addto.children.includes(container)){
  1501. addto.addChild(container);
  1502. }
  1503. if(keys.length>0){
  1504. if(playerids[myid].playerData && playerids[myid].playerData2){
  1505. if(aimbot || heavybot){
  1506. var targetid = -1;
  1507. var distances = {};
  1508. if(Gdocument.getElementById("ingamecountdown").style["visibility"] == "hidden"){
  1509. if(playerids[myid].playerData.transform){
  1510. var teamok = true;
  1511. if(playerids[myid].team>1){
  1512. teamok = false;
  1513. }
  1514. for(var i = 0;i<keys.length;i++){
  1515. if(playerids[keys[i]].playerData && playerids[keys[i]].playerData2 && keys[i]!=myid){
  1516. if(playerids[keys[i]].playerData.transform && (playerids[keys[i]].team != playerids[myid].team || teamok || FFA)){
  1517. distances[keys[i]] = Math.sqrt((playerids[keys[i]].playerData.transform.position.x-playerids[myid].playerData.transform.position.x)**2+(playerids[keys[i]].playerData.transform.position.y-playerids[myid].playerData.transform.position.y)**2);
  1518. }
  1519. }
  1520. }
  1521. }
  1522. }
  1523. var lowestD = [-1,-1];
  1524. var keys2 = Object.keys(distances);
  1525. for(var i = 0;i<keys2.length;i++){
  1526. if(myid != keys2[i]){
  1527. if(lowestD[1] == -1){
  1528. lowestD[1] = distances[keys2[i]];
  1529. lowestD[0] = keys2[i];
  1530. }
  1531. else if(distances[keys2[i]]<lowestD[1]){
  1532. lowestD[1] = distances[keys2[i]];
  1533. lowestD[0] = keys2[i];
  1534. }
  1535. }
  1536. }
  1537. targetid = lowestD[0];
  1538. if(targetid != -1 && playerids[myid].playerData.transform){
  1539. if(playerids[myid].playerData.children.length >= 7 && playerids[targetid].playerData && playerids[targetid].playerData?.transform && playerids[targetid].playerData2 && playerids[myid].playerData.transform && aimbot){
  1540. var indexE = -1;
  1541. for(var i = 0;i<playerids[myid].playerData.children.length;i++){
  1542. if(playerids[myid].playerData.children[i].constructor.name == "e"){
  1543. indexE = i;
  1544. break;
  1545. }
  1546. }
  1547. if(indexE != -1 && playerids[myid].playerData.children[indexE].visible){
  1548. if(started == 0){
  1549. started = now;
  1550. }
  1551. var scale2=1/(parseInt(canv.style["width"])/730);
  1552. scale2 /= scale/(1 + playerids[myid].playerData2.balance*0.0088)*(playerids[myid].playerData2.radius/12);
  1553. var Dstarted = (Math.min((now-started)/1000,10/3)/(10/3));
  1554. var v = multiplier * (Dstarted*100+15);
  1555. var g = gravity;
  1556. var mypos = playerids[myid].playerData.transform.position;
  1557. var targetpos = playerids[targetid].playerData.transform.position;
  1558. var deltapos = [(targetpos.x-mypos.x)*scale2,(targetpos.y-mypos.y)*scale2];
  1559. var dis = (Math.sqrt(deltapos[0]**2 + deltapos[1]**2))/v*prediction;
  1560. deltapos[0]+=playerids[targetid].playerData2.xvel*scale2*dis+(playerids[targetid].playerData2.xacc*scale2*(dis))**2/2;
  1561. deltapos[1]+=playerids[targetid].playerData2.yvel*scale2*dis+(playerids[targetid].playerData2.yacc*scale2*(dis))**2/2;
  1562. deltapos[1] = -deltapos[1];
  1563. var angle = positive(-Math.atan2(deltapos[1],deltapos[0]));
  1564. var rot = playerids[myid].playerData.children[indexE].transform.rotation;
  1565. rot = positive(rot);
  1566. angle = positive(angle);
  1567.  
  1568. var alpha = deltapos[0];
  1569. var beta = deltapos[1];
  1570. var v_squared = v**2;
  1571. var rootterm = v_squared**2 - g*(g*alpha**2+2*beta*v_squared);
  1572. if(rootterm < 0) {
  1573. } else {
  1574. gamma_first = (v_squared + Math.sqrt(rootterm));
  1575. gamma_second = (v_squared - Math.sqrt(rootterm));
  1576. theta_first = positive(-Math.atan2(gamma_first, g*alpha));
  1577. theta_second = positive(-Math.atan2(gamma_second, g*alpha));
  1578. if(angle_between(angle,theta_first)<angle_between(angle,theta_second)){
  1579. angle = theta_first;
  1580. }
  1581. else{
  1582. angle = theta_second;
  1583. }
  1584. }
  1585. var min = angle_between(angle,rot);
  1586. if(angle_between2(angle,rot)<0){
  1587. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1588. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"))
  1589. }
  1590. else{
  1591. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1592. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"))
  1593. }
  1594. if(min<0.05){
  1595. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1596. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1597. }
  1598. }
  1599. else if(started>0){
  1600. started = 0;
  1601. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1602. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1603. }
  1604. }
  1605. }
  1606. if(playerids[myid].playerData?.transform && heavybot && mode!="f" && mode!="bs"){
  1607. var myradius = playerids[myid].playerData2.radius / scale;
  1608. var mypos = playerids[myid].playerData.transform.position;
  1609. var breakout = false;
  1610. var collision_happened = false;
  1611. for(var i = 0;i<keys2.length;i++){
  1612. var targetradius = playerids[keys2[i]].playerData2.radius / scale;
  1613. var targetpos = playerids[keys2[i]].playerData.transform.position;
  1614. var deltapos = [(targetpos.x-mypos.x)/scale,(targetpos.y-mypos.y)/scale];
  1615. for(var i2 = 0;i2<300;i2++){
  1616. deltapos2 = [...deltapos];
  1617. var i3 = i2*0.25;
  1618. deltapos2[0]+=((playerids[keys2[i]].playerData2.xvel-playerids[myid].playerData2.xvel)/scale*i3);
  1619. deltapos2[1]+=((playerids[keys2[i]].playerData2.yvel-playerids[myid].playerData2.yvel)/scale*i3);
  1620. var dis = Math.sqrt(deltapos2[0]**2+deltapos2[1]**2);
  1621. if(dis<myradius+targetradius){
  1622. breakout = true;
  1623. holdheavy = 15;
  1624. collision_happened = true;
  1625. break;
  1626. }
  1627. }
  1628. if(breakout){
  1629. break;
  1630. }
  1631. }
  1632. if(holdheavy>0){
  1633. if(collision_happened && holdheavy<10){
  1634. holdheavy += 1;
  1635. }
  1636. if(!heavyheld2){
  1637. heavyheld = playerids[myid].playerData.children[heavyid].alpha>0;
  1638. }
  1639. fire("keydown",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  1640. heavyheld2 = true;
  1641. if(mode == "sp"){
  1642. if(!grappleheld2){
  1643. grappleheld = playerids[myid].playerData.children[specialid].vertexData?.length>0;
  1644. }
  1645. if(grappleheld){
  1646. fire("keyup",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  1647. }
  1648. grappleheld2 = true;
  1649. }
  1650. }
  1651. else if(holdheavy<0){
  1652. holdheavy = 0;
  1653. heavyheld2 = false;
  1654. grappleheld2 = false;
  1655. if(!heavyheld){
  1656. heavyheld = false;
  1657. fire("keyup",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  1658. }
  1659. if(grappleheld && mode == "sp"){
  1660. grappleheld = false;
  1661. fire("keydown",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  1662. }
  1663. }
  1664. else{
  1665. heavyheld2 = false;
  1666. heavyheld = false;
  1667. grappleheld2 = false;
  1668. grappleheld = false;
  1669. }
  1670. }
  1671.  
  1672. }
  1673. if(FollowCam){
  1674. if(playerids[myid].playerData?.transform){
  1675.  
  1676. pixiCircle.visible = true;
  1677.  
  1678. parentDraw.x = -playerids[myid].playerData.x*addto.scale.x+parseInt(width)/2;
  1679. parentDraw.y = -playerids[myid].playerData.y*addto.scale.y+parseInt(height)/2;
  1680. parentDraw.children[0].x = playerids[myid].playerData.x*addto.scale.x-parseInt(width)/2;
  1681. parentDraw.children[0].y = playerids[myid].playerData.y*addto.scale.y-parseInt(height)/2;
  1682. }
  1683. else{
  1684. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  1685. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  1686. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  1687. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  1688. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  1689. pixiCircle.visible = false;
  1690. }
  1691. else{
  1692. pixiCircle.visible = true;
  1693. }
  1694. }
  1695. }
  1696. }
  1697. }
  1698. if(!FollowCam){
  1699. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  1700. pixiCircle.visible = false;
  1701. }
  1702. else{
  1703. pixiCircle.visible = true;
  1704. }
  1705. }
  1706. }
  1707. return requestAnimationFrameOriginal.call(this,...args);
  1708. };
  1709. scope.SENDFUNCTION = function(args){return args;};
  1710. scope.RECIEVEFUNCTION = function(args){return args;};
  1711. scope.EVENTLOOPFUNCTION = function(){};
  1712.  
  1713. Gwindow.WebSocket.prototype.send = function(args) {
  1714. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=")){
  1715. if(typeof(args) == "string" && !bonkwssextra.includes(this)){
  1716. args = SENDFUNCTION(args);
  1717. wsssendlog.push(args);
  1718. wsssendrecievelog.push([0,args]);
  1719. if(!bonkwss){
  1720. bonkwss = this;
  1721. }
  1722. if(args.startsWith('42[26,')){
  1723. var jsonargs = JSON.parse(args.substring(2));
  1724. if(sandboxon){
  1725. if(typeof(sandboxplayerids[jsonargs[1]["targetID"]])!='undefined'){
  1726. var packet = '42[18,'+jsonargs[1]["targetID"]+','+jsonargs[1]["targetTeam"]+']';
  1727. RECIEVE(packet);
  1728. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  1729. }
  1730. }
  1731. }
  1732. if(args.startsWith('42[9,')){
  1733. var jsonargs = JSON.parse(args.substring(2));
  1734. if(sandboxon){
  1735. if(typeof(sandboxplayerids[jsonargs[1]["banshortid"]])!='undefined'){
  1736. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
  1737. var packet = '42[24,'+jsonargs[1]["banshortid"].toString()+','+jsonargs[1]["kickonly"]+']';
  1738. var packet2 = '42[5,'+jsonargs[1]["banshortid"].toString()+',0]';
  1739. RECIEVE(packet);
  1740. RECIEVE(packet2);
  1741. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet,packet2],to:[-1]}]));
  1742. }
  1743. else{
  1744. displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
  1745. }
  1746. }
  1747. }
  1748. }
  1749. if(args.startsWith('42[1,')){
  1750. return;
  1751. }
  1752.  
  1753. if(args.startsWith('42[4,')){
  1754. var jsonargs = JSON.parse(args.substring(2));
  1755. if(sandboxcopyme==myid && typeof(jsonargs[1]["i"])!="undefined"){
  1756. var jsonkeys = Object.keys(sandboxplayerids);
  1757. var jsonargs2 = jsonargs[1];
  1758. for(var i = 0; i<jsonkeys.length;i++){
  1759. jsonargs2["c"] = playerids[jsonkeys[i]].movecount;
  1760. var packet = '42[7,'+jsonkeys[i].toString()+','+JSON.stringify(jsonargs2)+']';
  1761. RECIEVE(packet);
  1762. }
  1763. jsonargs2["c"] = "CVALUE";
  1764. jsonargs2 = JSON.stringify(jsonargs2).replace('"CVALUE"',"CVALUE");
  1765. SEND("42"+JSON.stringify([4,{"type":"customfakerecieve","from":username,"packet":['42[7,ID,'+jsonargs2+']'],to:[-1]}]));
  1766. }
  1767. playerids[myid].lastmove = Date.now();
  1768. if(ishost && typeof(jsonargs[1]["i"])!="undefined"){
  1769. for(var i = 0;i<disabledkeys.length;i++){
  1770. if(GET_KEYS(jsonargs[1]["i"])[disabledkeys[i]]){
  1771. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(myid)){
  1772. killedids.push(myid);
  1773. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  1774. SEND('42[25,{"a":{"playersLeft":['+myid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  1775. RECIEVE('42[31,{"a":{"playersLeft":['+myid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  1776. break;
  1777. }
  1778. }
  1779. }
  1780. }
  1781. }
  1782. if(args.startsWith('42[29,')){
  1783. var jsonargs = JSON.parse(args.substring(2));
  1784. playerids[jsonargs[1]["sid"]].playerData2.balance = jsonargs[1]["bal"];
  1785. if(sandboxon){
  1786. if(typeof(sandboxplayerids[jsonargs[1]["sid"]])!='undefined'){
  1787. var packet = '42[36,'+jsonargs[1]["sid"]+','+jsonargs[1]["bal"]+']';
  1788. RECIEVE(packet);
  1789. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  1790. }
  1791. }
  1792. }
  1793. if(args.startsWith('42[12,')){
  1794. playerids = {};
  1795. var jsonargs2 = JSON.parse(args.substring(2));
  1796. var jsonargs = jsonargs2[1];
  1797. playerids["0"] = {"peerID":jsonargs["peerID"],"userName":username,"level":Gdocument.getElementById("pretty_top_level").textContent == "Guest" ? 0 : parseInt(Gdocument.getElementById("pretty_top_level").textContent.substring(3)),"guest":typeof(jsonargs.token)=="undefined","team":1,"avatar":jsonargs["avatar"],"movecount":0,"commands":true,"ratelimit":{"pm":0,"mode":0,"team":0,"poll":0,"join":Date.now()},"vote":{"poll":-1}};
  1798. myid = 0;
  1799. bonkwss = this;
  1800. hostid = 0;
  1801. }
  1802. if(args.startsWith('42[23,') && recteams){
  1803. var jsonargs = JSON.parse(args.substring(2));
  1804. var map = decodeFromDatabase(jsonargs[1]["m"]);
  1805. var spawns = map["spawns"];
  1806. var teamsneeded = true;
  1807. var excludedindexes = [];
  1808. var ffaspawns = false;
  1809. var ffaforsure = false;
  1810. for(var i = 0; i<spawns.length;i++){
  1811. var currentSpawn = spawns[i];
  1812. if(Math.sqrt(currentSpawn.x**2 + currentSpawn.y**2)>=850 || currentSpawn.y>250){
  1813. excludedindexes.push(i);
  1814. }
  1815. else if(!(currentSpawn.f || currentSpawn.r || currentSpawn.b || currentSpawn.gr || currentSpawn.ye)){
  1816. excludedindexes.push(i);
  1817. }
  1818. else if(currentSpawn.f){
  1819. ffaspawns = true;
  1820. if(!(currentSpawn.r || currentSpawn.b || currentSpawn.gr || currentSpawn.ye)){
  1821. excludedindexes.push(i);
  1822. ffaforsure = true
  1823. }
  1824. }
  1825. }
  1826. if(!ffaspawns && !ffaforsure){
  1827. teamsneeded = true;
  1828. }
  1829. else{
  1830. teamsneeded = false;
  1831. }
  1832. if(teamsneeded){
  1833. var newspawns = [];
  1834. for(var i = 0; i<spawns.length;i++){
  1835. if(!excludedindexes.includes(i)){
  1836. newspawns.push({"r":spawns[i]["r"],"g":spawns[i]["gr"],"b":spawns[i]["b"],"y":spawns[i]["ye"],"total":spawns[i]["r"]+spawns[i]["ye"]+spawns[i]["gr"]+spawns[i]["b"],"priority":spawns[i]["priority"]});
  1837. }
  1838. }
  1839. if(newspawns.length>0){
  1840. var teamletters = ["r","g","b","y"];
  1841. var ratios = {"r":0,"g":0,"b":0,"y":0};
  1842. for(var i = 0; i < newspawns.length;i++){
  1843. for(var i2 = 0; i2<teamletters.length;i2++){
  1844. var ct = teamletters[i2];
  1845. if(newspawns[i]["priority"]!=0){
  1846. ratios[ct]+=(newspawns[i][ct])/newspawns[i]["total"]*newspawns[i]["priority"];
  1847. }
  1848. }
  1849. }
  1850. var highest = ["",0];
  1851. for(var i = 0; i<teamletters.length;i++){
  1852. var ct = teamletters[i];
  1853. if(ratios[ct]>0 && highest[1]<ratios[ct]){
  1854. highest = [ct,ratios[ct]];
  1855. }
  1856. }
  1857. if(highest[0]!=""){
  1858. for(var i = 0; i<teamletters.length;i++){
  1859. var ct = teamletters[i];
  1860. ratios[ct] = ratios[ct]/highest[1];
  1861. }
  1862. }
  1863. var playerids3 = Object.keys(playerids);
  1864. var playerids2 = [];
  1865. for(var i = 0; i<playerids3.length;i++){
  1866. if(playerids[playerids3[i]].team>0){
  1867. playerids2.push(playerids3[i]);
  1868. }
  1869. }
  1870. var pi2l = playerids2.length;
  1871. var ratios2 = {"r":0,"r1":0,"g":0,"g1":0,"b":0,"b1":0,"y":0,"y1":0};
  1872. var items = Object.entries(ratios);
  1873. items.sort(function(a,b){return a[1]-b[1];});
  1874. var items = items.map(function(e){return e[0];});
  1875. var highest2 = ["",0];
  1876. while(pi2l>0){
  1877. var done = false;
  1878. for(var i2 = 0; i2<items.length;i2++){
  1879. var ci = items[i2];
  1880. var ci2 = items[i2]+"1";
  1881. for(var i = 0; i<teamletters.length;i++){
  1882. var ct = teamletters[i];
  1883. if(ratios2[ct]>0 && highest2[1]<ratios2[ct]){
  1884. highest2 = [ct,ratios2[ct]];
  1885. }
  1886. }
  1887. if(highest2[0]!=""){
  1888. for(var i = 0; i<teamletters.length;i++){
  1889. var ct = teamletters[i];
  1890. ratios2[ct+"1"] = ratios2[ct]/highest2[1];
  1891. }
  1892. }
  1893. if(ratios[ci]>0 && ratios[ci]>=ratios2[ci2] && pi2l>0){
  1894. ratios2[ci]+=1;
  1895. pi2l--;
  1896. done = true;
  1897. }
  1898. }
  1899. if(pi2l>0 && !done){
  1900. ratios2[highest2[0]]+=1;
  1901. pi2l--;
  1902. }
  1903. }
  1904. SEND('42[32,{"t":true}]');
  1905. RECIEVE('42[39,true]');
  1906. for(var i = 0; i<ratios2["r"];i++){
  1907. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  1908. SEND('42[26,{"targetID":'+pid+',"targetTeam":2}]');
  1909. if(playerids[keys[i]].peerID!="sandbox"){
  1910. RECIEVE('42[18,'+pid+',2]');
  1911. }
  1912. }
  1913. for(var i = 0; i<ratios2["g"];i++){
  1914. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  1915. SEND('42[26,{"targetID":'+pid+',"targetTeam":4}]');
  1916. if(playerids[keys[i]].peerID!="sandbox"){
  1917. RECIEVE('42[18,'+pid+',4]');
  1918. }
  1919. }
  1920. for(var i = 0; i<ratios2["b"];i++){
  1921. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  1922. SEND('42[26,{"targetID":'+pid+',"targetTeam":3}]');
  1923. if(playerids[keys[i]].peerID!="sandbox"){
  1924. RECIEVE('42[18,'+pid+',3]');
  1925. }
  1926. }
  1927. for(var i = 0; i<ratios2["y"];i++){
  1928. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  1929. SEND('42[26,{"targetID":'+pid+',"targetTeam":5}]');
  1930. if(playerids[keys[i]].peerID!="sandbox"){
  1931. RECIEVE('42[18,'+pid+',5]');
  1932. }
  1933. }
  1934. }
  1935. }
  1936. else{
  1937. SEND('42[32,{"t":false}]');
  1938. RECIEVE('42[39,false]');
  1939. }
  1940. }
  1941.  
  1942. if(args.startsWith('42[47,') && stopquickplay == 0 && ishost && document.hidden && !qppaused){
  1943. roundsperqp2++;
  1944. if(roundsperqp2>=roundsperqp){
  1945. if(shuffle){
  1946. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1947. var available = [];
  1948. var availableindexes = [];
  1949. var notempty = false;
  1950. for(var i = 0; i<e2.length;i++){
  1951. var a = false;
  1952. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1953. available.push(a);
  1954. if(a){
  1955. availableindexes.push(i);
  1956. notempty = true;
  1957. }
  1958. }
  1959. if(notempty){
  1960.  
  1961. if(availableindexes.length!=1){
  1962. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  1963. }
  1964. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  1965. }
  1966. }
  1967. else{
  1968. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  1969. var available = [];
  1970. var availableindexes = [];
  1971. var notempty = false;
  1972. for(var i = 0; i<e2.length;i++){
  1973. var a = false;
  1974. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  1975. available.push(a);
  1976. if(a){
  1977. availableindexes.push(i);
  1978. notempty = true;
  1979. }
  1980. }
  1981. if(notempty){
  1982. var above = [];
  1983. for(var i = 0;i<availableindexes.length;i++){
  1984. if(availableindexes[i]>quicki && !reverseqp){
  1985. above.push(availableindexes[i]);
  1986. }
  1987. else if(availableindexes[i]<quicki && reverseqp){
  1988. above.push(availableindexes[i])
  1989. }
  1990. }
  1991. if(above.length>0){
  1992. quicki = above[0];
  1993. if(reverseqp){
  1994. quicki = above[above.length-1];
  1995. }
  1996. }
  1997. else{
  1998. quicki = availableindexes[0];
  1999. if(reverseqp){
  2000. quicki = availableindexes[availableindexes.length-1];
  2001. }
  2002. }
  2003. }
  2004. }
  2005. }
  2006. canceled = false;
  2007. startedinqp = true;
  2008. window.map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length),0);
  2009. }
  2010. if(args.startsWith('42[32,')){
  2011. var jsonargs = JSON.parse(args.substring(2));
  2012. var keys = Object.keys(playerids);
  2013. if(!jsonargs[1]["t"]){
  2014. FFA = true;
  2015. for(var i = 0;i<keys.length;i++){
  2016. if(playerids[keys[i]].team!=0){
  2017. playerids[keys[i]].team = 1;
  2018. }
  2019. }
  2020. }
  2021. else{
  2022. FFA = false;
  2023. }
  2024. }
  2025. if(args.startsWith('42[5,')){
  2026. var jsonargs = JSON.parse(args.substring(2));
  2027. if(stopquickplay!=1 && startedinqp){
  2028. startedinqp = false;
  2029. jsonargs[1]["gs"]["wl"] = 999;
  2030. if(!instaqp){
  2031. var jsonargs2 = decodeIS(jsonargs[1]["is"]);
  2032. jsonargs2["ftu"] = 60;
  2033. if(jsonargs2["mm"]["rxa"] != ""){
  2034. jsonargs2["mm"]["a"] = jsonargs2["mm"]["rxa"];
  2035. jsonargs2["mm"]["n"] = jsonargs2["mm"]["rxn"];
  2036. }
  2037. jsonargs2 = encodeIS(jsonargs2);
  2038. jsonargs[1]["is"] = jsonargs2;
  2039. var jsonargs3 = decodeFromDatabase(jsonargs[1]["gs"]["map"]);
  2040. if(jsonargs3["m"]["rxa"] != ""){
  2041. jsonargs3["m"]["a"] = jsonargs3["m"]["rxa"];
  2042. jsonargs3["m"]["n"] = jsonargs3["m"]["rxn"];
  2043. }
  2044.  
  2045. jsonargs3 = encodeToDatabase(jsonargs3);
  2046. jsonargs[1]["gs"]["map"] = jsonargs3;
  2047. }
  2048. }
  2049.  
  2050. args = "42"+JSON.stringify(jsonargs);
  2051. }
  2052. }
  2053.  
  2054. }
  2055. else{
  2056. if(args.includes("rport")){
  2057. return;
  2058. }
  2059. }
  2060. if(this.url.includes(".bonk.io/socket.io/?EIO=3&transport=websocket&sid=") && !this.injected){
  2061. this.injected = true;
  2062.  
  2063. var originalRecieve = this.onmessage;
  2064. this.onmessage = function(args){
  2065. if(!bonkwssextra.includes(this)){
  2066. wssrecievelog.push(args.data);
  2067. wsssendrecievelog.push([1,args.data]);
  2068. if(typeof(args.data)=="string"){
  2069. args = {"data":RECIEVEFUNCTION(args.data)};
  2070. if(args.data.startsWith('42[1,')){
  2071. var jsonargs = JSON.parse(args.data.substring(2));
  2072. originalSend.call(this,'42[1,{"id":'+jsonargs[2]+'}]');
  2073. }
  2074. if(args.data.startsWith('42[36,')){
  2075. var jsonargs = JSON.parse(args.data.substring(2));
  2076. playerids[jsonargs[1]].playerData2.balance = jsonargs[2];
  2077. }
  2078. if(args.data.startsWith('42[24,')){
  2079. beenKickedTimeStamp = Date.now();
  2080. onlykicked = JSON.parse(args.data.substring(2))[2];
  2081. }
  2082. if(args.data.startsWith('42[21,')){
  2083. recievedinitdata = true;
  2084. }
  2085. if(args.data.startsWith('42[48,')){
  2086. recievedinitdata = true;
  2087. }
  2088. if(args.data.startsWith('42[16,')){
  2089. var jsonargs = JSON.parse(args.data.substring(2));
  2090. var now = Date.now();
  2091. if(jsonargs[1]=="chat_rate_limit"){
  2092. if(pollactive[1]+100>now){
  2093. pollactive = [false,0,0,[]];
  2094. displayInChat("Your poll failed due to chat rate limit.","#DA0808","#1EBCC1");
  2095. displayInChat("Please try again.","#DA0808","#1EBCC1");
  2096. }
  2097. }
  2098. }
  2099. if(args.data.startsWith('42[6,')){
  2100. var jsonargs = JSON.parse(args.data.substring(2));
  2101. if(typeof(playerids[jsonargs[1]])!='undefined'){
  2102. delplayerids[jsonargs[1]] = playerids[jsonargs[1]];
  2103. delete playerids[jsonargs[1]];
  2104. }
  2105. hostid = jsonargs[2];
  2106. }
  2107. if(args.data.startsWith('42[39,')){
  2108. var jsonargs = JSON.parse(args.data.substring(2));
  2109. var keys = Object.keys(playerids);
  2110. if(!jsonargs[1]){
  2111. FFA = true;
  2112. for(var i = 0;i<keys.length;i++){
  2113. if(playerids[keys[i]].team!=0){
  2114. playerids[keys[i]].team = 1;
  2115. }
  2116. }
  2117. }
  2118. else{
  2119. FFA = false;
  2120. }
  2121. }
  2122. if(args.data.startsWith('42[41,')){
  2123. var jsonargs = JSON.parse(args.data.substring(2));
  2124. hostid = jsonargs[1]["newHost"];
  2125. }
  2126. if(args.data.startsWith('42[20,')){
  2127. var jsonargs = JSON.parse(args.data.substring(2));
  2128. if(echo_list.includes(playerids[jsonargs[1]].userName)){
  2129. chat(flag_manage(echotext.replaceAll("username",playerids[jsonargs[1]].userName).replaceAll("message",jsonargs[2])));
  2130. }
  2131. if(pollactive[0] || pollactive2[0]){
  2132. var chatmessage = jsonargs[2].toUpperCase().trim().replace(")","");
  2133. var lettersindex = letters.indexOf(chatmessage);
  2134. if(ishost){
  2135. if(pollactive[3].length>0 && lettersindex!=-1 && lettersindex<pollactive[3].length){
  2136. playerids[jsonargs[1]].vote.poll = lettersindex;
  2137. }
  2138. }
  2139. else{
  2140. if(pollactive2[2].length>0 && lettersindex!=-1 && lettersindex<pollactive2[2].length){
  2141. playerids[jsonargs[1]].vote.poll = lettersindex;
  2142. }
  2143. }
  2144. }
  2145. }
  2146. if(args.data.startsWith('42[32')){
  2147. SEND('42[4,{"type":"inactive kick counter"}]');
  2148. }
  2149. if(args.data.startsWith('42[18')){
  2150. var jsonargs = JSON.parse(args.data.substring(2));
  2151. playerids[jsonargs[1]].team = jsonargs[2];
  2152. }
  2153. if(args.data.startsWith('42[40,')){
  2154. recordedTimeStamp = Date.now();
  2155. recordedId = JSON.parse(args.data.substring(2))[1];
  2156. }
  2157. if(args.data.startsWith('42[3,')){
  2158. playerids = {};
  2159. var jsonargs = JSON.parse(args.data.substring(2));
  2160. for(var i = 0; i<jsonargs[3].length;i++){
  2161. if(jsonargs[3][i]!=null){
  2162. playerids[i.toString()] = jsonargs[3][i];
  2163. playerids[i.toString()].commands = false;
  2164. playerids[i.toString()].ratelimit = {"pm":0,"mode":0,"team":0,"poll":0,"join":Date.now()};
  2165. playerids[i.toString()].vote = {"poll":-1};
  2166. }
  2167. }
  2168. if(playerids[jsonargs[1]].userName.startsWith(Gdocument.getElementById("pretty_top_name").textContent)){
  2169. myid = jsonargs[1];
  2170. bonkwss = this;
  2171. }
  2172. else{
  2173. bonkwssextra.push(this);
  2174. }
  2175. hostid = jsonargs[2];
  2176. SEND('42[4,{"type":"commands"}]');
  2177. setTimeout(function(){if(!sandboxon && !recievedinitdata && myid!=0){RECIEVE('42[21,{"map":{"v":13,"s":{"re":false,"nc":false,"pq":1,"gd":25,"fl":false},"physics":{"shapes":[],"fixtures":[],"bodies":[],"bro":[],"joints":[],"ppm":12},"spawns":[],"capZones":[],"m":{"a":"","n":"","dbv":0,"dbid":0,"authid":-1,"date":"","rxid":0,"rxn":"","rxa":"","rxdb":0,"cr":[],"pub":false,"mo":"","vu":0,"vd":0}},"gt":2,"wl":3,"q":false,"tl":false,"tea":false,"ga":"b","mo":"b","bal":[]}]');displayInChat("You have joined a ghost room.","#DA0808","#1EBCC1");}},6000);
  2178.  
  2179. }
  2180. if(args.data.startsWith('42[21,')){
  2181. var jsonargs = JSON.parse(args.data.substring(2));
  2182. mode = jsonargs[1]["mo"];
  2183. FFA = !jsonargs[1]["tea"];
  2184. }
  2185. if(args.data.startsWith('42[48,')){
  2186. var jsonargs = JSON.parse(args.data.substring(2));
  2187. mode = jsonargs[1]["gs"]["mo"];
  2188. FFA = !jsonargs[1]["gs"]["tea"];
  2189. }
  2190. if(args.data.startsWith('42[15,')){
  2191. var jsonargs = JSON.parse(args.data.substring(2));
  2192. dontswitch = false;
  2193. mode = jsonargs[3]["mo"];
  2194. gameStartTimeStamp = Date.now();
  2195. killedids = [];
  2196. Gdocument.getElementById("newbonklobby").style["z-index"] = "unset";
  2197. Gdocument.getElementById("mapeditorcontainer").style["z-index"] = "unset";
  2198. }
  2199. if(args.data.startsWith('42[33,')){
  2200. var jsonargs = JSON.parse(args.data.substring(2));
  2201. var decodedmap = decodeFromDatabase(jsonargs[1]);
  2202. if(decodedmap!=0){
  2203. requestedmaps = [decodedmap,jsonargs[1]].concat(requestedmaps);
  2204. }
  2205. }
  2206. if(args.data.startsWith('42[7,')){
  2207. var jsonargs2 = JSON.parse(args.data.substring(2));
  2208. var idofpacket = jsonargs2[1];
  2209. jsonargs = jsonargs2[2];
  2210. if(typeof(jsonargs["i"]) == "undefined"){
  2211. if(jsonargs["type"]=="private chat" && jsonargs["to"] == username){
  2212. from = jsonargs["from"];
  2213. if(Object.keys(playerids).includes(idofpacket.toString())){
  2214. from = playerids[idofpacket].userName;
  2215. }
  2216. if(!ignorepmlist.includes(from)){
  2217. if(typeof(jsonargs["message"])=="object" && typeof(jsonargs["password"]) == "object"){
  2218. if(public_key[0]==jsonargs["public key"][0] && public_key[1]==jsonargs["public key"][1]){
  2219. var now = Date.now();
  2220. if(jsonargs["password"].length<=25 && playerids[idofpacket].ratelimit.pm+250<now){
  2221. playerids[idofpacket].ratelimit.pm = now;
  2222. var password = CRYPT_MESSAGE(private_key,jsonargs["password"]);
  2223. var decodedtext = jsonargs["message"].slice(0,400);
  2224. var encodedtext = "";
  2225. for(var i=0;i<decodedtext.length;i++){
  2226. if(password[i%password.length]<1000){
  2227. encodedtext+=String.fromCharCode(password[i%password.length]^decodedtext[i]);
  2228. }
  2229. }
  2230. var code = 'Gwindow.private_chat = "'+from+'"; Gwindow.SEND("42"+JSON.stringify([4,{"type":"request public key","from":Gwindow.username,"to":Gwindow.private_chat}])); Gwindow.request_public_key_time_stamp = Date.now(); setTimeout(function(){if(Gwindow.private_chat_public_key[0]!=Gwindow.private_chat){Gwindow.displayInChat("Failed to connect to "+Gwindow.private_chat+".","#DA0808","#1EBCC1");Gwindow.private_chat = Gwindow.private_chat_public_key[0];}},1600);';
  2231. displayInChat('> '+'<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+from+'</a>'+': ',"#DA0808","#1EBCC1",{sanitize:false},encodedtext);
  2232.  
  2233. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  2234. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  2235. Laster_message = lastmessage();
  2236. }
  2237. }
  2238. else{
  2239. SEND("42"+JSON.stringify([4,{"type":"public key correction","from":username,"to":private_chat_public_key[0],"public key":public_key}]));
  2240. }
  2241. }
  2242. }
  2243. }
  2244. if(jsonargs["type"]=="request public key" && jsonargs["to"] == username){
  2245. SEND("42"+JSON.stringify([4,{"type":"public key","from":username,"public key":public_key}]));
  2246. }
  2247. if(jsonargs["type"]=="private chat users" && pmuserstimestamp+1500>Date.now()){
  2248. if(typeof(jsonargs["from"])!='undefined'){
  2249. from = jsonargs["from"];
  2250. if(Object.keys(playerids).includes(idofpacket.toString())){
  2251. from = playerids[idofpacket].userName;
  2252. }
  2253. if(!pmusers.includes(from) && username == jsonargs["to"]){
  2254. pmusers.push(from);
  2255. }
  2256. }
  2257. }
  2258. if(jsonargs["type"]=="request private chat users"){
  2259. if(typeof(jsonargs["from"])!='undefined'){
  2260. from = jsonargs["from"];
  2261. if(Object.keys(playerids).includes(idofpacket.toString())){
  2262. from = playerids[idofpacket].userName;
  2263. }
  2264. SEND("42"+JSON.stringify([4,{"type":"private chat users","from":username,"to":from}]));
  2265. }
  2266. }
  2267. if(jsonargs["type"]=="public key" && request_public_key_time_stamp+1500>Date.now()){
  2268. from = jsonargs["from"];
  2269. if(Object.keys(playerids).includes(idofpacket.toString())){
  2270. from = playerids[idofpacket].userName;
  2271. }
  2272. if(from == private_chat){
  2273. private_chat_public_key = [private_chat,jsonargs["public key"]];
  2274. displayInChat("Private chatting with "+private_chat+".","#DA0808","#1EBCC1");
  2275. }
  2276. }
  2277. if(jsonargs["type"]=="fakerecieve" && hostid == idofpacket && sandboxon && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2278. for(var i = 0;i<jsonargs["packet"].length;i++){
  2279. if(!jsonargs["packet"][i].startsWith("42[20,")){
  2280. RECIEVE(jsonargs["packet"][i]);
  2281. }
  2282. }
  2283. }
  2284. if(jsonargs["type"]=="customfakerecieve" && hostid == idofpacket && sandboxon && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2285. for(var i2 = 0;i2<jsonargs["packet"].length;i2++){
  2286. var keys = Object.keys(sandboxplayerids);
  2287. for(var i = 0;i<keys.length;i++){
  2288. if(jsonargs["packet"][i2].startsWith("42[7,")){
  2289. originalRecieve.call(this,{data:jsonargs["packet"][i2].replace("ID",keys[i].toString()).replace("CVALUE",playerids[keys[i]].movecount.toString())});
  2290. playerids[keys[i]].movecount+=1;
  2291. }
  2292. }
  2293. }
  2294. }
  2295. if(jsonargs["type"]=="commands"){
  2296. playerids[idofpacket].commands = true;
  2297. }
  2298. if(jsonargs["type"]=="sandboxid" && hostid == idofpacket && sandboxon && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2299. sandboxid = jsonargs["lastid"];
  2300. }
  2301. if(jsonargs["type"]=="sandboxon" && idofpacket == hostid){
  2302. if(!sandboxon){
  2303. displayInChat("This is a sandbox lobby.","#DA0808","#1EBCC1");
  2304. sandboxon = true;
  2305. }
  2306. }
  2307. if(jsonargs["type"]=="vote poll"){
  2308. from = jsonargs["from"];
  2309. if(Object.keys(playerids).includes(idofpacket.toString())){
  2310. from = playerids[idofpacket].userName;
  2311. }
  2312. if(typeof(jsonargs["vote"]) == 'number' && idofpacket!=hostid){
  2313. var now = Date.now();
  2314. if(ishost && pollactive[3].length>1 && pollactive[0]){
  2315. if(jsonargs["vote"]>=0 && jsonargs["vote"]<pollactive[3].length){
  2316. playerids[idofpacket].vote.poll = jsonargs["vote"];
  2317. }
  2318. }
  2319. else if(pollactive2[0] && pollactive2[2].length>1){
  2320. if(jsonargs["vote"]>=0 && jsonargs["vote"]<pollactive2[2].length){
  2321. playerids[idofpacket].vote.poll = jsonargs["vote"];
  2322. }
  2323. }
  2324. }
  2325.  
  2326. }
  2327. if(jsonargs["type"]=="poll end"){
  2328. from = jsonargs["from"];
  2329. if(Object.keys(playerids).includes(idofpacket.toString())){
  2330. from = playerids[idofpacket].userName;
  2331. }
  2332. var now = Date.now();
  2333. if(hostid == idofpacket && playerids[idofpacket].ratelimit.poll+5000<now){
  2334. playerids[idofpacket].ratelimit.poll = now;
  2335. var count = [0,0,0,0];
  2336. var keys = Object.keys(playerids);
  2337. for(var i = 0;i<keys.length;i++){
  2338. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive2[2].length-1){
  2339. count[playerids[keys[i]].vote.poll]++;
  2340. }
  2341. playerids[keys[i]].vote.poll = -1;
  2342. }
  2343. displayInChat("The poll ended.","#DA0808","#1EBCC1");
  2344. for(var i = 0;i<count.length;i++){
  2345. if(count[i]>1){
  2346. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  2347. }
  2348. if(count[i]==1){
  2349. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  2350. }
  2351. }
  2352. pollactive2 = [false,0,[]];
  2353. }
  2354.  
  2355. }
  2356. if(jsonargs["type"]=="poll" && idofpacket == hostid){
  2357. from = jsonargs["from"];
  2358. if(Object.keys(playerids).includes(idofpacket.toString())){
  2359. from = playerids[idofpacket].userName;
  2360. }
  2361. if(Array.isArray(jsonargs["poll"])){
  2362. var propperpoll = true;
  2363. var pollifproper = [];
  2364. if(jsonargs["poll"].length>5){
  2365. propperpoll = false;
  2366. }
  2367. else{
  2368. for(var i = 0;i<jsonargs["poll"].length;i++){
  2369. if(typeof(jsonargs["poll"][i]) == 'string'){
  2370. if(jsonargs["poll"][i].length>50){
  2371. propperpoll = false;
  2372. break;
  2373. }
  2374. else{
  2375. pollifproper.push(jsonargs["poll"][i]);
  2376. }
  2377. }
  2378. else{
  2379. propperpoll = false;
  2380. break;
  2381. }
  2382. }
  2383. }
  2384. if(propperpoll){
  2385. var now = Date.now();
  2386. var keys = Object.keys(playerids);
  2387. for(var i = 0;i<keys.length;i++){
  2388. playerids[keys[i]].vote.poll = -1;
  2389. }
  2390. pollactive2 = [true,now,pollifproper];
  2391. playerids[idofpacket].ratelimit.poll = now;
  2392. displayInChat(from+" started a poll:","#DA0808","#1EBCC1");
  2393. for(var i = 0;i<pollifproper.length;i++){
  2394. var code = 'Gwindow.displayInChat("You voted for option '+letters[i]+'.","#DA0808","#1EBCC1",{sanitize:false},"",true);Gwindow.SEND("42"+JSON.stringify([4,{"type":"vote poll","from":Gwindow.username,"vote":'+i+'}]));Gwindow.playerids[Gwindow.myid].vote.poll='+i+';Gwindow.Gdocument.getElementById("newbonklobby_chat_content").children[Gwindow.Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;Gwindow.Gdocument.getElementById("ingamechatcontent").children[Gwindow.Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;Gwindow.Laster_message = Gwindow.lastmessage();';
  2395. displayInChat('<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+letters[i]+')</a>',"#DA0808","#1EBCC1",{sanitize:false}," "+pollifproper[i]);
  2396. }
  2397. }
  2398. }
  2399. }
  2400. if(jsonargs["type"]=="request mode" && playerids[idofpacket].ratelimit.mode+1000<Date.now()){
  2401. playerids[idofpacket].ratelimit.mode = Date.now();
  2402. from = jsonargs["from"];
  2403. if(Object.keys(playerids).includes(idofpacket.toString())){
  2404. from = playerids[idofpacket].userName;
  2405. }
  2406. var req_mode = jsonargs["mode"];
  2407. var req_mode2 = "";
  2408. if(req_mode){
  2409. if(req_mode == "b"){
  2410. req_mode2 = "Classic";
  2411. }
  2412. else if(req_mode == "sp"){
  2413. req_mode2 = "Grapple";
  2414. }
  2415. else if(req_mode == "ar"){
  2416. req_mode2 = "Arrows";
  2417. }
  2418. else if(req_mode == "ard"){
  2419. req_mode2 = "Death Arrows";
  2420. }
  2421. }
  2422. if(req_mode2){
  2423. var code = 'if(!Gwindow.ishost){Gwindow.displayInChat("You must be host to change the mode.","#DA0808","#1EBCC1",{sanitize:false},"",true)}else{Gwindow.changemode("'+req_mode+'")}';
  2424. displayInChat('> '+playerids[idofpacket].userName+' requests [<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+req_mode2+'</a>]',"#DA0808","#1EBCC1",{sanitize:false}," mode.");
  2425. }
  2426.  
  2427. }
  2428. if(jsonargs["type"]=="public key correction" && private_chat_public_key[0] == private_chat){
  2429. from = jsonargs["from"];
  2430. if(Object.keys(playerids).includes(idofpacket.toString())){
  2431. from = playerids[idofpacket].userName;
  2432. }
  2433. if(from == private_chat){
  2434. private_chat_public_key = [private_chat,jsonargs["public key"]];
  2435. var text = pmlastmessage;
  2436. var password = [];
  2437. for(var i = 0;i<10;i++){
  2438. password.push(Math.floor(Math.random()*100+50));
  2439. }
  2440. var text2 = [];
  2441. for(var i = 0;i<text.length ;i++){
  2442. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  2443. }
  2444. cc
  2445. }
  2446. }
  2447.  
  2448. }
  2449. else{
  2450. var now = Date.now();
  2451. playerids[idofpacket.toString()].movecount+=1;
  2452. if(playerids[idofpacket.toString()]){
  2453. playerids[idofpacket.toString()].lastmove = now;
  2454. }
  2455. if(Math.abs(gameStartTimeStamp - (now-1000*jsonargs["f"]/30))>250){
  2456. gameStartTimeStamp = now-1000*jsonargs["f"]/30;
  2457. }
  2458. if(ishost){
  2459. if(sandboxon && idofpacket == sandboxcopyme){
  2460. var jsonkeys = Object.keys(sandboxplayerids);
  2461. if(!jsonkeys.includes(sandboxcopyme.toString())){
  2462. var jsonargs2 = jsonargs;
  2463. for(var i = 0; i<jsonkeys.length;i++){
  2464. jsonargs2["c"] = playerids[jsonkeys[i]].movecount;
  2465. var packet = '42[7,'+jsonkeys[i].toString()+','+JSON.stringify(jsonargs2)+']';
  2466. RECIEVE(packet);
  2467. }
  2468. jsonargs2["c"] = "CVALUE";
  2469. jsonargs2 = JSON.stringify(jsonargs2).replace('"CVALUE"',"CVALUE");
  2470. SEND("42"+JSON.stringify([4,{"type":"customfakerecieve","from":username,"packet":['42[7,ID,'+jsonargs2+']'],to:[-1]}]));
  2471. }
  2472. }
  2473. for(var i = 0;i<disabledkeys.length;i++){
  2474. var get_keys_var = GET_KEYS(jsonargs["i"]);
  2475. if(get_keys_var[disabledkeys[i]]){
  2476. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(idofpacket)){
  2477. killedids.push(idofpacket);
  2478. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  2479. SEND('42[25,{"a":{"playersLeft":['+idofpacket.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2480. RECIEVE('42[31,{"a":{"playersLeft":['+idofpacket.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2481. break;
  2482. }
  2483. }
  2484. }
  2485. }
  2486. }
  2487. }
  2488.  
  2489. if(args.data.startsWith('42[4,')){
  2490. var jsonargs = JSON.parse(args.data.substring(2));
  2491. playerids[jsonargs[1]] = {"peerID":jsonargs[2],"userName":jsonargs[3],"guest":jsonargs[4],"level":jsonargs[5],"team":jsonargs[6],"avatar":jsonargs[7],"movecount":0,"ratelimit":{"pm":0,"mode":0,"team":0,"poll":0,"join":Date.now()},"vote":{"poll":-1}};
  2492. if(jsonargs[2]!="sandbox"){
  2493. SEND('42[4,{"type":"commands"}]');
  2494. }
  2495. if(sandboxon){
  2496. var sandboxkeys = Object.keys(sandboxplayerids);
  2497. if(sandboxkeys.includes(jsonargs[1].toString())){
  2498. delete sandboxplayerids[jsonargs[1]];
  2499. }
  2500. if(jsonargs[2]=="sandbox"){
  2501. sandboxplayerids[jsonargs[1]] = jsonargs[3];
  2502. if(jsonargs[1]>sandboxid){
  2503. sandboxid = parseInt(jsonargs[1])+1;
  2504. }
  2505. }
  2506. else{
  2507. if(ishost){
  2508. SEND('42[4,{"type":"sandboxon"}]');
  2509. var sandboxkeys = Object.keys(sandboxplayerids);
  2510. var packets = [];
  2511. for(var i = 0;i<sandboxkeys.length;i++){
  2512. var p = playerids[sandboxkeys[i]];
  2513. var packet = '42'+JSON.stringify([4,sandboxkeys[i],p.peerID,p.userName,p.guest,p.level,p.team,p.avatar]);
  2514. packets.push(packet);
  2515. }
  2516. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":packets,to:[jsonargs[1]]}]));
  2517. SEND("42"+JSON.stringify([4,{"type":"sandboxid","from":username,"lastid":sandboxid,to:[jsonargs[1]]}]));
  2518. }
  2519. }
  2520. }
  2521. if(ishost){
  2522. if(jointext!="" && jsonargs[2]!="sandbox"){
  2523. chat(flag_manage(jointext.replaceAll("username",jsonargs[3])));
  2524. }
  2525. if(jointeam!=-1 && jsonargs[2]!="sandbox"){
  2526. SEND('42[26,{"targetID":'+jsonargs[1].toString()+',"targetTeam":'+jointeam.toString()+'}]');
  2527. setTimeout(function(){RECIEVE('42[18,'+jsonargs[1].toString()+','+jointeam.toString()+']');});
  2528. }
  2529. if(freejoin){
  2530. var count = 0;
  2531. var keys = Object.keys(playerids);
  2532. for(var i = 0; i<keys.length;i++){
  2533. if(playerids[keys[i]].team!=0){
  2534. count++;
  2535. }
  2536. }
  2537. if(count <= 2 && jsonargs[6]!=0){
  2538. setTimeout(function(){
  2539. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2540. Gdocument.getElementById("mapeditor_close").click();
  2541. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2542. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  2543. if(transitioning == true){
  2544. canceled = true;
  2545. }
  2546. },150);
  2547. }
  2548. }
  2549. }
  2550.  
  2551. }
  2552. if(args.data.startsWith('42[5,')){
  2553. var jsonargs = JSON.parse(args.data.substring(2));
  2554. if(typeof(playerids[jsonargs[1]])!='undefined'){
  2555. delplayerids[jsonargs[1]] = playerids[jsonargs[1]];
  2556. delete playerids[jsonargs[1]];
  2557. }
  2558. if(sandboxon && typeof(sandboxplayerids[jsonargs[1]])!='undefined'){
  2559. delete sandboxplayerids[jsonargs[1]];
  2560. }
  2561. }
  2562. }}
  2563. return originalRecieve.call(this,args);
  2564. };
  2565.  
  2566. var originalClose = this.onclose;
  2567. this.onclose = function () {
  2568. if(bonkwssextra.includes(this)){
  2569. bonkwssextra.splice(bonkwssextra.indexOf(this),1)
  2570. }
  2571. else{
  2572. window.bonkwss = 0;
  2573. }
  2574. return originalClose.call(this);
  2575. }
  2576.  
  2577. }
  2578. return originalSend.call(this,args);
  2579. };
  2580.  
  2581. scope.SEND = function(args){
  2582. if(bonkwss!=0){
  2583. bonkwss.send(args);
  2584. }
  2585. };
  2586. scope.RECIEVE = function(args){
  2587. if(bonkwss!=0){
  2588. bonkwss.onmessage({data:args});
  2589. }
  2590. };
  2591.  
  2592.  
  2593.  
  2594. scope.dontswitch = false;
  2595. scope.username = 0;
  2596. scope.timedelay = 1400;
  2597. scope.ishost = false;
  2598. scope.checkboxhidden = true;
  2599. scope.quicki=0;
  2600. scope.defaultmode = "d";
  2601. scope.recmodebool = false;
  2602. scope.shuffle = false;
  2603. scope.startedinqp = false;
  2604. scope.instaqp = false;
  2605. scope.freejoin = false;
  2606. scope.recordedTimeStamp = 0;
  2607. scope.recordedId = 0;
  2608. scope.smartteams = false;
  2609. scope.beenKickedTimeStamp = 0;
  2610. scope.stopquickplay = 1;
  2611. scope.currentFrame = 0;
  2612. scope.text2speech = false;
  2613. scope.gameStartTimeStamp = 0;
  2614. scope.canceled = false;
  2615. scope.wintext = "";
  2616. scope.banned = [];
  2617. scope.transitioning = false;
  2618. scope.echo_list = [];
  2619. scope.echoAppend = "";
  2620. scope.message = "";
  2621. scope.private_chat = "";
  2622. scope.private_chat_public_key = ["",[0,0]];
  2623. scope.disabledkeys = [];
  2624. scope.actuallyhost = false;
  2625. scope.pmusers = [];
  2626. scope.pmlastmessage = "";
  2627. scope.pmuserstimestamp = 0;
  2628. scope.ignorepmlist = [];
  2629. scope.scroll = false;
  2630. scope.elem = Gdocument.getElementById("maploadwindowmapscontainer");
  2631. scope.npermissions = 1;
  2632. scope.space_flag = false;
  2633. scope.rcaps_flag = false;
  2634. scope.number_flag = false;
  2635. scope.reverse_flag = false;
  2636. scope.request_public_key_time_stamp = 0;
  2637. scope.sandboxcopyme = -1;
  2638. scope.recteams = false;
  2639. scope.chatheight = 128;
  2640. scope.onlykicked = false;
  2641. scope.killedids = [];
  2642. scope.jointext = "";
  2643. scope.afkkill = -1;
  2644. scope.tournament_mode = "";
  2645. scope.tournament_scores = [];
  2646. scope.tournament_in_and_out = {"in":[],"out":[]};
  2647. scope.echotext = "message";
  2648. scope.nextafter = 0;
  2649. scope.nextafterbuffer = -1;
  2650. scope.roundsperqp = 1;
  2651. scope.roundsperqp2 = 0;
  2652. scope.autorecord = false;
  2653. scope.poll = [];
  2654. scope.letters = ["A","B","C","D","E"];
  2655. scope.qppaused = false;
  2656. scope.FollowCam = false;
  2657. scope.autocam = false;
  2658. scope.gravity = 20;
  2659. scope.multiplier = 3.85;
  2660. scope.aimbot = false;
  2661. scope.recievedinitdata = false;
  2662. scope.heavybot = false;
  2663. scope.zoom = 1;
  2664. scope.prediction = 1000;
  2665. scope.started = 0;
  2666. scope.holdheavy = 0;
  2667. scope.grappleheld = false;
  2668. scope.grappleheld2 = false;
  2669. scope.heavyheld = false;
  2670. scope.reverseqp = false;
  2671. scope.jointeam = -1;
  2672. scope.heavyheld2 = false;
  2673. scope.heavyid = 3;
  2674. scope.specialid = 0;
  2675. scope.keyCodes = {"BACK_SPACE":8,"TAB":9,"SHIFT":16,"ALT":18,"LEFT ARROW":37,"RIGHT ARROW":39,"DOWN ARROW":40,"UP ARROW":38,"CONTROL":17,"SPACE":32};
  2676. scope.leftRight = [37,39];
  2677. scope.heavy = 88;
  2678. scope.special = 90;
  2679. scope.newzoom2 = 1;
  2680. scope.zoom2 = 1;
  2681. scope.autokickban = 0;
  2682. scope.positive = function(angle){
  2683. if(angle<0){
  2684. angle += 2*Math.PI;
  2685. }
  2686. return angle%(Math.PI*2);
  2687. };
  2688. scope.angle_between = function(angle,angle2){
  2689. return Math.min(Math.abs(positive(angle)-positive(angle2)),Math.PI*2-Math.abs(positive(angle)-positive(angle2)));
  2690. };
  2691. scope.angle_between2 = function(angle,angle2){
  2692. if(angle_between(angle,angle2+Math.PI/2)<Math.PI/2){
  2693. return 1;
  2694. }
  2695. return -1;
  2696. };
  2697.  
  2698. scope.help = ["All the commands are:","/help","/?","/advhelp [command]","/space","/rcaps","/number","/speech","/followcam","/autocam","/zoom [in/out/reset]","/xray","/aimbot","/heavybot","/echo [username]","/clearecho","/remove [username]","/echotext [text]","/chatw [username]","/msg [text]","/ignorepm [username]","/pmusers","/pollstat","/lobby","/score","/team [letter]","/mode [mode]","/scroll","/hidechat","/showchat","/notify","/stopnotify","/support","Host commands are:","/startqp","/stopqp","/pauseqp","/revqp","/next","/nextafter [seconds]","/previous","/shuffle","/instaqp","/freejoin","/recmode","/recteam","/defaultmode [mode]","/start","/balanceA [number]","/moveA [letter]","/moveT [letter] [letter]","/rounds [number]","/roundsperqp [number]","/disablekeys [keys]","/jointext [text]","/jointeam [letter]","/wintext [text]","/autorecord","/afkkill [number]","/ban [username]","/kill [username]","/resetpoll","/addoption [text]","/deloption [letter]","/startpoll [seconds]","/endpoll","/autokick","/autoban","/sandbox","Sandbox commands are:","/addplayer [number]","/addname [text]","/delplayer [number]","/copy [username]","Debugging commands are:","/eval [code]","/debugger","Hotkeys are:","Alt L","Alt B","Alt C","Alt I","Alt <","Alt >","Alt N","Alt V","Alt G","Alt H","Alt J","Host hotkeys are:","Alt S","Alt P","Alt T","Alt E","Alt K","Alt M","Alt Q","Alt A","Alt D","Alt F","Alt R"];
  2699.  
  2700. scope.adv_help = {"help":"Shows all command names.",
  2701. "?":"Shows all command names.",
  2702. "advhelp":"Shows a command in detail.",
  2703. "space":"Toggles space. When space is on, whatever you type will be spaced apart.",
  2704. "rcaps":"Toggles rcaps. When rcaps is on, each letter will randomly get capitalized.",
  2705. "number":"Toggles number. When number is on, 'a' becomes 4, 'e' becomes 3, 's' becomes 5, 'o' becomes 0, 'l' and 'i' become 1.",
  2706. "speech":"Turns on text to speech for the chat.",
  2707. "echo":"Echoes a username. It copies the username's chat messages.",
  2708. "echotext":"Sets a message when someone who is echoed chats. \"message\" will get replaced by the person's message. \"username\" will get replaced by the person's username.",
  2709. "remove":"Removes username from echo list. You will not echo that username anymore.",
  2710. "clearecho":"Clears echo list. You will not echo anyone anymore.",
  2711. "chatw":"It private chats with username. Type /msg to message that username.",
  2712. "msg":"Messages with what username you are chatting with. Type /chatw to chat with a username.",
  2713. "ignorepm":"Ignores the username's private chat messages. To unignore, type '/ignorepm [username]'.",
  2714. "pmusers":"Dispays who you can private chat with.",
  2715. "pollstat":"Displays the current poll and its votes.",
  2716. "eval":"Evaluates code. Only use this if you are experienced in javascript.",
  2717. "debugger":"Opens debugger.",
  2718. "lobby":"Makes lobby visible when you are ingame. Type '/lobby' again to close lobby.",
  2719. "score":"Displays the current score while ingame. Type '/score' again to hide the score.",
  2720. "team":"Joins a specific team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  2721. "scroll":"Toggles a scrollbar in ingame chat.",
  2722. "followcam":"Enables follow camera. Your character will be centered on the screen.",
  2723. "autocam":"Zooms in/out enough for you to see everyone on the screen.",
  2724. "zoom":"Zooms in, out, or resets zoom.",
  2725. "xray":"Removes all shapes that don't have a shadow. This means all non-physics shapes will be hidden.",
  2726. "aimbot":"Toggles aimbot. Aimbot will aim for you in arrows or death arrows mode.",
  2727. "heavybot":"Enables heavy bot. Heavy bot will heavy right before collision. Turn this off when player collision is off, because heavy bot will still function.",
  2728. "hidechat":"Hides ingame chat. Type '/showchat' to show it again.",
  2729. "showchat":"Shows ingame chat. '/hidechat' hides the chat.",
  2730. "notify":"You will be notified if a person types @username",
  2731. "stopnotify":"You will not be notified if a person types @username",
  2732. "support":"Displays many ways to support LEGENDBOSS123.",
  2733. "startqp":"Starts cycling maps in your map menu.",
  2734. "stopqp":"Stops cycling maps in your map menu.",
  2735. "revqp":"Reverses the order of quickplay. '/next', '/previous' will be inverted.",
  2736. "pauseqp":"Only pauses or unpauses the quickplay cycle due to round end. '/next', '/previous' still work. Type 'pauseqp' to unpause quickplay.",
  2737. "next":"Skips the map. Usable only with '/startqp'.",
  2738. "nextafter":"Skips the map if no one is able to win/draw within a certain amount of time.",
  2739. "previous":"Goes to previous map. Usable only with '/startqp'.",
  2740. "shuffle":"Makes quickplay play random maps instead of in order.",
  2741. "freejoin":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  2742. "recmode":"In quickplay, it switches mode to recommended mode, according to editor.",
  2743. "recteam":"In quickplay, it sorts people into teams when teams are necessary.",
  2744. "defaultmode":"Switches mode to defaultmode if there is no recmode.",
  2745. "start":"Starts game instantly.",
  2746. "instaqp":"Rounds will instantly start without a countdown.",
  2747. "balanceA":"Balances everyone with balance number.",
  2748. "moveA":"Sets everyones team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  2749. "jointeam":"Sets the team of anyone who joins. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  2750. "moveT":"Sets everyone in one team to another team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  2751. "rounds":"Sets rounds to win.",
  2752. "roundsperqp":"After that many rounds, the map will change. Normally, the map will change after 1 round.",
  2753. "autorecord":"After a round ends, automatically records the last 15 seconds.",
  2754. "mode":"If host, switches mode. Otherwise, it requests the host to switch mode, as long as the host has this mod.",
  2755. "disablekeys":"If anyone presses a disabled key, they get killed. Key options: left right up down heavy special.",
  2756. "jointext":"Chats the jointext whenever someone joins. \"username\" will get replaced by the joining person's username.",
  2757. "wintext":"Chats the wintext whenever someone wins. \"username\" will get replaced by the winning person's username.",
  2758. "afkkill":"If a person stays afk for that many seconds, they get automatically killed.",
  2759. "ban":"Bans username from lobby. If they rejoin, it automatically bans.",
  2760. "kill":"Kills the person ingame.",
  2761. "resetpoll":"Clears the poll.",
  2762. "addoption":"Adds the option to the poll. You can only have 4 maximum options. Type '/deloption [letter]' to remove an option.",
  2763. "deloption":"Removes the option with that letter.",
  2764. "startpoll":"Starts a poll that lasts for at least 10 seconds. Type '/endpoll' to end it early.",
  2765. "endpoll":"Ends the poll early if the poll lasted for at least 10 seconds.",
  2766. "addplayer":"In sandbox, it adds bots.",
  2767. "addname":"Adds a bot with a specific name. If that name already exists, it will copy the skin of that player to the bot.",
  2768. "delplayer":"In sandbox, it deletes bots.",
  2769. "copy":"In sandbox, it makes all bots copy the username's movements.",
  2770. "sandbox":"Turns a normal lobby into a sandbox lobby. You cannot turn a sandbox lobby back into a normal lobby.",
  2771. "autokick":"Automatically kicks everyone who is not using this mod.",
  2772. "autoban":"Automatically bans everyone who is not using this mod.",
  2773. "Alt L":"Makes lobby visible when you are ingame. Press Alt L again to close lobby.",
  2774. "Alt C":"Hides ingame chat. Press Alt C again to show ingame chat.",
  2775. "Alt S":"Starts game instantly.",
  2776. "Alt T":"Toggles teams.",
  2777. "Alt N":"Enables follow camera. Your character will be centered on the screen.",
  2778. "Alt G":"Zooms in.",
  2779. "Alt H":"Resets zoom.",
  2780. "Alt J":"Zooms out.",
  2781. "Alt Y":"Enables xray. Removes all shapes that don't have a shadow. This means all non-physics shapes will be hidden.",
  2782. "Alt E":"Toggles editor.",
  2783. "Alt K":"Exits ingame and returns to lobby.",
  2784. "Alt M":"Switches modes.",
  2785. "Alt V":"Toggles autocam. Autocam zooms in/out enough for you to see everyone on the screen.",
  2786. "Alt Q":"Toggles quickplay.",
  2787. "Alt B":"Displays the current score while ingame. Press Alt B again to hide the score.",
  2788. "Alt A":"Skips the map if quickplay is on.",
  2789. "Alt D":"Goes to previous map if quickplay is on.",
  2790. "Alt F":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  2791. "Alt O":"Enables heavy bot. Heavy bot will heavy right before collision. Turn this off when player collision is off, because heavy bot will still function.",
  2792. "Alt U":"Toggles aimbot. Aimbot will aim for you in arrows or death arrows mode.",
  2793. "Alt P":"Only pauses or unpauses the quickplay cycle due to round end. '/next', '/previous' still work. Type 'pauseqp' to unpause quickplay.",
  2794. "Alt R":"In quickplay, it switches mode to recommended mode, according to editor.",
  2795. "Alt I":"Opens debugger.",
  2796. "Alt <":"Lowers ingame chat height.",
  2797. "Alt >":"Highers ingame chat height."
  2798. };
  2799. scope.displayadvhelp = function(command){
  2800. displayInChat(adv_help[command],"#009398","#DA0808",{sanitize:true},"",true);
  2801. };
  2802. scope.changemode = function(mode){
  2803. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  2804. RECIEVE('42[26,"b","'+mode+'"]');
  2805. };
  2806. Gdocument.getElementById("ingamechatcontent").style["pointer-events"]="all";
  2807. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  2808. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  2809. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  2810.  
  2811. document.getElementById('adboxverticalCurse').style["display"] = "none";
  2812. document.getElementById('adboxverticalleftCurse').style["display"] = "none";
  2813. elem.onclick=function(e){
  2814. if(stopquickplay==0 && ishost == true && e.isTrusted == true){
  2815. quicki = (Array.from(e.target.parentElement.parentNode.children).indexOf(e.target.parentNode)-1)%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  2816. if(reverseqp){
  2817. quicki+=2;
  2818. quicki = quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  2819. }
  2820. }
  2821. };
  2822. scope.urlify = function(text) {
  2823. if(!Gdocument.getElementById('bl_Menu')){
  2824. return text.replace(/(?:https?:\/\/)?(?:[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)(?:\.[A-Za-z0-9-ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøùîûñé]+)+(?:\/(?:[A-Za-z0-9-._~:/?#\[\]@!$&'()*+,;=]|%[0-9a-fA-F]{2})*)?(?:\?(?:[^=]+=[^&](?:&[^=]+=[^&])*)?)?/g, function(url) {
  2825. if(url.startsWith('https://') || url.startsWith('http://')){return '<a href="' + url + '" target="_blank" style = "color:orange">' + url + '</a>';}
  2826. else{return '<a href="https://' + url + '" target="_blank" style = "color:orange">' + url + '</a>';}
  2827. })}return text;
  2828. };
  2829.  
  2830. scope.fire = function(type,options,d = Gdocument){
  2831. var event= document.createEvent("HTMLEvents");
  2832. event.initEvent(type,true,false);
  2833. for(var p in options){
  2834. event[p]=options[p];
  2835. }
  2836. d.dispatchEvent(event);
  2837. };
  2838.  
  2839. scope.chat = function(message){
  2840. SEND('42[10,{"message":'+JSON.stringify(message)+'}]');
  2841. };
  2842. scope.chat2 = function(message,enteragain=false){
  2843. mess = Gdocument.getElementById("newbonklobby_chat_input").value;
  2844. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  2845. Gdocument.getElementById("newbonklobby_chat_input").value = message;
  2846. Gdocument.getElementById("ingamechatinputtext").value = message;
  2847. fire("keydown",{keyCode:13});
  2848. if(!enteragain){
  2849. fire("keydown",{keyCode:13});
  2850. }
  2851. Gdocument.getElementById("newbonklobby_chat_input").value = mess;
  2852. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  2853. };
  2854. scope.displayInChat = function(message, LobbyColor, InGameColor, options, message2, BringDown) {
  2855. options = options ?? {};
  2856. BringDown = BringDown ?? false;
  2857. message2 = message2 ?? "";
  2858. LobbyColor = LobbyColor ?? "#8800FF";
  2859. InGameColor = InGameColor ?? "#AA88FF";
  2860. let A = Gdocument.createElement("div");
  2861. let B = Gdocument.createElement("span");
  2862. B.className = "newbonklobby_chat_status";
  2863. B.style.color = LobbyColor;
  2864. A.appendChild(B);
  2865. B.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  2866. B.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  2867. let C = Gdocument.createElement("div");
  2868. let D = Gdocument.createElement("span");
  2869. D.style.color = InGameColor;
  2870. C.appendChild(D);
  2871. D.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  2872. D.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  2873. let a = BringDown;
  2874. if(Gdocument.getElementById("newbonklobby_chat_content").clientHeight + Gdocument.getElementById("newbonklobby_chat_content").scrollTop >= Gdocument.getElementById("newbonklobby_chat_content").scrollHeight-1) {
  2875. a = true;
  2876. }
  2877. A.style["parsed"] = true;
  2878. C.style["parsed"] = true;
  2879. Gdocument.getElementById("newbonklobby_chat_content").appendChild(A);
  2880. Gdocument.getElementById("ingamechatcontent").appendChild(C);
  2881. if (a) { Gdocument.getElementById("newbonklobby_chat_content").scrollTop = Number.MAX_SAFE_INTEGER;};
  2882. Gdocument.getElementById("ingamechatcontent").scrollTop = Number.MAX_SAFE_INTEGER;
  2883. if(Gdocument.getElementById("newbonklobby_chat_input").style["pointer-events"]!="auto" && !Gdocument.getElementById("ingamechatinputtext").classList.value.includes("ingamechatinputtextbg")){
  2884. chat2("");
  2885. }
  2886. };
  2887.  
  2888. scope.lobby = function(){
  2889. if (Gdocument.getElementById("newbonklobby").style["display"]=="none"){
  2890.  
  2891. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2892. Gdocument.getElementById("mapeditor_close").click();
  2893. if(Gdocument.getElementById("newbonklobby_playerbox_elementcontainer").children.length+Gdocument.getElementById("newbonklobby_specbox_elementcontainer").children.length-3>0){
  2894. Gdocument.getElementById("newbonklobby").style["z-index"]=1;
  2895. Gdocument.getElementById("maploadwindowcontainer").style["z-index"]=1;
  2896. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=1;
  2897. Gdocument.getElementById("pretty_top").style["z-index"]=3;
  2898. Gdocument.getElementById("settingsContainer").style["z-index"]=3;
  2899. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=3;
  2900. Gdocument.getElementById("hostleaveconfirmwindow").style["z-index"]=3;
  2901. debuggermenu.style["z-index"] = 2;
  2902. }
  2903. else{
  2904. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  2905. Gdocument.getElementById("newbonklobby").style["display"]="none";
  2906. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  2907.  
  2908. }
  2909.  
  2910. }
  2911. else if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  2912. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  2913. Gdocument.getElementById("newbonklobby").style["display"]="none";
  2914. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  2915.  
  2916. }
  2917. };
  2918.  
  2919. scope.lastmessage = function(){
  2920. if(Gdocument.getElementById("newbonklobby_chat_content").children.length!=0){
  2921. var lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  2922. var lm2 = "";
  2923. for(var i = 0; i<lm.length;i++){
  2924. lm2+=" "+lm[i].textContent.trim();
  2925. }
  2926. lm2 = lm2.trim();
  2927. if(lm2.startsWith("*")){
  2928. return lm2;
  2929. }
  2930. }
  2931. if(Gdocument.getElementById("ingamechatcontent").children.length!=0){
  2932. var lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  2933. var lm2 = "";
  2934. for(var i = 0; i<lm.length;i++){
  2935. lm2+=" "+lm[i].textContent.trim();
  2936. }
  2937. return lm2.trim();
  2938. }
  2939. return "";
  2940.  
  2941. };
  2942. scope.map = function(e,t=timedelay){
  2943. if(e<0){
  2944. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  2945. quicki = 0;
  2946. return;
  2947. }
  2948. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  2949. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  2950. return;
  2951. }
  2952.  
  2953. setTimeout(function(){if(!canceled){
  2954. startedinqp = true;
  2955. if(roundsperqp2>=roundsperqp){
  2956. roundsperqp2 = 0;
  2957. }
  2958. gameStartTimeStamp = Date.now();
  2959. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  2960. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2961. if(recmodebool && ishost){
  2962. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  2963. if(mode == "" && defaultmode!="d"){
  2964. mode = defaultmode;
  2965. }
  2966. if(mode != ""){
  2967. RECIEVE('42[26,"b","'+mode+'"]');
  2968. }
  2969. }
  2970. var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  2971. Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  2972. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2973. if(displayblock){
  2974. Gdocument.getElementById("newbonklobby").style["display"] = "block";
  2975. }
  2976. Gdocument.getElementById("mapeditor_midbox_testbutton").click();}
  2977. canceled = false;
  2978. transitioning = false;
  2979. },t);
  2980.  
  2981. };
  2982.  
  2983. scope.gotonextmap = function(e){
  2984. if(e<0){
  2985. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  2986. quicki = 0;
  2987. return;
  2988. }
  2989. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  2990. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  2991. return;
  2992. }
  2993. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  2994. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2995. if(recmodebool && ishost){
  2996. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  2997. if(mode == "" && defaultmode!="d"){
  2998. mode = defaultmode;
  2999. }
  3000. if(mode != ""){
  3001. RECIEVE('42[26,"b","'+mode+'"]');
  3002. }
  3003. }
  3004. startedinqp = true;
  3005. if(roundsperqp2>=roundsperqp){
  3006. roundsperqp2 = 0;
  3007. }
  3008. gameStartTimeStamp = Date.now();
  3009. var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  3010. Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  3011. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  3012. if(displayblock){
  3013. Gdocument.getElementById("newbonklobby").style["display"] = "block";
  3014. }
  3015. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  3016. Gdocument.getElementById("newbonklobby").style["visibility"] = "visible";
  3017. };
  3018. scope.commandhandle = function(chat_val){
  3019. if (chat_val.substring(1,6)=="echo " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3020. if (chat_val.substring(6).replace(/^\s+|\s+$/g, '')==username){
  3021. displayInChat("You cannot echo yourself.","#DA0808","#1EBCC1");
  3022. return "";
  3023. }
  3024. else if (echo_list.indexOf(chat_val.substring(6).replace(/^\s+|\s+$/g, ''))===-1) {
  3025.  
  3026. echo_list.push(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  3027. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is being echoed.","#DA0808","#1EBCC1");
  3028. return "";
  3029. }
  3030. else{
  3031. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '') + " is already being echoed.","#DA0808","#1EBCC1");
  3032. return "";
  3033. }
  3034. }
  3035. else if (chat_val.substring(1,8)=="remove " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3036. if (echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, ''))!==-1){
  3037. echo_list.splice(echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, '')),1);
  3038. displayInChat(chat_val.substring(7).replace(/^\s+|\s+$/g, '')+" is not being echoed.","#DA0808","#1EBCC1");
  3039. return "";
  3040. }
  3041. else{
  3042. displayInChat("You cannot remove someone that you didn't echo.","#DA0808","#1EBCC1");
  3043. return "";
  3044. }
  3045.  
  3046. }
  3047. else if (chat_val.substring(1,10)=="echotext " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  3048. echotext = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  3049. displayInChat("Set echotext as: "+echotext,"#DA0808","#1EBCC1");
  3050. displayInChat("Type '/echotext' to reset echotext.","#DA0808","#1EBCC1");
  3051. return "";
  3052.  
  3053. }
  3054. else if (chat_val.substring(1,9)=="echotext"){
  3055. echotext = "message";
  3056. displayInChat("Reset echotext.","#DA0808","#1EBCC1");
  3057. return "";
  3058.  
  3059. }
  3060. else if (chat_val.substring(1,10)=="clearecho"){
  3061. echo_list = [];
  3062. displayInChat("Cleared the echo list.","#DA0808","#1EBCC1");
  3063. return "";
  3064. }
  3065. else if (chat_val.substring(1,6)=="space"){
  3066. if(space_flag == true){
  3067. displayInChat("Space is now off.","#DA0808","#1EBCC1");
  3068. space_flag = false;
  3069. }
  3070. else{
  3071. displayInChat("Space is now on.","#DA0808","#1EBCC1");
  3072. space_flag = true;
  3073. }
  3074. return "";
  3075. }
  3076. else if (chat_val.substring(1,6)=="rcaps"){
  3077. if(rcaps_flag == true){
  3078. displayInChat("Rcaps is now off.","#DA0808","#1EBCC1");
  3079. rcaps_flag = false;
  3080. }
  3081. else{
  3082. displayInChat("Rcaps is now on.","#DA0808","#1EBCC1");
  3083. rcaps_flag = true;
  3084. }
  3085.  
  3086. return "";
  3087. }
  3088. else if (chat_val.substring(1,7)=="number"){
  3089. if(number_flag == true){
  3090. displayInChat("Number is now off.","#DA0808","#1EBCC1");
  3091. number_flag = false;
  3092. }
  3093. else{
  3094. displayInChat("Number is now on.","#DA0808","#1EBCC1");
  3095. number_flag = true;
  3096. }
  3097.  
  3098. return "";
  3099. }
  3100. else if (chat_val.substring(1,8)=="reverse"){
  3101. if(reverse_flag == true){
  3102. displayInChat("Reverse is now off.","#DA0808","#1EBCC1");
  3103. reverse_flag = false;
  3104. }
  3105. else{
  3106. displayInChat("Reverse is now on.","#DA0808","#1EBCC1");
  3107. reverse_flag = true;
  3108. }
  3109.  
  3110. return "";
  3111. }
  3112. else if (chat_val.substring(1,7)=="speech"){
  3113. if(text2speech == true){
  3114. displayInChat("Text to speech is now off.","#DA0808","#1EBCC1");
  3115. text2speech = false;
  3116. }
  3117. else{
  3118. displayInChat("Text to speech is now on.","#DA0808","#1EBCC1");
  3119. text2speech = true;
  3120. }
  3121.  
  3122. return "";
  3123. }
  3124. else if (chat_val.substring(1,6)=="eval " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3125. var ev = "";
  3126. try{
  3127. ev = eval(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  3128. }
  3129. catch(e){
  3130. displayInChat(e.message,"#DA0808","#1EBCC1");
  3131. }
  3132. try{
  3133. displayInChat(ev.toString(),"#DA0808","#1EBCC1");
  3134. }
  3135. catch{
  3136. }
  3137.  
  3138. return "";
  3139.  
  3140. }
  3141. else if (chat_val.substring(1,10)=="followcam"){
  3142. if(FollowCam == true){
  3143. displayInChat("Follow Camera is now off.","#DA0808","#1EBCC1");
  3144. FollowCam = false;
  3145. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  3146. var addto = {"children":[]};
  3147. for(var i = 0;i<parentDraw.children.length;i++){
  3148. if(parentDraw.children[i].constructor.name == "e"){
  3149. addto = parentDraw.children[i];
  3150. break;
  3151. }
  3152. }
  3153. var canv = 0;
  3154. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  3155. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  3156. canv = Gdocument.getElementById("gamerenderer").children[i];
  3157. break;
  3158. }
  3159. }
  3160. var width = parseInt(canv.style["width"]);
  3161. var height = parseInt(canv.style["height"]);
  3162. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  3163. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  3164. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  3165. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  3166. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  3167. pixiCircle.visible = false;
  3168. }
  3169. else{
  3170. pixiCircle.visible = true;
  3171. }
  3172. }
  3173. }
  3174. else{
  3175. displayInChat("Follow Camera is now on.","#DA0808","#1EBCC1");
  3176. FollowCam = true;
  3177. }
  3178.  
  3179. return "";
  3180. }
  3181. else if (chat_val.substring(1,8)=="autocam"){
  3182. if(autocam == true){
  3183. displayInChat("Auto Cam is now off.","#DA0808","#1EBCC1");
  3184. autocam = false
  3185. }
  3186. else{
  3187. displayInChat("Auto Cam is now on.","#DA0808","#1EBCC1");
  3188. autocam = true;
  3189. }
  3190.  
  3191. return "";
  3192. }
  3193. else if (chat_val.substring(1,7)=="aimbot"){
  3194. if(aimbot == true){
  3195. displayInChat("Aimbot is now off.","#DA0808","#1EBCC1");
  3196. aimbot = false;
  3197. }
  3198. else{
  3199. displayInChat("Aimbot is now on.","#DA0808","#1EBCC1");
  3200. aimbot = true;
  3201. var keykeys = Object.keys(keyCodes);
  3202. var keyslist = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[1].children).slice(1);
  3203. var keyslist2 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[2].children).slice(1);
  3204. for(var i = 0;i<keyslist.length;i++){
  3205. if(keykeys.includes(keyslist[i].textContent)){
  3206. leftRight[0] = keyCodes[keyslist[i].textContent];
  3207. break;
  3208. }
  3209. else{
  3210. leftRight[0] = keyslist[i].textContent.charCodeAt(0);
  3211. break
  3212. }
  3213. }
  3214. for(var i = 0;i<keyslist2.length;i++){
  3215. if(keykeys.includes(keyslist2[i].textContent)){
  3216. leftRight[1] = keyCodes[keyslist2[i].textContent];
  3217. break;
  3218. }
  3219. else{
  3220. leftRight[1] = keyslist2[i].textContent.charCodeAt(0);
  3221. }
  3222. }
  3223. }
  3224.  
  3225. return "";
  3226. }
  3227. else if (chat_val.substring(1,9)=="heavybot"){
  3228. if(heavybot == true){
  3229. displayInChat("Heavy bot is now off.","#DA0808","#1EBCC1");
  3230. heavybot = false;
  3231. }
  3232. else{
  3233. displayInChat("Heavy bot is now on.","#DA0808","#1EBCC1");
  3234. heavybot = true;
  3235. var keykeys = Object.keys(keyCodes);
  3236. var keyslist = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[5].children).slice(1);
  3237. for(var i = 0;i<keyslist.length;i++){
  3238. if(keykeys.includes(keyslist[i].textContent)){
  3239. heavy = keyCodes[keyslist[i].textContent];
  3240. break;
  3241. }
  3242. else{
  3243. heavy = keyslist[i].textContent.charCodeAt(0);
  3244. break
  3245. }
  3246. }
  3247. var keyslist2 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[6].children).slice(1);
  3248. for(var i = 0;i<keyslist2.length;i++){
  3249. if(keykeys.includes(keyslist2[i].textContent)){
  3250. special = keyCodes[keyslist2[i].textContent];
  3251. break;
  3252. }
  3253. else{
  3254. special = keyslist2[i].textContent.charCodeAt(0);
  3255. break
  3256. }
  3257. }
  3258. }
  3259.  
  3260. return "";
  3261. }
  3262. else if (chat_val.substring(1,5)=="xray"){
  3263. Gdocument.getElementById("pretty_top_settings").click();
  3264. Gdocument.getElementById("settings_close").click();
  3265. if(Gdocument.getElementById("settings_graphicsquality").value==1){
  3266. displayInChat("You must have medium or high quality enabled to use this feature.","#DA0808","#1EBCC1");
  3267. return "";
  3268. }
  3269.  
  3270.  
  3271. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  3272. var addto = {"children":[]};
  3273. for(var i = 0;i<parentDraw.children.length;i++){
  3274. if(parentDraw.children[i].constructor.name == "e"){
  3275. addto = parentDraw.children[i];
  3276. break;
  3277. }
  3278. }
  3279. var addto2 = {"children":[]};
  3280. for(var i = 0;i<addto.children.length;i++){
  3281. if(addto.children[i].constructor.name == "e"){
  3282. addto2 = addto.children[i];
  3283. break;
  3284. }
  3285. }
  3286. var checkxray = addto2.children[0];
  3287. var addto3 = addto2.children[0].children;
  3288. if(addto3.length==1){
  3289. checkxray = checkxray.children[0];
  3290. addto3 = addto3[0].children;
  3291. }
  3292. var xrayon = false;
  3293. if(checkxray.xrayon){
  3294. checkxray.xrayon = false;
  3295. xrayon = false;
  3296. }
  3297. else{
  3298. checkxray.xrayon = true;
  3299. xrayon = true;
  3300. }
  3301. if(xrayon){
  3302. displayInChat("Xray is now on.","#DA0808","#1EBCC1");
  3303. for(var i = 0;i<addto3.length;i++){
  3304. if(addto3[i].children.length>0){
  3305. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  3306. addto3[i].children[i3].visible = false;
  3307. if(addto3[i].children[i3].children.length>0){
  3308. addto3[i].children[i3].visible = true;
  3309. }
  3310. }
  3311. }
  3312. }
  3313.  
  3314. }
  3315. else{
  3316. displayInChat("Xray is now off.","#DA0808","#1EBCC1");
  3317. for(var i = 0;i<addto3.length;i++){
  3318. for(var i2 = 0;i2<addto3[i].children.length;i2++){
  3319. addto3[i].children[i2].visible = true;
  3320. }
  3321. }
  3322. }
  3323. }
  3324.  
  3325. return "";
  3326. }
  3327. else if (chat_val.substring(1,6)=="zoom "){
  3328. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  3329. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  3330. var addto = 0;
  3331. for(var i = 0;i<parentDraw.children.length;i++){
  3332. if(parentDraw.children[i].constructor.name == "e"){
  3333. addto = parentDraw.children[i];
  3334. break;
  3335. }
  3336. }
  3337. var canv = 0;
  3338. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  3339. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  3340. canv = Gdocument.getElementById("gamerenderer").children[i];
  3341. break;
  3342. }
  3343. }
  3344. var width = parseInt(canv.style["width"]);
  3345. var height = parseInt(canv.style["height"]);
  3346. if(addto){
  3347. if(text == "in"){
  3348. zoom *= 1.1;
  3349. }
  3350. else if(text == "out"){
  3351. zoom /= 1.1;
  3352. }
  3353. else if(text == "reset"){
  3354. zoom = 1;
  3355. }
  3356. else{
  3357. displayInChat("Options for zooming:","#DA0808","#1EBCC1");
  3358. displayInChat("in","#DA0808","#1EBCC1");
  3359. displayInChat("out","#DA0808","#1EBCC1");
  3360. displayInChat("reset","#DA0808","#1EBCC1");
  3361. return "";
  3362. }
  3363. addto.scale.x=zoom;
  3364. addto.scale.y=zoom;
  3365. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  3366. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  3367. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  3368. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  3369. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  3370. pixiCircle.visible = false;
  3371. }
  3372. else{
  3373. pixiCircle.visible = true;
  3374. }
  3375. }
  3376. }
  3377. return "";
  3378. }
  3379. else if (chat_val.substring(1,9)=="hidechat"){
  3380. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  3381. return "";
  3382. }
  3383. else if (chat_val.substring(1,9)=="showchat"){
  3384. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  3385. return "";
  3386. }
  3387. else if (chat_val.substring(1,6)=="score"){
  3388. var element = Gdocument.getElementById("ingamewinner_scores");
  3389. element.style["visibility"] = "visible";
  3390. if(element.style["opacity"]<1){
  3391. element.style["opacity"] = 1;
  3392. }
  3393. else{
  3394. element.style["opacity"] = 0;
  3395. }
  3396. return "";
  3397. }
  3398.  
  3399. else if (chat_val.substring(1,7)=="scroll"){
  3400. if(scroll==false){
  3401. scroll = true;
  3402. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="scroll";
  3403. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  3404. }
  3405. else if(scroll==true){
  3406. scroll = false;
  3407. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="hidden";
  3408. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  3409. }
  3410.  
  3411. return "";
  3412. }
  3413.  
  3414. else if (chat_val.substring(1,7)=="chatw "){
  3415. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  3416.  
  3417. if(username == text){
  3418. displayInChat("You cannot private chat with yourself.","#DA0808","#1EBCC1");
  3419. return "";
  3420. }
  3421. private_chat = text;
  3422.  
  3423. SEND("42"+JSON.stringify([4,{"type":"request public key","from":username,"to":private_chat}]));
  3424. request_public_key_time_stamp = Date.now();
  3425. setTimeout(function(){if(private_chat_public_key[0]!=private_chat){displayInChat("Failed to connect to "+private_chat+".","#DA0808","#1EBCC1");private_chat = private_chat_public_key[0];}},1600);
  3426. return "";
  3427. }
  3428.  
  3429. else if (chat_val.substring(1,5)=="msg " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  3430. if(private_chat_public_key[1][0] != 0 && private_chat_public_key[1][1] != 0 && private_chat_public_key[0] == private_chat){
  3431. var text = chat_val.substring(5).replace(/^\s+|\s+$/g, '');
  3432. var password = [];
  3433. for(var i = 0;i<10;i++){
  3434. password.push(Math.floor(Math.random()*100+50));
  3435. }
  3436. var text2 = [];
  3437. for(var i = 0;i<text.slice(0,400).length ;i++){
  3438. text2.push(password[i%password.length]^text.slice(0,400).charCodeAt(i));
  3439. }
  3440. pmlastmessage = text.slice(0,400);
  3441. SEND("42"+JSON.stringify([4,{"type":"private chat","from":username,"to":private_chat,"public key":private_chat_public_key[1],"message":text2,"password":CRYPT_MESSAGE(private_chat_public_key[1],password)}]));
  3442. displayInChat("> "+username+": ","#DA0808","#1EBCC1",{sanitize:false},text,false);
  3443. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  3444. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  3445. Laster_message = lastmessage();
  3446.  
  3447. }
  3448. return "";
  3449. }
  3450. else if (chat_val.substring(1,10)=="ignorepm " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  3451. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  3452. if(ignorepmlist.includes(text)){
  3453. var index = ignorepmlist.indexOf(text);
  3454. ignorepmlist.splice(index,1);
  3455. displayInChat("You are not ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  3456.  
  3457. }
  3458. else{
  3459. ignorepmlist.push(text);
  3460. displayInChat("You are now ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  3461. }
  3462. return "";
  3463. }
  3464. else if (chat_val.substring(1,8)=="pmusers"){
  3465. pmusers = [];
  3466. SEND("42"+JSON.stringify([4,{"type":"request private chat users","from":username}]));
  3467. pmuserstimestamp = Date.now();
  3468. setTimeout(function(){if(pmusers.length == 0){displayInChat("You cannot private chat with anyone.","#DA0808","#1EBCC1");
  3469. }else{displayInChat("You can private chat with:","#DA0808","#1EBCC1");for(var i = 0;i<pmusers.length;i++){var code = 'Gwindow.private_chat = "'+pmusers[i]+'"; Gwindow.SEND("42"+JSON.stringify([4,{"type":"request public key","from":Gwindow.username,"to":Gwindow.private_chat}])); Gwindow.request_public_key_time_stamp = Date.now(); setTimeout(function(){if(Gwindow.private_chat_public_key[0]!=Gwindow.private_chat){Gwindow.displayInChat("Failed to connect to "+Gwindow.private_chat+".","#DA0808","#1EBCC1");Gwindow.private_chat = Gwindow.private_chat_public_key[0];}},1600);';displayInChat('<a onclick = \''+code+'\' href = "javascript:void(0);" style = "color:green">'+pmusers[i]+'</a>',"#DA0808","#1EBCC1",{sanitize:false}); Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true; Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true; Laster_message = lastmessage(); }}},1600);
  3470. return "";
  3471. }
  3472. else if (chat_val.substring(1,6)=="lobby"){
  3473. lobby();
  3474. return "";
  3475. }
  3476. else if (chat_val.substring(1,9)=="debugger"){
  3477. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  3478. debuggeropen = true;
  3479. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  3480. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  3481. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  3482. }
  3483. else{
  3484. debuggeropen = false;
  3485. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  3486. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  3487. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  3488. }
  3489. return "";
  3490. }
  3491. else if (chat_val.substring(1,6)=="team " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3492. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  3493. if(text == "r"){Gdocument.getElementById("newbonklobby_redbutton").click();}
  3494. else if(text == "g"){Gdocument.getElementById("newbonklobby_greenbutton").click();}
  3495. else if(text == "y"){Gdocument.getElementById("newbonklobby_yellowbutton").click();}
  3496. else if(text == "b"){Gdocument.getElementById("newbonklobby_bluebutton").click();}
  3497. else if(text == "s"){Gdocument.getElementById("newbonklobby_specbutton").click();}
  3498. else if(text == "f"){Gdocument.getElementById("newbonklobby_ffabutton").click();}
  3499. return "";
  3500. }
  3501. else if (chat_val.substring(1,7)=="notify"){
  3502. npermissions = 1;
  3503. return "";
  3504. }
  3505. else if (chat_val.substring(1,11)=="stopnotify"){
  3506. npermissions = 0;
  3507. return "";
  3508. }
  3509. else if (chat_val.substring(1,8)=="support"){
  3510. displayInChat("Thanks everyone for helping me make this mod - LEGENDBOSS123","#0000FF","#FFFFFF");
  3511. displayInChat("mastery3","#0000FF","#FFFFFF");
  3512. displayInChat("UnmatchedBracket aka Left Paren","#0000FF","#FFFFFF");
  3513. displayInChat("iNeonz","#0000FF","#FFFFFF");
  3514. return "";
  3515. }
  3516. else if (chat_val.substring(1,9)=="pollstat"){
  3517. if(pollactive[0] || pollactive2[0]){
  3518. var count = [0,0,0,0];
  3519. var keys = Object.keys(playerids);
  3520. for(var i = 0;i<keys.length;i++){
  3521. if(ishost){
  3522. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  3523. count[playerids[keys[i]].vote.poll]++;
  3524. }
  3525. }
  3526. else{
  3527. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive2[2].length-1){
  3528. count[playerids[keys[i]].vote.poll]++;
  3529. }
  3530. }
  3531. }
  3532. for(var i = 0;i<count.length;i++){
  3533. if(count[i]>1){
  3534. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  3535. }
  3536. if(count[i]==1){
  3537. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  3538. }
  3539. }
  3540. if(ishost){
  3541. displayInChat("The poll will end in: "+((pollactive[2]-Date.now())/1000).toString()+" seconds.","#DA0808","#1EBCC1");
  3542. }
  3543. displayInChat("The poll is:","#DA0808","#1EBCC1");
  3544. if(ishost){
  3545. for(var i = 0;i<pollactive[3].length;i++){
  3546. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  3547. }
  3548. }
  3549. else{
  3550. for(var i = 0;i<pollactive2[2].length;i++){
  3551. displayInChat(letters[i]+") "+pollactive2[2][i],"#DA0808","#1EBCC1");
  3552. }
  3553. }
  3554. }
  3555. else{
  3556. displayInChat("No poll has been started.","#DA0808","#1EBCC1");
  3557. if(ishost){
  3558. displayInChat("Type '/startpoll [seconds]' to start a poll.","#DA0808","#1EBCC1");
  3559. if(poll.length>0){
  3560. displayInChat("The poll is:","#DA0808","#1EBCC1");
  3561. for(var i = 0;i<poll.length;i++){
  3562. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  3563. }
  3564. }
  3565. }
  3566. }
  3567. return "";
  3568. }
  3569. else if (chat_val.substring(1,5)=="help" || chat_val.substring(1,2)=="?"){
  3570. for(var i = 0;i<help.length;i++){
  3571. if(help[i].startsWith("/")){
  3572. var splitted = help[i].substring(1).split(" ");
  3573. var command = splitted[0];
  3574. var rest = "";
  3575. if(splitted.length>1){
  3576. rest = " "+splitted.slice(1).join(" ");
  3577. }
  3578. displayInChat("/"+'<a onclick = \'Gwindow.displayadvhelp("'+command+'");\' style = "color:green;" href = "javascript:void(0);">'+command+'</a>'+rest,"#DA0808","#1EBCC1",{sanitize:false},"",false);
  3579. }
  3580. else if(help[i].startsWith("Alt ")){
  3581. displayInChat('<a onclick = \'Gwindow.displayadvhelp("'+help[i]+'");\' style = "color:green;" href = "javascript:void(0);">'+help[i]+'</a>',"#DA0808","#1EBCC1",{sanitize:false},"",false);
  3582. }
  3583. else{
  3584. displayInChat(help[i],"#DA0808","#1EBCC1");
  3585. }
  3586.  
  3587. }
  3588. return "";
  3589. }
  3590. else if (chat_val.substring(1,9)=="advhelp " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  3591. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  3592. if(typeof(adv_help[text])!='undefined'){
  3593. displayInChat(adv_help[text],"#DA0808","#1EBCC1");
  3594. }
  3595. return "";
  3596. }
  3597. else if (chat_val.substring(1,6)=="mode " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3598. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  3599. var mode = "";
  3600. var text2 = text;
  3601. if(text == "arrows"){
  3602. text2 = "Arrows";
  3603. mode = "ar";
  3604. }
  3605. else if(text == "death arrows"){
  3606. mode = "ard";
  3607. text2 = "Death Arrows";
  3608. }
  3609. else if(text == "grapple"){
  3610. mode = "sp";
  3611. text2 = "Grapple";
  3612. }
  3613. else if(text == "classic"){
  3614. mode = "b";
  3615. text2 = "Classic";
  3616. }
  3617. else{
  3618. displayInChat("Mode options:","#DA0808","#1EBCC1");
  3619. displayInChat("classic","#DA0808","#1EBCC1");
  3620. displayInChat("arrows","#DA0808","#1EBCC1");
  3621. displayInChat("death arrows","#DA0808","#1EBCC1");
  3622. displayInChat("grapple","#DA0808","#1EBCC1");
  3623. }
  3624. if(mode != ""){
  3625. if(ishost){
  3626. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  3627. RECIEVE('42[26,"b","'+mode+'"]');
  3628. displayInChat("Changed mode to "+text+".","#DA0808","#1EBCC1");
  3629. }
  3630. else{
  3631. if(playerids[myid].ratelimit.mode+1000<Date.now()){
  3632. playerids[myid].ratelimit.mode=Date.now();
  3633. SEND("42"+JSON.stringify([4,{"type":"request mode","from":username,"mode":mode}]));
  3634. var code = 'if(!Gwindow.ishost){Gwindow.displayInChat("You must be host to change the mode.","#DA0808","#1EBCC1",{sanitize:false},"",true)}else{Gwindow.changemode("'+mode+'")}';
  3635. displayInChat('> '+username+' requests [<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+text2+'</a>]',"#DA0808","#1EBCC1",{sanitize:false}," mode.");
  3636.  
  3637. }
  3638. else{
  3639. displayInChat("You are requesting modes too quickly.","#DA0808","#1EBCC1");
  3640. }
  3641. }
  3642. }
  3643. return "";
  3644.  
  3645. }
  3646. else if(ishost){
  3647. if (chat_val.substring(1,11)=="nextafter " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  3648. var text = parseFloat(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  3649. if(isNaN(text)){
  3650. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  3651. return "";
  3652. }
  3653. else if(text<=0){
  3654. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  3655. return "";
  3656. }
  3657. nextafter = text;
  3658. displayInChat("Set next after to: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  3659. displayInChat("Type '/nextafter' to reset next after.","#DA0808","#1EBCC1");
  3660. return "";
  3661.  
  3662. }
  3663. else if (chat_val.substring(1,10)=="nextafter"){
  3664. nextafter = 0;
  3665. displayInChat("Reset next after.","#DA0808","#1EBCC1");
  3666. return "";
  3667.  
  3668. }
  3669. else if (chat_val.substring(1,5)=="next" && stopquickplay == 0){
  3670. roundsperqp2 = 0;
  3671. if(shuffle){
  3672. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3673. var available = [];
  3674. var availableindexes = [];
  3675. var notempty = false;
  3676. for(var i = 0; i<e.length;i++){
  3677. var a = false;
  3678. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3679. available.push(a);
  3680. if(a){
  3681. availableindexes.push(i);
  3682. notempty = true;
  3683. }
  3684. }
  3685. if(notempty){
  3686.  
  3687. if(availableindexes.length!=1){
  3688. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  3689. }
  3690. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  3691. }
  3692. }
  3693. else{
  3694. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3695. var available = [];
  3696. var availableindexes = [];
  3697. var notempty = false;
  3698. for(var i = 0; i<e.length;i++){
  3699. var a = false;
  3700. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3701. available.push(a);
  3702. if(a){
  3703. availableindexes.push(i);
  3704. notempty = true;
  3705. }
  3706. }
  3707. if(notempty){
  3708. var above = [];
  3709. for(var i = 0;i<availableindexes.length;i++){
  3710. if(availableindexes[i]>quicki && !reverseqp){
  3711. above.push(availableindexes[i]);
  3712. }
  3713. else if(availableindexes[i]<quicki && reverseqp){
  3714. above.push(availableindexes[i])
  3715. }
  3716. }
  3717. if(above.length>0){
  3718. quicki = above[0];
  3719. if(reverseqp){
  3720. quicki = above[above.length-1];
  3721. }
  3722. }
  3723. else{
  3724. quicki = availableindexes[0];
  3725. if(reverseqp){
  3726. quicki = availableindexes[availableindexes.length-1];
  3727. }
  3728. }
  3729. }
  3730. }
  3731. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  3732. displayInChat("Switched to next map.","#DA0808","#1EBCC1");
  3733. return "";
  3734.  
  3735. }
  3736. else if (chat_val.substring(1,9)=="freejoin"){
  3737. if(freejoin == false){
  3738. freejoin = true;
  3739. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  3740.  
  3741. }
  3742. else{
  3743. freejoin = false;
  3744. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  3745. }
  3746.  
  3747. return "";
  3748.  
  3749. }
  3750. else if (chat_val.substring(1,8)=="instaqp"){
  3751. if(instaqp == false){
  3752. instaqp = true;
  3753. displayInChat("Instaqp is now on.","#DA0808","#1EBCC1");
  3754.  
  3755. }
  3756. else{
  3757. instaqp = false;
  3758. displayInChat("Instaqp is now off.","#DA0808","#1EBCC1");
  3759. }
  3760.  
  3761. return "";
  3762.  
  3763. }
  3764.  
  3765. else if (chat_val.substring(1,9)=="previous" && stopquickplay == 0){
  3766. roundsperqp2 = 0;
  3767. if(shuffle){
  3768. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3769. var available = [];
  3770. var availableindexes = [];
  3771. var notempty = false;
  3772. for(var i = 0; i<e.length;i++){
  3773. var a = false;
  3774. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3775. available.push(a);
  3776. if(a){
  3777. availableindexes.push(i);
  3778. notempty = true;
  3779. }
  3780. }
  3781. if(notempty){
  3782.  
  3783. if(availableindexes.length!=1){
  3784. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  3785. }
  3786. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  3787. }
  3788. }
  3789. else{
  3790. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  3791. var available = [];
  3792. var availableindexes = [];
  3793. var notempty = false;
  3794. for(var i = 0; i<e.length;i++){
  3795. var a = false;
  3796. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  3797. available.push(a);
  3798. if(a){
  3799. availableindexes.push(i);
  3800. notempty = true;
  3801. }
  3802. }
  3803. if(notempty){
  3804. var above = [];
  3805. for(var i = 0;i<availableindexes.length;i++){
  3806. if(availableindexes[i]<quicki && !reverseqp){
  3807. above.push(availableindexes[i]);
  3808. }
  3809. else if(availableindexes[i]>quicki && reverseqp){
  3810. above.push(availableindexes[i])
  3811. }
  3812. }
  3813. if(above.length>0){
  3814. quicki = above[above.length-1];
  3815. if(reverseqp){
  3816. quicki = above[0];
  3817. }
  3818. }
  3819. else{
  3820. quicki = availableindexes[availableindexes.length-1];
  3821. if(reverseqp){
  3822. quicki = availableindexes[0];
  3823. }
  3824. }
  3825. }
  3826. }
  3827. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  3828.  
  3829. displayInChat("Switched to previous map.","#DA0808","#1EBCC1");
  3830. return "";
  3831. }
  3832. else if (chat_val.substring(1,6)=="start" && chat_val.length == 6){
  3833. if(Gdocument.getElementById("mapeditorcontainer").style["display"]!="block"){
  3834. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3835. }
  3836. if(recmodebool && ishost){
  3837. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  3838. if(mode == "" && defaultmode!="d"){
  3839. mode = defaultmode;
  3840. }
  3841. if(mode != ""){
  3842. RECIEVE('42[26,"b","'+mode+'"]');
  3843. }
  3844. }
  3845. Gdocument.getElementById("mapeditor_close").click();
  3846. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  3847. roundsperqp2 = 0;
  3848. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  3849.  
  3850. return "";
  3851. }
  3852.  
  3853. else if (chat_val.substring(1,8)=="startqp" && stopquickplay == 1){
  3854. stopquickplay = 0;
  3855. quicki = 0;
  3856. qppaused = false;
  3857. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  3858. return "";
  3859. }
  3860. else if (chat_val.substring(1,7)=="stopqp" && stopquickplay == 0){
  3861. stopquickplay = 1;
  3862. quicki = 0;
  3863. qppaused = false;
  3864. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  3865. return "";
  3866. }
  3867. else if (chat_val.substring(1,8)=="pauseqp" && stopquickplay == 0){
  3868. if(qppaused == false){
  3869. qppaused = true;
  3870. displayInChat("Paused quickplay.","#DA0808","#1EBCC1");
  3871. }
  3872. else{
  3873. qppaused = false;
  3874. displayInChat("Unpaused quickplay.","#DA0808","#1EBCC1");
  3875. }
  3876. return "";
  3877. }
  3878. else if (chat_val.substring(1,6)=="revqp" && stopquickplay == 0){
  3879. if(reverseqp == false){
  3880. reverseqp = true;
  3881. displayInChat("Reverseqp is now on..","#DA0808","#1EBCC1");
  3882. }
  3883. else{
  3884. reverseqp = false;
  3885. displayInChat("Reverseqp is now off.","#DA0808","#1EBCC1");
  3886. }
  3887. return "";
  3888. }
  3889.  
  3890. else if (chat_val.substring(1,5)=="ban " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  3891. banned.push(chat_val.substring(5).replace(/^\s+|\s+$/g, ''));
  3892. displayInChat("Banned "+chat_val.substring(5).replace(/^\s+|\s+$/g, '')+".","#DA0808","#1EBCC1");
  3893. return "/kick '" + chat_val.substring(5).replace(/^\s+|\s+$/g, '') + "'";
  3894. }
  3895. else if (chat_val.substring(1,6)=="kill " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3896. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  3897. var keys = Object.keys(playerids);
  3898. var killid = undefined;
  3899. for(var i = 0; i<keys.length; i++){
  3900. if(playerids[keys[i]].userName == text){
  3901. killid = keys[i];
  3902. }
  3903. }
  3904. if(typeof(killid)!="undefined" && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(killid)){
  3905. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  3906. killedids.push(killid);
  3907. SEND('42[25,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  3908. RECIEVE('42[31,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  3909. }
  3910. return "";
  3911. }
  3912. else if (chat_val.substring(1,10)=="balanceA " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  3913. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  3914. if(!isNaN(parseInt(text))){
  3915. if(parseInt(text)>=-100 && parseInt(text)<=100){
  3916. var keys = Object.keys(playerids);
  3917. for(var i = 0; i<keys.length;i++){
  3918. SEND('42[29,{"sid":'+keys[i]+',"bal":'+text+'}]');
  3919. RECIEVE('42[36,'+keys[i]+','+text+']');
  3920. }
  3921. }
  3922. }
  3923. return "";
  3924.  
  3925. }
  3926. else if (chat_val.substring(1,10)=="resetpoll"){
  3927. poll = [];
  3928. displayInChat("The poll has been reset.","#DA0808","#1EBCC1");
  3929. return "";
  3930. }
  3931. else if (chat_val.substring(1,11)=="addoption " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  3932. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  3933. if(text.length>50){
  3934. displayInChat("Your option is greater than 50 characters.","#DA0808","#1EBCC1");
  3935. return "";
  3936. }
  3937. if(poll.includes(text)){
  3938. displayInChat("This option already exists.","#DA0808","#1EBCC1");
  3939. }
  3940. else if(poll.length>=4){
  3941. displayInChat("Your poll already has the max 4 amounts of options.","#DA0808","#1EBCC1");
  3942. displayInChat("Type '/deloption [letter]' to remove a option.","#DA0808","#1EBCC1");
  3943. displayInChat("The poll is:","#DA0808","#1EBCC1");
  3944. for(var i = 0;i<poll.length;i++){
  3945. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  3946. }
  3947. }
  3948. else{
  3949. poll.push(text);
  3950. displayInChat("The poll is now:","#DA0808","#1EBCC1");
  3951. for(var i = 0;i<poll.length;i++){
  3952. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  3953. }
  3954. }
  3955. return "";
  3956. }
  3957. else if (chat_val.substring(1,11)=="deloption " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  3958. var text = letters.indexOf(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  3959. if(text==-1 || text>=poll.length){
  3960. if(poll.length>0){
  3961. displayInChat("Available options are:","#DA0808","#1EBCC1");
  3962. for(var i = 0;i<poll.length;i++){
  3963. displayInChat(letters[i],"#DA0808","#1EBCC1");
  3964. }
  3965. }
  3966. else{
  3967. displayInChat("Your poll is empty.","#DA0808","#1EBCC1");
  3968. displayInChat("Type '/addoption [text]' to add an option.","#DA0808","#1EBCC1");
  3969. }
  3970. }
  3971. else{
  3972. poll.splice(text,1);
  3973. displayInChat("The poll is now:","#DA0808","#1EBCC1");
  3974. for(var i = 0;i<poll.length;i++){
  3975. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  3976. }
  3977. }
  3978. return "";
  3979. }
  3980. else if (chat_val.substring(1,11)=="startpoll " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  3981. var text = parseFloat(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  3982. if(isNaN(text)){
  3983. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  3984. return "";
  3985. }
  3986. else if(text<=0){
  3987. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  3988. return "";
  3989. }
  3990. else if(text<10){
  3991. displayInChat("Your poll has to last for at least 10 seconds.","#DA0808","#1EBCC1");
  3992. return "";
  3993. }
  3994. if(pollactive[0]){
  3995. displayInChat("There is already an ongoing poll.","#DA0808","#1EBCC1");
  3996. displayInChat("Type '/endpoll' to end the poll.","#DA0808","#1EBCC1");
  3997. return "";
  3998. }
  3999. if(poll.length<2){
  4000. displayInChat("Your poll needs at least 2 options.","#DA0808","#1EBCC1");
  4001. displayInChat("Type '/addoption' to add to the poll.","#DA0808","#1EBCC1");
  4002. return "";
  4003. }
  4004. var now = Date.now();
  4005. pollactive = [true,now,now+text*1000,[...poll]];
  4006. playerids[myid].ratelimit.poll = now;
  4007. var chatpoll = [...poll];
  4008. chatpoll.push("Cancel vote.");
  4009. pollactive[3].push("Cancel vote.");
  4010. for(var i = 0;i<chatpoll.length;i++){
  4011. chatpoll[i] = letters[i]+") "+chatpoll[i];
  4012. }
  4013. chat(chatpoll.join("     "));
  4014. setTimeout(function(){
  4015. if(pollactive[0]){
  4016. SEND("42"+JSON.stringify([4,{"type":"poll","from":username,"poll":pollactive[3]}]));
  4017. var keys = Object.keys(playerids);
  4018. for(var i = 0;i<keys.length;i++){
  4019. playerids[keys[i]].vote.poll = -1;
  4020. }
  4021. displayInChat("The poll will end in: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  4022. displayInChat("Type '/endpoll' to end the poll early.","#DA0808","#1EBCC1");
  4023. }
  4024. },200);
  4025. return "";
  4026. }
  4027. else if (chat_val.substring(1,8)=="endpoll"){
  4028. if(pollactive[0]){
  4029. if(playerids[myid].ratelimit.poll+10000>Date.now()){
  4030. displayInChat("Your poll has to be at least 10 seconds.","#DA0808","#1EBCC1");
  4031. displayInChat("There are "+((playerids[myid].ratelimit.poll+10000-Date.now())/1000).toString()+" seconds left until you can end the poll early.","#DA0808","#1EBCC1");
  4032. return "";
  4033. }
  4034. playerids[myid].ratelimit.poll = Date.now();
  4035. SEND("42"+JSON.stringify([4,{"type":"poll end","from":username}]));
  4036. displayInChat("The poll ended.","#DA0808","#1EBCC1");
  4037. var count = [0,0,0,0];
  4038. var keys = Object.keys(playerids);
  4039. for(var i = 0;i<keys.length;i++){
  4040. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  4041. count[playerids[keys[i]].vote.poll]++;
  4042. }
  4043. playerids[keys[i]].vote.poll = -1;
  4044. }
  4045. for(var i = 0;i<count.length;i++){
  4046. if(count[i]>1){
  4047. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  4048. }
  4049. if(count[i]==1){
  4050. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  4051. }
  4052. }
  4053. displayInChat("The poll was:","#DA0808","#1EBCC1");
  4054. for(var i = 0;i<pollactive[3].length;i++){
  4055. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  4056. }
  4057. pollactive = [false,0,0,[]];
  4058. }
  4059. else{
  4060. displayInChat("No poll has been started","#DA0808","#1EBCC1");
  4061. displayInChat("Type '/startpoll [seconds]' to start a poll.","#DA0808","#1EBCC1");
  4062. }
  4063. return "";
  4064. }
  4065. else if (chat_val.substring(1,7)=="moveA " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  4066. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  4067. var keys = Object.keys(playerids);
  4068. var t = -1;
  4069. if(text == "f"){
  4070. t = 1;
  4071. }
  4072. else if(text == "b"){
  4073. t = 3;
  4074. }
  4075. else if(text == "g"){
  4076. t = 4;
  4077. }
  4078. else if(text == "r"){
  4079. t = 2;
  4080. }
  4081. else if(text == "y"){
  4082. t = 5;
  4083. }
  4084. else if(text == "s"){
  4085. t = 0;
  4086. }
  4087. if(t == -1){
  4088. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  4089. displayInChat("/moveA [letter]","#DA0808","#1EBCC1");
  4090. displayInChat("For example: '/moveA r' would move everyone to red team.","#DA0808","#1EBCC1");
  4091. return "";
  4092. }
  4093. for(var i = 0;i<keys.length;i++){
  4094. SEND('42[26,{"targetID":'+keys[i].toString()+',"targetTeam":'+t.toString()+'}]');
  4095. if(playerids[keys[i]].peerID!="sandbox"){
  4096. RECIEVE('42[18,'+keys[i].toString()+','+t.toString()+']');
  4097. }
  4098. }
  4099. return "";
  4100. }
  4101. else if (chat_val.substring(1,7)=="moveT " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  4102. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '').split(" ").filter(function(i){if(i==""){return false}else{return true}});
  4103. if(text.length == 2){
  4104. var firstteam = -1;
  4105. var secondteam = -1;
  4106. for(var i = 0;i<2;i++){
  4107. var t = -1;
  4108. if(text[i] == "f"){
  4109. t = 1;
  4110. }
  4111. else if(text[i] == "b"){
  4112. t = 3;
  4113. }
  4114. else if(text[i] == "g"){
  4115. t = 4;
  4116. }
  4117. else if(text[i] == "r"){
  4118. t = 2;
  4119. }
  4120. else if(text[i] == "y"){
  4121. t = 5;
  4122. }
  4123. else if(text[i] == "s"){
  4124. t = 0;
  4125. }
  4126. if(t==-1){
  4127. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  4128. displayInChat("/moveT [letter] [letter]","#DA0808","#1EBCC1");
  4129. displayInChat("For example: '/moveT s r' would move everyone in spectate to red team.","#DA0808","#1EBCC1");
  4130. return "";
  4131. }
  4132. else{
  4133. if(i == 0){
  4134. firstteam = t;
  4135. }
  4136. else{
  4137. secondteam = t;
  4138. }
  4139. }
  4140. }
  4141. var keys = Object.keys(playerids);
  4142. for(var i = 0;i<keys.length;i++){
  4143. if(playerids[keys[i]].team == firstteam){
  4144. SEND('42[26,{"targetID":'+keys[i].toString()+',"targetTeam":'+secondteam.toString()+'}]');
  4145. if(playerids[keys[i]].peerID!="sandbox"){
  4146. RECIEVE('42[18,'+keys[i].toString()+','+secondteam.toString()+']');
  4147. }
  4148. }
  4149. }
  4150. }
  4151. else{
  4152. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  4153. displayInChat("/moveT [team] [team]","#DA0808","#1EBCC1");
  4154. displayInChat("For example: '/moveT s r' would move everyone in spectate to red team.","#DA0808","#1EBCC1");
  4155. return "";
  4156. }
  4157. return "";
  4158. }
  4159. if (chat_val.substring(1,13)=="roundsperqp " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  4160. var text = parseInt(chat_val.substring(13).replace(/^\s+|\s+$/g, ''));
  4161. if(isNaN(text)){
  4162. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  4163. return "";
  4164. }
  4165. else if(text<=0){
  4166. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  4167. return "";
  4168. }
  4169. roundsperqp = text;
  4170. roundsperqp2 = 0;
  4171. displayInChat("Set rounds per quickplay to: " + text.toString(),"#DA0808","#1EBCC1");
  4172. displayInChat("Type '/roundsperqp' to reset rounds per quickplay.","#DA0808","#1EBCC1");
  4173. return "";
  4174.  
  4175. }
  4176. else if (chat_val.substring(1,12)=="roundsperqp"){
  4177. roundsperqp = 1;
  4178. roundsperqp2 = 0;
  4179. displayInChat("Reset rounds per quickplay.","#DA0808","#1EBCC1");
  4180. return "";
  4181.  
  4182. }
  4183. else if (chat_val.substring(1,8)=="rounds " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  4184. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  4185. if(!isNaN(parseInt(text))){
  4186. text = parseInt(text).toString();
  4187. SEND('42[21,{"w":'+text+'}]');
  4188. RECIEVE('42[27,'+text+']');
  4189. }
  4190. return "";
  4191.  
  4192. }
  4193. else if (chat_val.substring(1,13)=="disablekeys " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  4194. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  4195. var keys = text.split(" ");
  4196. var disabledkeys2 = [];
  4197. var possiblekeys = ["left","right","up","down","heavy","special"];
  4198. for(var i = 0; i<keys.length; i++){
  4199. if(keys[i]!="" && !disabledkeys2.includes(keys[i])){
  4200. if(possiblekeys.includes(keys[i])){
  4201. disabledkeys2.push(keys[i]);
  4202. }
  4203. else{
  4204. displayInChat("Key options: " + possiblekeys.join(" ") + ".","#DA0808","#1EBCC1");
  4205. return "";
  4206. }
  4207. }
  4208. }
  4209. disabledkeys = disabledkeys2;
  4210. displayInChat("Set disabled keys to: " + disabledkeys.join(" ") + ".","#DA0808","#1EBCC1");
  4211. displayInChat("Type '/disablekeys' to reset disabled keys.","#DA0808","#1EBCC1");
  4212. return "";
  4213.  
  4214. }
  4215. else if (chat_val.substring(1,12)=="disablekeys"){
  4216. displayInChat("Reset disabled keys.","#DA0808","#1EBCC1");
  4217. disabledkeys = [];
  4218. return "";
  4219.  
  4220. }
  4221. else if (chat_val.substring(1,10)=="jointext " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  4222. jointext = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  4223. displayInChat("Set jointext to: " + jointext,"#DA0808","#1EBCC1");
  4224. displayInChat("Type '/jointext' to reset jointext.","#DA0808","#1EBCC1");
  4225. return "";
  4226.  
  4227. }
  4228. else if (chat_val.substring(1,9)=="jointext"){
  4229. jointext = "";
  4230. displayInChat("Reset jointext.","#DA0808","#1EBCC1");
  4231. return "";
  4232.  
  4233. }
  4234. else if (chat_val.substring(1,10)=="jointeam " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  4235. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  4236. var keys = Object.keys(playerids);
  4237. var t = -1;
  4238. if(text == "f"){
  4239. t = 1;
  4240. displayInChat("Set jointeam to FFA.","#DA0808","#1EBCC1");
  4241. }
  4242. else if(text == "b"){
  4243. t = 3;
  4244. displayInChat("Set jointeam to blue team.","#DA0808","#1EBCC1");
  4245. }
  4246. else if(text == "g"){
  4247. t = 4;
  4248. displayInChat("Set jointeam to green team.","#DA0808","#1EBCC1");
  4249. }
  4250. else if(text == "r"){
  4251. t = 2;
  4252. displayInChat("Set jointeam to red team.","#DA0808","#1EBCC1");
  4253. }
  4254. else if(text == "y"){
  4255. t = 5;
  4256. displayInChat("Set jointeam to yellow team.","#DA0808","#1EBCC1");
  4257. }
  4258. else if(text == "s"){
  4259. t = 0;
  4260. displayInChat("Set jointeam to spectate.","#DA0808","#1EBCC1");
  4261. }
  4262. if(t == -1){
  4263. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  4264. displayInChat("/jointeam [letter]","#DA0808","#1EBCC1");
  4265. displayInChat("For example: '/jointeam r' would move every joined person to red team.","#DA0808","#1EBCC1");
  4266. return "";
  4267. }
  4268. displayInChat("Type '/jointeam' to reset jointeam.","#DA0808","#1EBCC1");
  4269. jointeam = t;
  4270. return "";
  4271. }
  4272. else if (chat_val.substring(1,9)=="jointeam"){
  4273. jointeam = -1;
  4274. displayInChat("Reset jointeam.","#DA0808","#1EBCC1");
  4275. return "";
  4276.  
  4277. }
  4278. else if (chat_val.substring(1,9)=="wintext " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  4279. wintext = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  4280. displayInChat("Set wintext to: " + wintext,"#DA0808","#1EBCC1");
  4281. displayInChat("Type '/wintext' to reset wintext.","#DA0808","#1EBCC1");
  4282. return "";
  4283.  
  4284. }
  4285. else if (chat_val.substring(1,8)=="wintext"){
  4286. wintext = "";
  4287. displayInChat("Reset wintext.","#DA0808","#1EBCC1");
  4288. return "";
  4289.  
  4290. }
  4291. else if (chat_val.substring(1,11)=="autorecord"){
  4292. if(autorecord){
  4293. autorecord = false;
  4294. displayInChat("Autorecord is now off.","#DA0808","#1EBCC1");
  4295. }
  4296. else{
  4297. autorecord = true;
  4298. displayInChat("Autorecord is now on.","#DA0808","#1EBCC1");
  4299. }
  4300. return "";
  4301.  
  4302. }
  4303. else if (chat_val.substring(1,9)=="afkkill " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  4304. var text = parseFloat(chat_val.substring(9).replace(/^\s+|\s+$/g, ''));
  4305. if(!isNaN(text)){
  4306. if(text>0){
  4307. displayInChat("Set afk kill to: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  4308. displayInChat("Type '/afkkill' to reset afk kill.","#DA0808","#1EBCC1");
  4309. var keys = Object.keys(playerids);
  4310. var now = Date.now();
  4311. for(var i = 0;i<keys.length;i++){
  4312. playerids[keys[i]].lastmove = now;
  4313. }
  4314. afkkill = text;
  4315. }
  4316. else{
  4317. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  4318. }
  4319. }
  4320. else{
  4321. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  4322. }
  4323. return "";
  4324.  
  4325. }
  4326. else if (chat_val.substring(1,9)=="afkkill"){
  4327. afkkill = -1;
  4328. displayInChat("Reset afk kill.","#DA0808","#1EBCC1");
  4329. return "";
  4330.  
  4331. }
  4332. else if (chat_val.substring(1,13)=="defaultmode " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  4333. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  4334. if(text == "default"){
  4335. defaultmode = "";
  4336. displayInChat("Changed default mode to default.","#DA0808","#1EBCC1");
  4337. }
  4338. else if(text == "arrows"){
  4339. defaultmode = "ar";
  4340. displayInChat("Changed default mode to arrows.","#DA0808","#1EBCC1");
  4341. }
  4342. else if(text == "death arrows"){
  4343. defaultmode = "ard";
  4344. displayInChat("Changed default mode to death arrows.","#DA0808","#1EBCC1");
  4345. }
  4346. else if(text == "grapple"){
  4347. defaultmode = "sp";
  4348. displayInChat("Changed default mode to grapple.","#DA0808","#1EBCC1");
  4349. }
  4350. else if(text == "classic"){
  4351. defaultmode = "b";
  4352. displayInChat("Changed default mode to classic.","#DA0808","#1EBCC1");
  4353.  
  4354. }
  4355. else{
  4356. displayInChat("Default mode options:","#DA0808","#1EBCC1");
  4357. displayInChat("default","#DA0808","#1EBCC1");
  4358. displayInChat("classic","#DA0808","#1EBCC1");
  4359. displayInChat("arrows","#DA0808","#1EBCC1");
  4360. displayInChat("death arrows","#DA0808","#1EBCC1");
  4361. displayInChat("grapple","#DA0808","#1EBCC1");
  4362. }
  4363. return "";
  4364.  
  4365. }
  4366. else if (chat_val.substring(1,8)=="recmode"){
  4367. if(recmodebool == true){
  4368. recmodebool = false;
  4369. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  4370.  
  4371. }
  4372. else{
  4373. recmodebool = true;
  4374. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  4375.  
  4376. }
  4377.  
  4378. return "";
  4379.  
  4380. }
  4381. else if (chat_val.substring(1,8)=="recteam"){
  4382. if(recteams == true){
  4383. recteams = false;
  4384. displayInChat("Recteam is now off.","#DA0808","#1EBCC1");
  4385.  
  4386. }
  4387. else{
  4388. recteams = true;
  4389. displayInChat("Recteam is now on.","#DA0808","#1EBCC1");
  4390.  
  4391. }
  4392. return "";
  4393. }
  4394. else if (chat_val.substring(1,8)=="shuffle"){
  4395. if(shuffle == true){
  4396. shuffle = false;
  4397. displayInChat("Shuffle is now off.","#DA0808","#1EBCC1");
  4398.  
  4399. }
  4400. else{
  4401. shuffle = true;
  4402. displayInChat("Shuffle is now on.","#DA0808","#1EBCC1");
  4403.  
  4404. }
  4405.  
  4406. return "";
  4407.  
  4408. }
  4409. else if (chat_val.substring(1,9)=="autokick"){
  4410. if(autokickban == 0){
  4411. displayInChat("Autokick is now on.","#DA0808","#1EBCC1");
  4412. autokickban = 1;
  4413. }
  4414. else if(autokickban == 1){
  4415. autokickban = 0;
  4416. displayInChat("Autokick is now off.","#DA0808","#1EBCC1");
  4417. }
  4418. else{
  4419. autokickban = 1;
  4420. displayInChat("Autokick is now on, and Autoban is now off.","#DA0808","#1EBCC1");
  4421. }
  4422.  
  4423. return "";
  4424. }
  4425. else if (chat_val.substring(1,8)=="autoban"){
  4426. if(autokickban == 0){
  4427. displayInChat("Autoban is now on.","#DA0808","#1EBCC1");
  4428. autokickban = 2;
  4429. }
  4430. else if(autokickban == 2){
  4431. autokickban = 0;
  4432. displayInChat("Autoban is now off.","#DA0808","#1EBCC1");
  4433. }
  4434. else{
  4435. autokickban = 2;
  4436. displayInChat("Autoban is now on, and Autokick is now off.","#DA0808","#1EBCC1");
  4437. }
  4438.  
  4439. return "";
  4440. }
  4441. else if (chat_val.substring(1,8)=="sandbox"){
  4442. if(sandboxon == false){
  4443. displayInChat("This room is now a sandbox room.","#DA0808","#1EBCC1");
  4444. sandboxon = true;
  4445. SEND('42[4,{"type":"sandboxon"}]');
  4446. var sandboxkeys = Object.keys(sandboxplayerids);
  4447. var packets = [];
  4448. for(var i = 0;i<sandboxkeys.length;i++){
  4449. var p = playerids[sandboxkeys[i]];
  4450. var packet = '42'+JSON.stringify([4,sandboxkeys[i],p.peerID,p.userName,p.guest,p.level,p.team,p.avatar]);
  4451. packets.push(packet);
  4452. }
  4453. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":packets,to:[-1]}]));
  4454. SEND("42"+JSON.stringify([4,{"type":"sandboxid","from":username,"lastid":sandboxid,to:[-1]}]));
  4455. }
  4456. else{
  4457. displayInChat("You cannot turn a sandbox room back into a normal room.","#DA0808","#1EBCC1");
  4458. }
  4459.  
  4460. return "";
  4461. }
  4462. else if(sandboxon){
  4463. if (chat_val.substring(1,11)=="addplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  4464. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  4465. if(!isNaN(parseInt(text))){
  4466. var text2 = parseInt(text);
  4467. if(text2>0){
  4468. for(var i = 0;i<text2;i++){
  4469. while(playerids[sandboxid]){
  4470. sandboxid+=1;
  4471. }
  4472. var color = Math.floor(Math.random() * 16777215).toString();
  4473. var packet = '42'+JSON.stringify([4,sandboxid,"sandbox",sandboxid.toString(),true,0,0,{"layers":[],"bc":color}]);
  4474. RECIEVE(packet);
  4475. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  4476. sandboxplayerids[sandboxid] = sandboxid.toString();
  4477. sandboxid+=1;
  4478. }
  4479.  
  4480. }
  4481. }
  4482. return "";
  4483.  
  4484. }
  4485. if (chat_val.substring(1,9)=="addname " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  4486. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  4487. while(playerids[sandboxid]){
  4488. sandboxid+=1;
  4489. }
  4490. var keys = Object.keys(playerids);
  4491. var addon = "";
  4492. var escape = false;
  4493. var keysi = -1;
  4494. while(!escape){
  4495. escape = true;
  4496. for(var i = 0;i<keys.length;i++){
  4497. if(playerids[keys[i]].userName == text+addon){
  4498. addon+="‎";
  4499. var escape = false;
  4500. }
  4501. if(playerids[keys[i]].userName == text){
  4502. keysi = keys[i];
  4503. }
  4504. }
  4505. }
  4506. if(keysi!=-1){
  4507. var packet = '42'+JSON.stringify([4,sandboxid,"sandbox",text+addon,playerids[keysi].guest,playerids[keysi].level,0,playerids[keysi].avatar]);
  4508. RECIEVE(packet);
  4509. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  4510. }
  4511. else{
  4512. var color = Math.floor(Math.random() * 16777215).toString();
  4513. var packet = '42'+JSON.stringify([4,sandboxid,"sandbox",text+addon,true,0,0,{"layers":[],"bc":color}]);
  4514. RECIEVE(packet);
  4515. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  4516. }
  4517. sandboxplayerids[sandboxid] = sandboxid.toString();
  4518. sandboxid+=1;
  4519. return "";
  4520.  
  4521. }
  4522. else if (chat_val.substring(1,11)=="delplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  4523. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  4524. if(!isNaN(parseInt(text))){
  4525. var text2 = parseInt(text);
  4526. if(text2>0){
  4527. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
  4528. var jsonkeys = Object.keys(sandboxplayerids).reverse();
  4529. var packets = [];
  4530. for(var i = 0;i<text2 && i<jsonkeys.length;i++){
  4531. var packet = '42[5,'+jsonkeys[i]+',0]';
  4532. RECIEVE(packet);
  4533. packets.push(packet);
  4534. delete sandboxplayerids[jsonkeys[i]];
  4535. }
  4536. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":packets,to:[-1]}]));
  4537. }
  4538. else{
  4539. displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
  4540. }
  4541.  
  4542. }
  4543. }
  4544. return "";
  4545. }
  4546. else if (chat_val.substring(1,6)=="copy " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  4547. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  4548. var keys = Object.keys(playerids);
  4549. var keys2 = Object.keys(sandboxplayerids);
  4550. var copiedperson = -1;
  4551. for(var i = 0;i<keys.length;i++){
  4552. if(playerids[keys[i]].userName==text){
  4553. copiedperson = keys[i];
  4554. }
  4555. }
  4556. if(copiedperson==-1){
  4557. displayInChat(playerids[copiedperson].userName + " was not found in this room.","#DA0808","#1EBCC1");
  4558. return "";
  4559. }
  4560. if(keys2.includes(copiedperson.toString())){
  4561. displayInChat("Bots cannot copy a bot.","#DA0808","#1EBCC1");
  4562. return "";
  4563. }
  4564. displayInChat("All bots will now copy "+playerids[copiedperson].userName+".","#DA0808","#1EBCC1");
  4565. displayInChat("To reset copy, type '/copy'.","#DA0808","#1EBCC1");
  4566. sandboxcopyme = copiedperson;
  4567.  
  4568. return "";
  4569. }
  4570. else if (chat_val.substring(1,5)=="copy"){
  4571. sandboxcopyme = -1;
  4572. displayInChat("Copy is now off.","#DA0808","#1EBCC1");
  4573. return "";
  4574. }
  4575. }
  4576. }
  4577. return chat_val;
  4578. };
  4579.  
  4580. scope.flag_manage = function(t){
  4581. var text = t;
  4582. if(reverse_flag == true){
  4583. text = text.split("").reverse().join("")
  4584. }
  4585. if(rcaps_flag == true){
  4586. text = text.split('');
  4587. for(var i = 0; i<text.length;i++){
  4588. if(Math.floor(Math.random()*2)){
  4589. text[i] = text[i].toUpperCase();
  4590. }
  4591. else{
  4592. text[i] = text[i].toLowerCase();
  4593. }
  4594. }
  4595. text = text.join('');
  4596. }
  4597. if(space_flag == true){
  4598. text = text.split('').join(' ')
  4599. }
  4600. if(number_flag == true){
  4601. text = text.replace(/[t|T][Oo]+/g,"2");
  4602. text = text.replace(/[f|F][o|O][r|R]/g,"4");
  4603. text = text.replace(/[a|A][t|T][e|E]/g,"8");
  4604. text = text.replace(/[e|E]/g,"3");
  4605. text = text.replace(/[a|A]/g,"4");
  4606. text = text.replace(/[o|O]/g,"0");
  4607. text = text.replace(/[s|S]/g,"5");
  4608. text = text.replace(/[i|I|l|L]/g,"1");
  4609. }
  4610. return text;
  4611. };
  4612. Gdocument.getElementById("newbonklobby_chat_input").onkeydown = function(e){
  4613. if(e.keyCode==13){
  4614.  
  4615. var chat_val = Gdocument.getElementById("newbonklobby_chat_input").value;
  4616.  
  4617. if (chat_val!="" && chat_val[0]=="/"){
  4618.  
  4619. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  4620. chat2(commandhandle(chat_val));
  4621. }
  4622. else{
  4623. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  4624. chat2(flag_manage(chat_val));
  4625. }
  4626.  
  4627. }
  4628. };
  4629. Gdocument.getElementById("ingamechatinputtext").onkeydown = function(e){
  4630. if(e.keyCode==13){
  4631.  
  4632. var chat_val = Gdocument.getElementById("ingamechatinputtext").value;
  4633.  
  4634. if (chat_val!="" && chat_val[0]=="/"){
  4635.  
  4636. Gdocument.getElementById("ingamechatinputtext").value = "";
  4637. chat2(commandhandle(chat_val));
  4638. }
  4639. else{
  4640. Gdocument.getElementById("ingamechatinputtext").value = "";
  4641. chat2(flag_manage(chat_val));
  4642. }
  4643. }
  4644. };
  4645. scope.Last_message = "";
  4646. scope.Laster_message = "";
  4647. scope.new_message = false;
  4648. scope.changed_chat = false;
  4649. scope.injectedBonkCommandsScript = setInterval(timeout123,60);
  4650.  
  4651. scope.hotkeys = function(e){
  4652. var keycode = e.code;
  4653. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  4654. if(keycode == "Period"){
  4655. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  4656. chatheight+=5;
  4657. if(chatheight>600){chatheight = 600;}
  4658. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  4659. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  4660. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  4661. }
  4662. e.preventDefault();
  4663. }
  4664. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4665. if(keycode == "KeyG"){
  4666. var addto = 0;
  4667. for(var i = 0;i<parentDraw.children.length;i++){
  4668. if(parentDraw.children[i].constructor.name == "e"){
  4669. addto = parentDraw.children[i];
  4670. break;
  4671. }
  4672. }
  4673. var canv = 0;
  4674. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  4675. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  4676. canv = Gdocument.getElementById("gamerenderer").children[i];
  4677. break;
  4678. }
  4679. }
  4680. var width = parseInt(canv.style["width"]);
  4681. var height = parseInt(canv.style["height"]);
  4682. if(addto){
  4683. zoom *= 1.1;
  4684. }
  4685. addto.scale.x = zoom;
  4686. addto.scale.y = zoom;
  4687. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  4688. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  4689. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  4690. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  4691. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  4692. pixiCircle.visible = false;
  4693. }
  4694. else{
  4695. pixiCircle.visible = true;
  4696. }
  4697. e.preventDefault();
  4698. }
  4699. if(keycode == "KeyH"){
  4700. var addto = 0;
  4701. for(var i = 0;i<parentDraw.children.length;i++){
  4702. if(parentDraw.children[i].constructor.name == "e"){
  4703. addto = parentDraw.children[i];
  4704. break;
  4705. }
  4706. }
  4707. var canv = 0;
  4708. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  4709. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  4710. canv = Gdocument.getElementById("gamerenderer").children[i];
  4711. break;
  4712. }
  4713. }
  4714. var width = parseInt(canv.style["width"]);
  4715. var height = parseInt(canv.style["height"]);
  4716. if(addto){
  4717. zoom = 1;
  4718. }
  4719. addto.scale.x = zoom;
  4720. addto.scale.y = zoom;
  4721. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  4722. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  4723. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  4724. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  4725. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  4726. pixiCircle.visible = false;
  4727. }
  4728. else{
  4729. pixiCircle.visible = true;
  4730. }
  4731. e.preventDefault();
  4732. }
  4733. if(keycode == "KeyJ"){
  4734. var addto = 0;
  4735. for(var i = 0;i<parentDraw.children.length;i++){
  4736. if(parentDraw.children[i].constructor.name == "e"){
  4737. addto = parentDraw.children[i];
  4738. break;
  4739. }
  4740. }
  4741. var canv = 0;
  4742. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  4743. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  4744. canv = Gdocument.getElementById("gamerenderer").children[i];
  4745. break;
  4746. }
  4747. }
  4748. var width = parseInt(canv.style["width"]);
  4749. var height = parseInt(canv.style["height"]);
  4750. if(addto){
  4751. zoom /= 1.1;
  4752. }
  4753. addto.scale.x = zoom;
  4754. addto.scale.y = zoom;
  4755. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  4756. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  4757. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  4758. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  4759. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  4760. pixiCircle.visible = false;
  4761. }
  4762. else{
  4763. pixiCircle.visible = true;
  4764. }
  4765. e.preventDefault();
  4766. }
  4767. }
  4768. if(keycode == "Comma"){
  4769. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  4770. chatheight-=5;
  4771. if(chatheight<100){chatheight = 100;}
  4772. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  4773. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  4774. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  4775. }
  4776. e.preventDefault();
  4777. }
  4778. }
  4779. if(e.repeat){return;}
  4780. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  4781. if(ishost){
  4782. if(keycode == "KeyE"){
  4783. if(Gdocument.getElementById("newbonklobby").style["display"] == "block"){
  4784. Gdocument.getElementById("newbonklobby_editorbutton").click();
  4785. }
  4786. else if(Gdocument.getElementById("mapeditorcontainer").style["display"] == "block"){
  4787. Gdocument.getElementById("mapeditor_close").click();
  4788. }
  4789. e.preventDefault();
  4790.  
  4791. }
  4792. else if(keycode == "KeyT"){
  4793. Gdocument.getElementById("newbonklobby_teamsbutton").click();
  4794. e.preventDefault();
  4795. }
  4796. else if(keycode == "KeyM"){
  4797. Gdocument.getElementById("newbonklobby_modebutton").click();
  4798. e.preventDefault();
  4799. }
  4800. else if(keycode == "KeyK"){
  4801. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4802. Gdocument.getElementById("pretty_top_exit").click();
  4803. }
  4804. e.preventDefault();
  4805. }
  4806. else if(keycode == "KeyS"){
  4807. if(Gdocument.getElementById("mapeditorcontainer").style["display"]!="block"){
  4808. Gdocument.getElementById("newbonklobby_editorbutton").click();
  4809. }
  4810. if(recmodebool && ishost){
  4811. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  4812. if(mode == "" && defaultmode!="d"){
  4813. mode = defaultmode;
  4814. }
  4815. if(mode != ""){
  4816. RECIEVE('42[26,"b","'+mode+'"]');
  4817. }
  4818. }
  4819. Gdocument.getElementById("mapeditor_close").click();
  4820. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  4821. roundsperqp2 = 0;
  4822. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  4823. e.preventDefault();
  4824. }
  4825. else if(keycode == "KeyD"){
  4826. roundsperqp2 = 0;
  4827. if(stopquickplay == 0){
  4828. if(shuffle){
  4829. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4830. var available = [];
  4831. var availableindexes = [];
  4832. var notempty = false;
  4833. for(var i = 0; i<e2.length;i++){
  4834. var a = false;
  4835. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4836. available.push(a);
  4837. if(a){
  4838. availableindexes.push(i);
  4839. notempty = true;
  4840. }
  4841. }
  4842. if(notempty){
  4843.  
  4844. if(availableindexes.length!=1){
  4845. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  4846. }
  4847. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  4848. }
  4849. }
  4850. else{
  4851. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4852. var available = [];
  4853. var availableindexes = [];
  4854. var notempty = false;
  4855. for(var i = 0; i<e2.length;i++){
  4856. var a = false;
  4857. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4858. available.push(a);
  4859. if(a){
  4860. availableindexes.push(i);
  4861. notempty = true;
  4862. }
  4863. }
  4864. if(notempty){
  4865. var above = [];
  4866. for(var i = 0;i<availableindexes.length;i++){
  4867. if(availableindexes[i]>quicki && !reverseqp){
  4868. above.push(availableindexes[i]);
  4869. }
  4870. else if(availableindexes[i]<quicki && reverseqp){
  4871. above.push(availableindexes[i])
  4872. }
  4873. }
  4874. if(above.length>0){
  4875. quicki = above[0];
  4876. if(reverseqp){
  4877. quicki = above[above.length-1];
  4878. }
  4879. }
  4880. else{
  4881. quicki = availableindexes[0];
  4882. if(reverseqp){
  4883. quicki = availableindexes[availableindexes.length-1];
  4884. }
  4885. }
  4886. }
  4887. }
  4888. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  4889. }
  4890. e.preventDefault();
  4891. }
  4892. else if(keycode == "KeyA"){
  4893. if(stopquickplay == 0){
  4894. roundsperqp2 = 0;
  4895. if(shuffle){
  4896. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4897. var available = [];
  4898. var availableindexes = [];
  4899. var notempty = false;
  4900. for(var i = 0; i<e2.length;i++){
  4901. var a = false;
  4902. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4903. available.push(a);
  4904. if(a){
  4905. availableindexes.push(i);
  4906. notempty = true;
  4907. }
  4908. }
  4909. if(notempty){
  4910.  
  4911. if(availableindexes.length!=1){
  4912. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  4913. }
  4914. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  4915. }
  4916. }
  4917. else{
  4918. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4919. var available = [];
  4920. var availableindexes = [];
  4921. var notempty = false;
  4922. for(var i = 0; i<e2.length;i++){
  4923. var a = false;
  4924. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4925. available.push(a);
  4926. if(a){
  4927. availableindexes.push(i);
  4928. notempty = true;
  4929. }
  4930. }
  4931. if(notempty){
  4932. var above = [];
  4933. for(var i = 0;i<availableindexes.length;i++){
  4934. if(availableindexes[i]<quicki && !reverseqp){
  4935. above.push(availableindexes[i]);
  4936. }
  4937. else if(availableindexes[i]>quicki && reverseqp){
  4938. above.push(availableindexes[i])
  4939. }
  4940. }
  4941. if(above.length>0){
  4942. quicki = above[above.length-1];
  4943. if(reverseqp){
  4944. quicki = above[0];
  4945. }
  4946. }
  4947. else{
  4948. quicki = availableindexes[availableindexes.length-1];
  4949. if(reverseqp){
  4950. quicki = availableindexes[0];
  4951. }
  4952. }
  4953. }
  4954. }
  4955. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  4956. }
  4957. e.preventDefault();
  4958. }
  4959. else if(keycode == "KeyQ"){
  4960. if(stopquickplay == 1){
  4961. stopquickplay = 0;
  4962. quicki = 0;
  4963. qppaused = false;
  4964. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  4965. }
  4966. else{
  4967. stopquickplay = 1;
  4968. quicki = 0;
  4969. qppaused = false;
  4970. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  4971. }
  4972. e.preventDefault();
  4973. }
  4974. else if(keycode == "KeyP" && stopquickplay==0){
  4975. if(qppaused == true){
  4976. qppaused = false;
  4977. displayInChat("Unpaused quickplay.","#DA0808","#1EBCC1");
  4978. }
  4979. else{
  4980. qppaused = true;
  4981. displayInChat("Paused quickplay.","#DA0808","#1EBCC1");
  4982. }
  4983. e.preventDefault();
  4984. }
  4985. else if(keycode == "KeyR"){
  4986. if(recmodebool == true){
  4987. recmodebool = false;
  4988. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  4989.  
  4990. }
  4991. else{
  4992. recmodebool = true;
  4993. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  4994.  
  4995. }
  4996. }
  4997. else if(keycode == "KeyF"){
  4998. if(freejoin == false){
  4999. freejoin = true;
  5000. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  5001.  
  5002. }
  5003. else{
  5004. freejoin = false;
  5005. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  5006. }
  5007. e.preventDefault();
  5008. }
  5009. }
  5010. else{
  5011. if(keycode == "KeyE"){
  5012. e.preventDefault();
  5013. }
  5014. else if(keycode == "KeyT"){
  5015. e.preventDefault();
  5016. }
  5017. else if(keycode == "KeyM"){
  5018. e.preventDefault();
  5019. }
  5020. else if(keycode == "KeyK"){
  5021. e.preventDefault();
  5022. }
  5023. else if(keycode == "KeyS"){
  5024. e.preventDefault();
  5025. }
  5026. else if(keycode == "KeyD"){
  5027. e.preventDefault();
  5028. }
  5029. else if(keycode == "KeyA"){
  5030. e.preventDefault();
  5031. }
  5032. else if(keycode == "KeyQ"){
  5033. e.preventDefault();
  5034. }
  5035. else if(keycode == "KeyP"){
  5036. e.preventDefault();
  5037. }
  5038. else if(keycode == "KeyF"){
  5039. e.preventDefault();
  5040. }
  5041. else if(keycode == "KeyR"){
  5042. e.preventDefault();
  5043. }
  5044.  
  5045. }
  5046. if(keycode == "KeyL"){
  5047. lobby();
  5048. e.preventDefault();
  5049. }
  5050. if(keycode == "KeyC"){
  5051. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  5052. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]=="0px"){
  5053. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  5054. }
  5055. else{
  5056. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  5057. }
  5058. }
  5059. e.preventDefault();
  5060. }
  5061. if(keycode == "KeyI"){
  5062. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  5063. debuggeropen = true;
  5064. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  5065. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  5066. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  5067. }
  5068. else{
  5069. debuggeropen = false;
  5070. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  5071. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  5072. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  5073. }
  5074. e.preventDefault();
  5075. }
  5076. if(keycode == "KeyB"){
  5077. var element = Gdocument.getElementById("ingamewinner_scores");
  5078. element.style["visibility"] = "visible";
  5079. if(element.style["opacity"]<1){
  5080. element.style["opacity"] = 1;
  5081. }
  5082. else{
  5083. element.style["opacity"] = 0;
  5084. }
  5085. e.preventDefault();
  5086. }
  5087. if(keycode == "KeyY"){
  5088. Gdocument.getElementById("pretty_top_settings").click();
  5089. Gdocument.getElementById("settings_close").click();
  5090. if(Gdocument.getElementById("settings_graphicsquality").value==1){
  5091. displayInChat("You must have medium or high quality enabled to use this feature.","#DA0808","#1EBCC1");
  5092. return "";
  5093. }
  5094.  
  5095.  
  5096. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  5097. var addto = {"children":[]};
  5098. for(var i = 0;i<parentDraw.children.length;i++){
  5099. if(parentDraw.children[i].constructor.name == "e"){
  5100. addto = parentDraw.children[i];
  5101. break;
  5102. }
  5103. }
  5104. var addto2 = {"children":[]};
  5105. for(var i = 0;i<addto.children.length;i++){
  5106. if(addto.children[i].constructor.name == "e"){
  5107. addto2 = addto.children[i];
  5108. break;
  5109. }
  5110. }
  5111. var checkxray = addto2.children[0];
  5112. var addto3 = addto2.children[0].children;
  5113. if(addto3.length==1){
  5114. checkxray = checkxray.children[0];
  5115. addto3 = addto3[0].children;
  5116. }
  5117. var xrayon = false;
  5118. if(checkxray.xrayon){
  5119. checkxray.xrayon = false;
  5120. xrayon = false;
  5121. }
  5122. else{
  5123. checkxray.xrayon = true;
  5124. xrayon = true;
  5125. }
  5126. if(xrayon){
  5127. displayInChat("Xray is now on.","#DA0808","#1EBCC1");
  5128. for(var i = 0;i<addto3.length;i++){
  5129. if(addto3[i].children.length>0){
  5130. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  5131. addto3[i].children[i3].visible = false;
  5132. if(addto3[i].children[i3].children.length>0){
  5133. addto3[i].children[i3].visible = true;
  5134. }
  5135. }
  5136. }
  5137. }
  5138.  
  5139. }
  5140. else{
  5141. displayInChat("Xray is now off.","#DA0808","#1EBCC1");
  5142. for(var i = 0;i<addto3.length;i++){
  5143. for(var i2 = 0;i2<addto3[i].children.length;i2++){
  5144. addto3[i].children[i2].visible = true;
  5145. }
  5146. }
  5147. }
  5148. }
  5149. e.preventDefault();
  5150. }
  5151. if(keycode == "KeyN"){
  5152. if(FollowCam == true){
  5153. displayInChat("Follow Camera is now off.","#DA0808","#1EBCC1");
  5154. FollowCam = false;
  5155. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  5156. var addto = {"children":[]};
  5157. for(var i = 0;i<parentDraw.children.length;i++){
  5158. if(parentDraw.children[i].constructor.name == "e"){
  5159. addto = parentDraw.children[i];
  5160. break;
  5161. }
  5162. }
  5163. var canv = 0;
  5164. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  5165. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  5166. canv = Gdocument.getElementById("gamerenderer").children[i];
  5167. break;
  5168. }
  5169. }
  5170. var width = parseInt(canv.style["width"]);
  5171. var height = parseInt(canv.style["height"]);
  5172. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  5173. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  5174. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  5175. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  5176. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  5177. pixiCircle.visible = false;
  5178. }
  5179. else{
  5180. pixiCircle.visible = true;
  5181. }
  5182. }
  5183. }
  5184. else{
  5185. displayInChat("Follow Camera is now on.","#DA0808","#1EBCC1");
  5186. FollowCam = true;
  5187. }
  5188. e.preventDefault();
  5189. }
  5190. if(keycode == "KeyV"){
  5191. if(autocam == true){
  5192. displayInChat("Auto Cam is now off.","#DA0808","#1EBCC1");
  5193. autocam = false
  5194. }
  5195. else{
  5196. displayInChat("Auto Cam is now on.","#DA0808","#1EBCC1");
  5197. autocam = true;
  5198. }
  5199. e.preventDefault();
  5200. }
  5201. if(keycode == "KeyO"){
  5202. if(heavybot == true){
  5203. displayInChat("Heavy bot is now off.","#DA0808","#1EBCC1");
  5204. heavybot = false;
  5205. }
  5206. else{
  5207. displayInChat("Heavy bot is now on.","#DA0808","#1EBCC1");
  5208. heavybot = true;
  5209. var keykeys = Object.keys(keyCodes);
  5210. var keyslist = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[5].children).slice(1);
  5211. for(var i = 0;i<keyslist.length;i++){
  5212. if(keykeys.includes(keyslist[i].textContent)){
  5213. heavy = keyCodes[keyslist[i].textContent];
  5214. break;
  5215. }
  5216. else{
  5217. heavy = keyslist[i].textContent.charCodeAt(0);
  5218. break
  5219. }
  5220. }
  5221. var keyslist2 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[6].children).slice(1);
  5222. for(var i = 0;i<keyslist2.length;i++){
  5223. if(keykeys.includes(keyslist2[i].textContent)){
  5224. special = keyCodes[keyslist2[i].textContent];
  5225. break;
  5226. }
  5227. else{
  5228. special = keyslist2[i].textContent.charCodeAt(0);
  5229. break
  5230. }
  5231. }
  5232. }
  5233. e.preventDefault();
  5234. }
  5235. if(keycode == "KeyU"){
  5236. if(aimbot == true){
  5237. displayInChat("Aimbot is now off.","#DA0808","#1EBCC1");
  5238. aimbot = false;
  5239. }
  5240. else{
  5241. displayInChat("Aimbot is now on.","#DA0808","#1EBCC1");
  5242. aimbot = true;
  5243. var keykeys = Object.keys(keyCodes);
  5244. var keyslist = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[1].children).slice(1);
  5245. var keyslist2 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[2].children).slice(1);
  5246. for(var i = 0;i<keyslist.length;i++){
  5247. if(keykeys.includes(keyslist[i].textContent)){
  5248. leftRight[0] = keyCodes[keyslist[i].textContent];
  5249. break;
  5250. }
  5251. else{
  5252. leftRight[0] = keyslist[i].textContent.charCodeAt(0);
  5253. break
  5254. }
  5255. }
  5256. for(var i = 0;i<keyslist2.length;i++){
  5257. if(keykeys.includes(keyslist2[i].textContent)){
  5258. leftRight[1] = keyCodes[keyslist2[i].textContent];
  5259. break;
  5260. }
  5261. else{
  5262. leftRight[1] = keyslist2[i].textContent.charCodeAt(0);
  5263. }
  5264. }
  5265. }
  5266. e.preventDefault();
  5267. }
  5268. }
  5269. if(!e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  5270. if(keycode == "Slash" && !(Gdocument.getElementById("gmeditor")?.style["transform"] == "scale(1)")){
  5271. if(Gdocument.getElementById("newbonklobby").style["display"]=="block" && Gdocument.getElementById("newbonklobby_chat_input").value == "" && Gdocument.getElementById("maploadwindowcontainer").style["display"]!="block" && Gdocument.getElementById("newbonklobby_chat_input").style["display"]==""){
  5272. Gdocument.getElementById("newbonklobby_chat_input").value = "/";
  5273. if(Gdocument.getElementById("newbonklobby_chat_input").style["pointer-events"] == "none"){
  5274. fire("keydown",{keyCode:13});
  5275. }
  5276. else{
  5277. Gdocument.getElementById("newbonklobby_chat_input").focus();
  5278. }
  5279. e.preventDefault();
  5280.  
  5281. }
  5282. else if(Gdocument.getElementById("ingamechatinputtext").style["visibility"]=="visible" && Gdocument.getElementById("ingamechatinputtext").style["display"]=="" && Gdocument.getElementById("mapeditorcontainer").style["display"]!="block" && Gdocument.getElementById("ingamechatinputtext").value == ""){
  5283. Gdocument.getElementById("ingamechatinputtext").value = "/";
  5284. if(!Gdocument.getElementById("ingamechatinputtext").classList.value.includes("ingamechatinputtextbg")){
  5285. fire("keydown",{keyCode:13});
  5286. }
  5287. else{
  5288. Gdocument.getElementById("ingamechatinputtext").focus();
  5289. }
  5290. e.preventDefault();
  5291.  
  5292. }
  5293. }
  5294. }
  5295. };
  5296.  
  5297. Gdocument.onkeydown = hotkeys;
  5298.  
  5299. Gwindow.addEventListener('resize',function(e){
  5300. debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
  5301. debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
  5302. scope.width = parseInt(Gdocument.getElementById("bonkiocontainer").style["width"])-20;
  5303. scope.height = parseInt(Gdocument.getElementById("bonkiocontainer").style["height"])-210;
  5304. logmenu.style["width"] = width.toString()+"px";
  5305. logmenu.style["height"] = height.toString()+"px";
  5306. logmenutopleft.style["width"] = (width/2).toString()+"px";
  5307. logmenutopright.style["width"] = (width/2).toString()+"px";
  5308. logmenutopright.style["left"] = (width/2).toString()+"px";
  5309. debuggerinput.style["width"] = width.toString()+"px";
  5310. debuggerinput.style["top"] = (height+90).toString()+"px";
  5311. debuggersendrecieve.style["top"] = (height+120).toString()+"px";
  5312. debuggerpausebutton.style["top"] = (height+150).toString()+"px";
  5313. debuggereval.style["width"] = (width-150).toString()+"px";
  5314. debuggereval.style["top"] = (height+120).toString()+"px";},true);
  5315.  
  5316.  
  5317. function timeout123() {
  5318. updateWssLog();
  5319. EVENTLOOPFUNCTION();
  5320. var now = Date.now();
  5321. var keys = Object.keys(playerids);
  5322. for(var i = 0;i<keys.length;i++){
  5323. if(!playerids[keys[i]]?.commands && autokickban>0 && playerids[keys[i]].peerID!="sandbox" && ishost && playerids[keys[i]].ratelimit.join+750<now){
  5324. SEND('42[9,{"banshortid":'+keys[i].toString()+',"kickonly":'+(autokickban == 1).toString()+'}]');
  5325. }
  5326. if(playerids[keys[i]].playerData){
  5327. if(playerids[keys[i]].playerData2){
  5328. if(playerids[keys[i]].playerData.transform){
  5329. playerids[keys[i]].playerData2.alive = true;
  5330. if(playerids[keys[i]].playerData2.timeStamp == 0){
  5331. playerids[keys[i]].playerData2.px = playerids[keys[i]].playerData.transform.position.x;
  5332. playerids[keys[i]].playerData2.py = playerids[keys[i]].playerData.transform.position.y;
  5333. playerids[keys[i]].playerData2.timeStamp = now;
  5334. }
  5335. else{
  5336. playerids[keys[i]].playerData2.xvel = (playerids[keys[i]].playerData2.px - playerids[keys[i]].playerData.transform.position.x)/(playerids[keys[i]].playerData2.timeStamp-now);
  5337. playerids[keys[i]].playerData2.yvel = (playerids[keys[i]].playerData2.py - playerids[keys[i]].playerData.transform.position.y)/(playerids[keys[i]].playerData2.timeStamp-now);
  5338. playerids[keys[i]].playerData2.px = playerids[keys[i]].playerData.transform.position.x;
  5339. playerids[keys[i]].playerData2.py = playerids[keys[i]].playerData.transform.position.y;
  5340. playerids[keys[i]].playerData2.timeStamp = now;
  5341. }
  5342. if(playerids[keys[i]].playerData2.timeStamp2 == 0){
  5343. playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.xvel;
  5344. playerids[keys[i]].playerData2.pvy = playerids[keys[i]].playerData2.yvel;
  5345. playerids[keys[i]].playerData2.timeStamp2 = now;
  5346. }
  5347. else{
  5348. playerids[keys[i]].playerData2.xacc = (playerids[keys[i]].playerData2.pvx - playerids[keys[i]].playerData2.xvel)/((playerids[keys[i]].playerData2.timeStamp2-now));
  5349. playerids[keys[i]].playerData2.yacc = (playerids[keys[i]].playerData2.pvy - playerids[keys[i]].playerData2.yvel)/((playerids[keys[i]].playerData2.timeStamp2-now));
  5350. playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.xvel;
  5351. playerids[keys[i]].playerData2.pvy = playerids[keys[i]].playerData2.yvel;
  5352. playerids[keys[i]].playerData2.timeStamp2 = now;
  5353. }
  5354. }
  5355. else{
  5356. if(playerids[keys[i]].playerData2.alive){
  5357.  
  5358. }
  5359. playerids[keys[i]].playerData2.alive = false;
  5360. }
  5361. }
  5362. else{
  5363. playerids[keys[i]].playerData2 = {alive:true,radius:12,timeStamp:0,timeStamp2:0,px:0,py:0,pvx:0,pvy:0,xacc:0,yacc:0,xvel:0,yvel:0,balance:0};
  5364. }
  5365. }
  5366. }
  5367. for(var i = 0;i<keys.length;i++){
  5368. if(!playerids[keys[i]].playerData2){
  5369. playerids[keys[i]].playerData2 = {alive:true,radius:12,timeStamp:0,timeStamp2:0,px:0,py:0,pvx:0,pvy:0,xacc:0,yacc:0,xvel:0,yvel:0,balance:0};
  5370. }
  5371. }
  5372. if(Gdocument.getElementById("redefineControls_table").children[0].children.length<=1 && keys.length>0){
  5373. Gdocument.getElementById("pretty_top_settings").click();
  5374. Gdocument.getElementById("settings_close").click();
  5375. }
  5376. if(pollactive[0] && pollactive[2]<now && ishost){
  5377. playerids[myid].ratelimit.poll = Date.now();
  5378. SEND("42"+JSON.stringify([4,{"type":"poll end","from":username}]));
  5379. var count = [0,0,0,0];
  5380. var keys = Object.keys(playerids);
  5381. for(var i = 0;i<keys.length;i++){
  5382. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  5383. count[playerids[keys[i]].vote.poll]++;
  5384. }
  5385. playerids[keys[i]].vote.poll = -1;
  5386. }
  5387. displayInChat("The poll ended due to time.","#DA0808","#1EBCC1");
  5388. for(var i = 0;i<count.length;i++){
  5389. if(count[i]>1){
  5390. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  5391. }
  5392. if(count[i]==1){
  5393. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  5394. }
  5395. }
  5396. displayInChat("The poll was:","#DA0808","#1EBCC1");
  5397. for(var i = 0;i<pollactive[3].length;i++){
  5398. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  5399. }
  5400. pollactive = [false,0,0,[]];
  5401. }
  5402. if(!ishost && sandboxcopyme!=-1){
  5403. sandboxcopyme = -1;
  5404. }
  5405. if(afkkill>0 && ishost){
  5406. var keys = Object.keys(playerids);
  5407. currentFrame = Math.floor((now - gameStartTimeStamp)/1000*30);
  5408. for(var i = 0; i<keys.length;i++){
  5409. if(typeof(playerids[keys[i]].lastmove)=="undefined"){
  5410. playerids[keys[i]].lastmove = now;
  5411. }
  5412. else{
  5413. if(playerids[keys[i]].playerData2?.alive && now-playerids[keys[i]].lastmove>=afkkill*1000 && now-gameStartTimeStamp>=afkkill*1000 && !killedids.includes(keys[i])){
  5414. killedids.push(keys[i]);
  5415. SEND('42[25,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  5416. RECIEVE('42[31,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  5417. break;
  5418. }
  5419. }
  5420. }
  5421. }
  5422. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  5423. clearmaprequests.style["display"] = "block";
  5424. refreshmaprequests.style["display"] = "block";
  5425. }
  5426. else{
  5427. clearmaprequests.style["display"] = "none";
  5428. refreshmaprequests.style["display"] = "none";
  5429. }
  5430. if(Gdocument.getElementById("gamerenderer").style["visibility"]=="hidden"){
  5431. Gdocument.getElementById("ingamewinner_scores").style["visibility"] = "unset";
  5432. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  5433. }
  5434. if(Gdocument.getElementById("maploadwindowmapscontainer").children.length>0 && maponclick == 0){
  5435. maponclick = Gdocument.getElementById("maploadwindowmapscontainer").children[0].onclick;
  5436. }
  5437. if((Gdocument.getElementById("sm_connectingContainer").style["visibility"] == "hidden" || Gdocument.getElementById("sm_connectingContainer").style["visibility"] == "") && (Gdocument.getElementById("roomlistcreatewindowcontainer").style["visibility"] == "hidden" || Gdocument.getElementById("roomlistcreatewindowcontainer").style["visibility"] == "")){
  5438. var chatbox = Gdocument.getElementById("newbonklobby_chat_content");
  5439. while (chatbox.firstChild) {
  5440. chatbox.removeChild(chatbox.firstChild);
  5441. }
  5442. rcaps_flag = false;
  5443. space_flag = false;
  5444. number_flag = false;
  5445. reverse_flag = false;
  5446. echo_list = [];
  5447. scroll = false;
  5448. FollowCam = false;
  5449. autocam = false;
  5450. aimbot = false;
  5451. recievedinitdata = false;
  5452. zoom = 1;
  5453. zoom2 = 1;
  5454. newzoom = 1;
  5455. newzoom2 = 1;
  5456. FFA = true;
  5457. mode = "b";
  5458. heavybot = false;
  5459. stopquickplay = 1;
  5460. roundsperqp = 1;
  5461. roundsperqp2 = 0;
  5462. reverseqp = false;
  5463. jointeam = -1;
  5464. checkboxhidden = false;
  5465. freejoin = false;
  5466. shuffle = false;
  5467. defaultmode = "";
  5468. recmodebool = false;
  5469. recteams = false;
  5470. autorecord = false;
  5471. pollactive = [false,0,0,[]];
  5472. pollactive2 = [false,0,[]];
  5473. afkkill = -1;
  5474. nextafter = 0;
  5475. jointext = "";
  5476. ishost = false;
  5477. parentDraw = 0;
  5478. sandboxplayerids = {};
  5479. sandboxcopyme = -1;
  5480. wintext = "";
  5481. sandboxon = false;
  5482. sandboxid = 200;
  5483. disabledkeys = [];
  5484. myid = -1;
  5485. autokickban = 0;
  5486. if(!bonkwss){
  5487. playerids = {};
  5488. }
  5489. qppaused = false;
  5490. nextafterbuffer = -1;
  5491. hostid = -1;
  5492. if(chatlog[chatlog.length-1]!="ROOM END"){
  5493. chatlog.push("ROOM END");
  5494. }
  5495. }
  5496. else{
  5497. if(chatlog[chatlog.length-1]=="ROOM END"){
  5498. chatlog.push("ROOM START");
  5499. }
  5500. }
  5501.  
  5502. if(Gdocument.getElementById("newbonklobby").style["display"]=="block"){
  5503. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="hidden";
  5504. }
  5505. else{
  5506. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="visible";
  5507.  
  5508. }
  5509. if(Gdocument.getElementsByClassName('newbonklobby_settings_button brownButton brownButton_classic buttonShadow brownButtonDisabled').length == 0){
  5510. ishost = true;
  5511. }
  5512. else{
  5513. ishost = actuallyhost;
  5514. }
  5515.  
  5516. if(Gdocument.getElementById("pretty_top_name")!=null){
  5517. username = Gdocument.getElementById("pretty_top_name").textContent;
  5518. if(myid!=-1){
  5519. username = playerids[myid].userName;
  5520. }
  5521. }
  5522. try{
  5523. Last_message = lastmessage()
  5524. } catch{
  5525. Last_message = "";
  5526. }
  5527. if (Laster_message != Last_message){
  5528. Laster_message = Last_message;
  5529. if(changed_chat==false){
  5530. new_message = true;
  5531. }
  5532. else{
  5533. changed_chat = false;
  5534. }
  5535. }
  5536. if(new_message){
  5537. chatlog.push(Last_message);
  5538. var lm = "";
  5539. try{
  5540. lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  5541. if(typeof(lm[0].parentElement.style["parsed"]) == 'undefined'){
  5542. if (lm[0].className == "newbonklobby_chat_msg_colorbox"){
  5543. lm[2].innerHTML = urlify(lm[2].innerHTML);
  5544. Laster_message = lastmessage();
  5545. lm[0].parentElement.style["parsed"] = true;
  5546. }
  5547. if (lm[0].className == "newbonklobby_chat_status"){
  5548. lm[0].innerHTML = urlify(lm[0].innerHTML);
  5549. Laster_message = lastmessage();
  5550. lm[0].parentElement.style["parsed"] = true;
  5551. }
  5552. }
  5553. }
  5554. catch{
  5555. lm = "";
  5556. }
  5557.  
  5558. if(Last_message.indexOf("@"+username)!=-1 && npermissions == 1){
  5559. if(Notification.requestPermission()){
  5560. var n = new Notification(Last_message);
  5561. }
  5562. }
  5563.  
  5564. try{
  5565. lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  5566. if(typeof(lm[0].parentElement.style["parsed"])=='undefined'){
  5567. if(lm[0].className == "ingamechatname"){
  5568. lm[1].innerHTML = urlify(lm[1].innerHTML);
  5569. Laster_message = lastmessage();
  5570. lm[0].parentElement.style["parsed"] = true;
  5571. }
  5572. if(lm[0].className == ""){
  5573. lm[0].innerHTML = urlify(lm[0].innerHTML);
  5574. Laster_message = lastmessage();
  5575. lm[0].parentElement.style["parsed"] = true;
  5576. }
  5577. }
  5578. }
  5579. catch{
  5580. lm = "";
  5581. }
  5582. if(text2speech){
  5583. if(!sayer.speaking){
  5584. if(Last_message.includes(": ")){
  5585. speech.text = Last_message.substring(0,Last_message.indexOf(":")).toLowerCase();
  5586. speech.rate = 2.25;
  5587. sayer.speak(speech);
  5588. speech.text = Last_message.substring(Last_message.indexOf(": ")+3).toLowerCase();
  5589. speech.rate = 1.25;
  5590. sayer.speak(speech);
  5591. }
  5592. else{
  5593. speech.text = Last_message.toLowerCase();
  5594. sayer.speak(speech);
  5595. }
  5596. }
  5597. }
  5598. }
  5599. if (ishost==true && new_message){
  5600. for(i=0;i<banned.length;i++){
  5601. if(Last_message.startsWith("* "+banned[i]+" has joined the game")){
  5602. chat2("/kick '"+banned[i]+"'");
  5603. }
  5604. }
  5605. }
  5606. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden" && ishost){
  5607. roundsperqp2 = 0;
  5608. }
  5609. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && ishost){
  5610. if(Gdocument.getElementById("ingamewinner").style["parsed"] != true){
  5611. if(stopquickplay!=1){
  5612. roundsperqp2++;
  5613. }
  5614. if(autorecord){
  5615. Gdocument.getElementById("pretty_top_replay").click();
  5616. }
  5617. }
  5618. if(Gdocument.getElementById("ingamewinner").style["parsed"] != true && wintext!="" && Gdocument.getElementById("ingamewinner_bottom").textContent!="DRAW"){
  5619. chat(flag_manage(wintext.replaceAll("username",Gdocument.getElementById("ingamewinner_top").textContent)));
  5620. }
  5621. Gdocument.getElementById("ingamewinner").style["parsed"] = true;
  5622. }
  5623. else{
  5624. Gdocument.getElementById("ingamewinner").style["parsed"] = false;
  5625. }
  5626. if(ishost && stopquickplay == 0){
  5627. if(checkboxhidden){
  5628. checkboxhidden = false;
  5629. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  5630. for(var i = 0; i<classes.length;i++){
  5631. classes[i].style["display"] = "block";
  5632. classes[i].className = "quickplaycheckbox quickplaychecked";
  5633. }
  5634. Gdocument.getElementById('clearallcheckboxes').style["display"] = "block";
  5635.  
  5636. }
  5637. if(nextafter>0 && gameStartTimeStamp+nextafter*1000<=now && Gdocument.getElementById("gamerenderer").style["visibility"] != "hidden" && dontswitch == false && Gdocument.getElementById("ingamewinner").style["visibility"]!="inherit" && !qppaused){
  5638. roundsperqp2 = 0;
  5639. if(shuffle){
  5640. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5641. var available = [];
  5642. var availableindexes = [];
  5643. var notempty = false;
  5644. for(var i = 0; i<e.length;i++){
  5645. var a = false;
  5646. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5647. available.push(a);
  5648. if(a){
  5649. availableindexes.push(i);
  5650. notempty = true;
  5651. }
  5652. }
  5653. if(notempty){
  5654. if(availableindexes.length!=1){
  5655. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  5656. }
  5657. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  5658. }
  5659. }
  5660. else{
  5661. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5662. var available = [];
  5663. var availableindexes = [];
  5664. var notempty = false;
  5665. for(var i = 0; i<e.length;i++){
  5666. var a = false;
  5667. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5668. available.push(a);
  5669. if(a){
  5670. availableindexes.push(i);
  5671. notempty = true;
  5672. }
  5673. }
  5674. if(notempty){
  5675. var above = [];
  5676. for(var i = 0;i<availableindexes.length;i++){
  5677. if(availableindexes[i]>quicki && !reverseqp){
  5678. above.push(availableindexes[i]);
  5679. }
  5680. else if(availableindexes[i]<quicki && reverseqp){
  5681. above.push(availableindexes[i]);
  5682. }
  5683. }
  5684. if(above.length>0){
  5685. quicki = above[0];
  5686. if(reverseqp){
  5687. above[above.length-1];
  5688. }
  5689. }
  5690. else{
  5691. quicki = availableindexes[0];
  5692. if(reverseqp){
  5693. quicki = availableindexes[availableindexes.length-1];
  5694. }
  5695. }
  5696. }
  5697. }
  5698. startedinqp = true;
  5699. dontswitch = true;
  5700. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  5701. }
  5702. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && dontswitch == false && !document.hidden && !qppaused){
  5703. if(roundsperqp2>=roundsperqp){
  5704. if(shuffle){
  5705. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5706. var available = [];
  5707. var availableindexes = [];
  5708. var notempty = false;
  5709. for(var i = 0; i<e.length;i++){
  5710. var a = false;
  5711. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5712. available.push(a);
  5713. if(a){
  5714. availableindexes.push(i);
  5715. notempty = true;
  5716. }
  5717. }
  5718. if(notempty){
  5719.  
  5720. if(availableindexes.length!=1){
  5721. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  5722. }
  5723. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  5724. }
  5725. }
  5726. else{
  5727. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5728. var available = [];
  5729. var availableindexes = [];
  5730. var notempty = false;
  5731. for(var i = 0; i<e.length;i++){
  5732. var a = false;
  5733. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5734. available.push(a);
  5735. if(a){
  5736. availableindexes.push(i);
  5737. notempty = true;
  5738. }
  5739. }
  5740. if(notempty){
  5741. var above = [];
  5742. for(var i = 0;i<availableindexes.length;i++){
  5743. if(availableindexes[i]>quicki && !reverseqp){
  5744. above.push(availableindexes[i]);
  5745. }
  5746. else if(availableindexes[i]<quicki && reverseqp){
  5747. above.push(availableindexes[i])
  5748. }
  5749. }
  5750. if(above.length>0){
  5751. quicki = above[0];
  5752. if(reverseqp){
  5753. quicki = above[above.length-1];
  5754. }
  5755. }
  5756. else{
  5757. quicki = availableindexes[0];
  5758. if(reverseqp){
  5759. quicki = availableindexes[availableindexes.length-1];
  5760. }
  5761.  
  5762. }
  5763. }
  5764. }
  5765. }
  5766. transitioning = true;
  5767. startedinqp = true;
  5768. map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  5769. dontswitch = true;
  5770. setTimeout(function(){Gdocument.getElementById("ingamewinner").style["visibility"]="hidden"; dontswitch = false;},timedelay);
  5771. }
  5772. }
  5773. else{
  5774. if(!checkboxhidden){
  5775. checkboxhidden = true;
  5776. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  5777. for(var i = 0; i<classes.length;i++){
  5778. classes[i].style["display"] = "none";
  5779. classes[i].className = "quickplaycheckbox quickplayunchecked";
  5780. }
  5781. Gdocument.getElementById('clearallcheckboxes').style["display"] = "none";
  5782. }
  5783. }
  5784. new_message = false;
  5785. };
  5786. });

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址