Bonk Commands

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

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

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

QingJ © 2025

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