Bonk Commands

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

  1. // ==UserScript==
  2. // @name Bonk Commands
  3. // @namespace https://gf.qytechs.cn/en/scripts/451341-bonk-commands
  4. // @version 20.7
  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. // @match https://bonkisback.io/*
  9. // @match https://multiplayer.gg/physics/*
  10. // @run-at document-idle
  11. // @grant none
  12. // @unwrap
  13. // ==/UserScript==
  14.  
  15.  
  16. function BonkCommandsScriptInjector(f){
  17. if(window.location == window.parent.location){
  18. if(document.readyState == "complete"){f();}
  19. else{document.addEventListener('readystatechange',function(){setTimeout(f,1500);});}
  20. }
  21. }
  22. BonkCommandsScriptInjector(function(){
  23. var scope = window;
  24. scope.scope = scope;
  25. scope.Gwindow = document.getElementById("maingameframe").contentWindow;
  26. scope.Gdocument = document.getElementById("maingameframe").contentDocument;
  27. Gwindow.Gwindow = window;
  28. Gwindow.Gdocument = document;
  29. scope.link2pastebin = "https://pastebin.com/2b8XqqYu";
  30. scope.link2greasyfork = "https://gf.qytechs.cn/en/scripts/451341-bonk-commands";
  31. if(typeof(scope.injectedBonkCommandsScript)=='undefined'){
  32. scope.injectedBonkCommandsScript = true;
  33. }
  34. else{
  35. clearInterval(injectedBonkCommandsScript);
  36. }
  37. scope.GENERATE_COPRIME_NUMBER = function(mini = 0,maxi = 0,coprimewith = 0,choices = []){
  38. if(choices.length == 0){
  39. for(var i = mini;i<maxi+1;i++){
  40. choices.push(i);
  41. }
  42. }
  43. firstTry = choices[Math.floor(Math.random()*choices.length)];
  44. for(var i = 2; i<firstTry+1;i++){
  45. if(firstTry%i == 0 && coprimewith%i == 0){
  46. choices.splice(choices.indexOf(firstTry),1);
  47. if(choices.length == 0){
  48. return 0;
  49. }
  50. return GENERATE_COPRIME_NUMBER(mini,maxi,coprimewith,choices);
  51. }
  52. }
  53. return firstTry;
  54. };
  55. scope.GENERATE_PRIME_NUMBER = function(mini = 0,maxi = 0,choices = []){
  56. if(choices.length == 0){
  57. for(var i = mini;i<maxi+1;i++){
  58. choices.push(i);
  59. }
  60. }
  61. firstTry = choices[Math.floor(Math.random()*choices.length)];
  62. for(var i = 2; i<Math.floor(Math.sqrt(firstTry)+1);i++){
  63. if(i!=firstTry){
  64. if(firstTry%i == 0){
  65. choices.splice(choices.indexOf(firstTry),1);
  66. if(choices.length == 0){
  67. return 0;
  68. }
  69. return GENERATE_PRIME_NUMBER(mini,maxi,choices);
  70. }
  71. }
  72. }
  73. return firstTry;
  74. };
  75. scope.SHUFFLE_LIST = function(x){
  76. var nl = x.slice();
  77. for(var i = nl.length - 1;i>0;i--){
  78. var r = Math.floor(Math.random()*(i+1));
  79. var t = nl[i];
  80. nl[i] = nl[r];
  81. nl[r] = t;
  82. }
  83. return nl;
  84. };
  85. scope.str2ab = function(str) {
  86. const buf = new ArrayBuffer(str.length);
  87. const bufView = new Uint8Array(buf);
  88. for (let i = 0, strLen = str.length; i < strLen; i++) {
  89. bufView[i] = str.charCodeAt(i);
  90. }
  91. return buf;
  92. };
  93. scope.ab2str = function(buffer) {
  94. return String.fromCharCode.apply(null, new Uint8Array(buffer));
  95. };
  96. scope.GENERATE_KEYS = async function(){
  97. return crypto.subtle.generateKey({name: "RSA-OAEP",modulusLength: 2048,publicExponent: new Uint8Array([1, 0, 1]),hash: {name: "SHA-256"}},true,["encrypt","decrypt"]);
  98. };
  99. scope.CRYPT_NUMBER = function(key, data){
  100. result = 1;
  101. for(var i = 0;i<key[1];i++){
  102. result*=data;
  103. result = result%key[0];
  104. }
  105. return result%key[0];
  106. };
  107. scope.ENCRYPT_MESSAGE = async function(key,data){
  108. try{
  109. var encrypted = await window.crypto.subtle.encrypt(
  110. {
  111. name: "RSA-OAEP"
  112. },
  113. key,
  114. new TextEncoder().encode(data)
  115. );
  116. return btoa(ab2str(encrypted));
  117. }
  118. catch(E){
  119. console.log(E);
  120. return 0;
  121. }
  122. };
  123. scope.DECRYPT_MESSAGE = async function(key,data){
  124. try{
  125. var decrypted = await window.crypto.subtle.decrypt(
  126. {
  127. name: "RSA-OAEP"
  128. },
  129. key,
  130. str2ab(atob(data))
  131. );
  132. return new TextDecoder().decode(decrypted);
  133. }
  134. catch{
  135. return 0;
  136. }
  137. };
  138. scope.IMPORT_KEY = async function(key){
  139. return await crypto.subtle.importKey("spki", str2ab(atob(key)),public_key.algorithm,true,["encrypt"]);
  140. };
  141. scope.EXPORT_KEY = async function(key){
  142. var result = await crypto.subtle.exportKey("spki",key);
  143. return btoa(ab2str(result));
  144. };
  145. scope.loadMap = function (m, encode = true) {
  146. var mapdata = m;
  147. if (encode) {
  148. var mapdata = encodeToDatabase(m);
  149. }
  150. RECIEVE('42' + JSON.stringify([29, mapdata]));
  151. SEND('42' + JSON.stringify([23, { "m": mapdata }]));
  152. };
  153. if(typeof(scope.textdecoder)=='undefined'){scope.textdecoder = new Gwindow.TextDecoder;}
  154. if(typeof(scope.textencoder)=='undefined'){scope.textencoder = new Gwindow.TextEncoder;}
  155. class bytebuffer2 {
  156. constructor() {
  157. var g1d = [arguments];
  158. this.index = 0;
  159. this.buffer = new ArrayBuffer(100*1024);
  160. this.view = new DataView(this.buffer);
  161. this.implicitClassAliasArray = [];
  162. this.implicitStringArray = [];
  163. this.bodgeCaptureZoneDataIdentifierArray = [];
  164. }
  165. readByte() {
  166. var N0H = [arguments];
  167. N0H[4] = this.view.getUint8(this.index);
  168. this.index += 1;
  169. return N0H[4];
  170. }
  171. writeByte(z0w) {
  172. var v8$ = [arguments];
  173. this.view.setUint8(this.index, v8$[0][0]);
  174. this.index += 1;
  175. }
  176. readInt() {
  177. var A71 = [arguments];
  178. A71[6] = this.view.getInt32(this.index);
  179. this.index += 4;
  180. return A71[6];
  181. }
  182. writeInt(W6i) {
  183. var p5u = [arguments];
  184. this.view.setInt32(this.index, p5u[0][0]);
  185. this.index += 4;
  186. }
  187. readShort() {
  188. var R1R = [arguments];
  189. R1R[9] = this.view.getInt16(this.index);
  190. this.index += 2;
  191. return R1R[9];
  192. }
  193. writeShort(H8B) {
  194. var d_3 = [arguments];
  195. this.view.setInt16(this.index, d_3[0][0]);
  196. this.index += 2;
  197. }
  198. readUint() {
  199. var W2$ = [arguments];
  200. W2$[8] = this.view.getUint32(this.index);
  201. this.index += 4;
  202. return W2$[8];
  203. }
  204. writeUint(B2X) {
  205. var f8B = [arguments];
  206. this.view.setUint32(this.index, f8B[0][0]);
  207. this.index += 4;
  208. }
  209. readBoolean() {
  210. var h6P = [arguments];
  211. h6P[6] = this.readByte();
  212. return h6P[6] == 1;
  213. }
  214. writeBoolean(Y3I) {
  215. var l79 = [arguments];
  216. if (l79[0][0]) {
  217. this.writeByte(1);
  218. } else {
  219. this.writeByte(0);
  220. }
  221. }
  222. readDouble() {
  223. var V60 = [arguments];
  224. V60[4] = this.view.getFloat64(this.index);
  225. this.index += 8;
  226. return V60[4];
  227. }
  228. writeDouble(z4Z) {
  229. var O41 = [arguments];
  230. this.view.setFloat64(this.index, O41[0][0]);
  231. this.index += 8;
  232. }
  233. readFloat() {
  234. var I0l = [arguments];
  235. I0l[5] = this.view.getFloat32(this.index);
  236. this.index += 4;
  237. return I0l[5];
  238. }
  239. writeFloat(y4B) {
  240. var B0v = [arguments];
  241. this.view.setFloat32(this.index, B0v[0][0]);
  242. this.index += 4;
  243. }
  244. readUTF() {
  245. var d6I = [arguments];
  246. d6I[8] = this.readByte();
  247. d6I[7] = this.readByte();
  248. d6I[9] = d6I[8] * 256 + d6I[7];
  249. d6I[1] = new Uint8Array(d6I[9]);
  250. for (d6I[6] = 0; d6I[6] < d6I[9]; d6I[6]++) {
  251. d6I[1][d6I[6]] = this.readByte();
  252. }
  253. return textdecoder.decode(d6I[1]);
  254. }
  255. writeUTF(L3Z) {
  256. var Z75 = [arguments];
  257. Z75[4] = textencoder.encode(Z75[0][0]);
  258. Z75[3] = Z75[4].length;
  259. Z75[5] = Math.floor(Z75[3]/256);
  260. Z75[8] = Z75[3] % 256;
  261. this.writeByte(Z75[5]);
  262. this.writeByte(Z75[8]);
  263. Z75[7] = this;
  264. Z75[4].forEach(I_O);
  265. function I_O(s0Q, H4K, j$o) {
  266. var N0o = [arguments];
  267. Z75[7].writeByte(N0o[0][0]);
  268. }
  269. }
  270. toBase64() {
  271. var P4$ = [arguments];
  272. P4$[4] = "";
  273. P4$[9] = new Uint8Array(this.buffer);
  274. P4$[8] = this.index;
  275. for (P4$[7] = 0; P4$[7] < P4$[8]; P4$[7]++) {
  276. P4$[4] += String.fromCharCode(P4$[9][P4$[7]]);
  277. }
  278. return Gwindow.btoa(P4$[4]);
  279. }
  280. fromBase64(W69, A8Q) {
  281. var o0n = [arguments];
  282. o0n[8] = Gwindow.pako;
  283. o0n[6] = Gwindow.atob(o0n[0][0]);
  284. o0n[9] = o0n[6].length;
  285. o0n[4] = new Uint8Array(o0n[9]);
  286. for (o0n[1] = 0; o0n[1] < o0n[9]; o0n[1]++) {
  287. o0n[4][o0n[1]] = o0n[6].charCodeAt(o0n[1]);
  288. }
  289. if (o0n[0][1] === true) {
  290. o0n[5] = o0n[8].inflate(o0n[4]);
  291. o0n[4] = o0n[5];
  292. }
  293. this.buffer = o0n[4].buffer.slice(
  294. o0n[4].byteOffset,
  295. o0n[4].byteLength + o0n[4].byteOffset
  296. );
  297. this.view = new DataView(this.buffer);
  298. this.index = 0;
  299. }
  300. };
  301. if(typeof(scope.originalSend)=='undefined'){scope.originalSend = Gwindow.WebSocket.prototype.send;}
  302. if(typeof(scope.originalDatenow)=='undefined'){scope.originalDatenow = Gwindow.Date.now;}
  303. if(typeof(scope.originalXMLOpen)=='undefined'){scope.originalXMLOpen = Gwindow.XMLHttpRequest.prototype.open;}
  304. if(typeof(scope.originalXMLSend)=='undefined'){scope.originalXMLSend = Gwindow.XMLHttpRequest.prototype.send;}
  305. if(typeof(scope.searchrequested)=='undefined'){scope.searchrequested = 0;}
  306. if(typeof(scope.originalDrawCircle)=='undefined'){scope.originalDrawCircle = Gwindow.PIXI.Graphics.prototype.drawCircle;}
  307. if(typeof(scope.parentDraw)=='undefined'){scope.parentDraw = 0;}
  308. if(typeof(scope.pixiCircle)=='undefined'){scope.pixiCircle = new Gwindow.PIXI.Graphics();}
  309. if(typeof(scope.container)=='undefined'){scope.container = new Gwindow.PIXI.Container();container.addChild(pixiCircle);}
  310. if(typeof(scope.canvasWidth)=='undefined'){scope.canvasWidth = -1;}
  311. if(typeof(scope.savedrooms)=='undefined'){scope.savedrooms = [];}
  312. if(typeof(scope.inroom)=='undefined'){scope.inroom = false;}
  313. if(typeof(scope.currentroomaddress)=='undefined'){scope.currentroomaddress = -1;}
  314. if(typeof(scope.savedroomsdata)=='undefined'){scope.savedroomsdata = {};}
  315. if(typeof(scope.jukeboxplayerURL)=='undefined'){scope.jukeboxplayerURL = "";}
  316. if(typeof(scope.jukeboxplayervolume)=='undefined'){scope.jukeboxplayervolume = 20;}
  317. if(typeof(scope.gameStartTimeStamp)=='undefined'){scope.gameStartTimeStamp = 0;}
  318. scope.checkInstance = async function(index){
  319. var doesitwork = false;
  320. await fetch(pipedurllist[index]+"dQw4w9WgXcQ").then(
  321. function(r){
  322. return r.json();
  323. }
  324. ).then(async function(r){
  325. if (r.audioStreams && !r.error){
  326. for(var i2 = 0;i2<r.audioStreams.length;i2++){
  327. if(r.audioStreams[i2].url){
  328. try{
  329. var f = await fetch(r.audioStreams[i2].url);
  330. if(f.ok){
  331. doesitwork = true;
  332. return;
  333. }
  334. }
  335. catch(e){}
  336. }
  337. }
  338. }
  339. }).catch(function(e){});
  340. if(!doesitwork){
  341. return -1;
  342. }
  343. return index;
  344. };
  345. scope.checkJukeboxStream = async function(index,id){
  346. var doesitwork = false;
  347. var urlreturn = [];
  348. await fetch(pipedurllist[index]+id).then(
  349. function(r){
  350. return r.json();
  351. }
  352. ).then(async function(r){
  353. if (r.audioStreams && !r.error){
  354. for(var i2 = 0;i2<r.audioStreams.length;i2++){
  355. if(r.audioStreams[i2].url){
  356. try{
  357. var f = await fetch(r.audioStreams[i2].url);
  358. if(f.ok){
  359. doesitwork = true;
  360. urlreturn = [r.audioStreams[i2].url,r.title,r.uploader];
  361. return;
  362. }
  363. }
  364. catch(e){}
  365. }
  366. }
  367. }
  368. }).catch(function(e){});
  369. if(!doesitwork){
  370. return -1;
  371. }
  372. return urlreturn;
  373. };
  374. scope.checkInstances = async function (){
  375. pipedindexes = [];
  376. for (var index = 0;index<pipedurllist.length;index++){
  377. checkInstance(index).then(function(value){
  378. if(value!=-1){
  379. pipedindexes.push(value);
  380. }
  381. });
  382. }
  383. };
  384. if(typeof(scope.pipedurllist)=='undefined'){
  385. scope.pipedurllist = [
  386. "https://pipedapi.kavin.rocks/streams/",
  387. "https://pipedapi.syncpundit.io/streams/",
  388. "https://api-piped.mha.fi/streams/",
  389. "https://piped-api.garudalinux.org/streams/",
  390. "https://pipedapi.rivo.lol/streams/",
  391. "https://pipedapi.leptons.xyz/streams/",
  392. "https://piped-api.lunar.icu/streams/",
  393. "https://ytapi.dc09.ru/streams/",
  394. "https://piped.tokhmi.xyz/streams/",
  395. "https://pipedapi.aeong.one/streams/"];
  396. scope.pipedindexes = [];
  397. checkInstances();
  398. }
  399. if(typeof(scope.requestAnimationFrameOriginal)=='undefined'){scope.requestAnimationFrameOriginal = Gwindow.requestAnimationFrame;}
  400. if(typeof(scope.bonkwss)=='undefined'){scope.bonkwss = 0;}
  401. if(typeof(scope.bonkwssextra)=='undefined'){scope.bonkwssextra = [];}
  402. if(typeof(scope.chatlog)=='undefined'){scope.chatlog = ["ROOM START"];}
  403. if(typeof(scope.wsssendrecievelog)=='undefined'){scope.wsssendrecievelog = [];}
  404. if(typeof(scope.wsssendlog)=='undefined'){scope.wsssendlog = [];}
  405. if(typeof(scope.wssrecievelog)=='undefined'){scope.wssrecievelog = [];}
  406. if(typeof(scope.wsslogpaused)=='undefined'){scope.wsslogpaused = false;}
  407. if(typeof(scope.debuggeropen)=='undefined'){scope.debuggeropen = false;}
  408. if(typeof(scope.debuggercount)=='undefined'){scope.debuggercount = true;}
  409. if(typeof(scope.packetcount)=='undefined'){scope.packetcount = 0;}
  410. if(typeof(scope.requestedmaps)=='undefined'){scope.requestedmaps = [];}
  411. if(typeof(scope.maponclick)=='undefined'){scope.maponclick = 0;}
  412. if(typeof(scope.LZString)=='undefined'){scope.LZString = Gwindow.LZString;}
  413. if(typeof(scope.PSON)=='undefined'){scope.PSON = Gwindow.dcodeIO.PSON;}
  414. if(typeof(scope.bytebuffer)=='undefined'){scope.bytebuffer = Gwindow.dcodeIO.ByteBuffer;}
  415. if(typeof(scope.speech)=='undefined'){scope.speech = new SpeechSynthesisUtterance();speech.pitch = 0.75;}
  416. if(typeof(scope.sayer)=='undefined'){scope.sayer = speechSynthesis;sayer.volume = 0.5;sayer.rate = 1.25;}
  417. if(typeof(scope.pollactive)=='undefined'){scope.pollactive = [false,0,0,[]];}
  418. if(typeof(scope.pollactive2)=='undefined'){scope.pollactive2 = [false,0,[]];}
  419. if(typeof(scope.mode)=='undefined'){scope.mode = '';}
  420. if(typeof(scope.FFA)=='undefined'){scope.FFA = true;}
  421. if(typeof(scope.recording)=='undefined'){scope.recording = false;}
  422. if(typeof(scope.recordingdata)=='undefined'){scope.recordingdata = [];}
  423. if(typeof(scope.recorddata)=='undefined'){scope.recorddata = {};}
  424. if(typeof(scope.recordingid)=='undefined'){scope.recordingid = -1;}
  425. if (typeof (scope.currentmap) == 'undefined') { scope.currentmap = []; }
  426.  
  427. if(typeof(scope.wordlist)=='undefined'){
  428. scope.wordlist = [];
  429. fetch("https://api.github.com/repos/first20hours/google-10000-english/contents/20k.txt").then(function(data){
  430. return data.json();
  431. }).then(function(data){
  432. fetch("https://api.github.com/repos/first20hours/google-10000-english/git/blobs/"+data.sha).then(function(data){
  433. return data.json();
  434. }).then(function(data){
  435. scope.wordlist = atob(data.content).split("\n");
  436. });
  437. });
  438. }
  439. if(typeof(scope.allstyles)=='undefined'){scope.allstyles = {};}
  440. if(typeof(scope.mystyle)=='undefined'){scope.mystyle = [0,0,0];}
  441. 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]);}
  442. if(typeof(scope.sandboxon)=='undefined'){scope.sandboxon = false;}
  443. if(typeof(scope.sandboxid)=='undefined'){scope.sandboxid = 200;}
  444. if(typeof(scope.playerids)=='undefined'){scope.playerids = {};}
  445. if(typeof(scope.delplayerids)=='undefined'){scope.delplayerids = {};}
  446. if(typeof(scope.myid)=='undefined'){scope.myid = -1;}
  447. if(typeof(scope.hostid)=='undefined'){scope.hostid = -1;}
  448. if(typeof(scope.sandboxplayerids)=='undefined'){scope.sandboxplayerids = {};}
  449. if(typeof(scope.originalMapLoad)=='undefined'){scope.originalMapLoad = Gdocument.getElementById("maploadwindowmapscontainer").appendChild;}
  450. if(typeof(scope.originalLobbyChat)=='undefined'){scope.originalLobbyChat = Gdocument.getElementById("newbonklobby_chat_content").appendChild;}
  451. if(typeof(scope.originalIngameChat)=='undefined'){scope.originalIngameChat = Gdocument.getElementById("ingamechatcontent").appendChild;}
  452. if(typeof(scope.private_chat_keys)=='undefined'){GENERATE_KEYS().then(function(e){scope.private_chat_keys = e;scope.private_key = private_chat_keys.privateKey;scope.public_key = private_chat_keys.publicKey;});}
  453. if(typeof(scope.jukeboxplayer)=='undefined'){
  454. scope.jukeboxplayer = Gdocument.createElement("audio");
  455. jukeboxplayer.controls = true;
  456. jukeboxplayer.loop = true;
  457. }
  458. if(Gdocument.getElementById("savedroombutton") == null){
  459. scope.savedroombutton = Gdocument.createElement("div");
  460. savedroombutton.id = "savedroombutton";
  461. savedroombutton.className = "brownButton brownButton_classic buttonShadow brownButtonDisabled";
  462. savedroombutton.textContent = "Save Room";
  463. savedroombutton.style["left"] = "120px";
  464. savedroombutton.style["position"] = "absolute";
  465. savedroombutton.style["width"] = "90px";
  466. savedroombutton.style["height"] = "30px";
  467. savedroombutton.style["color"] = "#ffffff";
  468. savedroombutton.style["text-align"] = "center";
  469. savedroombutton.style["vertical-align"] = "middle";
  470. savedroombutton.style["line-height"] = "30px";
  471. savedroombutton.style["right"] = "0";
  472. savedroombutton.style["cursor"] = "pointer";
  473. savedroombutton.style["bottom"] = "10px";
  474. savedroombutton.style["margin"] = "auto";
  475. savedroombutton.style["bottom"] = "10px";
  476. savedroombutton.onclick = function(){
  477. if(!savedrooms.includes(currentroomaddress) && currentroomaddress!=-1){
  478. savedrooms.push(currentroomaddress);
  479. savedroomsdata[currentroomaddress] = {"exists":true};
  480. }
  481. Gdocument.getElementById("sm_connectingWindowCancelButton").click();
  482. };
  483. Gdocument.getElementById("sm_connectingWindowCancelButton").style["left"] = "-120px";
  484. Gdocument.getElementById("sm_connectingWindow").appendChild(savedroombutton)
  485. }
  486. if(Gdocument.getElementById("maploadtypedropdowntitlerequested") == null){
  487. scope.clearmaprequests = Gdocument.createElement("div");
  488. clearmaprequests.id = "clearmaprequests";
  489. clearmaprequests.classList.value = "brownButton brownButton_classic buttonShadow";
  490. clearmaprequests.textContent = "Clear";
  491. clearmaprequests.style["position"] = "absolute";
  492. clearmaprequests.style["display"] = "none";
  493. if(typeof(ishost)!='undefined'){
  494. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  495. clearmaprequests.style["display"] = "block";
  496. }
  497. }
  498. clearmaprequests.style["right"] = "306px";
  499. clearmaprequests.style["top"] = "57px";
  500. clearmaprequests.style["height"] = "23px";
  501. clearmaprequests.style["width"] = "47px";
  502. clearmaprequests.style["line-height"] = "23px";
  503. clearmaprequests.style["font-size"] = "14px";
  504. clearmaprequests.addEventListener("click",function(){
  505. requestedmaps = [];
  506. Gdocument.getElementById("maploadwindowstatustext").style["visibility"] = "inherit";
  507. Gdocument.getElementById("maploadwindowstatustext").textContent = "No Maps";
  508. while(Gdocument.getElementById("maploadwindowmapscontainer").children.length>0){
  509. Gdocument.getElementById("maploadwindowmapscontainer").removeChild(Gdocument.getElementById("maploadwindowmapscontainer").firstChild);
  510. }
  511. });
  512. Gdocument.getElementById("maploadwindow").insertBefore(clearmaprequests,Gdocument.getElementById("maploadwindowsearchinput"));
  513. scope.refreshmaprequests = Gdocument.createElement("div");
  514. refreshmaprequests.id = "refreshmaprequests";
  515. refreshmaprequests.classList.value = "brownButton brownButton_classic buttonShadow";
  516. refreshmaprequests.textContent = "Refresh";
  517. refreshmaprequests.style["position"] = "absolute";
  518. refreshmaprequests.style["display"] = "none";
  519. if(typeof(ishost)!='undefined'){
  520. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  521. refreshmaprequests.style["display"] = "block";
  522. }
  523. }
  524. refreshmaprequests.style["right"] = "357px";
  525. refreshmaprequests.style["top"] = "57px";
  526. refreshmaprequests.style["height"] = "23px";
  527. refreshmaprequests.style["width"] = "47px";
  528. refreshmaprequests.style["line-height"] = "23px";
  529. refreshmaprequests.style["font-size"] = "14px";
  530. refreshmaprequests.addEventListener("click",function(){
  531. searchrequested = 1;
  532. Gdocument.getElementById("maploadtypedropdowntitle").click();
  533. Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdownrequested.textContent;
  534. dropdownrequested.style["display"] = "none";
  535. clearmaprequests.style["display"] = "block";
  536. refreshmaprequests.style["display"] = "block";
  537. Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
  538. Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
  539. Gdocument.getElementById("maploadtypedropdownoption10").click();
  540. });
  541. Gdocument.getElementById("maploadwindow").insertBefore(refreshmaprequests,Gdocument.getElementById("maploadwindowsearchinput"));
  542. scope.dropdownrequested = Gdocument.createElement("div");
  543. dropdownrequested.classList = "dropdown-option dropdown_classic";
  544. dropdownrequested.style["display"] = "none";
  545. dropdownrequested.id = "maploadtypedropdowntitlerequested";
  546. if(Gdocument.getElementById("maploadtypedropdownoption10").style["display"] == "block"){
  547. dropdownrequested.style["display"] = "block";
  548. }
  549. dropdownrequested.textContent = "MAP REQUESTS";
  550. dropdownrequested.onclick = function(){
  551. searchrequested = 1;
  552. Gdocument.getElementById("maploadtypedropdowntitle").click();
  553. Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdownrequested.textContent;
  554. dropdownrequested.style["display"] = "none";
  555. clearmaprequests.style["display"] = "block";
  556. refreshmaprequests.style["display"] = "block";
  557. Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
  558. Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
  559. Gdocument.getElementById("maploadtypedropdownoption10").click();
  560. };
  561. (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});
  562. Gdocument.getElementById("maploadtypedropdown").insertBefore(dropdownrequested,Gdocument.getElementById("maploadtypedropdownoption1"));
  563. Gdocument.getElementById("maploadwindowmapscontainer").__defineGetter__("clientHeight",function(){if(Gdocument.getElementById("maploadtypedropdowntitle").textContent != "MAP REQUESTS"){return Gdocument.getElementById("maploadwindowmapscontainer").getClientRects()[0].height;}else{return 0;}});
  564. };
  565. scope.sandboxonclick = function(){
  566. Gdocument.getElementById("roomlistrefreshbutton").click();
  567. Gdocument.getElementById("roomlistcreatebutton").click();
  568. sandboxon = true;
  569. };
  570. scope.checkboxclearbuttononclick = function(){
  571. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  572. var e = true;
  573. for(var i = 0; i<classes.length;i++){
  574. if(classes[i].checked == true){
  575. e = false
  576. }
  577. classes[i].checked = false;
  578. }
  579. if(e){
  580. for(var i = 0; i<classes.length;i++){
  581. classes[i].checked = true;
  582. }
  583. }
  584. };
  585. Gdocument.getElementById("ingamechatcontent").__defineGetter__("childElementCount",function(){return this.children.length/50;});
  586. if(Gdocument.getElementById("classic_mid_sandbox")==null){
  587. Gdocument.getElementById("roomlistrefreshbutton").click();
  588. scope.sandboxbutton = Gdocument.createElement("div");
  589. sandboxbutton.id = "classic_mid_sandbox";
  590. sandboxbutton.classList.value = "brownButton brownButton_classic classic_mid_buttons";
  591. sandboxbutton.textContent = "Sandbox";
  592. sandboxbutton.addEventListener("click",sandboxonclick);
  593. Gdocument.getElementById("classic_mid").insertBefore(sandboxbutton,Gdocument.getElementById("classic_mid_news"));
  594. }
  595. if(Gdocument.getElementById("clearallcheckboxes")==null){
  596. scope.checkboxclearbutton = Gdocument.createElement("div");
  597. checkboxclearbutton.id = "clearallcheckboxes";
  598. checkboxclearbutton.classList.value = "brownButton brownButton_classic buttonShadow";
  599. checkboxclearbutton.textContent = "On/Off";
  600. checkboxclearbutton.style["position"] = "absolute";
  601. checkboxclearbutton.style["display"] = "none";
  602. if(typeof(ishost)!='undefined'){
  603. if(ishost && stopquickplay == 0){
  604. checkboxclearbutton.style["display"] = "block";
  605. }
  606. }
  607. checkboxclearbutton.style["right"] = "255px";
  608. checkboxclearbutton.style["top"] = "57px";
  609. checkboxclearbutton.style["height"] = "23px";
  610. checkboxclearbutton.style["width"] = "47px";
  611. checkboxclearbutton.style["line-height"] = "23px";
  612. checkboxclearbutton.style["font-size"] = "13px";
  613. checkboxclearbutton.addEventListener("click",checkboxclearbuttononclick);
  614. Gdocument.getElementById("maploadwindow").insertBefore(checkboxclearbutton,Gdocument.getElementById("maploadwindowsearchinput"));
  615. }
  616. scope.holdloadbuttonTimeout = [];
  617. scope.holdloadbutton = function(){
  618. var scrollcount = 0;
  619. var mapwindow = Gdocument.getElementById("maploadwindowmapscontainer");
  620. mapwindow.scroll(0,mapwindow.scrollHeight);
  621. };
  622. if(Gdocument.getElementById("mapwindowloadall")==null){
  623. scope.loadall = Gdocument.createElement("div");
  624. loadall.id = "mapwindowloadall";
  625. loadall.classList.value = "brownButton brownButton_classic buttonShadow";
  626. loadall.textContent = "Load";
  627. loadall.style["position"] = "absolute";
  628. loadall.style["display"] = "block";
  629. loadall.style["left"] = "204px";
  630. loadall.style["top"] = "57px";
  631. loadall.style["height"] = "23px";
  632. loadall.style["width"] = "34px";
  633. loadall.style["line-height"] = "23px";
  634. loadall.style["font-size"] = "12px";
  635. var repeat = function(){holdloadbutton();holdloadbuttonTimeout.push(setTimeout(repeat,25));};
  636. loadall.onmousedown = function(){repeat();};
  637. loadall.onmouseup = function(){for(var i = 0; i<holdloadbuttonTimeout.length; i++){clearTimeout(holdloadbuttonTimeout[i]);}};
  638. loadall.onmouseout = function(){for(var i = 0; i<holdloadbuttonTimeout.length; i++){clearTimeout(holdloadbuttonTimeout[i]);}};
  639. Gdocument.getElementById("maploadwindow").insertBefore(loadall,Gdocument.getElementById("maploadwindowsearchinput"));
  640. }
  641. if(Gdocument.getElementById("BonkCommandsDebuggerContainer")==null){
  642. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=3;
  643. scope.debuggermenu = Gdocument.createElement("div");
  644. debuggermenu.id = "BonkCommandsDebuggerContainer";
  645. debuggermenu.style["position"] = "absolute";
  646. debuggermenu.style["display"] = "none";
  647. if(typeof(debuggeropen)!='undefined'){
  648. if(debuggeropen){
  649. debuggermenu.style["display"] = "block";
  650. }
  651. }
  652. debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
  653. debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
  654. debuggermenu.style["background"] = "rgb(26, 39, 51)";
  655. scope.width = parseInt(Gdocument.getElementById("bonkiocontainer").style["width"])-20;
  656. scope.height = parseInt(Gdocument.getElementById("bonkiocontainer").style["height"])-210;
  657. scope.logmenu = Gdocument.createElement("div");
  658. logmenu.id = "BonkCommandsWebSocketLog";
  659. logmenu.style["position"] = "absolute";
  660. logmenu.style["width"] = width.toString()+"px";
  661. logmenu.style["height"] = height.toString()+"px";
  662. logmenu.style["top"] = "80px";
  663. logmenu.style["left"] = "10px";
  664. logmenu.style["background"] = "rgb(207, 216, 220)";
  665. scope.logmenutopleft = Gdocument.createElement("div");
  666. logmenutopleft.id = "BonkCommandsWebSocketLog";
  667. logmenutopleft.style["position"] = "absolute";
  668. logmenutopleft.textContent = "Sending";
  669. logmenutopleft.classList = "newbonklobby_boxtop newbonklobby_boxtop_classic";
  670. logmenutopleft.style["width"] = (width/2).toString()+"px";
  671. logmenutopleft.style["height"] = "30px";
  672. logmenutopleft.style["top"] = "-30px";
  673. logmenutopleft.style["background"] = "rgb(0, 150, 136)";
  674. logmenu.appendChild(logmenutopleft);
  675. scope.logmenutopright = Gdocument.createElement("div");
  676. logmenutopright.id = "BonkCommandsWebSocketLog";
  677. logmenutopright.style["position"] = "absolute";
  678. logmenutopright.textContent = "Recieving";
  679. logmenutopright.classList = "newbonklobby_boxtop newbonklobby_boxtop_classic";
  680. logmenutopright.style["width"] = (width/2).toString()+"px";
  681. logmenutopright.style["height"] = "30px";
  682. logmenutopright.style["left"] = (width/2).toString()+"px";
  683. logmenutopright.style["top"] = "-30px";
  684. logmenutopright.style["background"] = "rgb(0, 150, 136)";
  685. logmenu.appendChild(logmenutopright);
  686. scope.logmenutable = Gdocument.createElement("table");
  687. logmenutable.id = "BonkCommandsWebSocketTable";
  688. logmenutable.style["position"] = "absolute";
  689. logmenutable.style["border-spacing"] = "0px";
  690. logmenutable.style["font-size"] = "12px";
  691. logmenutable.style["display"] = "table-cell";
  692. logmenutable.style["width"] = "50%";
  693. logmenutable.style["height"] = "100%";
  694. logmenutable.style["table-layout"] = "fixed";
  695. logmenutable.style["overflow-y"] = "scroll";
  696. scope.logmenutable2 = Gdocument.createElement("table");
  697. logmenutable2.id = "BonkCommandsWebSocketTable2";
  698. logmenutable2.style["position"] = "absolute";
  699. logmenutable2.style["width"] = "50%";
  700. logmenutable2.style["left"] = "50%";
  701. logmenutable2.style["font-size"] = "12px";
  702. logmenutable2.style["display"] = "table-cell";
  703. logmenutable2.style["height"] = "100%";
  704. logmenutable2.style["table-layout"] = "fixed";
  705. logmenutable2.style["overflow-y"] = "scroll";
  706. logmenutable2.style["border-spacing"] = "0px";
  707. scope.leftsync = false;
  708. scope.rightsync = false;
  709. logmenutable2.onscroll = function(){
  710. if(!leftsync){
  711. rightsync = true;
  712. logmenutable.scrollTop = this.scrollTop;
  713. }
  714. else{
  715. leftsync = false;
  716. }
  717. };
  718. logmenutable.onscroll = function(){
  719. if(!rightsync){
  720. leftsync = true;
  721. logmenutable2.scrollTop = this.scrollTop;
  722. }
  723. else{
  724. rightsync = false
  725. }
  726. };
  727. logmenu.appendChild(logmenutable);
  728. logmenu.appendChild(logmenutable2);
  729. debuggermenu.appendChild(logmenu);
  730. scope.debuggermenuclose = Gdocument.createElement("div");
  731. debuggermenuclose.id = "debuggerclose";
  732. debuggermenuclose.classList = "windowCloseButton brownButton brownButton_classic buttonShadow";
  733. debuggermenuclose.style["position"] = "absolute";
  734. debuggermenuclose.style["top"] = "40px";
  735. debuggermenuclose.style["right"] = "5px";
  736. debuggermenuclose.onclick = function(){debuggeropen = false;debuggermenu.style["display"] = "none";Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  737. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";};
  738. debuggermenu.appendChild(debuggermenuclose);
  739. scope.debuggerform = Gdocument.createElement("form");
  740. debuggerform.autocomplete = "off";
  741. scope.debuggerinput = Gdocument.createElement("input");
  742. debuggerinput.style["position"] = "absolute";
  743. debuggerinput.style["width"] = width.toString()+"px";
  744. debuggerinput.style["left"] = "10px";
  745. debuggerinput.style["top"] = (height+90).toString()+"px";
  746. debuggerinput.style["font-size"] = "12px";
  747. debuggerinput.style["height"] = "20px";
  748. debuggerform.appendChild(debuggerinput);
  749. scope.debuggersendrecieve = Gdocument.createElement("div");
  750. debuggersendrecieve.style["position"] = "absolute";
  751. debuggersendrecieve.style["width"] = "140px";
  752. debuggersendrecieve.style["left"] = "10px";
  753. debuggersendrecieve.style["top"] = (height+120).toString()+"px";
  754. debuggersendrecieve.style["font-size"] = "15px";
  755. debuggersendrecieve.style["height"] = "20px";
  756. debuggersendrecieve.classList = "brownButton brownButton_classic buttonShadow";
  757. debuggersendrecieve.textContent = "Send";
  758. debuggersendrecieve.value = 0;
  759. debuggersendrecieve.onclick = function(){if(this.value == 0){this.textContent = "Recieve";this.value = 1;}else{this.textContent = "Send";this.value = 0;}};
  760. debuggermenu.appendChild(debuggersendrecieve);
  761. scope.debuggerpausebutton = Gdocument.createElement("div");
  762. debuggerpausebutton.style["position"] = "absolute";
  763. debuggerpausebutton.style["width"] = "140px";
  764. debuggerpausebutton.style["left"] = "10px";
  765. debuggerpausebutton.style["top"] = (height+150).toString()+"px";
  766. debuggerpausebutton.style["font-size"] = "15px";
  767. debuggerpausebutton.style["height"] = "20px";
  768. debuggerpausebutton.classList = "brownButton brownButton_classic buttonShadow";
  769. debuggerpausebutton.textContent = "Pause";
  770. debuggerpausebutton.value = 0;
  771. debuggerpausebutton.onclick = function(){if(this.value == 0){this.textContent = "Play";this.value = 1;wsslogpaused = true}else{this.textContent = "Pause";this.value = 0;wsslogpaused = false;}};
  772. debuggermenu.appendChild(debuggerpausebutton);
  773. scope.debuggereval = Gdocument.createElement("input");
  774. debuggereval.style["position"] = "absolute";
  775. debuggereval.style["width"] = (width-150).toString()+"px";
  776. debuggereval.style["right"] = "10px";
  777. debuggereval.style["top"] = (height+120).toString()+"px";
  778. debuggereval.style["font-size"] = "12px";
  779. debuggereval.style["height"] = "20px";
  780. 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);}}});
  781. debuggerform.appendChild(debuggereval);
  782. debuggermenu.appendChild(debuggerform);
  783. Gdocument.getElementById("newbonkgamecontainer").appendChild(debuggermenu);
  784. }
  785. scope.ISdecode = function(rawdata) {
  786. rawdata_caseflipped = "";
  787. for (i = 0; i < rawdata.length; i++) {
  788. if (i <= 100 && rawdata.charAt(i) === rawdata.charAt(i).toLowerCase()) {
  789. rawdata_caseflipped += rawdata.charAt(i).toUpperCase();
  790. } else if (i <= 100 && rawdata.charAt(i) === rawdata.charAt(i).toUpperCase()) {
  791. rawdata_caseflipped += rawdata.charAt(i).toLowerCase();
  792. } else {
  793. rawdata_caseflipped += rawdata.charAt(i);
  794. }
  795. }
  796. data_deLZd = LZString.decompressFromEncodedURIComponent(rawdata_caseflipped);
  797. databuffer = bytebuffer.fromBase64(data_deLZd);
  798. data = ISpsonpair.decode(databuffer.buffer);
  799. return data;
  800. };
  801. scope.ISencode = function(obj) {
  802. data = ISpsonpair.encode(obj);
  803. b64 = data.toBase64();
  804. lzd = LZString.compressToEncodedURIComponent(b64);
  805. caseflipped = "";
  806. for (i = 0; i < lzd.length; i++) {
  807. if (i <= 100 && lzd.charAt(i) === lzd.charAt(i).toLowerCase()) {
  808. caseflipped += lzd.charAt(i).toUpperCase();
  809. } else if (i <= 100 && lzd.charAt(i) === lzd.charAt(i).toUpperCase()) {
  810. caseflipped += lzd.charAt(i).toLowerCase();
  811. } else {
  812. caseflipped += lzd.charAt(i);
  813. }
  814. }
  815. return caseflipped;
  816. };
  817. scope.decodeIS = function(x){
  818. return ISdecode(x);
  819. };
  820. scope.encodeIS = function(x){
  821. return ISencode(x);
  822. };
  823. scope.encodeToDatabase = function (W2A) {
  824. var M3n = [arguments];
  825. M3n[1] = new bytebuffer2;
  826. M3n[9] = M3n[0][0].physics;
  827. M3n[0][0].v = 15;
  828. M3n[1].writeShort(M3n[0][0].v);
  829. M3n[1].writeBoolean(M3n[0][0].s.re);
  830. M3n[1].writeBoolean(M3n[0][0].s.nc);
  831. M3n[1].writeShort(M3n[0][0].s.pq);
  832. M3n[1].writeFloat(M3n[0][0].s.gd);
  833. M3n[1].writeBoolean(M3n[0][0].s.fl);
  834. M3n[1].writeUTF(M3n[0][0].m.rxn);
  835. M3n[1].writeUTF(M3n[0][0].m.rxa);
  836. M3n[1].writeUint(M3n[0][0].m.rxid);
  837. M3n[1].writeShort(M3n[0][0].m.rxdb);
  838. M3n[1].writeUTF(M3n[0][0].m.n);
  839. M3n[1].writeUTF(M3n[0][0].m.a);
  840. M3n[1].writeUint(M3n[0][0].m.vu);
  841. M3n[1].writeUint(M3n[0][0].m.vd);
  842. M3n[1].writeShort(M3n[0][0].m.cr.length);
  843. for (
  844. M3n[84] = 0;
  845. M3n[84] < M3n[0][0].m.cr.length;
  846. M3n[84]++
  847. ) {
  848. M3n[1].writeUTF(M3n[0][0].m.cr[M3n[84]]);
  849. }
  850. M3n[1].writeUTF(M3n[0][0].m.mo);
  851. M3n[1].writeInt(M3n[0][0].m.dbid);
  852. M3n[1].writeBoolean(M3n[0][0].m.pub);
  853. M3n[1].writeInt(M3n[0][0].m.dbv);
  854. M3n[1].writeShort(M3n[9].ppm);
  855. M3n[1].writeShort(M3n[9].bro.length);
  856. for (M3n[17] = 0; M3n[17] < M3n[9].bro.length; M3n[17]++) {
  857. M3n[1].writeShort(M3n[9].bro[M3n[17]]);
  858. }
  859. M3n[1].writeShort(M3n[9].shapes.length);
  860. for (M3n[80] = 0; M3n[80] < M3n[9].shapes.length; M3n[80]++) {
  861. M3n[2] = M3n[9].shapes[M3n[80]];
  862. if (M3n[2].type == "bx") {
  863. M3n[1].writeShort(1);
  864. M3n[1].writeDouble(M3n[2].w);
  865. M3n[1].writeDouble(M3n[2].h);
  866. M3n[1].writeDouble(M3n[2].c[0]);
  867. M3n[1].writeDouble(M3n[2].c[1]);
  868. M3n[1].writeDouble(M3n[2].a);
  869. M3n[1].writeBoolean(M3n[2].sk);
  870. }
  871. if (M3n[2].type == "ci") {
  872. M3n[1].writeShort(2);
  873. M3n[1].writeDouble(M3n[2].r);
  874. M3n[1].writeDouble(M3n[2].c[0]);
  875. M3n[1].writeDouble(M3n[2].c[1]);
  876. M3n[1].writeBoolean(M3n[2].sk);
  877. }
  878. if (M3n[2].type == "po") {
  879. M3n[1].writeShort(3);
  880. M3n[1].writeDouble(M3n[2].s);
  881. M3n[1].writeDouble(M3n[2].a);
  882. M3n[1].writeDouble(M3n[2].c[0]);
  883. M3n[1].writeDouble(M3n[2].c[1]);
  884. M3n[1].writeShort(M3n[2].v.length);
  885. for (M3n[61] = 0; M3n[61] < M3n[2].v.length; M3n[61]++) {
  886. M3n[1].writeDouble(M3n[2].v[M3n[61]][0]);
  887. M3n[1].writeDouble(M3n[2].v[M3n[61]][1]);
  888. }
  889. }
  890. }
  891. M3n[1].writeShort(M3n[9].fixtures.length);
  892. for (M3n[20] = 0; M3n[20] < M3n[9].fixtures.length; M3n[20]++) {
  893. M3n[7] = M3n[9].fixtures[M3n[20]];
  894. M3n[1].writeShort(M3n[7].sh);
  895. M3n[1].writeUTF(M3n[7].n);
  896. if (M3n[7].fr === null) {
  897. M3n[1].writeDouble(Number.MAX_VALUE);
  898. } else {
  899. M3n[1].writeDouble(M3n[7].fr);
  900. }
  901. if (M3n[7].fp === null) {
  902. M3n[1].writeShort(0);
  903. }
  904. if (M3n[7].fp === false) {
  905. M3n[1].writeShort(1);
  906. }
  907. if (M3n[7].fp === true) {
  908. M3n[1].writeShort(2);
  909. }
  910. if (M3n[7].re === null) {
  911. M3n[1].writeDouble(Number.MAX_VALUE);
  912. } else {
  913. M3n[1].writeDouble(M3n[7].re);
  914. }
  915. if (M3n[7].de === null) {
  916. M3n[1].writeDouble(Number.MAX_VALUE);
  917. } else {
  918. M3n[1].writeDouble(M3n[7].de);
  919. }
  920. M3n[1].writeUint(M3n[7].f);
  921. M3n[1].writeBoolean(M3n[7].d);
  922. M3n[1].writeBoolean(M3n[7].np);
  923. M3n[1].writeBoolean(M3n[7].ng);
  924. M3n[1].writeBoolean(M3n[7].ig);
  925. }
  926. M3n[1].writeShort(M3n[9].bodies.length);
  927. for (M3n[37] = 0; M3n[37] < M3n[9].bodies.length; M3n[37]++) {
  928. M3n[4] = M3n[9].bodies[M3n[37]];
  929. M3n[1].writeUTF(M3n[4].type);
  930. M3n[1].writeUTF(M3n[4].n);
  931. M3n[1].writeDouble(M3n[4].p[0]);
  932. M3n[1].writeDouble(M3n[4].p[1]);
  933. M3n[1].writeDouble(M3n[4].a);
  934. M3n[1].writeDouble(M3n[4].fric);
  935. M3n[1].writeBoolean(M3n[4].fricp);
  936. M3n[1].writeDouble(M3n[4].re);
  937. M3n[1].writeDouble(M3n[4].de);
  938. M3n[1].writeDouble(M3n[4].lv[0]);
  939. M3n[1].writeDouble(M3n[4].lv[1]);
  940. M3n[1].writeDouble(M3n[4].av);
  941. M3n[1].writeDouble(M3n[4].ld);
  942. M3n[1].writeDouble(M3n[4].ad);
  943. M3n[1].writeBoolean(M3n[4].fr);
  944. M3n[1].writeBoolean(M3n[4].bu);
  945. M3n[1].writeDouble(M3n[4].cf.x);
  946. M3n[1].writeDouble(M3n[4].cf.y);
  947. M3n[1].writeDouble(M3n[4].cf.ct);
  948. M3n[1].writeBoolean(M3n[4].cf.w);
  949. M3n[1].writeShort(M3n[4].f_c);
  950. M3n[1].writeBoolean(M3n[4].f_1);
  951. M3n[1].writeBoolean(M3n[4].f_2);
  952. M3n[1].writeBoolean(M3n[4].f_3);
  953. M3n[1].writeBoolean(M3n[4].f_4);
  954. M3n[1].writeBoolean(M3n[4].f_p);
  955. M3n[1].writeBoolean(M3n[4].fz.on);
  956. if (M3n[4].fz.on) {
  957. M3n[1].writeDouble(M3n[4].fz.x);
  958. M3n[1].writeDouble(M3n[4].fz.y);
  959. M3n[1].writeBoolean(M3n[4].fz.d);
  960. M3n[1].writeBoolean(M3n[4].fz.p);
  961. M3n[1].writeBoolean(M3n[4].fz.a);
  962. M3n[1].writeShort(M3n[4].fz.t);
  963. + M3n[1].writeDouble(M3n[4].fz.cf);
  964. }
  965. M3n[1].writeShort(M3n[4].fx.length);
  966. for (M3n[28] = 0; M3n[28] < M3n[4].fx.length; M3n[28]++) {
  967. M3n[1].writeShort(M3n[4].fx[M3n[28]]);
  968. }
  969. }
  970. M3n[1].writeShort(M3n[0][0].spawns.length);
  971. for (
  972. M3n[30] = 0;
  973. M3n[30] < M3n[0][0].spawns.length;
  974. M3n[30]++
  975. ) {
  976. M3n[6] = M3n[0][0].spawns[M3n[30]];
  977. M3n[1].writeDouble(M3n[6].x);
  978. M3n[1].writeDouble(M3n[6].y);
  979. M3n[1].writeDouble(M3n[6].xv);
  980. M3n[1].writeDouble(M3n[6].yv);
  981. M3n[1].writeShort(M3n[6].priority);
  982. M3n[1].writeBoolean(M3n[6].r);
  983. M3n[1].writeBoolean(M3n[6].f);
  984. M3n[1].writeBoolean(M3n[6].b);
  985. M3n[1].writeBoolean(M3n[6].gr);
  986. M3n[1].writeBoolean(M3n[6].ye);
  987. M3n[1].writeUTF(M3n[6].n);
  988. }
  989. M3n[1].writeShort(M3n[0][0].capZones.length);
  990. for (
  991. M3n[74] = 0;
  992. M3n[74] < M3n[0][0].capZones.length;
  993. M3n[74]++
  994. ) {
  995. M3n[3] = M3n[0][0].capZones[M3n[74]];
  996. M3n[1].writeUTF(M3n[3].n);
  997. M3n[1].writeDouble(M3n[3].l);
  998. M3n[1].writeShort(M3n[3].i);
  999. M3n[1].writeShort(M3n[3].ty);
  1000. }
  1001. M3n[1].writeShort(M3n[9].joints.length);
  1002. for (M3n[89] = 0; M3n[89] < M3n[9].joints.length; M3n[89]++) {
  1003. M3n[5] = M3n[9].joints[M3n[89]];
  1004. if (M3n[5].type == "rv") {
  1005. M3n[1].writeShort(1);
  1006. M3n[1].writeDouble(M3n[5].d.la);
  1007. M3n[1].writeDouble(M3n[5].d.ua);
  1008. M3n[1].writeDouble(M3n[5].d.mmt);
  1009. M3n[1].writeDouble(M3n[5].d.ms);
  1010. M3n[1].writeBoolean(M3n[5].d.el);
  1011. M3n[1].writeBoolean(M3n[5].d.em);
  1012. M3n[1].writeDouble(M3n[5].aa[0]);
  1013. M3n[1].writeDouble(M3n[5].aa[1]);
  1014. }
  1015. if (M3n[5].type == "d") {
  1016. M3n[1].writeShort(2);
  1017. M3n[1].writeDouble(M3n[5].d.fh);
  1018. M3n[1].writeDouble(M3n[5].d.dr);
  1019. M3n[1].writeDouble(M3n[5].aa[0]);
  1020. M3n[1].writeDouble(M3n[5].aa[1]);
  1021. M3n[1].writeDouble(M3n[5].ab[0]);
  1022. M3n[1].writeDouble(M3n[5].ab[1]);
  1023. }
  1024. if (M3n[5].type == "lpj") {
  1025. M3n[1].writeShort(3);
  1026. M3n[1].writeDouble(M3n[5].pax);
  1027. M3n[1].writeDouble(M3n[5].pay);
  1028. M3n[1].writeDouble(M3n[5].pa);
  1029. M3n[1].writeDouble(M3n[5].pf);
  1030. M3n[1].writeDouble(M3n[5].pl);
  1031. M3n[1].writeDouble(M3n[5].pu);
  1032. M3n[1].writeDouble(M3n[5].plen);
  1033. M3n[1].writeDouble(M3n[5].pms);
  1034. }
  1035. if (M3n[5].type == "lsj") {
  1036. M3n[1].writeShort(4);
  1037. M3n[1].writeDouble(M3n[5].sax);
  1038. M3n[1].writeDouble(M3n[5].say);
  1039. M3n[1].writeDouble(M3n[5].sf);
  1040. M3n[1].writeDouble(M3n[5].slen);
  1041. }
  1042. if(M3n[5].type == "g"){
  1043. M3n[1].writeShort(5);
  1044. M3n[1].writeUTF(M3n[5].n);
  1045. M3n[1].writeShort(M3n[5].ja);
  1046. M3n[1].writeShort(M3n[5].jb);
  1047. M3n[1].writeDouble(M3n[5].r);
  1048. }
  1049. if(M3n[5].type != "g"){
  1050. M3n[1].writeShort(M3n[5].ba);
  1051. M3n[1].writeShort(M3n[5].bb);
  1052. M3n[1].writeBoolean(M3n[5].d.cc);
  1053. M3n[1].writeDouble(M3n[5].d.bf);
  1054. M3n[1].writeBoolean(M3n[5].d.dl);
  1055. }
  1056. }
  1057. M3n[32] = M3n[1].toBase64();
  1058. M3n[77] = LZString.compressToEncodedURIComponent(M3n[32]);
  1059. return M3n[77];
  1060. };
  1061. scope.decodeFromDatabase = function (map) {
  1062. var F5W = [arguments];
  1063. var b64mapdata = LZString.decompressFromEncodedURIComponent(map);
  1064. var binaryReader = new bytebuffer2;
  1065. binaryReader.fromBase64(b64mapdata, false);
  1066. 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: "", }};
  1067. map.physics = map.physics;
  1068. map.v = binaryReader.readShort();
  1069. if (map.v > 15) {
  1070. throw new Error("Future map version, please refresh page");
  1071. }
  1072. map.s.re = binaryReader.readBoolean();
  1073. map.s.nc = binaryReader.readBoolean();
  1074. if (map.v >= 3) {
  1075. map.s.pq = binaryReader.readShort();
  1076. }
  1077. if (map.v >= 4 && map.v <= 12) {
  1078. map.s.gd = binaryReader.readShort();
  1079. } else if (map.v >= 13) {
  1080. map.s.gd = binaryReader.readFloat();
  1081. }
  1082. if (map.v >= 9) {
  1083. map.s.fl = binaryReader.readBoolean();
  1084. }
  1085. map.m.rxn = binaryReader.readUTF();
  1086. map.m.rxa = binaryReader.readUTF();
  1087. map.m.rxid = binaryReader.readUint();
  1088. map.m.rxdb = binaryReader.readShort();
  1089. map.m.n = binaryReader.readUTF();
  1090. map.m.a = binaryReader.readUTF();
  1091. if (map.v >= 10) {
  1092. map.m.vu = binaryReader.readUint();
  1093. map.m.vd = binaryReader.readUint();
  1094. }
  1095. if (map.v >= 4) {
  1096. F5W[7] = binaryReader.readShort();
  1097. for (F5W[83] = 0; F5W[83] < F5W[7]; F5W[83]++) {
  1098. map.m.cr.push(binaryReader.readUTF());
  1099. }
  1100. }
  1101. if (map.v >= 5) {
  1102. map.m.mo = binaryReader.readUTF();
  1103. map.m.dbid = binaryReader.readInt();
  1104. }
  1105. if (map.v >= 7) {
  1106. map.m.pub = binaryReader.readBoolean();
  1107. }
  1108. if (map.v >= 8) {
  1109. map.m.dbv = binaryReader.readInt();
  1110. }
  1111. map.physics.ppm = binaryReader.readShort();
  1112. F5W[4] = binaryReader.readShort();
  1113. for (F5W[15] = 0; F5W[15] < F5W[4]; F5W[15]++) {
  1114. map.physics.bro[F5W[15]] = binaryReader.readShort();
  1115. }
  1116. F5W[6] = binaryReader.readShort();
  1117. for (F5W[28] = 0; F5W[28] < F5W[6]; F5W[28]++) {
  1118. F5W[5] = binaryReader.readShort();
  1119. if (F5W[5] == 1) {
  1120. map.physics.shapes[F5W[28]] = { type: "bx", w: 10, h: 40, c: [0, 0], a: 0.0, sk: false };
  1121. map.physics.shapes[F5W[28]].w = binaryReader.readDouble();
  1122. map.physics.shapes[F5W[28]].h = binaryReader.readDouble();
  1123. map.physics.shapes[F5W[28]].c = [
  1124. binaryReader.readDouble(),
  1125. binaryReader.readDouble(),
  1126. ];
  1127. map.physics.shapes[F5W[28]].a = binaryReader.readDouble();
  1128. map.physics.shapes[F5W[28]].sk = binaryReader.readBoolean();
  1129. }
  1130. if (F5W[5] == 2) {
  1131. map.physics.shapes[F5W[28]] = { type: "ci", r: 25, c: [0, 0], sk: false };
  1132. map.physics.shapes[F5W[28]].r = binaryReader.readDouble();
  1133. map.physics.shapes[F5W[28]].c = [
  1134. binaryReader.readDouble(),
  1135. binaryReader.readDouble(),
  1136. ];
  1137. map.physics.shapes[F5W[28]].sk = binaryReader.readBoolean();
  1138. }
  1139. if (F5W[5] == 3) {
  1140. map.physics.shapes[F5W[28]] = { type: "po", v: [], s: 1, a: 0, c: [0, 0] };
  1141. map.physics.shapes[F5W[28]].s = binaryReader.readDouble();
  1142. map.physics.shapes[F5W[28]].a = binaryReader.readDouble();
  1143. map.physics.shapes[F5W[28]].c = [
  1144. binaryReader.readDouble(),
  1145. binaryReader.readDouble(),
  1146. ];
  1147. F5W[74] = binaryReader.readShort();
  1148. map.physics.shapes[F5W[28]].v = [];
  1149. for (F5W[27] = 0; F5W[27] < F5W[74]; F5W[27]++) {
  1150. map.physics.shapes[F5W[28]].v.push([
  1151. binaryReader.readDouble(),
  1152. binaryReader.readDouble(),
  1153. ]);
  1154. }
  1155. }
  1156. }
  1157. F5W[71] = binaryReader.readShort();
  1158. for (F5W[17] = 0; F5W[17] < F5W[71]; F5W[17]++) {
  1159. 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 };
  1160. map.physics.fixtures[F5W[17]].sh = binaryReader.readShort();
  1161. map.physics.fixtures[F5W[17]].n = binaryReader.readUTF();
  1162. map.physics.fixtures[F5W[17]].fr = binaryReader.readDouble();
  1163. if (map.physics.fixtures[F5W[17]].fr == Number.MAX_VALUE) {
  1164. map.physics.fixtures[F5W[17]].fr = null;
  1165. }
  1166. F5W[12] = binaryReader.readShort();
  1167. if (F5W[12] == 0) {
  1168. map.physics.fixtures[F5W[17]].fp = null;
  1169. }
  1170. if (F5W[12] == 1) {
  1171. map.physics.fixtures[F5W[17]].fp = false;
  1172. }
  1173. if (F5W[12] == 2) {
  1174. map.physics.fixtures[F5W[17]].fp = true;
  1175. }
  1176. map.physics.fixtures[F5W[17]].re = binaryReader.readDouble();
  1177. if (map.physics.fixtures[F5W[17]].re == Number.MAX_VALUE) {
  1178. map.physics.fixtures[F5W[17]].re = null;
  1179. }
  1180. map.physics.fixtures[F5W[17]].de = binaryReader.readDouble();
  1181. if (map.physics.fixtures[F5W[17]].de == Number.MAX_VALUE) {
  1182. map.physics.fixtures[F5W[17]].de = null;
  1183. }
  1184. map.physics.fixtures[F5W[17]].f = binaryReader.readUint();
  1185. map.physics.fixtures[F5W[17]].d = binaryReader.readBoolean();
  1186. map.physics.fixtures[F5W[17]].np = binaryReader.readBoolean();
  1187. if (map.v >= 11) {
  1188. map.physics.fixtures[F5W[17]].ng = binaryReader.readBoolean();
  1189. }
  1190. if (map.v >= 12) {
  1191. map.physics.fixtures[F5W[17]].ig = binaryReader.readBoolean();
  1192. }
  1193. }
  1194. F5W[63] = binaryReader.readShort();
  1195. for (F5W[52] = 0; F5W[52] < F5W[63]; F5W[52]++) {
  1196. 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, t: 0, cf: 0}};
  1197. map.physics.bodies[F5W[52]].type = binaryReader.readUTF();
  1198. map.physics.bodies[F5W[52]].n = binaryReader.readUTF();
  1199. map.physics.bodies[F5W[52]].p = [binaryReader.readDouble(), binaryReader.readDouble()];
  1200. map.physics.bodies[F5W[52]].a = binaryReader.readDouble();
  1201. map.physics.bodies[F5W[52]].fric = binaryReader.readDouble();
  1202. map.physics.bodies[F5W[52]].fricp = binaryReader.readBoolean();
  1203. map.physics.bodies[F5W[52]].re = binaryReader.readDouble();
  1204. map.physics.bodies[F5W[52]].de = binaryReader.readDouble();
  1205. map.physics.bodies[F5W[52]].lv = [
  1206. binaryReader.readDouble(),
  1207. binaryReader.readDouble(),
  1208. ];
  1209. map.physics.bodies[F5W[52]].av = binaryReader.readDouble();
  1210. map.physics.bodies[F5W[52]].ld = binaryReader.readDouble();
  1211. map.physics.bodies[F5W[52]].ad = binaryReader.readDouble();
  1212. map.physics.bodies[F5W[52]].fr = binaryReader.readBoolean();
  1213. map.physics.bodies[F5W[52]].bu = binaryReader.readBoolean();
  1214. map.physics.bodies[F5W[52]].cf.x = binaryReader.readDouble();
  1215. map.physics.bodies[F5W[52]].cf.y = binaryReader.readDouble();
  1216. map.physics.bodies[F5W[52]].cf.ct = binaryReader.readDouble();
  1217. map.physics.bodies[F5W[52]].cf.w = binaryReader.readBoolean();
  1218. map.physics.bodies[F5W[52]].f_c = binaryReader.readShort();
  1219. map.physics.bodies[F5W[52]].f_1 = binaryReader.readBoolean();
  1220. map.physics.bodies[F5W[52]].f_2 = binaryReader.readBoolean();
  1221. map.physics.bodies[F5W[52]].f_3 = binaryReader.readBoolean();
  1222. map.physics.bodies[F5W[52]].f_4 = binaryReader.readBoolean();
  1223. if (map.v >= 2) {
  1224. map.physics.bodies[F5W[52]].f_p = binaryReader.readBoolean();
  1225. }
  1226. if (map.v >= 14) {
  1227. map.physics.bodies[F5W[52]].fz.on = binaryReader.readBoolean();
  1228. if (map.physics.bodies[F5W[52]].fz.on) {
  1229. map.physics.bodies[F5W[52]].fz.x = binaryReader.readDouble();
  1230. map.physics.bodies[F5W[52]].fz.y = binaryReader.readDouble();
  1231. map.physics.bodies[F5W[52]].fz.d = binaryReader.readBoolean();
  1232. map.physics.bodies[F5W[52]].fz.p = binaryReader.readBoolean();
  1233. map.physics.bodies[F5W[52]].fz.a = binaryReader.readBoolean();
  1234. if(map.v >= 15){
  1235. map.physics.bodies[F5W[52]].t = binaryReader.readShort();
  1236. map.physics.bodies[F5W[52]].cf = binaryReader.readDouble();
  1237. }
  1238. }
  1239. }
  1240. F5W[88] = binaryReader.readShort();
  1241. for (F5W[65] = 0; F5W[65] < F5W[88]; F5W[65]++) {
  1242. map.physics.bodies[F5W[52]].fx.push(binaryReader.readShort());
  1243. }
  1244. }
  1245. F5W[97] = binaryReader.readShort();
  1246. for (F5W[41] = 0; F5W[41] < F5W[97]; F5W[41]++) {
  1247. 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"};
  1248. F5W[35] = map.spawns[F5W[41]];
  1249. F5W[35].x = binaryReader.readDouble();
  1250. F5W[35].y = binaryReader.readDouble();
  1251. F5W[35].xv = binaryReader.readDouble();
  1252. F5W[35].yv = binaryReader.readDouble();
  1253. F5W[35].priority = binaryReader.readShort();
  1254. F5W[35].r = binaryReader.readBoolean();
  1255. F5W[35].f = binaryReader.readBoolean();
  1256. F5W[35].b = binaryReader.readBoolean();
  1257. F5W[35].gr = binaryReader.readBoolean();
  1258. F5W[35].ye = binaryReader.readBoolean();
  1259. F5W[35].n = binaryReader.readUTF();
  1260. }
  1261. F5W[16] = binaryReader.readShort();
  1262. for (F5W[25] = 0; F5W[25] < F5W[16]; F5W[25]++) {
  1263. map.capZones[F5W[25]] = {"n":"Cap Zone","ty":1,"l":10,"i":-1};
  1264. map.capZones[F5W[25]].n = binaryReader.readUTF();
  1265. map.capZones[F5W[25]].l = binaryReader.readDouble();
  1266. map.capZones[F5W[25]].i = binaryReader.readShort();
  1267. if (map.v >= 6) {
  1268. map.capZones[F5W[25]].ty = binaryReader.readShort();
  1269. }
  1270. }
  1271. F5W[98] = binaryReader.readShort();
  1272. for (F5W[19] = 0; F5W[19] < F5W[98]; F5W[19]++) {
  1273. F5W[31] = binaryReader.readShort();
  1274. if (F5W[31] == 1) {
  1275. 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]};
  1276. F5W[20] = map.physics.joints[F5W[19]];
  1277. F5W[20].d.la = binaryReader.readDouble();
  1278. F5W[20].d.ua = binaryReader.readDouble();
  1279. F5W[20].d.mmt = binaryReader.readDouble();
  1280. F5W[20].d.ms = binaryReader.readDouble();
  1281. F5W[20].d.el = binaryReader.readBoolean();
  1282. F5W[20].d.em = binaryReader.readBoolean();
  1283. F5W[20].aa = [binaryReader.readDouble(), binaryReader.readDouble()];
  1284. }
  1285. if (F5W[31] == 2) {
  1286. map.physics.joints[F5W[19]] = {"type":"d","d":{"fh":0,"dr":0,"cc":false,"bf":0,"dl":true},"aa":[0,0],"ab":[0,0]};
  1287. F5W[87] = map.physics.joints[F5W[19]];
  1288. F5W[87].d.fh = binaryReader.readDouble();
  1289. F5W[87].d.dr = binaryReader.readDouble();
  1290. F5W[87].aa = [binaryReader.readDouble(), binaryReader.readDouble()];
  1291. F5W[87].ab = [binaryReader.readDouble(), binaryReader.readDouble()];
  1292. }
  1293. if (F5W[31] == 3) {
  1294. 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};
  1295. F5W[90] = map.physics.joints[F5W[19]];
  1296. F5W[90].pax = binaryReader.readDouble();
  1297. F5W[90].pay = binaryReader.readDouble();
  1298. F5W[90].pa = binaryReader.readDouble();
  1299. F5W[90].pf = binaryReader.readDouble();
  1300. F5W[90].pl = binaryReader.readDouble();
  1301. F5W[90].pu = binaryReader.readDouble();
  1302. F5W[90].plen = binaryReader.readDouble();
  1303. F5W[90].pms = binaryReader.readDouble();
  1304. }
  1305. if (F5W[31] == 4) {
  1306. map.physics.joints[F5W[19]] = {"type":"lsj","d":{"cc":false,"bf":0,"dl":true},"sax":0,"say":0,"sf":0,"slen":0};
  1307. F5W[44] = map.physics.joints[F5W[19]];
  1308. F5W[44].sax = binaryReader.readDouble();
  1309. F5W[44].say = binaryReader.readDouble();
  1310. F5W[44].sf = binaryReader.readDouble();
  1311. F5W[44].slen = binaryReader.readDouble();
  1312. }
  1313. if(F5W[31] == 5){
  1314. map.physics.joints[F5W[19]] = {type:"g",n:"",ja:-1,jb:-1,r:1};
  1315. F5W[91] = map.physics.joints[F5W[19]];
  1316. F5W[91].n = binaryReader.readUTF();
  1317. F5W[91].ja = binaryReader.readShort();
  1318. F5W[91].jb = binaryReader.readShort();
  1319. F5W[91].r = binaryReader.readDouble();
  1320.  
  1321. }
  1322. if(F5W[31]!=5){
  1323. map.physics.joints[F5W[19]].ba = binaryReader.readShort();
  1324. map.physics.joints[F5W[19]].bb = binaryReader.readShort();
  1325. map.physics.joints[F5W[19]].d.cc = binaryReader.readBoolean();
  1326. map.physics.joints[F5W[19]].d.bf = binaryReader.readDouble();
  1327. map.physics.joints[F5W[19]].d.dl = binaryReader.readBoolean();
  1328. }
  1329. }
  1330. return map;
  1331. };
  1332. scope.updateWssLog = function(){
  1333. if(!wsslogpaused){
  1334. if(logmenutable.children.length < wsssendrecievelog.length){
  1335. var bottomscroll = logmenutable.clientHeight + logmenutable.scrollTop >= logmenutable.scrollHeight-1;
  1336. while (logmenutable.children.length>1000) {
  1337. logmenutable.removeChild(logmenutable.firstChild);
  1338. logmenutable2.removeChild(logmenutable2.firstChild);
  1339. }
  1340. var loopthro = wsssendrecievelog.slice(packetcount);
  1341. for(var i = 0; i < loopthro.length;i++){
  1342. packetcount++;
  1343. var row = document.createElement("tr");
  1344. var row2 = document.createElement("tr");
  1345. var cell1 = document.createElement("td");
  1346. cell1.style["overflow-x"] = "scroll";
  1347. cell1.style["padding"] = "0px";
  1348. cell1.style["width"] = "100000px";
  1349. var cell2 = document.createElement("td");
  1350. cell2.style["overflow-x"] = "scroll";
  1351. cell2.style["padding"] = "0px";
  1352. cell2.style["width"] = "100000px";
  1353. if(debuggercount){
  1354. cell1.style["background"] = "rgb(178, 185, 189)";
  1355. debuggercount = false;
  1356. }
  1357. else{
  1358. cell2.style["background"] = "rgb(178, 185, 189)";
  1359. debuggercount = true;
  1360. }
  1361. cell1.textContent = loopthro[i][1];
  1362. cell2.textContent = loopthro[i][1];
  1363. if(loopthro[i][0] == 0){
  1364. cell2.style["color"] = "transparent";
  1365. cell1.onclick = function(){debuggerinput.value = this.textContent};
  1366. }
  1367. else{
  1368. cell1.style["color"] = "transparent";
  1369. cell2.onclick = function(){debuggerinput.value = this.textContent};
  1370. }
  1371. row.appendChild(cell1);
  1372. row2.appendChild(cell2);
  1373. logmenutable.appendChild(row);
  1374. logmenutable2.appendChild(row2);
  1375. }
  1376. while (logmenutable.children.length>1000) {
  1377. logmenutable.removeChild(logmenutable.firstChild);
  1378. logmenutable2.removeChild(logmenutable2.firstChild);
  1379. }
  1380. if(bottomscroll){
  1381. logmenutable.scrollTop = logmenutable.scrollHeight;
  1382. logmenutable2.scrollTop = logmenutable.scrollHeight;
  1383. }
  1384. }
  1385. }
  1386. };
  1387. Gdocument.getElementById("maploadwindowmapscontainer").appendChild = function(args){
  1388. var checkbox = Gdocument.createElement("input");
  1389. checkbox.type = "checkbox";
  1390. checkbox.style["position"]="absolute";
  1391. checkbox.style["margin-top"] = "135px";
  1392. checkbox.style["margin-left"] = "140px";
  1393. checkbox.style["scale"] = "2";
  1394. checkbox.style["display"] = "none";
  1395. checkbox.className = "quickplaycheckbox quickplayunchecked";
  1396. if(ishost && stopquickplay==0){
  1397. checkbox.style["display"] = "block";
  1398. checkbox.className = "quickplaycheckbox quickplaychecked";
  1399. }
  1400. checkbox.checked = true;
  1401. checkbox.onclick = function(e){e.stopPropagation();};
  1402. args.appendChild(checkbox);
  1403. originalMapLoad.call(this,args);
  1404. };
  1405. Gdocument.getElementById("newbonklobby_chat_content").appendChild = function(args){
  1406. if(beenKickedTimeStamp+100>Date.now() && args.children.length>0){
  1407. if(args.children[0].textContent.endsWith(" has left the game ") && args.children[0].textContent.startsWith("* ")){
  1408. var kickedorbanned = "banned";
  1409. if(onlykicked){
  1410. kickedorbanned = "kicked";
  1411. }
  1412. args.children[0].textContent = args.children[0].textContent.substring(0,args.children[0].textContent.length-19)+" has been "+kickedorbanned+" from the game ";
  1413. }
  1414. }
  1415. setTimeout(function(){
  1416. if(args.textContent.startsWith("* ") && args.children.length>=5){
  1417. var newarg = args.cloneNode();
  1418. for(var i = 0;i<args.children.length;i++){
  1419. var newarg2 = args.children[i].cloneNode();
  1420. newarg2.textContent = args.children[i].textContent;
  1421. newarg2.style.color = '#ffffffd6';
  1422. newarg2.onclick = args.children[i].onclick;
  1423. newarg2.suggestID = args.children[i].suggestID;
  1424. newarg.appendChild(newarg2);
  1425. }
  1426. Gdocument.getElementById("ingamechatcontent").appendChild(newarg);
  1427. Gdocument.getElementById("ingamechatcontent").scrollTop = Number.MAX_SAFE_INTEGER;
  1428. }},0);
  1429. originalLobbyChat.call(this,args);
  1430. };
  1431. Gdocument.getElementById("ingamechatcontent").appendChild = function(args){
  1432. if(beenKickedTimeStamp+100>Date.now() && args.children.length>0){
  1433. if(args.children[0].textContent.endsWith(" has left the game.") && args.children[0].textContent.startsWith("* ")){
  1434. var kickedorbanned = "banned";
  1435. if(onlykicked){
  1436. kickedorbanned = "kicked";
  1437. }
  1438. args.children[0].textContent = args.children[0].textContent.substring(0,args.children[0].textContent.length-19)+" has been "+kickedorbanned+" from the game.";
  1439. }
  1440. }
  1441. if(recordedTimeStamp+100>Date.now() && args.children.length>0){
  1442. if(args.children[0].textContent.includes("seconds") && args.children[0].textContent.startsWith("* ")){
  1443. args.children[0].textContent = args.children[0].textContent + " - " + playerids[recordedId].userName;
  1444. }
  1445. }
  1446. originalIngameChat.call(this,args);
  1447. };
  1448. Gwindow.Date.now = function(){
  1449. if(overideDate[0]){
  1450. return overideDate[1];
  1451. }
  1452. else if(causelag){
  1453. return originalDatenow.call(this,...arguments)-causelag2;
  1454. }
  1455. return originalDatenow.call(this,...arguments);
  1456. };
  1457. Gwindow.XMLHttpRequest.prototype.open = function(_, url) {
  1458. if (url.includes("scripts/map_get") || url.includes("scripts/map_b1_get") || url.includes("scripts/hotmaps/")) {
  1459. if(searchrequested==1){
  1460. Gdocument.getElementById("maploadtypedropdowntitle").click();
  1461. Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdownrequested.textContent;
  1462. dropdownrequested.style["display"] = "none";
  1463. clearmaprequests.style["display"] = "block";
  1464. refreshmaprequests.style["display"] = "block";
  1465. Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
  1466. Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
  1467. searchrequested = 0;
  1468. this.isSearchMap = true;
  1469. }
  1470. }
  1471. else if(url.includes("getrooms.php")){
  1472. this.isGetRooms = true;
  1473. }
  1474. else if(url.includes("getroomaddress.php")){
  1475. this.isGetRoomAddress = true;
  1476. }
  1477. originalXMLOpen.call(this, ...arguments);
  1478. };
  1479. Gwindow.XMLHttpRequest.prototype.send = function(data) {
  1480. if(this.isGetRoomAddress){
  1481. currentroomaddress = parseInt(data.slice(3));
  1482. }
  1483. else if(this.isGetRooms && inroom){
  1484. this.onreadystatechange = function(){
  1485. if(this.readyState == 4){
  1486. lastrooms = JSON.parse(this.response)["rooms"];
  1487. if(lastrooms){
  1488. var keys = Object.keys(savedroomsdata);
  1489. for(var i = 0;i<lastrooms.length;i++){
  1490. if(savedrooms.includes(lastrooms[i].id)){
  1491. exists = true;
  1492. savedroomsdata[lastrooms[i].id] = lastrooms[i];
  1493. savedroomsdata[lastrooms[i].id].exists = true;
  1494. savedroomsdata[lastrooms[i].id].exists2 = true;
  1495. if(lastrooms[i].maxplayers>lastrooms[i].players){
  1496. if(inroom){
  1497. if(lastrooms[i].id!=currentroomaddress){
  1498. displayInChat('The room '+JSON.stringify(lastrooms[i].roomname)+' is now open with '+lastrooms[i].players+"/"+lastrooms[i].maxplayers+" players.","#DA0808","#1EBCC1");
  1499. savedrooms.splice(savedrooms.indexOf(lastrooms[i].id),1);
  1500. delete savedroomsdata[lastrooms[i].id];
  1501. keys.splice(keys.indexOf((lastrooms[i].id).toString()),1);
  1502. }
  1503. else{
  1504. savedrooms.splice(savedrooms.indexOf(lastrooms[i].id),1);
  1505. delete savedroomsdata[lastrooms[i].id];
  1506. keys.splice(keys.indexOf((lastrooms[i].id).toString()),1);
  1507. }
  1508. }
  1509. }
  1510. }
  1511. }
  1512. for(var i = 0;i<keys.length;i++){
  1513. if(!savedroomsdata[keys[i]].exists2){
  1514. savedroomsdata[keys[i]].exists = false;
  1515. }
  1516. savedroomsdata[keys[i]].exists2 = false;
  1517. }
  1518. for(var i = 0;i<keys.length;i++){
  1519. if(!savedroomsdata[keys[i]].exists){
  1520. savedrooms.splice(savedrooms.indexOf(parseInt(keys[i])),1);
  1521. displayInChat('The room '+JSON.stringify(savedroomsdata[keys[i]].roomname)+" does not exist anymore.","#DA0808","#1EBCC1");
  1522. delete savedroomsdata[keys[i]];
  1523. }
  1524. }
  1525. }
  1526. }
  1527. }
  1528. }
  1529. else if (this.isSearchMap) {
  1530. this.onreadystatechange = function () {
  1531. if (this.readyState == 4){
  1532. var jsonargs = {r:"success",maps:[],more:true};
  1533. for(var i = 0; i<requestedmaps.length; i++){
  1534. var dec = requestedmaps[i][0];
  1535. var undec = requestedmaps[i][1];
  1536. var map = {};
  1537. map.id = dec["m"]["dbid"];
  1538. map.name = dec["m"]["n"];
  1539. map.authorname = dec["m"]["a"];
  1540. map.leveldata = undec;
  1541. map.publisheddate = dec["m"]["date"];
  1542. map.remixauthor = dec["m"]["rxa"];
  1543. map.remixdb = dec["m"]["rxdb"];
  1544. map.remixid = dec["m"]["rxid"];
  1545. map.remixname = dec["m"]["rxn"];
  1546. map.vd = dec["m"]["vd"];
  1547. map.vu = dec["m"]["vu"];
  1548. jsonargs.maps.push(map);
  1549. }
  1550. jsonargs2 = JSON.stringify(jsonargs);
  1551. function stringifyjsonargs(){
  1552. return jsonargs2;
  1553. }
  1554. this.__defineGetter__("responseText", stringifyjsonargs);
  1555. this.__defineGetter__("response", stringifyjsonargs);
  1556. }
  1557. }
  1558. }
  1559. originalXMLSend.call(this, ...arguments);
  1560. };
  1561. scope.STB = function(x){
  1562. if(x == "0"){
  1563. return 0;
  1564. }
  1565. else{
  1566. return 1;
  1567. }
  1568. };
  1569. scope.BTS = function(x){
  1570. if(x == 0){
  1571. return "0";
  1572. }
  1573. else{
  1574. return "1";
  1575. }
  1576. };
  1577. scope.GET_KEYS = function(x){
  1578. var x2 = ((x+64)>>>0).toString(2).substring(1).split("");
  1579. 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])}
  1580. };
  1581. scope.MAKE_KEYS = function(x){
  1582. return x.special*32+x.heavy*16+x.down*8+x.up*4+x.right*2+x.left
  1583. };
  1584. Gwindow.PIXI.Graphics.prototype.drawCircle = function(...args){
  1585. var This = this;
  1586. var Args = [...args];
  1587. setTimeout(function(){
  1588. if(This.parent){
  1589. var childs = This.parent.children;
  1590. var user = 0;
  1591. for(var i = 0;i<childs.length;i++){
  1592. if(childs[i]._text){
  1593. user = childs[i]._text;
  1594. }
  1595. if(i==2 && childs[i]!=This){
  1596. return;
  1597. }
  1598. }
  1599. var keys = Object.keys(playerids);
  1600. for(var i = 0;i<keys.length;i++){
  1601. if(playerids[keys[i]].userName == user){
  1602. playerids[keys[i]].playerData = This.parent;
  1603. if(!playerids[keys[i]].playerData2){
  1604. 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};
  1605. }
  1606. playerids[keys[i]].playerData2.radius = Args[2];
  1607. parentDraw = This.parent;
  1608. while(parentDraw.parent){
  1609. parentDraw = parentDraw.parent;
  1610. }
  1611. }
  1612. }
  1613. }
  1614. },0);
  1615. return originalDrawCircle.call(this,...args);
  1616. };
  1617. Gwindow.requestAnimationFrame = function(...args){
  1618. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  1619. while(parentDraw.parent){
  1620. parentDraw = parentDraw.parent;
  1621. }
  1622. var canv = 0;
  1623. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  1624. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  1625. canv = Gdocument.getElementById("gamerenderer").children[i];
  1626. break;
  1627. }
  1628. }
  1629. var width = parseInt(canv.style["width"]);
  1630. var height = parseInt(canv.style["height"]);
  1631. scale = (parseInt(canv.style["width"])/730);
  1632. var now = Date.now();
  1633. var keys = Object.keys(playerids);
  1634. addto = {"children":[]};
  1635. for(var i = 0;i<parentDraw.children.length;i++){
  1636. if(parentDraw.children[i].constructor.name == "e"){
  1637. addto = parentDraw.children[i];
  1638. break;
  1639. }
  1640. }
  1641. if(pan_enabled && Gdocument.getElementById("gamerenderer")?.childElementCount>0 && (keys_being_held["ShiftLeft"] || keys_being_held["ShiftRight"])){
  1642. var temp_zoom = zoom;
  1643. if(keys_being_held["ArrowUp"]){
  1644. pan.y+=pan_speed/temp_zoom;
  1645. }
  1646. if(keys_being_held["ArrowDown"]){
  1647. pan.y-=pan_speed/temp_zoom;
  1648. }
  1649. if(keys_being_held["ArrowRight"]){
  1650. pan.x-=pan_speed/temp_zoom;
  1651. }
  1652. if(keys_being_held["ArrowLeft"]){
  1653. pan.x+=pan_speed/temp_zoom;
  1654. }
  1655. }
  1656. var panx = 0;
  1657. var pany = 0;
  1658. if(pan){
  1659. panx = pan.x;
  1660. pany = pan.y;
  1661. }
  1662. if(autocam){
  1663. var autocamx = 365*scale;
  1664. var autocamy = 250*scale;
  1665. if(FollowCam && playerids[myid].playerData?.transform){
  1666. autocamx = playerids[myid].playerData.transform.position.x;
  1667. autocamy = playerids[myid].playerData.transform.position.y;
  1668. }
  1669. var distances = {};
  1670. for(var i = 0;i<keys.length;i++){
  1671. if(playerids[keys[i]].playerData && playerids[keys[i]].playerData2){
  1672. if(playerids[keys[i]].playerData.transform){
  1673. var ypos = playerids[keys[i]].playerData.transform.position.y;
  1674. if(ypos>460*scale && ypos< 500 * scale){
  1675. ypos = scale * 460;
  1676. }
  1677. distances[keys[i]] = [playerids[keys[i]].playerData.transform.position.x-autocamx,ypos-autocamy];
  1678. }
  1679. }
  1680. }
  1681. distances["topleft"] = [autocamx-40,autocamy-40];
  1682. distances["topright"] = [690*scale-autocamx,autocamy-40];
  1683. distances["bottomleft"] = [autocamx-40,460*scale-autocamy];
  1684. distances["bottomright"] = [690*scale-autocamx,460*scale-autocamy];
  1685. var lowestD = [-1,-1];
  1686. var keys2 = Object.keys(distances);
  1687. for(var i = 0;i<keys2.length;i++){
  1688. if(Math.abs(distances[keys2[i]][0]/scale)>lowestD[0]){
  1689. lowestD[0] = Math.abs(distances[keys2[i]][0]/scale);
  1690. }
  1691. if(Math.abs(distances[keys2[i]][1]/scale)>lowestD[1]){
  1692. lowestD[1] = Math.abs(distances[keys2[i]][1]/scale);
  1693. }
  1694. }
  1695. var horizontal = (lowestD[0])/345;
  1696. var vertical = (lowestD[1])/230;
  1697. newzoom = Math.min(Math.abs(1/Math.max(horizontal,vertical)),1);
  1698. }
  1699. else{
  1700. newzoom = 1;
  1701. }
  1702. newzoom2 = newzoom2 + 0.15*(newzoom-newzoom2);
  1703. zoom2 = zoom2 + 0.15*(zoom-zoom2);
  1704. addto.scale.x = newzoom2 * zoom2;
  1705. addto.scale.y = newzoom2 * zoom2;
  1706. if(holdheavy>0){
  1707. if(holdheavy==1){
  1708. holdheavy = -1;
  1709. }
  1710. else{
  1711. holdheavy-=1;
  1712. }
  1713. }
  1714. if(playerids[myid].playerData?.children){
  1715. for(var i = 0;i<playerids[myid].playerData.children.length;i++){
  1716. if(playerids[myid].playerData.children[i].alpha!=1){
  1717. heavyid = i;
  1718. }
  1719. if(playerids[myid].playerData.children[i].vertextData){
  1720. if(playerids[myid].playerData.children[i].vertextData.length == 0){
  1721. specialid = i;
  1722. }
  1723. }
  1724. }
  1725. }
  1726. for(var i = 0;i<keys.length;i++){
  1727. if(allstyles[playerids[keys[i]].userName]){
  1728. var isadmin = [false,0];
  1729. for(var i3 = 0;i3<admins.length;i3++){
  1730. if(admins[i3][0] == playerids[keys[i]].userName && !playerids[keys[i].guest]){
  1731. isadmin = [true,i3];
  1732. break;
  1733. }
  1734. }
  1735. if(playerids[keys[i]].playerData?.children){
  1736. for(var i2 = 0;i2<playerids[keys[i]].playerData.children.length;i2++){
  1737. if(playerids[keys[i]].playerData.children[i2].text){
  1738. if(allstyles[playerids[keys[i]].userName][0]==0 && allstyles[playerids[keys[i]].userName][1]==0 && allstyles[playerids[keys[i]].userName][2]==0){
  1739. playerids[keys[i]].playerData.children[i2].tint = 255*256**3-1;
  1740. }
  1741. else{
  1742. playerids[keys[i]].playerData.children[i2].tint = allstyles[playerids[keys[i]].userName][0]*256**2 + allstyles[playerids[keys[i]].userName][1]*256 + allstyles[playerids[keys[i]].userName][2];
  1743. }
  1744. }
  1745. }
  1746. }
  1747. if(isadmin[1]<=3){
  1748. if(isadmin[0]){
  1749. if(playerids[keys[i]].playerData?.children && playerids[keys[i]].guest==false){
  1750. for(var i2 = 0;i2<playerids[keys[i]].playerData.children.length;i2++){
  1751. if(playerids[keys[i]].playerData.children[i2].text && (allstyles[playerids[keys[i]].userName][0]==0 && allstyles[playerids[keys[i]].userName][1]==0 && allstyles[playerids[keys[i]].userName][2]==0)){
  1752. playerids[keys[i]].playerData.children[i2].tint = (75+Math.abs(180-admins[isadmin[1]][1][0]))*256**2 + (75+Math.abs(180-admins[isadmin[1]][1][1]))*256 + 75+Math.abs(180-admins[isadmin[1]][1][2]);
  1753. }
  1754. if(!Array.isArray(playerids[keys[i]].playerData.children[i2].filters)){
  1755. playerids[keys[i]].playerData.children[i2].filters = [new Gwindow.PIXI.filters.ColorMatrixFilter()];
  1756. playerids[keys[i]].playerData.children[i2].filters[0].resolution = 3;
  1757. }
  1758. var rotatevalue = 0;
  1759. if(admins[isadmin[1]][1][3]<90){
  1760. rotatevalue = admins[isadmin[1]][1][3]/2;
  1761. }
  1762. else if(admins[isadmin[1]][1][3]<270){
  1763. rotatevalue =(180-admins[isadmin[1]][1][3])/2;
  1764. }
  1765. else if(admins[isadmin[1]][1][3]<360){
  1766. rotatevalue = (-360+admins[isadmin[1]][1][3])/2;
  1767. }
  1768. playerids[keys[i]].playerData.children[i2].filters[0].hue(rotatevalue);
  1769. }
  1770. }
  1771. }
  1772. }
  1773. }
  1774. }
  1775. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  1776. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  1777. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  1778. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  1779. if(canvasWidth!=width){
  1780. canvasWidth = width;
  1781. pixiCircle.clear();
  1782. pixiCircle.x = parseInt(canv.style["width"])/2;
  1783. pixiCircle.y = parseInt(canv.style["height"])/2;
  1784. pixiCircle.lineStyle(3, 0x8B8000);
  1785. pixiCircle.drawRect(-parseInt(canv.style["width"])/2,-parseInt(canv.style["height"])/2,parseInt(canv.style["width"]),parseInt(canv.style["height"]));
  1786. pixiCircle.lineStyle(3, 0xFF0000);
  1787. pixiCircle.arc(0, 0, 850*scale,Math.atan2(250,-100*Math.sqrt(66)),Math.atan2(250,100*Math.sqrt(66)));
  1788. pixiCircle.lineTo(-100*Math.sqrt(66)*scale,250*scale);
  1789. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  1790. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  1791. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  1792. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  1793. }
  1794. if(!addto.children.includes(container)){
  1795. addto.addChild(container);
  1796. }
  1797. if(keys.length>0){
  1798. if(playerids[myid].playerData && playerids[myid].playerData2){
  1799. if(aimbot || heavybot || staystill){
  1800. var targetid = -1;
  1801. var distances = {};
  1802. if(Gdocument.getElementById("ingamecountdown").style["visibility"] == "hidden"){
  1803. if(playerids[myid].playerData.transform){
  1804. var teamok = true;
  1805. if(playerids[myid].team>1){
  1806. teamok = false;
  1807. }
  1808. for(var i = 0;i<keys.length;i++){
  1809. if(playerids[keys[i]].playerData && playerids[keys[i]].playerData2 && keys[i]!=myid){
  1810. if(playerids[keys[i]].playerData.transform && (playerids[keys[i]].team != playerids[myid].team || teamok || FFA)){
  1811. 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);
  1812. }
  1813. }
  1814. }
  1815. }
  1816. }
  1817. var lowestD = [-1,-1];
  1818. var keys2 = Object.keys(distances);
  1819. for(var i = 0;i<keys2.length;i++){
  1820. if(myid != keys2[i]){
  1821. if(lowestD[1] == -1){
  1822. lowestD[1] = distances[keys2[i]];
  1823. lowestD[0] = keys2[i];
  1824. }
  1825. else if(distances[keys2[i]]<lowestD[1]){
  1826. lowestD[1] = distances[keys2[i]];
  1827. lowestD[0] = keys2[i];
  1828. }
  1829. }
  1830. }
  1831. targetid = lowestD[0];
  1832. if(playerids[myid].playerData?.transform && playerids[myid].playerData2){
  1833. if(staystill & staystillpos[0]!=null){
  1834. var playerpos = playerids[myid].playerData.transform.position;
  1835. if(Math.abs(staystillpos[0]-playerpos.x/scale)<3){
  1836. if(playerids[myid].playerData2.xvel/scale>0){
  1837. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1838. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1839. }
  1840. else if(playerids[myid].playerData2.xvel/scale<0){
  1841. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1842. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1843. }
  1844. else{
  1845. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1846. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1847. }
  1848. }
  1849. else{
  1850. if(staystillpos[0]>playerpos.x/scale){
  1851. if(playerids[myid].playerData2.xvel/scale>10){
  1852. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1853. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1854. }
  1855. else{
  1856. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1857. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1858. }
  1859. }
  1860. else if(staystillpos[0]<playerpos.x/scale){
  1861. if(playerids[myid].playerData2.xvel/scale<-10){
  1862. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1863. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1864. }
  1865. else{
  1866. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1867. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1868. }
  1869. }
  1870. }
  1871. }
  1872. }
  1873. if(targetid != -1 && playerids[myid].playerData?.transform){
  1874. if(playerids[myid].playerData.children.length >= 7 && playerids[targetid].playerData && playerids[targetid].playerData.transform && playerids[targetid].playerData2 && aimbot){
  1875. var indexE = -1;
  1876. for(var i = 0;i<playerids[myid].playerData.children.length;i++){
  1877. if(playerids[myid].playerData.children[i].constructor.name == "e"){
  1878. indexE = i;
  1879. break;
  1880. }
  1881. }
  1882. if(indexE != -1 && playerids[myid].playerData.children[indexE].visible){
  1883. if(started == 0){
  1884. started = now;
  1885. }
  1886. var scale2=1/(parseInt(canv.style["width"])/730);
  1887. scale2 /= scale/(1 + playerids[myid].playerData2.balance*0.0088)*(playerids[myid].playerData2.radius/12);
  1888. var Dstarted = (Math.min((now-started)/1000,10/3)/(10/3));
  1889. var v = multiplier * (Dstarted*100+15)*scale2;
  1890. var g = gravity;
  1891. var mypos = playerids[myid].playerData.transform.position;
  1892. var targetpos = playerids[targetid].playerData.transform.position;
  1893. var deltapos = [(targetpos.x-mypos.x)*scale2,(targetpos.y-mypos.y)*scale2];
  1894. var dis = (Math.sqrt(deltapos[0]**2 + deltapos[1]**2))/v*prediction;
  1895. deltapos[0]+=(playerids[targetid].playerData2.xvel*scale2*dis+(playerids[targetid].playerData2.xacc*scale2*(dis))**2/2);
  1896. deltapos[1]+=(playerids[targetid].playerData2.yvel*scale2*dis+(playerids[targetid].playerData2.yacc*scale2*(dis))**2/2);
  1897. deltapos[1] = -deltapos[1];
  1898. var angle = positive(-Math.atan2(deltapos[1],deltapos[0]));
  1899. var rot = playerids[myid].playerData.children[indexE].transform.rotation;
  1900. rot = positive(rot);
  1901. angle = positive(angle);
  1902. var alpha = deltapos[0];
  1903. var beta = deltapos[1];
  1904. var v_squared = v**2;
  1905. var eff = 2*v_squared/g;
  1906. var rootterm = eff*(eff-2*beta)-2*alpha**2;
  1907. if(rootterm < 0) {
  1908. } else {
  1909. gamma_first = (eff + Math.sqrt(rootterm));
  1910. gamma_second = (eff - Math.sqrt(rootterm));
  1911. theta_first = positive(-Math.atan2(gamma_first, alpha));
  1912. theta_second = positive(-Math.atan2(gamma_second, alpha));
  1913. if(angle_between(angle,theta_first)<angle_between(angle,theta_second)){
  1914. angle = theta_first;
  1915. }
  1916. else{
  1917. angle = theta_second;
  1918. }
  1919. }
  1920. var min = angle_between(angle,rot);
  1921. if(angle_between2(angle,rot)<0){
  1922. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1923. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1924. }
  1925. else{
  1926. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1927. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1928. }
  1929. if(min<0.05){
  1930. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1931. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1932. }
  1933. }
  1934. else if(started>0){
  1935. started = 0;
  1936. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1937. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1938. }
  1939. }
  1940. }
  1941. if(playerids[myid].playerData?.transform && heavybot && mode!="f" && mode!="bs"){
  1942. var myradius = playerids[myid].playerData2.radius / scale;
  1943. var mypos = playerids[myid].playerData.transform.position;
  1944. var breakout = false;
  1945. for(var i = 0;i<keys2.length;i++){
  1946. var targetradius = playerids[keys2[i]].playerData2.radius / scale;
  1947. var targetpos = playerids[keys2[i]].playerData.transform.position;
  1948. var deltapos = [(targetpos.x-mypos.x)/scale,(targetpos.y-mypos.y)/scale];
  1949. for(var i2 = 0;i2<160;i2++){
  1950. deltapos2 = [...deltapos];
  1951. var i3 = i2*0.5;
  1952. deltapos2[0]+=((playerids[keys2[i]].playerData2.xvel-playerids[myid].playerData2.xvel)/scale*i3);
  1953. deltapos2[1]+=((playerids[keys2[i]].playerData2.yvel-playerids[myid].playerData2.yvel)/scale*i3);
  1954. var dis = Math.sqrt(deltapos2[0]**2+deltapos2[1]**2);
  1955. if(dis<myradius+targetradius){
  1956. breakout = true;
  1957. holdheavy = 20;
  1958. break;
  1959. }
  1960. }
  1961. if(breakout){
  1962. break;
  1963. }
  1964. }
  1965. if(holdheavy>0){
  1966. if(!heavyheld2){
  1967. heavyheld = playerids[myid].playerData.children[heavyid].alpha>0;
  1968. }
  1969. fire("keydown",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  1970. heavyheld2 = true;
  1971. if(mode == "sp"){
  1972. if(!grappleheld2){
  1973. grappleheld = playerids[myid].playerData.children[specialid].vertexData?.length>0;
  1974. }
  1975. if(grappleheld){
  1976. fire("keyup",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  1977. }
  1978. grappleheld2 = true;
  1979. }
  1980. }
  1981. else if(holdheavy<0){
  1982. holdheavy = 0;
  1983. heavyheld2 = false;
  1984. grappleheld2 = false;
  1985. if(!heavyheld){
  1986. heavyheld = false;
  1987. fire("keyup",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  1988. }
  1989. if(grappleheld && mode == "sp"){
  1990. grappleheld = false;
  1991. fire("keydown",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  1992. }
  1993. }
  1994. else{
  1995. heavyheld2 = false;
  1996. heavyheld = false;
  1997. grappleheld2 = false;
  1998. grappleheld = false;
  1999. }
  2000. }
  2001. }
  2002. if(FollowCam){
  2003. if(playerids[myid].playerData?.transform){
  2004. pixiCircle.visible = true;
  2005. parentDraw.x = -playerids[myid].playerData.x*addto.scale.x+parseInt(width)/2;
  2006. parentDraw.y = -playerids[myid].playerData.y*addto.scale.y+parseInt(height)/2;
  2007. parentDraw.children[0].x = playerids[myid].playerData.x*addto.scale.x-parseInt(width)/2;
  2008. parentDraw.children[0].y = playerids[myid].playerData.y*addto.scale.y-parseInt(height)/2;
  2009. }
  2010. else{
  2011. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  2012. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  2013. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  2014. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  2015. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  2016. pixiCircle.visible = false;
  2017. }
  2018. else{
  2019. pixiCircle.visible = true;
  2020. }
  2021. }
  2022. }
  2023. }
  2024. }
  2025. if(!FollowCam){
  2026. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !pan_enabled){
  2027. pixiCircle.visible = false;
  2028. }
  2029. else{
  2030. pixiCircle.visible = true;
  2031. }
  2032. }
  2033. parentDraw.x+=panx*addto.scale.x;
  2034. parentDraw.y+=pany*addto.scale.y;
  2035. parentDraw.children[0].x-=panx*addto.scale.x;
  2036. parentDraw.children[0].y-=pany*addto.scale.y;
  2037. }
  2038. if(maxfps){
  2039. return setTimeout.call(this,...args);
  2040. }
  2041. return requestAnimationFrameOriginal.call(this,...args);
  2042. };
  2043. scope.SENDFUNCTION = function(args){return args;};
  2044. scope.RECIEVEFUNCTION = function(args){return args;};
  2045. scope.EVENTLOOPFUNCTION = function(){};
  2046. Gwindow.WebSocket.prototype.send = function(args) {
  2047. if(this.url.includes("socket.io/?EIO=3&transport=websocket&sid=")){
  2048. if(typeof(args) == "string" && !bonkwssextra.includes(this)){
  2049. args = SENDFUNCTION(args);
  2050. wsssendlog.push(args);
  2051. wsssendrecievelog.push([0,args]);
  2052. if(!bonkwss){
  2053. bonkwss = this;
  2054. }
  2055. if(args.startsWith('42[26,')){
  2056. var jsonargs = JSON.parse(args.substring(2));
  2057. if(sandboxon){
  2058. if(typeof(sandboxplayerids[jsonargs[1]["targetID"]])!='undefined'){
  2059. var packet = '42[18,'+jsonargs[1]["targetID"]+','+jsonargs[1]["targetTeam"]+']';
  2060. RECIEVE(packet);
  2061. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  2062. }
  2063. }
  2064. }
  2065. if(args.startsWith('42[9,')){
  2066. var jsonargs = JSON.parse(args.substring(2));
  2067. if(sandboxon){
  2068. if(typeof(sandboxplayerids[jsonargs[1]["banshortid"]])!='undefined'){
  2069. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
  2070. var packet = '42[24,'+jsonargs[1]["banshortid"].toString()+','+jsonargs[1]["kickonly"]+']';
  2071. var packet2 = '42[5,'+jsonargs[1]["banshortid"].toString()+',0]';
  2072. RECIEVE(packet);
  2073. RECIEVE(packet2);
  2074. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet,packet2],to:[-1]}]));
  2075. }
  2076. else{
  2077. displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
  2078. }
  2079. }
  2080. }
  2081. }
  2082. if(args.startsWith('42[1,')){
  2083. return;
  2084. }
  2085. if(args.startsWith('42[4,')){
  2086. var jsonargs = JSON.parse(args.substring(2));
  2087. if(sandboxcopyme==myid && typeof(jsonargs[1]["i"])!="undefined"){
  2088. var jsonkeys = Object.keys(sandboxplayerids);
  2089. var jsonargs2 = jsonargs[1];
  2090. for(var i = 0; i<jsonkeys.length;i++){
  2091. jsonargs2["c"] = playerids[jsonkeys[i]].movecount;
  2092. var packet = '42[7,'+jsonkeys[i].toString()+','+JSON.stringify(jsonargs2)+']';
  2093. RECIEVE(packet);
  2094. }
  2095. jsonargs2["c"] = "CVALUE";
  2096. jsonargs2 = JSON.stringify(jsonargs2).replace('"CVALUE"',"CVALUE");
  2097. SEND("42"+JSON.stringify([4,{"type":"customfakerecieve","from":username,"packet":['42[7,ID,'+jsonargs2+']'],to:[-1]}]));
  2098. }
  2099. if(typeof(jsonargs[1]["i"]) != "undefined"){
  2100. if(playerids[myid].movecount>=jsonargs[1]["c"]){
  2101. jsonargs[1]["c"] = playerids[myid].movecount;
  2102. playerids[myid].movecount+=1;
  2103. }
  2104. else{
  2105. playerids[myid].movecount = jsonargs[1]["c"]+1;
  2106. }
  2107. }
  2108. if(recording && typeof(jsonargs[1]["i"])!="undefined"){
  2109. if(myid.toString() == recordingid){
  2110. if(recordingdata.length == 0){
  2111. recordingdata.push([jsonargs[1]["i"],jsonargs[1]["f"]]);
  2112. }
  2113. else{
  2114. recordingdata.push([jsonargs[1]["i"],jsonargs[1]["f"]-recordingdata[0][1]]);
  2115. }
  2116. }
  2117. }
  2118. playerids[myid].lastmove = Date.now();
  2119. if(ishost && typeof(jsonargs[1]["i"])!="undefined"){
  2120. for(var i = 0;i<disabledkeys.length;i++){
  2121. if(GET_KEYS(jsonargs[1]["i"])[disabledkeys[i]]){
  2122. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(myid)){
  2123. killedids.push(myid);
  2124. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  2125. SEND('42[25,{"a":{"playersLeft":['+myid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2126. RECIEVE('42[31,{"a":{"playersLeft":['+myid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2127. break;
  2128. }
  2129. }
  2130. }
  2131. }
  2132. args = "42"+JSON.stringify(jsonargs);
  2133. }
  2134. if(args.startsWith('42[29,')){
  2135. var jsonargs = JSON.parse(args.substring(2));
  2136. playerids[jsonargs[1]["sid"]].playerData2.balance = jsonargs[1]["bal"];
  2137. if(sandboxon){
  2138. if(typeof(sandboxplayerids[jsonargs[1]["sid"]])!='undefined'){
  2139. var packet = '42[36,'+jsonargs[1]["sid"]+','+jsonargs[1]["bal"]+']';
  2140. RECIEVE(packet);
  2141. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  2142. }
  2143. }
  2144. }
  2145. if(args.startsWith('42[12,')){
  2146. playerids = {};
  2147. var jsonargs2 = JSON.parse(args.substring(2));
  2148. var jsonargs = jsonargs2[1];
  2149. 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(),"style":0},"vote":{"poll":-1}};
  2150. allstyles[username] = [0,0,0];
  2151. myid = 0;
  2152. bonkwss = this;
  2153. hostid = 0;
  2154. inroom = true;
  2155. if(savedrooms.length>0){
  2156. Gdocument.getElementById("roomlistrefreshbutton").click();
  2157. }
  2158. }
  2159. if(args.startsWith('42[10')){
  2160. var jsonargs = JSON.parse(args.substring(2));
  2161. if(jsonargs[2]){
  2162. args = "42"+JSON.stringify([10,jsonargs[1]]);
  2163. }
  2164. else if(translating2[0]){
  2165. text = translate(jsonargs[1]["message"],"auto",translating2[1]).then(function(r){SEND("42"+JSON.stringify([10,{"message":r},true]))});
  2166. return;
  2167. }
  2168. }
  2169. if (args.startsWith('42[23,')) {
  2170. var jsonargs = JSON.parse(args.substring(2));
  2171. var map = decodeFromDatabase(jsonargs[1]["m"]);
  2172. currentmap.push(map);
  2173. }
  2174. if(args.startsWith('42[23,') && recteams){
  2175. var jsonargs = JSON.parse(args.substring(2));
  2176. var map = decodeFromDatabase(jsonargs[1]["m"]);
  2177. var spawns = map["spawns"];
  2178. var teamsneeded = true;
  2179. var excludedindexes = [];
  2180. var ffaspawns = false;
  2181. var ffaforsure = false;
  2182. for(var i = 0; i<spawns.length;i++){
  2183. var currentSpawn = spawns[i];
  2184. if(Math.sqrt(currentSpawn.x**2 + currentSpawn.y**2)>=850 || currentSpawn.y>250){
  2185. excludedindexes.push(i);
  2186. }
  2187. else if(!(currentSpawn.f || currentSpawn.r || currentSpawn.b || currentSpawn.gr || currentSpawn.ye)){
  2188. excludedindexes.push(i);
  2189. }
  2190. else if(currentSpawn.f){
  2191. ffaspawns = true;
  2192. if(!(currentSpawn.r || currentSpawn.b || currentSpawn.gr || currentSpawn.ye)){
  2193. excludedindexes.push(i);
  2194. ffaforsure = true
  2195. }
  2196. }
  2197. }
  2198. if(!ffaspawns && !ffaforsure){
  2199. teamsneeded = true;
  2200. }
  2201. else{
  2202. teamsneeded = false;
  2203. }
  2204. if(teamsneeded){
  2205. var newspawns = [];
  2206. for(var i = 0; i<spawns.length;i++){
  2207. if(!excludedindexes.includes(i)){
  2208. 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"]});
  2209. }
  2210. }
  2211. if(newspawns.length>0){
  2212. var teamletters = ["r","g","b","y"];
  2213. var ratios = {"r":0,"g":0,"b":0,"y":0};
  2214. for(var i = 0; i < newspawns.length;i++){
  2215. for(var i2 = 0; i2<teamletters.length;i2++){
  2216. var ct = teamletters[i2];
  2217. if(newspawns[i]["priority"]!=0){
  2218. ratios[ct]+=(newspawns[i][ct])/newspawns[i]["total"]*newspawns[i]["priority"];
  2219. }
  2220. }
  2221. }
  2222. var highest = ["",0];
  2223. for(var i = 0; i<teamletters.length;i++){
  2224. var ct = teamletters[i];
  2225. if(ratios[ct]>0 && highest[1]<ratios[ct]){
  2226. highest = [ct,ratios[ct]];
  2227. }
  2228. }
  2229. if(highest[0]!=""){
  2230. for(var i = 0; i<teamletters.length;i++){
  2231. var ct = teamletters[i];
  2232. ratios[ct] = ratios[ct]/highest[1];
  2233. }
  2234. }
  2235. var playerids3 = Object.keys(playerids);
  2236. var playerids2 = [];
  2237. for(var i = 0; i<playerids3.length;i++){
  2238. if(playerids[playerids3[i]].team>0){
  2239. playerids2.push(playerids3[i]);
  2240. }
  2241. }
  2242. var pi2l = playerids2.length;
  2243. var ratios2 = {"r":0,"r1":0,"g":0,"g1":0,"b":0,"b1":0,"y":0,"y1":0};
  2244. var items = Object.entries(ratios);
  2245. items.sort(function(a,b){return a[1]-b[1];});
  2246. var items = items.map(function(e){return e[0];});
  2247. var highest2 = ["",0];
  2248. while(pi2l>0){
  2249. var done = false;
  2250. for(var i2 = 0; i2<items.length;i2++){
  2251. var ci = items[i2];
  2252. var ci2 = items[i2]+"1";
  2253. for(var i = 0; i<teamletters.length;i++){
  2254. var ct = teamletters[i];
  2255. if(ratios2[ct]>0 && highest2[1]<ratios2[ct]){
  2256. highest2 = [ct,ratios2[ct]];
  2257. }
  2258. }
  2259. if(highest2[0]!=""){
  2260. for(var i = 0; i<teamletters.length;i++){
  2261. var ct = teamletters[i];
  2262. ratios2[ct+"1"] = ratios2[ct]/highest2[1];
  2263. }
  2264. }
  2265. if(ratios[ci]>0 && ratios[ci]>=ratios2[ci2] && pi2l>0){
  2266. ratios2[ci]+=1;
  2267. pi2l--;
  2268. done = true;
  2269. }
  2270. }
  2271. if(pi2l>0 && !done){
  2272. ratios2[highest2[0]]+=1;
  2273. pi2l--;
  2274. }
  2275. }
  2276. SEND('42[32,{"t":true}]');
  2277. RECIEVE('42[39,true]');
  2278. for(var i = 0; i<ratios2["r"];i++){
  2279. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  2280. SEND('42[26,{"targetID":'+pid+',"targetTeam":2}]');
  2281. if(playerids[pid].peerID!="sandbox"){
  2282. RECIEVE('42[18,'+pid+',2]');
  2283. }
  2284. }
  2285. for(var i = 0; i<ratios2["g"];i++){
  2286. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  2287. SEND('42[26,{"targetID":'+pid+',"targetTeam":4}]');
  2288. if(playerids[pid].peerID!="sandbox"){
  2289. RECIEVE('42[18,'+pid+',4]');
  2290. }
  2291. }
  2292. for(var i = 0; i<ratios2["b"];i++){
  2293. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  2294. SEND('42[26,{"targetID":'+pid+',"targetTeam":3}]');
  2295. if(playerids[pid].peerID!="sandbox"){
  2296. RECIEVE('42[18,'+pid+',3]');
  2297. }
  2298. }
  2299. for(var i = 0; i<ratios2["y"];i++){
  2300. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  2301. SEND('42[26,{"targetID":'+pid+',"targetTeam":5}]');
  2302. if(playerids[pid].peerID!="sandbox"){
  2303. RECIEVE('42[18,'+pid+',5]');
  2304. }
  2305. }
  2306. }
  2307. }
  2308. else{
  2309. SEND('42[32,{"t":false}]');
  2310. RECIEVE('42[39,false]');
  2311. }
  2312. }
  2313. if(args.startsWith('42[47,') && stopquickplay == 0 && ishost && document.hidden && !qppaused){
  2314. roundsperqp2++;
  2315. if(roundsperqp2>=roundsperqp){
  2316. if(shuffle){
  2317. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2318. var available = [];
  2319. var availableindexes = [];
  2320. var notempty = false;
  2321. for(var i = 0; i<e2.length;i++){
  2322. var a = false;
  2323. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2324. available.push(a);
  2325. if(a){
  2326. availableindexes.push(i);
  2327. notempty = true;
  2328. }
  2329. }
  2330. if(notempty){
  2331. if(availableindexes.length!=1){
  2332. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  2333. }
  2334. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  2335. }
  2336. }
  2337. else{
  2338. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2339. var available = [];
  2340. var availableindexes = [];
  2341. var notempty = false;
  2342. for(var i = 0; i<e2.length;i++){
  2343. var a = false;
  2344. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2345. available.push(a);
  2346. if(a){
  2347. availableindexes.push(i);
  2348. notempty = true;
  2349. }
  2350. }
  2351. if(notempty){
  2352. var above = [];
  2353. for(var i = 0;i<availableindexes.length;i++){
  2354. if(availableindexes[i]>quicki && !reverseqp){
  2355. above.push(availableindexes[i]);
  2356. }
  2357. else if(availableindexes[i]<quicki && reverseqp){
  2358. above.push(availableindexes[i])
  2359. }
  2360. }
  2361. if(above.length>0){
  2362. quicki = above[0];
  2363. if(reverseqp){
  2364. quicki = above[above.length-1];
  2365. }
  2366. }
  2367. else{
  2368. quicki = availableindexes[0];
  2369. if(reverseqp){
  2370. quicki = availableindexes[availableindexes.length-1];
  2371. }
  2372. }
  2373. }
  2374. }
  2375. }
  2376. canceled = false;
  2377. startedinqp = true;
  2378. window.map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length),0);
  2379. }
  2380. if(args.startsWith('42[32,')){
  2381. var jsonargs = JSON.parse(args.substring(2));
  2382. var keys = Object.keys(playerids);
  2383. if(!jsonargs[1]["t"]){
  2384. FFA = true;
  2385. for(var i = 0;i<keys.length;i++){
  2386. if(playerids[keys[i]].team!=0){
  2387. playerids[keys[i]].team = 1;
  2388. }
  2389. }
  2390. }
  2391. else{
  2392. FFA = false;
  2393. }
  2394. }
  2395. if(args.startsWith('42[5,')){
  2396. var jsonargs = JSON.parse(args.substring(2));
  2397. if(stopquickplay!=1 && startedinqp){
  2398. startedinqp = false;
  2399. jsonargs[1]["gs"]["wl"] = 999;
  2400. if(!instaqp){
  2401. var jsonargs2 = decodeIS(jsonargs[1]["is"]);
  2402. jsonargs2["ftu"] = 60;
  2403. if(jsonargs2["mm"]["rxa"] != ""){
  2404. jsonargs2["mm"]["a"] = jsonargs2["mm"]["rxa"];
  2405. jsonargs2["mm"]["n"] = jsonargs2["mm"]["rxn"];
  2406. }
  2407. jsonargs2 = encodeIS(jsonargs2);
  2408. jsonargs[1]["is"] = jsonargs2;
  2409. var jsonargs3 = decodeFromDatabase(jsonargs[1]["gs"]["map"]);
  2410. if(jsonargs3["m"]["rxa"] != ""){
  2411. jsonargs3["m"]["a"] = jsonargs3["m"]["rxa"];
  2412. jsonargs3["m"]["n"] = jsonargs3["m"]["rxn"];
  2413. }
  2414. jsonargs3 = encodeToDatabase(jsonargs3);
  2415. jsonargs[1]["gs"]["map"] = jsonargs3;
  2416. }
  2417. }
  2418. args = "42"+JSON.stringify(jsonargs);
  2419. }
  2420. }
  2421. }
  2422. else{
  2423. if(args.includes("rport")){
  2424. return;
  2425. }
  2426. }
  2427. if(this.url.includes("socket.io/?EIO=3&transport=websocket&sid=") && !this.injected){
  2428. this.injected = true;
  2429. var originalRecieve = this.onmessage;
  2430. this.onmessage = function(args){
  2431. if(!bonkwssextra.includes(this)){
  2432. if (typeof (args.data) == "string" && args.data.startsWith("42[")) {
  2433. args = { "data": args.data };
  2434. var args2 = JSON.parse(args.data.substring(2));
  2435. args2[0] = parseInt(args2[0]);
  2436. args.data = "42"+JSON.stringify(args2);
  2437. }
  2438. wssrecievelog.push(args.data);
  2439. wsssendrecievelog.push([1,args.data]);
  2440. if(typeof(args.data)=="string"){
  2441. args = {"data":RECIEVEFUNCTION(args.data)};
  2442. if(args.data.startsWith('42[1,')){
  2443. var jsonargs = JSON.parse(args.data.substring(2));
  2444. originalSend.call(this,'42[1,{"id":'+jsonargs[2]+'}]');
  2445. }
  2446. if(args.data.startsWith('42[36,')){
  2447. var jsonargs = JSON.parse(args.data.substring(2));
  2448. playerids[jsonargs[1]].playerData2.balance = jsonargs[2];
  2449. }
  2450. if(args.data.startsWith('42[24,')){
  2451. beenKickedTimeStamp = Date.now();
  2452. onlykicked = JSON.parse(args.data.substring(2))[2];
  2453. }
  2454. if(args.data.startsWith('42[21,')){
  2455. recievedinitdata = true;
  2456. var jsonargs = JSON.parse(args.data.substring(2));
  2457. currentmap.push(jsonargs[1]["map"]);
  2458. }
  2459. if(args.data.startsWith('42[48,')){
  2460. recievedinitdata = true;
  2461. }
  2462. if(args.data.startsWith('42[23,')){
  2463. var jsonargs = JSON.parse(args.data.substring(2));
  2464. if(causelag){
  2465. jsonargs[1]["result"]-=causelag2;
  2466. }
  2467. args.data = '42'+JSON.stringify(jsonargs);
  2468. }
  2469. if(args.data.startsWith('42[16,')){
  2470. var jsonargs = JSON.parse(args.data.substring(2));
  2471. var now = Date.now();
  2472. if(jsonargs[1]=="chat_rate_limit"){
  2473. if(pollactive[1]+100>now){
  2474. pollactive = [false,0,0,[]];
  2475. displayInChat("Your poll failed due to chat rate limit.","#DA0808","#1EBCC1");
  2476. displayInChat("Please try again.","#DA0808","#1EBCC1");
  2477. }
  2478. }
  2479. else if(jsonargs[1]=="room_full"){
  2480. if(!savedrooms.includes(currentroomaddress)){
  2481. savedroombutton.className = "brownButton brownButton_classic buttonShadow";
  2482. }
  2483. }
  2484. }
  2485. if(args.data.startsWith('42[6,')){
  2486. var jsonargs = JSON.parse(args.data.substring(2));
  2487. if(typeof(playerids[jsonargs[1]])!='undefined'){
  2488. delplayerids[jsonargs[1]] = playerids[jsonargs[1]];
  2489. delete playerids[jsonargs[1]];
  2490. }
  2491. hostid = jsonargs[2];
  2492. }
  2493. if(args.data.startsWith('42[39,')){
  2494. var jsonargs = JSON.parse(args.data.substring(2));
  2495. var keys = Object.keys(playerids);
  2496. if(!jsonargs[1]){
  2497. FFA = true;
  2498. for(var i = 0;i<keys.length;i++){
  2499. if(playerids[keys[i]].team!=0){
  2500. playerids[keys[i]].team = 1;
  2501. }
  2502. }
  2503. }
  2504. else{
  2505. FFA = false;
  2506. }
  2507. }
  2508. if(args.data.startsWith('42[41,')){
  2509. var jsonargs = JSON.parse(args.data.substring(2));
  2510. hostid = jsonargs[1]["newHost"];
  2511. }
  2512. if (args.data.startsWith('42[29,')) {
  2513. var jsonargs = JSON.parse(args.data.substring(2));
  2514. currentmap.push(decodeFromDatabase(jsonargs[1]));
  2515. }
  2516. if(args.data.startsWith('42[20,')){
  2517. var jsonargs = JSON.parse(args.data.substring(2));
  2518. if(translating[0]){
  2519. translate(jsonargs[2],"auto",translating[1]).then(function(r){if(r==jsonargs[2]){return;} displayInChat(playerids[jsonargs[1]].userName+": "+r,"#DA0808","#1EBCC1")});
  2520. }
  2521. if(echo_list.includes(playerids[jsonargs[1]].userName)){
  2522. chat(flag_manage(echotext.replaceAll("username",playerids[jsonargs[1]].userName).replaceAll("message",jsonargs[2])));
  2523. }
  2524. if(randomchat){
  2525. var isin = false;
  2526. for(var i = 0;i<randomchatpriority[1].length;i++){
  2527. if(randomchatpriority[1][i][0] == jsonargs[2]){
  2528. isin = true;
  2529. if(myid!=jsonargs[1]){
  2530. randomchatpriority[1][i][1]+=2;
  2531. randomchatpriority[0]+=2;
  2532. }
  2533. break;
  2534. }
  2535. }
  2536. if(!isin){
  2537. randomchatpriority[1].push([jsonargs[2],Math.max(35-Math.abs(35-jsonargs[2].length),1)]);
  2538. randomchatpriority[0]+=Math.max(35-Math.abs(35-jsonargs[2].length),1);
  2539. }
  2540. }
  2541. if(pollactive[0] || pollactive2[0]){
  2542. var chatmessage = jsonargs[2].toUpperCase().trim().replace(")","");
  2543. var lettersindex = letters.indexOf(chatmessage);
  2544. if(ishost){
  2545. if(pollactive[3].length>0 && lettersindex!=-1 && lettersindex<pollactive[3].length){
  2546. playerids[jsonargs[1]].vote.poll = lettersindex;
  2547. }
  2548. }
  2549. else{
  2550. if(pollactive2[2].length>0 && lettersindex!=-1 && lettersindex<pollactive2[2].length){
  2551. playerids[jsonargs[1]].vote.poll = lettersindex;
  2552. }
  2553. }
  2554. }
  2555. }
  2556. if(args.data.startsWith('42[32')){
  2557. SEND('42[4,{"type":"inactive kick counter"}]');
  2558. }
  2559. if(args.data.startsWith('42[18')){
  2560. var jsonargs = JSON.parse(args.data.substring(2));
  2561. playerids[jsonargs[1]].team = jsonargs[2];
  2562. }
  2563. if(args.data.startsWith('42[40,')){
  2564. recordedTimeStamp = Date.now();
  2565. recordedId = JSON.parse(args.data.substring(2))[1];
  2566. }
  2567. if(args.data.startsWith('42[3,')){
  2568. playerids = {};
  2569. var jsonargs = JSON.parse(args.data.substring(2));
  2570. var jsonargs2 = JSON.parse(args.data.substring(2));
  2571. for(var i = 0; i<jsonargs[3].length;i++){
  2572. if(jsonargs[3][i]!=null){
  2573. if(jsonargs[3][i].userName == "Juice1313" && jsonargs[3][i].level > 0){
  2574. jsonargs2[3][i].userName = "Piss1313";
  2575. jsonargs[3][i].userName = "Piss1313";
  2576. }
  2577. if(jsonargs[3][i].userName == "LEGENDBOSS123" && jsonargs[3][i].level > 0){
  2578. jsonargs2[3][i].level = -jsonargs2[3][i].level;
  2579. }
  2580. playerids[i.toString()] = jsonargs[3][i];
  2581. playerids[i.toString()].commands = false;
  2582. playerids[i.toString()].ratelimit = {"pm":0,"mode":0,"team":0,"poll":0,"join":Date.now(),"style":0};
  2583. playerids[i.toString()].vote = {"poll":-1};
  2584. allstyles[playerids[i.toString()].userName] = [0,0,0];
  2585. }
  2586. }
  2587. if(playerids[jsonargs[1]].userName.startsWith(Gdocument.getElementById("pretty_top_name").textContent)){
  2588. myid = jsonargs[1];
  2589. bonkwss = this;
  2590. playerids[myid].commands = true;
  2591. /*setTimeout(function(){var me = playerids[myid];RECIEVE('42'+JSON.stringify([4,myid,me.peerID,me.userName,me.guest,me.level,me.team,me.avatar]));});*/
  2592. }
  2593. else{
  2594. bonkwssextra.push(this);
  2595. }
  2596. inroom = true;
  2597. hostid = jsonargs[2];
  2598. SEND('42[4,{"type":"commands"}]');
  2599. SEND("42"+JSON.stringify([4,{"type":"style","from":username,"style":mystyle}]));
  2600. allstyles[playerids[myid].userName] = [...mystyle];
  2601. ghostroomwss = bonkwss;
  2602. Gdocument.getElementById("roomlistrefreshbutton").click();
  2603. setTimeout(function(){if(bonkwss == ghostroomwss && !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);
  2604. args.data = "42"+JSON.stringify(jsonargs2);
  2605. }
  2606. if(args.data.startsWith('42[21,')){
  2607. var jsonargs = JSON.parse(args.data.substring(2));
  2608. mode = jsonargs[1]["mo"];
  2609. FFA = !jsonargs[1]["tea"];
  2610. }
  2611. if(args.data.startsWith('42[48,')){
  2612. var jsonargs = JSON.parse(args.data.substring(2));
  2613. currentmap.push(decodeFromDatabase(jsonargs[1]["gs"]["map"]));
  2614. mode = jsonargs[1]["gs"]["mo"];
  2615. FFA = !jsonargs[1]["gs"]["tea"];
  2616. }
  2617. if(args.data.startsWith('42[49,')){
  2618. /*
  2619. var me = playerids[myid];
  2620. RECIEVE('42'+JSON.stringify([4,myid,me.peerID,me.userName,me.guest,me.level,me.team,me.avatar]));
  2621. */
  2622. }
  2623. if(args.data.startsWith('42[15,')){
  2624. var jsonargs = JSON.parse(args.data.substring(2));
  2625. dontswitch = false;
  2626. mode = jsonargs[3]["mo"];
  2627. gameStartTimeStamp = jsonargs[1];
  2628. killedids = [];
  2629. Gdocument.getElementById("newbonklobby").style["z-index"] = "unset";
  2630. Gdocument.getElementById("mapeditorcontainer").style["z-index"] = "unset";
  2631. currentmap.push(decodeFromDatabase(jsonargs[3]["map"]));
  2632. }
  2633. if(args.data.startsWith('42[33,')){
  2634. var jsonargs = JSON.parse(args.data.substring(2));
  2635. var decodedmap = decodeFromDatabase(jsonargs[1]);
  2636. if(decodedmap!=0){
  2637. requestedmaps = [[decodedmap,jsonargs[1]]].concat(requestedmaps);
  2638. }
  2639. }
  2640. if(args.data.startsWith('42[7,')){
  2641. var jsonargs2 = JSON.parse(args.data.substring(2));
  2642. var idofpacket = jsonargs2[1];
  2643. jsonargs = jsonargs2[2];
  2644. if(typeof(jsonargs["i"]) == "undefined"){
  2645. if(jsonargs["type"]=="private chat" && jsonargs["to"] == username){
  2646. from = jsonargs["from"];
  2647. if(Object.keys(playerids).includes(idofpacket.toString())){
  2648. from = playerids[idofpacket].userName;
  2649. }
  2650. if(!ignorepmlist.includes(from)){
  2651. if(typeof(jsonargs["message"])=="string"){
  2652. var now = Date.now();
  2653. if(playerids[idofpacket].ratelimit.pm+500<now){
  2654. playerids[idofpacket].ratelimit.pm = now;
  2655. DECRYPT_MESSAGE(private_key,jsonargs["message"]).then(function(e){
  2656. var encodedtext = e;
  2657. 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);';
  2658. displayInChat('> '+'<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+sanitize(from)+'</a>'+': ',"#DA0808","#1EBCC1",{sanitize:false},encodedtext);
  2659. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  2660. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  2661. Laster_message = lastmessage();
  2662. }).catch(function(){EXPORT_KEY(public_key).then(function(e){SEND("42"+JSON.stringify([4,{"type":"public key correction","from":username,"to":private_chat_public_key[0],"public key":e}]));});});
  2663. }
  2664. }
  2665. }
  2666. }
  2667. if(jsonargs["type"]=="request public key" && jsonargs["to"] == username){
  2668. EXPORT_KEY(public_key).then(function(e){SEND("42"+JSON.stringify([4,{"type":"public key","from":username,"public key":e}]));});
  2669. }
  2670. if(jsonargs["type"]=="private chat users" && pmuserstimestamp+1500>Date.now()){
  2671. if(typeof(jsonargs["from"])!='undefined'){
  2672. from = jsonargs["from"];
  2673. if(Object.keys(playerids).includes(idofpacket.toString())){
  2674. from = playerids[idofpacket].userName;
  2675. }
  2676. if(!pmusers.includes(from) && username == jsonargs["to"]){
  2677. pmusers.push(from);
  2678. }
  2679. }
  2680. }
  2681. if(jsonargs["type"]=="style" && playerids[idofpacket].ratelimit["style"]+3000<Date.now()){
  2682. playerids[idofpacket].ratelimit["style"] = Date.now();
  2683. if(Array.isArray(jsonargs["style"])){
  2684. if(jsonargs["style"].length == 3){
  2685. var valid = true;
  2686. for(var i = 0;i<jsonargs["style"].length;i++){
  2687. if(Number.isInteger(jsonargs["style"][i])){
  2688. if(jsonargs["style"][i]>255 || jsonargs["style"][i]<0){
  2689. valid = false;
  2690. break;
  2691. }
  2692. }
  2693. else{
  2694. valid = false;
  2695. break;
  2696. }
  2697. }
  2698. if(valid){
  2699. allstyles[playerids[idofpacket].userName] = jsonargs["style"];
  2700. }
  2701. }
  2702. }
  2703. }
  2704. if(jsonargs["type"]=="request private chat users"){
  2705. if(typeof(jsonargs["from"])!='undefined'){
  2706. from = jsonargs["from"];
  2707. if(Object.keys(playerids).includes(idofpacket.toString())){
  2708. from = playerids[idofpacket].userName;
  2709. }
  2710. SEND("42"+JSON.stringify([4,{"type":"private chat users","from":username,"to":from}]));
  2711. }
  2712. }
  2713. if(jsonargs["type"]=="public key" && request_public_key_time_stamp+1500>Date.now()){
  2714. from = jsonargs["from"];
  2715. if(Object.keys(playerids).includes(idofpacket.toString())){
  2716. from = playerids[idofpacket].userName;
  2717. }
  2718. if(from == private_chat){
  2719. IMPORT_KEY(jsonargs["public key"]).then(function(key){private_chat_public_key = [private_chat,key];displayInChat("Private chatting with "+private_chat+".","#DA0808","#1EBCC1");});
  2720. }
  2721. }
  2722. if(jsonargs["type"]=="fakerecieve" && hostid == idofpacket && sandboxon && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2723. for(var i = 0;i<jsonargs["packet"].length;i++){
  2724. if(!jsonargs["packet"][i].trim().startsWith("42[20,") && !jsonargs["packet"][i].trim().startsWith("41")){
  2725. RECIEVE(sanitize(jsonargs["packet"][i]));
  2726. }
  2727. }
  2728. }
  2729. if(jsonargs["type"]=="customfakerecieve" && hostid == idofpacket && sandboxon && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2730. for(var i2 = 0;i2<jsonargs["packet"].length;i2++){
  2731. var keys = Object.keys(sandboxplayerids);
  2732. for(var i = 0;i<keys.length;i++){
  2733. if(jsonargs["packet"][i2].startsWith("42[7,")){
  2734. originalRecieve.call(this,{data:jsonargs["packet"][i2].replace("ID",keys[i].toString()).replace("CVALUE",playerids[keys[i]].movecount.toString())});
  2735. playerids[keys[i]].movecount+=1;
  2736. }
  2737. }
  2738. }
  2739. }
  2740. if(jsonargs["type"]=="commands"){
  2741. playerids[idofpacket].commands = true;
  2742. }
  2743. if(jsonargs["type"]=="sandboxid" && hostid == idofpacket && sandboxon && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2744. sandboxid = jsonargs["lastid"];
  2745. }
  2746. if(jsonargs["type"]=="sandboxon" && idofpacket == hostid){
  2747. if(!sandboxon){
  2748. displayInChat("This is a sandbox lobby.","#DA0808","#1EBCC1");
  2749. sandboxon = true;
  2750. }
  2751. }
  2752. if(jsonargs["type"]=="vote poll"){
  2753. from = jsonargs["from"];
  2754. if(Object.keys(playerids).includes(idofpacket.toString())){
  2755. from = playerids[idofpacket].userName;
  2756. }
  2757. if(typeof(jsonargs["vote"]) == 'number' && idofpacket!=hostid){
  2758. var now = Date.now();
  2759. if(ishost && pollactive[3].length>1 && pollactive[0]){
  2760. if(jsonargs["vote"]>=0 && jsonargs["vote"]<pollactive[3].length){
  2761. playerids[idofpacket].vote.poll = jsonargs["vote"];
  2762. }
  2763. }
  2764. else if(pollactive2[0] && pollactive2[2].length>1){
  2765. if(jsonargs["vote"]>=0 && jsonargs["vote"]<pollactive2[2].length){
  2766. playerids[idofpacket].vote.poll = jsonargs["vote"];
  2767. }
  2768. }
  2769. }
  2770. }
  2771. if(jsonargs["type"]=="poll end"){
  2772. from = jsonargs["from"];
  2773. if(Object.keys(playerids).includes(idofpacket.toString())){
  2774. from = playerids[idofpacket].userName;
  2775. }
  2776. var now = Date.now();
  2777. if(hostid == idofpacket && playerids[idofpacket].ratelimit.poll+5000<now){
  2778. playerids[idofpacket].ratelimit.poll = now;
  2779. var count = [0,0,0,0];
  2780. var keys = Object.keys(playerids);
  2781. for(var i = 0;i<keys.length;i++){
  2782. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive2[2].length-1){
  2783. count[playerids[keys[i]].vote.poll]++;
  2784. }
  2785. playerids[keys[i]].vote.poll = -1;
  2786. }
  2787. displayInChat("The poll ended.","#DA0808","#1EBCC1");
  2788. for(var i = 0;i<count.length;i++){
  2789. if(count[i]>1){
  2790. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  2791. }
  2792. if(count[i]==1){
  2793. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  2794. }
  2795. }
  2796. pollactive2 = [false,0,[]];
  2797. }
  2798. }
  2799. if(jsonargs["type"] == "video player" && idofpacket == hostid && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2800. changeJukeboxURL(jsonargs["url"],jsonargs["timestamp"]);
  2801. }
  2802. if(jsonargs["type"]=="poll" && idofpacket == hostid){
  2803. from = jsonargs["from"];
  2804. if(Object.keys(playerids).includes(idofpacket.toString())){
  2805. from = playerids[idofpacket].userName;
  2806. }
  2807. if(Array.isArray(jsonargs["poll"])){
  2808. var propperpoll = true;
  2809. var pollifproper = [];
  2810. if(jsonargs["poll"].length>5){
  2811. propperpoll = false;
  2812. }
  2813. else{
  2814. for(var i = 0;i<jsonargs["poll"].length;i++){
  2815. if(typeof(jsonargs["poll"][i]) == 'string'){
  2816. if(jsonargs["poll"][i].length>50){
  2817. propperpoll = false;
  2818. break;
  2819. }
  2820. else{
  2821. pollifproper.push(jsonargs["poll"][i]);
  2822. }
  2823. }
  2824. else{
  2825. propperpoll = false;
  2826. break;
  2827. }
  2828. }
  2829. }
  2830. if(propperpoll){
  2831. var now = Date.now();
  2832. var keys = Object.keys(playerids);
  2833. for(var i = 0;i<keys.length;i++){
  2834. playerids[keys[i]].vote.poll = -1;
  2835. }
  2836. pollactive2 = [true,now,pollifproper];
  2837. playerids[idofpacket].ratelimit.poll = now;
  2838. displayInChat(from+" started a poll:","#DA0808","#1EBCC1");
  2839. for(var i = 0;i<pollifproper.length;i++){
  2840. 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();';
  2841. displayInChat('<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+letters[i]+')</a>',"#DA0808","#1EBCC1",{sanitize:false}," "+pollifproper[i]);
  2842. }
  2843. }
  2844. }
  2845. }
  2846. if(jsonargs["type"]=="request mode" && playerids[idofpacket].ratelimit.mode+1000<Date.now()){
  2847. playerids[idofpacket].ratelimit.mode = Date.now();
  2848. from = jsonargs["from"];
  2849. if(Object.keys(playerids).includes(idofpacket.toString())){
  2850. from = playerids[idofpacket].userName;
  2851. }
  2852. var req_mode = jsonargs["mode"];
  2853. var req_mode2 = "";
  2854. if(req_mode){
  2855. if(req_mode == "b"){
  2856. req_mode2 = "Classic";
  2857. }
  2858. else if(req_mode == "sp"){
  2859. req_mode2 = "Grapple";
  2860. }
  2861. else if(req_mode == "ar"){
  2862. req_mode2 = "Arrows";
  2863. }
  2864. else if(req_mode == "ard"){
  2865. req_mode2 = "Death Arrows";
  2866. }
  2867. }
  2868. if(req_mode2){
  2869. 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+'")}';
  2870. displayInChat('> '+playerids[idofpacket].userName+' requests [<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+req_mode2+'</a>]',"#DA0808","#1EBCC1",{sanitize:false}," mode.");
  2871. }
  2872. }
  2873. if(jsonargs["type"]=="public key correction" && private_chat_public_key[0] == private_chat){
  2874. from = jsonargs["from"];
  2875. if(Object.keys(playerids).includes(idofpacket.toString())){
  2876. from = playerids[idofpacket].userName;
  2877. }
  2878. if(from == private_chat){
  2879. IMPORT_KEY(jsonargs["public key"]).then(function(public_key){private_chat_public_key = [private_chat,public_key]; ENCRYPT_MESSAGE(private_chat_public_key[1],pmlastmessage).then(function(e){
  2880. setTimeout(function(){SEND("42"+JSON.stringify([4,{"type":"private chat","from":username,"to":private_chat,"message":e}]))},500);
  2881. });});
  2882. }
  2883. }
  2884. }
  2885. else{
  2886. var now = Date.now();
  2887. if(playerids[idofpacket.toString()]){
  2888. playerids[idofpacket.toString()].lastmove = now;
  2889. }
  2890. if(idofpacket!=myid){
  2891. playerids[idofpacket.toString()].movecount+=1;
  2892. }
  2893. if(Math.abs(gameStartTimeStamp - (now-1000*jsonargs["f"]/30))>1000 && idofpacket!=myid){
  2894. gameStartTimeStamp = now-1000*jsonargs["f"]/30;
  2895. }
  2896. if(recording){
  2897. if(idofpacket.toString() == recordingid){
  2898. if(recordingdata.length == 0){
  2899. recordingdata.push([jsonargs["i"],jsonargs["f"]]);
  2900. }
  2901. recordingdata.push([jsonargs["i"],jsonargs["f"]-recordingdata[0][1]]);
  2902. }
  2903. }
  2904. if(ishost){
  2905. if(sandboxon && idofpacket == sandboxcopyme){
  2906. var jsonkeys = Object.keys(sandboxplayerids);
  2907. if(!jsonkeys.includes(sandboxcopyme.toString())){
  2908. var jsonargs2 = jsonargs;
  2909. for(var i = 0; i<jsonkeys.length;i++){
  2910. jsonargs2["c"] = playerids[jsonkeys[i]].movecount;
  2911. var packet = '42[7,'+jsonkeys[i].toString()+','+JSON.stringify(jsonargs2)+']';
  2912. RECIEVE(packet);
  2913. }
  2914. jsonargs2["c"] = "CVALUE";
  2915. jsonargs2 = JSON.stringify(jsonargs2).replace('"CVALUE"',"CVALUE");
  2916. SEND("42"+JSON.stringify([4,{"type":"customfakerecieve","from":username,"packet":['42[7,ID,'+jsonargs2+']'],to:[-1]}]));
  2917. }
  2918. }
  2919. for(var i = 0;i<disabledkeys.length;i++){
  2920. var get_keys_var = GET_KEYS(jsonargs["i"]);
  2921. if(get_keys_var[disabledkeys[i]]){
  2922. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(idofpacket)){
  2923. killedids.push(idofpacket);
  2924. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  2925. SEND('42[25,{"a":{"playersLeft":['+idofpacket.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2926. RECIEVE('42[31,{"a":{"playersLeft":['+idofpacket.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2927. break;
  2928. }
  2929. }
  2930. }
  2931. }
  2932. }
  2933. }
  2934. if(args.data.startsWith('42[4,')){
  2935. var jsonargs = JSON.parse(args.data.substring(2));
  2936. if(jsonargs[3] == "Juice1313" && jsonargs[5] > 0){
  2937. jsonargs[3] = "Piss1313";
  2938. }
  2939. 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(),"style":0},"vote":{"poll":-1}};
  2940. if(jsonargs[2]!="sandbox"){
  2941. SEND('42[4,{"type":"commands"}]');
  2942. if(!Object.keys(allstyles).includes(jsonargs[3])){
  2943. allstyles[jsonargs[3]] = [0,0,0];
  2944. SEND("42"+JSON.stringify([4,{"type":"style","from":username,"style":allstyles[playerids[myid].userName]}]));
  2945. }
  2946. }
  2947. if(sandboxon){
  2948. var sandboxkeys = Object.keys(sandboxplayerids);
  2949. if(sandboxkeys.includes(jsonargs[1].toString())){
  2950. delete sandboxplayerids[jsonargs[1]];
  2951. }
  2952. if(jsonargs[2]=="sandbox"){
  2953. sandboxplayerids[jsonargs[1]] = jsonargs[3];
  2954. if(jsonargs[1]>sandboxid){
  2955. sandboxid = parseInt(jsonargs[1])+1;
  2956. }
  2957. }
  2958. else{
  2959. if(ishost){
  2960. SEND('42[4,{"type":"sandboxon"}]');
  2961. var sandboxkeys = Object.keys(sandboxplayerids);
  2962. var packets = [];
  2963. for(var i = 0;i<sandboxkeys.length;i++){
  2964. var p = playerids[sandboxkeys[i]];
  2965. var packet = '42'+JSON.stringify([4,sandboxkeys[i],p.peerID,p.userName,p.guest,p.level,p.team,p.avatar]);
  2966. packets.push(packet);
  2967. }
  2968. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":packets,to:[jsonargs[1]]}]));
  2969. SEND("42"+JSON.stringify([4,{"type":"sandboxid","from":username,"lastid":sandboxid,to:[jsonargs[1]]}]));
  2970. }
  2971. }
  2972. }
  2973. if(ishost){
  2974. if(jointext!="" && jsonargs[2]!="sandbox"){
  2975. chat(flag_manage(jointext.replaceAll("username",jsonargs[3])));
  2976. }
  2977. if(jointeam!=-1 && jsonargs[2]!="sandbox"){
  2978. SEND('42[26,{"targetID":'+jsonargs[1].toString()+',"targetTeam":'+jointeam.toString()+'}]');
  2979. setTimeout(function(){RECIEVE('42[18,'+jsonargs[1].toString()+','+jointeam.toString()+']');});
  2980. }
  2981. if(jukeboxplayer.src!="" && !jukeboxplayer.paused){
  2982. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":jukeboxplayerURL,"timestamp":Date.now()-jukeboxplayer.currentTime*1000,"to":[jsonargs[1]]}]));
  2983. }
  2984. if(freejoin){
  2985. var count = 0;
  2986. var keys = Object.keys(playerids);
  2987. for(var i = 0; i<keys.length;i++){
  2988. if(playerids[keys[i]].team!=0){
  2989. count++;
  2990. }
  2991. }
  2992. if(count <= 2 && jsonargs[6]!=0){
  2993. setTimeout(function(){
  2994. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2995. Gdocument.getElementById("mapeditor_close").click();
  2996. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2997. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  2998. if(transitioning == true){
  2999. canceled = true;
  3000. }
  3001. },150);
  3002. }
  3003. }
  3004. }
  3005. if(jsonargs[3] == "LEGENDBOSS123" && jsonargs[5] > 0){
  3006. jsonargs[5] = -jsonargs[5];
  3007. }
  3008. args.data = "42" + JSON.stringify(jsonargs);
  3009. }
  3010. if(args.data.startsWith('42[5,')){
  3011. var jsonargs = JSON.parse(args.data.substring(2));
  3012. if(typeof(playerids[jsonargs[1]])!='undefined'){
  3013. delplayerids[jsonargs[1]] = playerids[jsonargs[1]];
  3014. delete allstyles[playerids[jsonargs[1]].userName];
  3015. delete playerids[jsonargs[1]];
  3016. }
  3017. if(sandboxon && typeof(sandboxplayerids[jsonargs[1]])!='undefined'){
  3018. delete sandboxplayerids[jsonargs[1]];
  3019. }
  3020. }
  3021. }}
  3022. return originalRecieve.call(this,args);
  3023. };
  3024. var originalClose = this.onclose;
  3025. this.onclose = function () {
  3026. if(bonkwssextra.includes(this)){
  3027. bonkwssextra.splice(bonkwssextra.indexOf(this),1)
  3028. }
  3029. else{
  3030. window.bonkwss = 0;
  3031. }
  3032. return originalClose.call(this);
  3033. }
  3034. }
  3035. return originalSend.call(this,args);
  3036. };
  3037. scope.SEND = function(args){
  3038. if(bonkwss!=0){
  3039. bonkwss.send(args);
  3040. }
  3041. };
  3042. scope.RECIEVE = function(args){
  3043. if(bonkwss!=0){
  3044. bonkwss.onmessage({data:args});
  3045. }
  3046. };
  3047. scope.dontswitch = false;
  3048. scope.username = 0;
  3049. scope.timedelay = 1400;
  3050. scope.ishost = false;
  3051. scope.checkboxhidden = true;
  3052. scope.quicki=0;
  3053. scope.defaultmode = "d";
  3054. scope.recmodebool = false;
  3055. scope.shuffle = false;
  3056. scope.startedinqp = false;
  3057. scope.instaqp = false;
  3058. scope.freejoin = false;
  3059. scope.recordedTimeStamp = 0;
  3060. scope.recordedId = 0;
  3061. scope.smartteams = false;
  3062. scope.beenKickedTimeStamp = 0;
  3063. scope.stopquickplay = 1;
  3064. scope.currentFrame = 0;
  3065. scope.text2speech = false;
  3066. scope.canceled = false;
  3067. scope.wintext = "";
  3068. scope.banned = [];
  3069. scope.transitioning = false;
  3070. scope.echo_list = [];
  3071. scope.echoAppend = "";
  3072. scope.message = "";
  3073. scope.private_chat = "";
  3074. scope.private_chat_public_key = ["",[0,0]];
  3075. scope.disabledkeys = [];
  3076. scope.actuallyhost = false;
  3077. scope.pmusers = [];
  3078. scope.pmlastmessage = "";
  3079. scope.pmuserstimestamp = 0;
  3080. scope.ignorepmlist = [];
  3081. scope.scroll = false;
  3082. scope.elem = Gdocument.getElementById("maploadwindowmapscontainer");
  3083. scope.npermissions = 1;
  3084. scope.space_flag = false;
  3085. scope.rcaps_flag = false;
  3086. scope.number_flag = false;
  3087. scope.reverse_flag = false;
  3088. scope.autocorrect = false;
  3089. scope.request_public_key_time_stamp = 0;
  3090. scope.sandboxcopyme = -1;
  3091. scope.recteams = false;
  3092. scope.chatheight = 128;
  3093. scope.onlykicked = false;
  3094. scope.killedids = [];
  3095. scope.jointext = "";
  3096. scope.randomchat = false;
  3097. scope.randomchatpriority = [0,[]];
  3098. scope.randomchatlastmessage = ["",0];
  3099. scope.afkkill = -1;
  3100. scope.tournament_mode = "";
  3101. scope.tournament_scores = [];
  3102. scope.tournament_in_and_out = {"in":[],"out":[]};
  3103. scope.echotext = "message";
  3104. scope.nextafter = 0;
  3105. scope.nextafterbuffer = -1;
  3106. scope.roundsperqp = 1;
  3107. scope.roundsperqp2 = 0;
  3108. scope.autorecord = false;
  3109. scope.poll = [];
  3110. scope.letters = ["A","B","C","D","E"];
  3111. scope.qppaused = false;
  3112. scope.FollowCam = false;
  3113. scope.autocam = false;
  3114. scope.gravity = 20;
  3115. scope.randomchat = false;
  3116. scope.randomchat_randomtimestamp = 0;
  3117. scope.randomchat_timestamp = 0;
  3118. scope.multiplier = 3.65;
  3119. scope.aimbot = false;
  3120. scope.recievedinitdata = false;
  3121. scope.heavybot = false;
  3122. scope.zoom = 1;
  3123. scope.prediction = 350;
  3124. scope.started = 0;
  3125. scope.holdheavy = 0;
  3126. scope.maxfps = false;
  3127. scope.grappleheld = false;
  3128. scope.grappleheld2 = false;
  3129. scope.heavyheld = false;
  3130. scope.reverseqp = false;
  3131. scope.jointeam = -1;
  3132. scope.heavyheld2 = false;
  3133. scope.heavyid = 3;
  3134. scope.specialid = 0;
  3135. 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};
  3136. scope.leftRight = [37,39];
  3137. scope.upDown = [38,40];
  3138. scope.heavy = 88;
  3139. scope.special = 90;
  3140. scope.newzoom2 = 1;
  3141. scope.staystill = false;
  3142. scope.staystillpos = [0,0];
  3143. scope.zoom2 = 1;
  3144. scope.admins = [["LEGENDBOSS123",[0,0,0,0]],["iNeonz",[0,0,0,0]],["left paren",[0,0,0,0]],["OG_New_Player",[0,0,0,0]],["An Admin",[0,0,0,0]],["L armee d LS",[0,0,0,0]],["Pixelmelt",[0,0,0,0]],["pro9905",[0,0,0,0]],["JustANameForMe",[0,0,0]],["nefarious mouse",[0,0,0,0]],["Annihilate Red",[0,0,0,0]],["Ghost_mit",[0,0,0,0]],["Neptune_1",[0,0,0,0]]];
  3145.  
  3146. scope.letters2 = Array.from("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
  3147. scope.superscript_letters = Array.from("ᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖᑫʳˢᵗᵘᵛʷˣʸᶻᴬᴮᶜᴰᴱᶠᴳᴴᴵᴶᴷᴸᴹᴺᴼᴾQᴿˢᵀᵁⱽᵂˣʸᶻ");
  3148. scope.hollow_letters = Array.from("𝕒𝕓𝕔𝕕𝕖𝕗𝕘𝕙𝕚𝕛𝕜𝕝𝕞𝕟𝕠𝕡𝕢𝕣𝕤𝕥𝕦𝕧𝕨𝕩𝕪𝕫𝔸𝔹ℂ𝔻𝔼𝔽𝔾ℍ𝕀𝕁𝕂𝕃𝕄ℕ𝕆ℙℚℝ𝕊𝕋𝕌𝕍𝕎𝕏𝕐ℤ");
  3149. scope.block_letters = Array.from("🅰🅱🅲🅳🅴🅵🅶🅷🅸🅹🅺🅻🅼🅽🅾🅿🆀🆁🆂🆃🆄🆅🆆🆇🆈🆉🅰🅱🅲🅳🅴🅵🅶🅷🅸🅹🅺🅻🅼🅽🅾🅿🆀🆁🆂🆃🆄🆅🆆🆇🆈🆉");
  3150. scope.bold_letters = Array.from("𝐚𝐛𝐜𝐝𝐞𝐟𝐠𝐡𝐢𝐣𝐤𝐥𝐦𝐧𝐨𝐩𝐪𝐫𝐬𝐭𝐮𝐯𝐰𝐱𝐲𝐳𝐀𝐁𝐂𝐃𝐄𝐅𝐆𝐇𝐈𝐉𝐊𝐋𝐌𝐍𝐎𝐏𝐐𝐑𝐒𝐓𝐔𝐕𝐖𝐗𝐘𝐙");
  3151. scope.italicized_letters = Array.from("𝘢𝘣𝘤𝘥𝘦𝘧𝘨𝘩𝘪𝘫𝘬𝘭𝘮𝘯𝘰𝘱𝘲𝘳𝘴𝘵𝘶𝘷𝘸𝘹𝘺𝘻𝘈𝘉𝘊𝘋𝘌𝘍𝘎𝘏𝘐𝘑𝘒𝘓𝘔𝘕𝘖𝘗𝘘𝘙𝘚𝘛𝘜𝘝𝘞𝘟𝘠𝘡");
  3152. scope.glitched_letters = Array.from("ⱥƀȼđēӻꞡħīɉҟłᵯꞥꝋꝑꝗɍꞩⱦᵾꝟⱳӿɏƶȺɃȻĐɆӺ₲ĦĪɈҞŁᛗꞤꝊꝐꝖꞦꞨȾɄꝞⱲӾɎƵ");
  3153. scope.cursive_letters = Array.from("𝒶𝒷𝒸𝒹𝑒𝒻𝑔𝒽𝒾𝒿𝓀𝓁𝓂𝓃𝑜𝓅𝓆𝓇𝓈𝓉𝓊𝓋𝓌𝓍𝓎𝓏𝒜𝐵𝒞𝒟𝐸𝐹𝒢𝐻𝐼𝒥𝒦𝐿𝑀𝒩𝒪𝒫𝒬𝑅𝒮𝒯𝒰𝒱𝒲𝒳𝒴𝒵");
  3154.  
  3155. scope.letter_dictionary = {};
  3156. for(var i = 0;i<letters2.length;i++){
  3157. letter_dictionary[letters2[i]] = [superscript_letters[i],hollow_letters[i],block_letters[i],bold_letters[i],italicized_letters[i],glitched_letters[i],cursive_letters[i]];
  3158. }
  3159. scope.textmode = -1;
  3160. scope.changeColor = function(x,operation1, operation2, operation3){
  3161. for(var f of x.physics.fixtures){
  3162. var r = Math.floor(f.f/256/256);
  3163. var g = Math.floor(f.f/256)%256;
  3164. var b = f.f%256;
  3165. r = operation1(r, 0);
  3166. g = operation2(g, 1);
  3167. b = operation3(b, 2);
  3168. f.f = Math.floor(r%256) * 256 * 256 + Math.floor(g%256) * 256 + Math.floor(b%256);
  3169. }
  3170. return x;
  3171. };
  3172. scope.autokickban = 0;
  3173. scope.ghostroomwss = -1;
  3174. scope.autokickbantimestamp = 0;
  3175. scope.getroomslastcheck = 0;
  3176. scope.causelag = false;
  3177. scope.causelag2 = 0;
  3178. scope.overideDate = [false,0];
  3179. scope.scale = 1;
  3180. scope.translating = [false,""];
  3181. scope.translating2 = [false,""];
  3182. scope.translatingkeys = {"english":"en","chinese":"zh","japanese":"ja","dutch":"nl","hindi":"hi","spanish":"es","portugese":"pt","french":"fr","arabic":"ar","russian":"ru","korean":"ko"};
  3183. scope.translate = function(text,fromL,toL) {
  3184. var fL = fromL || 'en';
  3185. var tL = toL || 'de';
  3186. var url = 'https://translate.googleapis.com/translate_a/single?client=gtx&sl='+ fL + "&tl=" + tL + "&dt=t&q=" + encodeURI(text);
  3187. var parseJSON = txt => JSON.parse(txt.split(',').map( x => x || 'null').join(',')) ;
  3188. var joinSnippets = json => json[0].map( x => x[0] ).join('');
  3189. return fetch(url).then(function(res){
  3190. return res.text();
  3191. }).then(function(text){
  3192. return joinSnippets(parseJSON(text));
  3193. });
  3194. };
  3195. scope.positive = function(angle){
  3196. if(angle<0){
  3197. angle += 2*Math.PI;
  3198. }
  3199. return angle%(Math.PI*2);
  3200. };
  3201. scope.angle_between = function(angle,angle2){
  3202. return Math.min(Math.abs(positive(angle)-positive(angle2)),Math.PI*2-Math.abs(positive(angle)-positive(angle2)));
  3203. };
  3204. scope.angle_between2 = function(angle,angle2){
  3205. if(angle_between(angle,angle2+Math.PI/2)<Math.PI/2){
  3206. return 1;
  3207. }
  3208. return -1;
  3209. };
  3210. scope.stringdistance = function(s1,s2){
  3211. s1 = s1.toLowerCase();
  3212. s2 = s2.toLowerCase();
  3213. var matrix = Array(s1.length+1);
  3214. for(var i = 0;i<matrix.length;i++){
  3215. matrix[i] = Array(s2.length+1);
  3216. matrix[i][0] = i;
  3217. }
  3218. for(var i = 0;i<matrix[0].length;i++){
  3219. matrix[0][i] = i;
  3220. }
  3221. for(var i = 1;i<s1.length+1;i++){
  3222. for(var i2 = 1;i2<s2.length+1;i2++){
  3223. if(s1[i-1]==s2[i2-1]){
  3224. matrix[i][i2] = matrix[i-1][i2-1];
  3225. }
  3226. else{
  3227. matrix[i][i2] = Math.min(matrix[i][i2-1],matrix[i-1][i2],matrix[i-1][i2-1])+1;
  3228. }
  3229. }
  3230. }
  3231. return matrix[s1.length][s2.length];
  3232. };
  3233. scope.closestWord = function(word){
  3234. if(word.length>20 || word.length<2){
  3235. return word;
  3236. }
  3237. var distances = [word.length,""];
  3238. var playernamelist = [];
  3239. var keys = Object.keys(playerids);
  3240. for(var i = 0;i<keys.length;i++){
  3241. playernamelist.push(playerids[keys[i]].userName);
  3242. }
  3243. var wordlist2 = playernamelist.concat(wordlist);
  3244. for(var i = 0;i<wordlist2.length;i++){
  3245. var distance = stringdistance(word,wordlist2[i]);
  3246. if(distance<=distances[0]){
  3247. distances[0] = distance;
  3248. distances[1] = wordlist2[i];
  3249. if(distance == 0){
  3250. return wordlist2[i];
  3251. }
  3252. }
  3253. };
  3254. if(distances[1] == ""){
  3255. return word;
  3256. }
  3257. return distances[1];
  3258. };
  3259. scope.replay = function(){
  3260. var frame = getCurrentFrame();
  3261. /*var replaycounter = 0;
  3262. while(1){
  3263. if(replaycounter != recordingdata.length-1){
  3264. for(var i = 0;i<recordingdata[replaycounter+1][1]-recordingdata[replaycounter][1];i++){
  3265. RECIEVE('42[7,'+myid+',{"i":'+recordingdata[replaycounter][0]+',"f":'+(frame+i+recordingdata[replaycounter][1]).toString()+',"c":'+playerids[myid].movecount+'}]');
  3266. playerids[myid].movecount+=1;
  3267. }
  3268. replaycounter+=1;
  3269. }
  3270. else{
  3271. break;
  3272. }
  3273. }*/
  3274. for(var i = 0;i<recordingdata.length;i++){
  3275. SEND('42[4,{"i":'+recordingdata[i][0]+',"f":'+(frame+recordingdata[i][1]).toString()+',"c":'+playerids[myid].movecount+'}]');
  3276. }
  3277. };
  3278. scope.presskeys = function(x,y){
  3279. if(!x.left && y.left){
  3280. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  3281. }
  3282. else if(x.left && !y.left){
  3283. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  3284. }
  3285. if(!x.right && y.right){
  3286. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  3287. }
  3288. else if(x.right && !y.right){
  3289. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  3290. }
  3291. if(!x.up && y.up){
  3292. fire("keydown",{"keyCode":upDown[0]},Gdocument.getElementById("gamerenderer"));
  3293. }
  3294. else if(x.up && !y.up){
  3295. fire("keyup",{"keyCode":upDown[0]},Gdocument.getElementById("gamerenderer"));
  3296. }
  3297. if(!x.down && y.down){
  3298. fire("keydown",{"keyCode":upDown[1]},Gdocument.getElementById("gamerenderer"));
  3299. }
  3300. else if(x.down && !y.down){
  3301. fire("keyup",{"keyCode":upDown[1]},Gdocument.getElementById("gamerenderer"));
  3302. }
  3303. if(!x.heavy && y.heavy){
  3304. fire("keydown",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  3305. }
  3306. else if(x.heavy && !y.heavy){
  3307. fire("keyup",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  3308. }
  3309. if(!x.special && y.special){
  3310. fire("keydown",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  3311. }
  3312. else if(x.special && !y.special){
  3313. fire("keyup",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  3314. }
  3315. };
  3316. scope.getplayerkeys = function(){
  3317. var keykeys = Object.keys(keyCodes);
  3318. var keyslist = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[1].children).slice(1);
  3319. var keyslist2 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[2].children).slice(1);
  3320. var keyslist3 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[3].children).slice(1);
  3321. var keyslist4 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[4].children).slice(1);
  3322. var keyslist5 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[5].children).slice(1);
  3323. var keyslist6 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[6].children).slice(1);
  3324. for(var i = 0;i<keyslist.length;i++){
  3325. if(keykeys.includes(keyslist[i].textContent)){
  3326. leftRight[0] = keyCodes[keyslist[i].textContent];
  3327. break;
  3328. }
  3329. else{
  3330. leftRight[0] = keyslist[i].textContent.charCodeAt(0);
  3331. break
  3332. }
  3333. }
  3334. for(var i = 0;i<keyslist2.length;i++){
  3335. if(keykeys.includes(keyslist2[i].textContent)){
  3336. leftRight[1] = keyCodes[keyslist2[i].textContent];
  3337. break;
  3338. }
  3339. else{
  3340. leftRight[1] = keyslist2[i].textContent.charCodeAt(0);
  3341. break
  3342. }
  3343. }
  3344. for(var i = 0;i<keyslist3.length;i++){
  3345. if(keykeys.includes(keyslist3[i].textContent)){
  3346. upDown[0] = keyCodes[keyslist3[i].textContent];
  3347. break;
  3348. }
  3349. else{
  3350. upDown[0] = keyslist3[i].textContent.charCodeAt(0);
  3351. break
  3352. }
  3353. }
  3354. for(var i = 0;i<keyslist4.length;i++){
  3355. if(keykeys.includes(keyslist4[i].textContent)){
  3356. upDown[1] = keyCodes[keyslist4[i].textContent];
  3357. break;
  3358. }
  3359. else{
  3360. upDown[1] = keyslist4[i].textContent.charCodeAt(0);
  3361. break
  3362. }
  3363. }
  3364. for(var i = 0;i<keyslist5.length;i++){
  3365. if(keykeys.includes(keyslist5[i].textContent)){
  3366. heavy = keyCodes[keyslist5[i].textContent];
  3367. break;
  3368. }
  3369. else{
  3370. heavy = keyslist5[i].textContent.charCodeAt(0);
  3371. break
  3372. }
  3373. }
  3374. for(var i = 0;i<keyslist6.length;i++){
  3375. if(keykeys.includes(keyslist6[i].textContent)){
  3376. special = keyCodes[keyslist6[i].textContent];
  3377. break;
  3378. }
  3379. else{
  3380. special = keyslist6[i].textContent.charCodeAt(0);
  3381. break
  3382. }
  3383. }
  3384. };
  3385. scope.changeJukeboxURL = function(url,timestamp = 0){
  3386. if(pipedurllist.length == 0){
  3387. displayInChat("The jukebox is still being set up.","#DA0808","#1EBCC1");
  3388. return;
  3389. }
  3390. if(url == ""){
  3391. jukeboxplayer.pause();
  3392. jukeboxplayer.src = '';
  3393. displayInChat("The jukebox has been paused.","#DA0808","#1EBCC1");
  3394. }
  3395. else if(url == jukeboxplayerURL && Date.now()-timestamp >= 2000){
  3396. jukeboxplayer.volume = jukeboxplayervolume/100;
  3397. displayInChat("The jukebox has been unpaused or reset.","#DA0808","#1EBCC1",{sanitize:false});
  3398. jukeboxplayer.play();
  3399. jukeboxplayer.currentTime = (Date.now()-timestamp)/1000;
  3400. }
  3401. else{
  3402. var id = url.match(/youtu\.?be.com\/watch\?.*v=[a-z|A-Z|0-9|_|-]{11}/)[0].split("?v=");
  3403. id = id[id.length-1];
  3404. var loaded = false;
  3405. var loaded2 = 0;
  3406. for(var inst = 0;inst<pipedindexes.length;inst++){
  3407. checkJukeboxStream(pipedindexes[inst],id).then(function(value){
  3408. loaded2+=1;
  3409. if(value!=-1 && !loaded){
  3410. loaded = true;
  3411. jukeboxplayer.src = value[0];
  3412. jukeboxplayer.volume = jukeboxplayervolume/100;
  3413. jukeboxplayerURL = url;
  3414. jukeboxplayer.oncanplaythrough = function(){
  3415. displayInChat("The jukebox has been changed to: ","#DA0808","#1EBCC1",{sanitize:false},url);
  3416. displayInChat("Jukebox is now playing: "+value[1]+" by "+value[2]+".","#DA0808","#1EBCC1");
  3417. jukeboxplayer.play();
  3418. jukeboxplayer.currentTime = (Date.now()-timestamp)/1000;
  3419. jukeboxplayer.oncanplaythrough = null;
  3420. };
  3421. jukeboxplayer.onerror = function(){
  3422. displayInChat("The jukebox failed to load. Please try again.","#DA0808","#1EBCC1");
  3423. };
  3424. }
  3425. });
  3426. }
  3427. new Promise(function(r){
  3428. var interv = setInterval(function(){
  3429. if(loaded2>=pipedindexes.length){
  3430. if(!loaded){
  3431. displayInChat("The jukebox failed to load. Please try again.","#DA0808","#1EBCC1");
  3432. }
  3433. clearInterval(interv);
  3434. }
  3435. },60)
  3436. });
  3437. }
  3438. };
  3439. scope.help = ["All the commands are:","/help","/?","/advhelp [command]","/space","/rcaps","/number","/autocorrect","/translateto [language]","/translate [language]","/randomchat","/speech","/savedroom","/clearsavedroom","/pan","/resetpan","/style [R G B]","/maxfps","/textmode [1-7]","/followcam","/autocam","/zoom [in/out/reset]","/xray","/aimbot","/heavybot","/still","/echo [username]","/clearecho","/remove [username]","/echotext [text]","/chatw [username]","/msg [text]","/ignorepm [username]","/record [username]","/replay","/stoprecord","/loadrecording [text]","/saverecording [text]","/delrecording [text]","/volume [0-100]","/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","/jukebox [link]","/pausejukebox","/resetjukebox","/playjukebox","/freejoin","/recmode","/recteam","/defaultmode [mode]","/start","/balanceA [number]","/colorshift [number]","/brighten [number]","/moveA [letter]","/moveT [letter] [letter]","/balanceT [letter] [number]","/killA","/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","Alt W","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","Alt [","Alt ]"];
  3440. scope.adv_help = {"help":"Shows all command names.",
  3441. "?":"Shows all command names.",
  3442. "advhelp":"Shows a command in detail.",
  3443. "space":"Toggles space. When space is on, whatever you type will be spaced apart.",
  3444. "rcaps":"Toggles rcaps. When rcaps is on, each letter will randomly get capitalized.",
  3445. "number":"Toggles number. When number is on, 'a' becomes 4, 'e' becomes 3, 's' becomes 5, 'o' becomes 0, 'l' and 'i' become 1.",
  3446. "speech":"Turns on text to speech for the chat.",
  3447. "savedroom":"Displays all the rooms you have saved, you can remove individual ones from the saved rooms by clicking \"Remove\".",
  3448. "maxfps":"Toggles maxfps. When maxfps is on, your fps will be increased.",
  3449. "clearsavedroom":"Clears all the saved rooms.",
  3450. "echo":"Echoes a username. It copies the username's chat messages.",
  3451. "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.",
  3452. "remove":"Removes username from echo list. You will not echo that username anymore.",
  3453. "clearecho":"Clears echo list. You will not echo anyone anymore.",
  3454. "chatw":"It private chats with username. Type /msg to message that username.",
  3455. "msg":"Messages with what username you are chatting with. Type /chatw to chat with a username.",
  3456. "ignorepm":"Ignores the username's private chat messages. To unignore, type '/ignorepm [username]'.",
  3457. "pmusers":"Dispays who you can private chat with.",
  3458. "pollstat":"Displays the current poll and its votes.",
  3459. "textmode":"Changes the text font.",
  3460. "eval":"Evaluates code. Only use this if you are experienced in javascript.",
  3461. "debugger":"Opens debugger.",
  3462. "style":"Change the color of your username, level, and background. For example, '/style 255 0 0' will make your username red.",
  3463. "translate":"Translates peoples texts to the chosen language.",
  3464. "translateto":"You will now speak the chosen language.",
  3465. "autocorrect":"Fixes spelling mistakes.",
  3466. "randomchat":"Spams random chat messages from the past.",
  3467. "lobby":"Makes lobby visible when you are ingame. Type '/lobby' again to close lobby.",
  3468. "score":"Displays the current score while ingame. Type '/score' again to hide the score.",
  3469. "pan":"Toggles pan mode. Use Shift+Arrow Keys to move the camera around.",
  3470. "resetpan":"Resets pan.",
  3471. "team":"Joins a specific team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3472. "scroll":"Toggles a scrollbar in ingame chat.",
  3473. "followcam":"Enables follow camera. Your character will be centered on the screen.",
  3474. "autocam":"Zooms in/out enough for you to see everyone on the screen.",
  3475. "zoom":"Zooms in, out, or resets zoom.",
  3476. "xray":"Removes all shapes that don't have a shadow. This means all non-physics shapes will be hidden.",
  3477. "aimbot":"Toggles aimbot. Aimbot will aim for you in arrows or death arrows mode.",
  3478. "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.",
  3479. "still":"Saves your position, and tries to reach it constantly. This is useful in parkour if you want to go afk. Use Alt+W instead, because this feature will fail when you are in chat.",
  3480. "lagbot":"Makes your movements very laggy. Type '/lagbot 0' to turn it off.",
  3481. "hidechat":"Hides ingame chat. Type '/showchat' to show it again.",
  3482. "showchat":"Shows ingame chat. '/hidechat' hides the chat.",
  3483. "notify":"You will be notified if a person types @username",
  3484. "stopnotify":"You will not be notified if a person types @username",
  3485. "support":"Displays all the people who have supported this mod.",
  3486. "startqp":"Starts cycling maps in your map menu.",
  3487. "stopqp":"Stops cycling maps in your map menu.",
  3488. "revqp":"Reverses the order of quickplay. '/next', '/previous' will be inverted.",
  3489. "pauseqp":"Only pauses or unpauses the quickplay cycle due to round end. '/next', '/previous' still work. Type 'pauseqp' to unpause quickplay.",
  3490. "next":"Skips the map. Usable only with '/startqp'.",
  3491. "nextafter":"Skips the map if no one is able to win/draw within a certain amount of time.",
  3492. "previous":"Goes to previous map. Usable only with '/startqp'.",
  3493. "shuffle":"Makes quickplay play random maps instead of in order.",
  3494. "freejoin":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  3495. "recmode":"In quickplay, it switches mode to recommended mode, according to editor.",
  3496. "recteam":"In quickplay, it sorts people into teams when teams are necessary.",
  3497. "defaultmode":"Switches mode to defaultmode if there is no recmode.",
  3498. "start":"Starts game instantly.",
  3499. "instaqp":"Rounds will instantly start without a countdown.",
  3500. "balanceA":"Balances everyone with balance number.",
  3501. "colorshift": "Shifts the color of the map.",
  3502. "brighten": "Brightens the map by the number.",
  3503. "moveA":"Sets everyones team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3504. "balanceT":"Sets everyones balance to the number. The team is 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3505. "killA":"Kills everyone.",
  3506. "jointeam":"Sets the team of anyone who joins. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3507. "moveT":"Sets everyone in one team to another team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3508. "rounds":"Sets rounds to win.",
  3509. "replay":"Replays the movements that were recorded",
  3510. "record":"Records movements of the username",
  3511. "delrecording":"Deletes the recording with the name.",
  3512. "saverecording":"Saves the recording with the name.",
  3513. "loadrecording":"Loads the recording with the name. Type '/replay' to replay it.",
  3514. "stoprecord":"Stops recording the player. Type '/saverecording [text]' to save it.",
  3515. "jukebox":"Sets the jukebox to a link. That link will play for everyone who has this mod.",
  3516. "volume":"Sets the volume of the jukebox.",
  3517. "pausejukebox":"If the jukebox is playing, it pauses it.",
  3518. "resetjukebox":"Resets the jukebox, so it starts from the very beginning.",
  3519. "playjukebox":"If the jukebox is paused, it plays it.",
  3520. "roundsperqp":"After that many rounds, the map will change. Normally, the map will change after 1 round.",
  3521. "autorecord":"After a round ends, automatically records the last 15 seconds.",
  3522. "mode":"If host, switches mode. Otherwise, it requests the host to switch mode, as long as the host has this mod.",
  3523. "disablekeys":"If anyone presses a disabled key, they get killed. Key options: left right up down heavy special.",
  3524. "jointext":"Chats the jointext whenever someone joins. \"username\" will get replaced by the joining person's username.",
  3525. "wintext":"Chats the wintext whenever someone wins. \"username\" will get replaced by the winning person's username.",
  3526. "afkkill":"If a person stays afk for that many seconds, they get automatically killed.",
  3527. "ban":"Bans username from lobby. If they rejoin, it automatically bans.",
  3528. "kill":"Kills the person ingame.",
  3529. "resetpoll":"Clears the poll.",
  3530. "addoption":"Adds the option to the poll. You can only have 4 maximum options. Type '/deloption [letter]' to remove an option.",
  3531. "deloption":"Removes the option with that letter.",
  3532. "startpoll":"Starts a poll that lasts for at least 10 seconds. Type '/endpoll' to end it early.",
  3533. "endpoll":"Ends the poll early if the poll lasted for at least 10 seconds.",
  3534. "addplayer":"In sandbox, it adds bots.",
  3535. "addname":"Adds a bot with a specific name. If that name already exists, it will copy the skin of that player to the bot.",
  3536. "delplayer":"In sandbox, it deletes bots.",
  3537. "copy":"In sandbox, it makes all bots copy the username's movements.",
  3538. "sandbox":"Turns a normal lobby into a sandbox lobby. You cannot turn a sandbox lobby back into a normal lobby.",
  3539. "autokick":"Automatically kicks everyone who is not using this mod.",
  3540. "autoban":"Automatically bans everyone who is not using this mod.",
  3541. "Alt L":"Makes lobby visible when you are ingame. Press Alt L again to close lobby.",
  3542. "Alt C":"Hides ingame chat. Press Alt C again to show ingame chat.",
  3543. "Alt S":"Starts game instantly.",
  3544. "Alt T":"Toggles teams.",
  3545. "Alt N":"Enables follow camera. Your character will be centered on the screen.",
  3546. "Alt G":"Zooms in.",
  3547. "Alt H":"Resets zoom.",
  3548. "Alt J":"Zooms out.",
  3549. "Alt Y":"Enables xray. Removes all shapes that don't have a shadow. This means all non-physics shapes will be hidden.",
  3550. "Alt E":"Toggles editor.",
  3551. "Alt K":"Exits ingame and returns to lobby.",
  3552. "Alt M":"Switches modes.",
  3553. "Alt V":"Toggles autocam. Autocam zooms in/out enough for you to see everyone on the screen.",
  3554. "Alt Q":"Toggles quickplay.",
  3555. "Alt B":"Displays the current score while ingame. Press Alt B again to hide the score.",
  3556. "Alt A":"Skips the map if quickplay is on.",
  3557. "Alt D":"Goes to previous map if quickplay is on.",
  3558. "Alt F":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  3559. "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.",
  3560. "Alt U":"Toggles aimbot. Aimbot will aim for you in arrows or death arrows mode.",
  3561. "Alt P":"Only pauses or unpauses the quickplay cycle due to round end. '/next', '/previous' still work. Type 'pauseqp' to unpause quickplay.",
  3562. "Alt R":"In quickplay, it switches mode to recommended mode, according to editor.",
  3563. "Alt I":"Opens debugger.",
  3564. "Alt W":"Saves your position, and tries to reach it constantly. This is useful in parkour if you want to go afk.",
  3565. "Alt <":"Lowers ingame chat height.",
  3566. "Alt >":"Highers ingame chat height.",
  3567. "Alt [":"Toggles pan mode. Use Shift+Arrow Keys to move the camera around.",
  3568. "Alt ]":"Resets pan."
  3569. };
  3570. scope.displayadvhelp = function(command){
  3571. displayInChat(adv_help[command],"#009398","#DA0808",{sanitize:true},"",true);
  3572. };
  3573. scope.changemode = function(mode){
  3574. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  3575. RECIEVE('42[26,"b","'+mode+'"]');
  3576. };
  3577. Gdocument.getElementById("ingamechatcontent").style["pointer-events"]="all";
  3578. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  3579. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  3580. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  3581. document.getElementById('adboxverticalCurse').style["display"] = "none";
  3582. document.getElementById('adboxverticalleftCurse').style["display"] = "none";
  3583. elem.onclick=function(e){
  3584. if(stopquickplay==0 && ishost == true && e.isTrusted == true){
  3585. quicki = (Array.from(e.target.parentElement.parentNode.children).indexOf(e.target.parentNode)-1)%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  3586. if(reverseqp){
  3587. quicki+=2;
  3588. quicki = quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  3589. }
  3590. }
  3591. };
  3592. scope.getCurrentFrame = function(){
  3593. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  3594. return currentFrame;
  3595. };
  3596. scope.urlify = function(text) {
  3597. if(!Gdocument.getElementById('bl_Menu')){
  3598. return text.replace(/[(http(s)?):\/\/(www\.)?a-zA-Z0-9@:;%.\-_\+~#=]{2,256}\.[\-a-z]{2,6}\b([\-a-zA-Z0-9@:;%_\+.~#?&//=]*)/ig, function(url) {
  3599. var extratext = "";
  3600. var matches = url.match(/youtu\.?be.com\/watch\?.*v=[a-z|A-Z|0-9|_|-]{11}/);
  3601. if(matches){
  3602. var button = Gdocument.createElement("a");
  3603. button.style["color"] = "green";
  3604. button.textContent = "Play";
  3605. button.href = "javascript:void(0)";
  3606. button.setAttribute("onclick",function(){
  3607. if(Gwindow.ishost){
  3608. Gwindow.SEND("42"+JSON.stringify([4,{"type":"video player","from":Gwindow.username,"url":"URL INSERT HERE","timestamp":Gwindow.Date.now()+2000,"to":[-1]}]));
  3609. Gwindow.displayInChat("Jukebox is loading... Please wait a few seconds.","#DA0808","#1EBCC1");
  3610. Gwindow.changeJukeboxURL("URL INSERT HERE",Gwindow.Date.now()+2000);
  3611. }
  3612. else{
  3613. Gwindow.displayInChat("You need to be host.","#DA0808","#1EBCC1");
  3614. }
  3615. });
  3616. button.attributes["onclick"].nodeValue = button.attributes["onclick"].nodeValue.slice(11,-1).replaceAll("URL INSERT HERE","https://www."+matches[0]);
  3617. var extratext = ' ['+button.outerHTML+']';
  3618. }
  3619. if(url.startsWith('https://') || url.startsWith('http://')){return '<a href="' + url + '" target="_blank" style = "color:orange">' + sanitize(url) + '</a>'+extratext;}
  3620. else{return '<a href="https://' + url + '" target="_blank" style = "color:orange">' + sanitize(url) + '</a>'+extratext;}
  3621. })}return text;
  3622. };
  3623. scope.fire = function(type,options,d = Gdocument){
  3624. var event= document.createEvent("HTMLEvents");
  3625. event.initEvent(type,true,false);
  3626. for(var p in options){
  3627. event[p]=options[p];
  3628. }
  3629. d.dispatchEvent(event);
  3630. };
  3631. scope.chat = function(message){
  3632. SEND('42[10,{"message":'+JSON.stringify(message)+'}]');
  3633. };
  3634. scope.chat2 = function(message,enteragain=false){
  3635. mess = Gdocument.getElementById("newbonklobby_chat_input").value;
  3636. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  3637. Gdocument.getElementById("newbonklobby_chat_input").value = message;
  3638. Gdocument.getElementById("ingamechatinputtext").value = message;
  3639. fire("keydown",{keyCode:13});
  3640. if(!enteragain){
  3641. fire("keydown",{keyCode:13});
  3642. }
  3643. Gdocument.getElementById("newbonklobby_chat_input").value = mess;
  3644. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  3645. };
  3646. scope.sanitize = function(message){
  3647. return message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;');
  3648. };
  3649. scope.displayInChat = function(message, LobbyColor, InGameColor, options, message2, BringDown) {
  3650. options = options ?? {};
  3651. BringDown = BringDown ?? false;
  3652. message2 = message2 ?? "";
  3653. LobbyColor = LobbyColor ?? "#8800FF";
  3654. InGameColor = InGameColor ?? "#AA88FF";
  3655. var A = Gdocument.createElement("div");
  3656. var B = Gdocument.createElement("span");
  3657. B.className = "newbonklobby_chat_status";
  3658. B.style.color = LobbyColor;
  3659. A.appendChild(B);
  3660. B.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  3661. B.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  3662. var C = Gdocument.createElement("div");
  3663. var D = Gdocument.createElement("span");
  3664. D.style.color = InGameColor;
  3665. C.appendChild(D);
  3666. D.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  3667. D.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  3668. var a = BringDown;
  3669. if(Gdocument.getElementById("newbonklobby_chat_content").clientHeight + Gdocument.getElementById("newbonklobby_chat_content").scrollTop >= Gdocument.getElementById("newbonklobby_chat_content").scrollHeight-1) {
  3670. a = true;
  3671. }
  3672. var b = BringDown;
  3673. if(Gdocument.getElementById("ingamechatcontent").clientHeight + Gdocument.getElementById("ingamechatcontent").scrollTop >= Gdocument.getElementById("ingamechatcontent").scrollHeight-1) {
  3674. b = true;
  3675. }
  3676. A.style["parsed"] = true;
  3677. C.style["parsed"] = true;
  3678. Gdocument.getElementById("newbonklobby_chat_content").appendChild(A);
  3679. Gdocument.getElementById("ingamechatcontent").appendChild(C);
  3680. if (a) { Gdocument.getElementById("newbonklobby_chat_content").scrollTop = Gdocument.getElementById("newbonklobby_chat_content").scrollHeight;};
  3681. if (b) { Gdocument.getElementById("ingamechatcontent").scrollTop = Gdocument.getElementById("ingamechatcontent").scrollHeight;};
  3682. if(Gdocument.getElementById("newbonklobby_chat_input").style["pointer-events"]!="auto" && !Gdocument.getElementById("ingamechatinputtext").classList.value.includes("ingamechatinputtextbg")){
  3683. chat2("");
  3684. }
  3685. };
  3686. scope.lobby = function(){
  3687. if (Gdocument.getElementById("newbonklobby").style["display"]=="none"){
  3688. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3689. Gdocument.getElementById("mapeditor_close").click();
  3690. if(Gdocument.getElementById("newbonklobby_playerbox_elementcontainer").children.length+Gdocument.getElementById("newbonklobby_specbox_elementcontainer").children.length-3>0){
  3691. Gdocument.getElementById("newbonklobby").style["z-index"]=1;
  3692. Gdocument.getElementById("maploadwindowcontainer").style["z-index"]=1;
  3693. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=1;
  3694. Gdocument.getElementById("pretty_top").style["z-index"]=3;
  3695. Gdocument.getElementById("settingsContainer").style["z-index"]=3;
  3696. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=3;
  3697. Gdocument.getElementById("hostleaveconfirmwindow").style["z-index"]=3;
  3698. debuggermenu.style["z-index"] = 2;
  3699. }
  3700. else{
  3701. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  3702. Gdocument.getElementById("newbonklobby").style["display"]="none";
  3703. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  3704. }
  3705. }
  3706. else if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  3707. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  3708. Gdocument.getElementById("newbonklobby").style["display"]="none";
  3709. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  3710. }
  3711. };
  3712. scope.lastmessage = function(){
  3713. if(Gdocument.getElementById("newbonklobby_chat_content").children.length!=0){
  3714. var lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  3715. var lm2 = "";
  3716. for(var i = 0; i<lm.length;i++){
  3717. lm2+=" "+lm[i].textContent.trim();
  3718. }
  3719. lm2 = lm2.trim();
  3720. if(lm2.startsWith("*")){
  3721. return lm2;
  3722. }
  3723. }
  3724. if(Gdocument.getElementById("ingamechatcontent").children.length!=0){
  3725. var lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  3726. var lm2 = "";
  3727. for(var i = 0; i<lm.length;i++){
  3728. lm2+=" "+lm[i].textContent.trim();
  3729. }
  3730. return lm2.trim();
  3731. }
  3732. return "";
  3733. };
  3734. scope.map = function(e,t=timedelay){
  3735. if(e<0){
  3736. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  3737. quicki = 0;
  3738. return;
  3739. }
  3740. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  3741. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  3742. return;
  3743. }
  3744. setTimeout(function(){if(!canceled){
  3745. startedinqp = true;
  3746. if(roundsperqp2>=roundsperqp){
  3747. roundsperqp2 = 0;
  3748. }
  3749. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  3750. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3751. if(recmodebool && ishost){
  3752. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  3753. if(mode == "" && defaultmode!="d"){
  3754. mode = defaultmode;
  3755. }
  3756. if(mode != ""){
  3757. RECIEVE('42[26,"b","'+mode+'"]');
  3758. }
  3759. }
  3760. var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  3761. Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  3762. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  3763. if(displayblock){
  3764. Gdocument.getElementById("newbonklobby").style["display"] = "block";
  3765. }
  3766. Gdocument.getElementById("mapeditor_midbox_testbutton").click();}
  3767. canceled = false;
  3768. transitioning = false;
  3769. },t);
  3770. };
  3771. scope.gotonextmap = function(e){
  3772. if(e<0){
  3773. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  3774. quicki = 0;
  3775. return;
  3776. }
  3777. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  3778. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  3779. return;
  3780. }
  3781. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  3782. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3783. if(recmodebool && ishost){
  3784. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  3785. if(mode == "" && defaultmode!="d"){
  3786. mode = defaultmode;
  3787. }
  3788. if(mode != ""){
  3789. RECIEVE('42[26,"b","'+mode+'"]');
  3790. }
  3791. }
  3792. startedinqp = true;
  3793. if(roundsperqp2>=roundsperqp){
  3794. roundsperqp2 = 0;
  3795. }
  3796. var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  3797. Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  3798. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  3799. if(displayblock){
  3800. Gdocument.getElementById("newbonklobby").style["display"] = "block";
  3801. }
  3802. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  3803. Gdocument.getElementById("newbonklobby").style["visibility"] = "visible";
  3804. };
  3805. scope.commandhandle = function(chat_val){
  3806. if (chat_val.substring(1,6)=="echo " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3807. if (chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"")==username){
  3808. displayInChat("You cannot echo yourself.","#DA0808","#1EBCC1");
  3809. return "";
  3810. }
  3811. else if (echo_list.indexOf(chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',""))===-1) {
  3812. echo_list.push(chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',""));
  3813. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"") + " is being echoed.","#DA0808","#1EBCC1");
  3814. return "";
  3815. }
  3816. else{
  3817. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"") + " is already being echoed.","#DA0808","#1EBCC1");
  3818. return "";
  3819. }
  3820. }
  3821. else if (chat_val.substring(1,8)=="remove " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3822. if (echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',""))!==-1){
  3823. echo_list.splice(echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"")),1);
  3824. displayInChat(chat_val.substring(7).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"")+" is not being echoed.","#DA0808","#1EBCC1");
  3825. return "";
  3826. }
  3827. else{
  3828. displayInChat("You cannot remove someone that you didn't echo.","#DA0808","#1EBCC1");
  3829. return "";
  3830. }
  3831. }
  3832. else if (chat_val.substring(1,10)=="echotext " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  3833. echotext = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  3834. displayInChat("Set echotext as: "+echotext,"#DA0808","#1EBCC1");
  3835. displayInChat("Type '/echotext' to reset echotext.","#DA0808","#1EBCC1");
  3836. return "";
  3837. }
  3838. else if (chat_val.substring(1,9)=="echotext"){
  3839. echotext = "message";
  3840. displayInChat("Reset echotext.","#DA0808","#1EBCC1");
  3841. return "";
  3842. }
  3843. else if (chat_val.substring(1,10)=="clearecho"){
  3844. echo_list = [];
  3845. displayInChat("Cleared the echo list.","#DA0808","#1EBCC1");
  3846. return "";
  3847. }
  3848. else if (chat_val.substring(1,11)=="randomchat"){
  3849. if(randomchat == true){
  3850. displayInChat("Random chat is now off.","#DA0808","#1EBCC1");
  3851. randomchat = false;
  3852. }
  3853. else{
  3854. displayInChat("Random chat is now on.","#DA0808","#1EBCC1");
  3855. randomchat = true;
  3856. }
  3857. return "";
  3858. }
  3859. else if (chat_val.substring(1,12)=="autocorrect"){
  3860. if(autocorrect == true){
  3861. displayInChat("Autocorrect is now off.","#DA0808","#1EBCC1");
  3862. autocorrect = false;
  3863. }
  3864. else{
  3865. displayInChat("Autocorrect is now on.","#DA0808","#1EBCC1");
  3866. autocorrect = true;
  3867. }
  3868. return "";
  3869. }
  3870. else if (chat_val.substring(1,13)=="translateto " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  3871. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '').toLowerCase();
  3872. var keys = Object.keys(translatingkeys);
  3873. if(keys.includes(text)){
  3874. translating2 = [true,translatingkeys[text]];
  3875. displayInChat("You will now speak the "+text+" language.","#DA0808","#1EBCC1");
  3876. }
  3877. else{
  3878. displayInChat("Invalid language. Here are the current language options:","#DA0808","#1EBCC1");
  3879. for(var i = 0;i<keys.length;i++){
  3880. displayInChat(keys[i],"#DA0808","#1EBCC1");
  3881. }
  3882. }
  3883. return "";
  3884. }
  3885. else if (chat_val.substring(1,12)=="translateto"){
  3886. translating2 = [false,""];
  3887. displayInChat("You will not speak another language anymore.","#DA0808","#1EBCC1");
  3888. return "";
  3889. }
  3890. else if (chat_val.substring(1,11)=="translate " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  3891. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '').toLowerCase();
  3892. var keys = Object.keys(translatingkeys);
  3893. if(keys.includes(text)){
  3894. translating = [true,translatingkeys[text]];
  3895. displayInChat("Translator has been set to the "+text+" language.","#DA0808","#1EBCC1");
  3896. }
  3897. else{
  3898. displayInChat("Invalid language. Here are the current language options:","#DA0808","#1EBCC1");
  3899. for(var i = 0;i<keys.length;i++){
  3900. displayInChat(keys[i],"#DA0808","#1EBCC1");
  3901. }
  3902. }
  3903. return "";
  3904. }
  3905. else if (chat_val.substring(1,10)=="translate"){
  3906. translating = [false,""];
  3907. displayInChat("Translator has been turned off.","#DA0808","#1EBCC1");
  3908. return "";
  3909. }
  3910. else if (chat_val.substring(1,6)=="space"){
  3911. if(space_flag == true){
  3912. displayInChat("Space is now off.","#DA0808","#1EBCC1");
  3913. space_flag = false;
  3914. }
  3915. else{
  3916. displayInChat("Space is now on.","#DA0808","#1EBCC1");
  3917. space_flag = true;
  3918. }
  3919. return "";
  3920. }
  3921. else if (chat_val.substring(1,6)=="rcaps"){
  3922. if(rcaps_flag == true){
  3923. displayInChat("Rcaps is now off.","#DA0808","#1EBCC1");
  3924. rcaps_flag = false;
  3925. }
  3926. else{
  3927. displayInChat("Rcaps is now on.","#DA0808","#1EBCC1");
  3928. rcaps_flag = true;
  3929. }
  3930. return "";
  3931. }
  3932. else if (chat_val.substring(1,7)=="number"){
  3933. if(number_flag == true){
  3934. displayInChat("Number is now off.","#DA0808","#1EBCC1");
  3935. number_flag = false;
  3936. }
  3937. else{
  3938. displayInChat("Number is now on.","#DA0808","#1EBCC1");
  3939. number_flag = true;
  3940. }
  3941. return "";
  3942. }
  3943. else if (chat_val.substring(1,8)=="reverse"){
  3944. if(reverse_flag == true){
  3945. displayInChat("Reverse is now off.","#DA0808","#1EBCC1");
  3946. reverse_flag = false;
  3947. }
  3948. else{
  3949. displayInChat("Reverse is now on.","#DA0808","#1EBCC1");
  3950. reverse_flag = true;
  3951. }
  3952. return "";
  3953. }
  3954. else if (chat_val.substring(1,7)=="speech"){
  3955. if(text2speech == true){
  3956. displayInChat("Text to speech is now off.","#DA0808","#1EBCC1");
  3957. text2speech = false;
  3958. }
  3959. else{
  3960. displayInChat("Text to speech is now on.","#DA0808","#1EBCC1");
  3961. text2speech = true;
  3962. }
  3963. return "";
  3964. }
  3965. else if (chat_val.substring(1,7)=="maxfps"){
  3966. if(maxfps){
  3967. displayInChat("Max FPS is now off.","#DA0808","#1EBCC1");
  3968. maxfps = false;
  3969. }
  3970. else{
  3971. displayInChat("Max FPS is now on.","#DA0808","#1EBCC1");
  3972. maxfps = true;
  3973. }
  3974. return "";
  3975. }
  3976. else if (chat_val.substring(1,6)=="eval " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3977. var ev = "";
  3978. try{
  3979. ev = eval(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  3980. }
  3981. catch(e){
  3982. displayInChat(e.message,"#DA0808","#1EBCC1");
  3983. }
  3984. try{
  3985. displayInChat(ev.toString(),"#DA0808","#1EBCC1");
  3986. }
  3987. catch{
  3988. }
  3989. return "";
  3990. }
  3991. else if (chat_val.substring(1,10)=="textmode " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  3992. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  3993. var parsed = parseInt(text);
  3994. if(!isNaN(parsed)){
  3995. if(parsed<=7 && parsed>=1){
  3996. textmode = parsed-1;
  3997. displayInChat("Type '/textmode' to reset textmode.","#DA0808","#1EBCC1");
  3998. }
  3999. else{
  4000. displayInChat("Please enter a integer from 1-7 inclusive.","#DA0808","#1EBCC1");
  4001. }
  4002. }
  4003. else{
  4004. displayInChat("Please enter a integer from 1-7 inclusive.","#DA0808","#1EBCC1");
  4005. }
  4006. return "";
  4007.  
  4008. }
  4009. else if (chat_val.substring(1,9)=="textmode"){
  4010. textmode = -1;
  4011. displayInChat("Reset textmode.","#DA0808","#1EBCC1");
  4012. return "";
  4013. }
  4014. else if (chat_val.substring(1,10)=="savedroom"){
  4015. if(savedrooms.length == 0){
  4016. displayInChat("You do not have any saved rooms.","#DA0808","#1EBCC1");
  4017. return "";
  4018. }
  4019. else{
  4020. var keys = Object.keys(savedroomsdata);
  4021. for(var i = 0;i<keys.length;i++){
  4022. var code = 'this.parentElement.remove();delete Gwindow.savedroomsdata["'+keys[i]+'"];Gwindow.savedrooms.splice(Gwindow.savedrooms.indexOf('+keys[i]+'),1);';
  4023. displayInChat('<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">Remove</a>'+' - ',"#DA0808","#1EBCC1",{sanitize:false},JSON.stringify(savedroomsdata[keys[i]].roomname)+" - "+savedroomsdata[keys[i]].players+"/"+savedroomsdata[keys[i]].maxplayers+" players.");
  4024. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  4025. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  4026. Laster_message = lastmessage();
  4027. }
  4028. }
  4029. return "";
  4030. }
  4031. else if (chat_val.substring(1,15)=="clearsavedroom"){
  4032. if(savedrooms.length == 0){
  4033. displayInChat("You do not have any saved rooms.","#DA0808","#1EBCC1");
  4034. return "";
  4035. }
  4036. else{
  4037. var keys = Object.keys(savedroomsdata);
  4038. for(var i = 0;i<keys.length;i++){
  4039. savedrooms.splice(savedrooms.indexOf(parseInt(keys[i])),1);
  4040. delete savedroomsdata[keys[i]];
  4041. }
  4042. }
  4043. return "";
  4044. }
  4045. else if (chat_val.substring(1,10)=="followcam"){
  4046. if(FollowCam == true){
  4047. displayInChat("Follow Camera is now off.","#DA0808","#1EBCC1");
  4048. FollowCam = false;
  4049. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4050. var addto = {"children":[]};
  4051. for(var i = 0;i<parentDraw.children.length;i++){
  4052. if(parentDraw.children[i].constructor.name == "e"){
  4053. addto = parentDraw.children[i];
  4054. break;
  4055. }
  4056. }
  4057. var canv = 0;
  4058. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  4059. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  4060. canv = Gdocument.getElementById("gamerenderer").children[i];
  4061. break;
  4062. }
  4063. }
  4064. var width = parseInt(canv.style["width"]);
  4065. var height = parseInt(canv.style["height"]);
  4066. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  4067. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  4068. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  4069. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  4070. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  4071. pixiCircle.visible = false;
  4072. }
  4073. else{
  4074. pixiCircle.visible = true;
  4075. }
  4076. }
  4077. }
  4078. else{
  4079. displayInChat("Follow Camera is now on.","#DA0808","#1EBCC1");
  4080. FollowCam = true;
  4081. }
  4082. return "";
  4083. }
  4084. else if (chat_val.substring(1,8)=="autocam"){
  4085. if(autocam == true){
  4086. displayInChat("Auto Cam is now off.","#DA0808","#1EBCC1");
  4087. autocam = false
  4088. }
  4089. else{
  4090. displayInChat("Auto Cam is now on.","#DA0808","#1EBCC1");
  4091. autocam = true;
  4092. }
  4093. return "";
  4094. }
  4095. else if (chat_val.substring(1,4)=="pan"){
  4096. if(pan_enabled == true){
  4097. displayInChat("Pan is now off.","#DA0808","#1EBCC1");
  4098. pan_enabled = false;
  4099. pan = {"x":0,"y":0};
  4100. }
  4101. else{
  4102. displayInChat("Pan is now on. Shift + Arrow Keys to pan.","#DA0808","#1EBCC1");
  4103. pan_enabled = true;
  4104. }
  4105. return "";
  4106. }
  4107. else if (chat_val.substring(1,9)=="resetpan"){
  4108. pan = {"x":0,"y":0};
  4109. displayInChat("Reset pan.","#DA0808","#1EBCC1");
  4110. return "";
  4111. }
  4112. else if (chat_val.substring(1,7)=="aimbot"){
  4113. if(aimbot == true){
  4114. displayInChat("Aimbot is now off.","#DA0808","#1EBCC1");
  4115. aimbot = false;
  4116. }
  4117. else{
  4118. displayInChat("Aimbot is now on.","#DA0808","#1EBCC1");
  4119. aimbot = true;
  4120. getplayerkeys();
  4121. }
  4122. return "";
  4123. }
  4124. else if (chat_val.substring(1,8)=="volume " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  4125. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  4126. if(!isNaN(parseInt(text))){
  4127. int_text = parseInt(text);
  4128. if(int_text>=0 && int_text<=100){
  4129. jukeboxplayer.volume = int_text/100;
  4130. jukeboxplayervolume = int_text;
  4131. displayInChat("Jukebox volume set to: "+int_text.toString()+" percent.","#DA0808","#1EBCC1");
  4132. }
  4133. else{
  4134. displayInChat("Volume must be between 0 and 100 percent.","#DA0808","#1EBCC1");
  4135. }
  4136. }
  4137. return "";
  4138. }
  4139. else if (chat_val.substring(1,6)=="still"){
  4140. if(staystill == true){
  4141. displayInChat("Still is now off.","#DA0808","#1EBCC1");
  4142. staystill = false;
  4143. staystillpos = [0,0];
  4144. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  4145. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  4146. }
  4147. else{
  4148. if(playerids[myid].playerData?.transform){
  4149. displayInChat("Still is now on.","#DA0808","#1EBCC1");
  4150. staystill = true;
  4151. staystillpos = [playerids[myid].playerData.transform.position.x/scale,playerids[myid].playerData.transform.position.y/scale];
  4152. getplayerkeys();
  4153. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  4154. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  4155. }
  4156. else{
  4157. displayInChat("You have to be alive to use this command.","#DA0808","#1EBCC1");
  4158. }
  4159. }
  4160. return "";
  4161. }
  4162. else if (chat_val.substring(1,9)=="heavybot"){
  4163. if(heavybot == true){
  4164. displayInChat("Heavy bot is now off.","#DA0808","#1EBCC1");
  4165. heavybot = false;
  4166. }
  4167. else{
  4168. displayInChat("Heavy bot is now on.","#DA0808","#1EBCC1");
  4169. heavybot = true;
  4170. getplayerkeys();
  4171. }
  4172. return "";
  4173. }
  4174. else if (chat_val.substring(1,5)=="xray"){
  4175. Gdocument.getElementById("pretty_top_settings").click();
  4176. Gdocument.getElementById("settings_close").click();
  4177. if(Gdocument.getElementById("settings_graphicsquality").value==1){
  4178. displayInChat("You must have medium or high quality enabled to use this feature.","#DA0808","#1EBCC1");
  4179. return "";
  4180. }
  4181. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4182. var addto = {"children":[]};
  4183. for(var i = 0;i<parentDraw.children.length;i++){
  4184. if(parentDraw.children[i].constructor.name == "e"){
  4185. addto = parentDraw.children[i];
  4186. break;
  4187. }
  4188. }
  4189. var addto2 = {"children":[]};
  4190. for(var i = 0;i<addto.children.length;i++){
  4191. if(addto.children[i].constructor.name == "e"){
  4192. addto2 = addto.children[i];
  4193. break;
  4194. }
  4195. }
  4196. var checkxray = addto2.children[0];
  4197. var addto3 = addto2.children[0].children;
  4198. if(addto3.length==1){
  4199. checkxray = checkxray.children[0];
  4200. addto3 = addto3[0].children;
  4201. }
  4202. var xrayon = false;
  4203. if(checkxray.xrayon){
  4204. checkxray.xrayon = false;
  4205. xrayon = false;
  4206. }
  4207. else{
  4208. checkxray.xrayon = true;
  4209. xrayon = true;
  4210. }
  4211. if(xrayon){
  4212. displayInChat("Xray is now on.","#DA0808","#1EBCC1");
  4213. for(var i = 0;i<addto3.length;i++){
  4214. if(addto3[i].children.length>0){
  4215. var ids = [];
  4216. var ids2 = [];
  4217. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  4218. addto3[i].children[i3].visible = false;
  4219. if(addto3[i].children[i3].children.length>0){
  4220. for(var i4 = 0;i4<addto3[i].children[i3].children.length;i4++){
  4221. if(addto3[i].children[i3].children[i4].geometry?.id){
  4222. ids.push(addto3[i].children[i3].children[i4].geometry.id);
  4223. }
  4224. else if(addto3[i].children[i3].children[i4].texture?.baseTexture?.uid){
  4225. ids2.push(addto3[i].children[i3].children[i4].texture.baseTexture.uid);
  4226. }
  4227. }
  4228. }
  4229. }
  4230. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  4231. if(addto3[i].children[i3].children.length==0){
  4232. if(addto3[i].children[i3].geometry?.id){
  4233. if(ids.includes(addto3[i].children[i3].geometry.id+1)){
  4234. addto3[i].children[i3].visible = true;
  4235. addto3[i].children[i3].alpha = 0.5;
  4236. }
  4237. }
  4238. else if(addto3[i].children[i3].texture?.baseTexture?.uid){
  4239. if(ids2.includes(addto3[i].children[i3].texture.baseTexture.uid+1)){
  4240. addto3[i].children[i3].visible = true;
  4241. addto3[i].children[i3].alpha = 0.5;
  4242. }
  4243. }
  4244. }
  4245. }
  4246. }
  4247. }
  4248. }
  4249. else{
  4250. displayInChat("Xray is now off.","#DA0808","#1EBCC1");
  4251. for(var i = 0;i<addto3.length;i++){
  4252. for(var i2 = 0;i2<addto3[i].children.length;i2++){
  4253. addto3[i].children[i2].visible = true;
  4254. addto3[i].children[i2].alpha = 1;
  4255. }
  4256. }
  4257. }
  4258. }
  4259. return "";
  4260. }
  4261. else if (chat_val.substring(1,6)=="zoom "){
  4262. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  4263. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4264. var addto = 0;
  4265. for(var i = 0;i<parentDraw.children.length;i++){
  4266. if(parentDraw.children[i].constructor.name == "e"){
  4267. addto = parentDraw.children[i];
  4268. break;
  4269. }
  4270. }
  4271. var canv = 0;
  4272. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  4273. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  4274. canv = Gdocument.getElementById("gamerenderer").children[i];
  4275. break;
  4276. }
  4277. }
  4278. var width = parseInt(canv.style["width"]);
  4279. var height = parseInt(canv.style["height"]);
  4280. if(addto){
  4281. if(text == "in"){
  4282. zoom *= 1.1;
  4283. }
  4284. else if(text == "out"){
  4285. zoom /= 1.1;
  4286. }
  4287. else if(text == "reset"){
  4288. zoom = 1;
  4289. }
  4290. else{
  4291. displayInChat("Options for zooming:","#DA0808","#1EBCC1");
  4292. displayInChat("in","#DA0808","#1EBCC1");
  4293. displayInChat("out","#DA0808","#1EBCC1");
  4294. displayInChat("reset","#DA0808","#1EBCC1");
  4295. return "";
  4296. }
  4297. addto.scale.x=zoom;
  4298. addto.scale.y=zoom;
  4299. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  4300. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  4301. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  4302. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  4303. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  4304. pixiCircle.visible = false;
  4305. }
  4306. else{
  4307. pixiCircle.visible = true;
  4308. }
  4309. }
  4310. }
  4311. return "";
  4312. }
  4313. else if (chat_val.substring(1,9)=="hidechat"){
  4314. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  4315. return "";
  4316. }
  4317. else if (chat_val.substring(1,9)=="showchat"){
  4318. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  4319. return "";
  4320. }
  4321. else if (chat_val.substring(1,6)=="score"){
  4322. var element = Gdocument.getElementById("ingamewinner_scores");
  4323. if(element.style["opacity"]<1){
  4324. element.style["opacity"] = 1;
  4325. element.style["visibility"] = "visible";
  4326. }
  4327. else{
  4328. element.style["opacity"] = 0;
  4329. element.style["visibility"] = "unset";
  4330. }
  4331. return "";
  4332. }
  4333. else if (chat_val.substring(1,7)=="scroll"){
  4334. if(scroll==false){
  4335. scroll = true;
  4336. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="scroll";
  4337. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  4338. }
  4339. else if(scroll==true){
  4340. scroll = false;
  4341. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="hidden";
  4342. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  4343. }
  4344. return "";
  4345. }
  4346. else if (chat_val.substring(1,7)=="chatw "){
  4347. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  4348. if(username == text){
  4349. displayInChat("You cannot private chat with yourself.","#DA0808","#1EBCC1");
  4350. return "";
  4351. }
  4352. private_chat = text;
  4353. SEND("42"+JSON.stringify([4,{"type":"request public key","from":username,"to":private_chat}]));
  4354. request_public_key_time_stamp = Date.now();
  4355. 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);
  4356. return "";
  4357. }
  4358. else if (chat_val.substring(1,8)=="lagbot " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  4359. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  4360. if(!isNaN(parseInt(text))){
  4361. int_text = parseInt(text);
  4362. if(int_text == 0){
  4363. causelag = false;
  4364. causelag2 = 0;
  4365. displayInChat("Lagbot is now off.","#DA0808","#1EBCC1");
  4366. displayInChat("To enable lagbot, type '/lagbot [number]' with a number between 1 and 10.","#DA0808","#1EBCC1");
  4367. }
  4368. else if(int_text>0 && int_text<=10){
  4369. causelag = true;
  4370. causelag2 = 45*int_text;
  4371. displayInChat("Lagbot is now on with a lag setting of "+int_text.toString()+" (~"+(45*int_text).toString()+"MS).","#DA0808","#1EBCC1");
  4372. displayInChat("Type '/lagbot 0' to turn off lagbot.","#DA0808","#1EBCC1");
  4373. }
  4374. else{
  4375. displayInChat("To enable lagbot, type '/lagbot [number]' with a number between 1 and 10.","#DA0808","#1EBCC1");
  4376. displayInChat("Type '/lagbot 0' to turn off lagbot.","#DA0808","#1EBCC1");
  4377. }
  4378. return "";
  4379. }
  4380. }
  4381. else if (chat_val.substring(1,8)=="record " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  4382. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  4383. var keys = Object.keys(playerids);
  4384. var recordingid2 = -1;
  4385. for(var i = 0;i<keys.length;i++){
  4386. if(playerids[keys[i]].userName == text){
  4387. recordingid2 = keys[i];
  4388. }
  4389. }
  4390. if(recordingid2 == -1){
  4391. displayInChat("Player not found. Please type a valid username.","#DA0808","#1EBCC1");
  4392. return "";
  4393. }
  4394. else{
  4395. recording = true;
  4396. recordingid = recordingid2;
  4397. displayInChat(playerids[recordingid].userName+" is now being recorded.","#DA0808","#1EBCC1");
  4398. if(recordingdata.length>0){
  4399. displayInChat("Any unsaved recording data is now cleared.","#DA0808","#1EBCC1");
  4400. }
  4401. recordingdata = [];
  4402. }
  4403. return "";
  4404. }
  4405. else if (chat_val.substring(1,11)=="stoprecord"){
  4406. if(recording){
  4407. displayInChat(playerids[recordingid].userName+" is not being recorded anymore.","#DA0808","#1EBCC1");
  4408. displayInChat("Type '/saverecording [text]' to save this recording.","#DA0808","#1EBCC1");
  4409. recording = false;
  4410. recordingid = -1;
  4411. recordingdata[0][1] = 0;
  4412. }
  4413. else{
  4414. displayInChat("No one is being recorded.","#DA0808","#1EBCC1");
  4415. }
  4416. return "";
  4417. }
  4418. else if (chat_val.substring(1,15)=="saverecording " && chat_val.replace(/^\s+|\s+$/g, '').length>=16){
  4419. var text = chat_val.substring(15).replace(/^\s+|\s+$/g, '');
  4420. if(Object.keys(recorddata).includes(text)){
  4421. displayInChat("This recording already exists. Please use a different name or type '/delrecording "+text+"'.","#DA0808","#1EBCC1");
  4422. }
  4423. else if(recordingdata.length>0){
  4424. recorddata[text] = JSON.parse(JSON.stringify(recordingdata));
  4425. displayInChat("Recording saved as: "+text,"#DA0808","#1EBCC1");
  4426. }
  4427. else{
  4428. displayInChat("There is no recording data to save. Please record data using '/record [username]'","#DA0808","#1EBCC1");
  4429. }
  4430. return "";
  4431. }
  4432. else if (chat_val.substring(1,14)=="delrecording " && chat_val.replace(/^\s+|\s+$/g, '').length>=15){
  4433. var text = chat_val.substring(14).replace(/^\s+|\s+$/g, '');
  4434. if(Object.keys(recorddata).includes(text)){
  4435. displayInChat("Recording deleted.","#DA0808","#1EBCC1");
  4436. delete recorddata[text];
  4437. }
  4438. else{
  4439. displayInChat("This recording does not exist.","#DA0808","#1EBCC1");
  4440. }
  4441. return "";
  4442. }
  4443. else if (chat_val.substring(1,15)=="loadrecording " && chat_val.replace(/^\s+|\s+$/g, '').length>=16){
  4444. var text = chat_val.substring(15).replace(/^\s+|\s+$/g, '');
  4445. if(!Object.keys(recorddata).includes(text)){
  4446. displayInChat("This recording does not exist.","#DA0808","#1EBCC1");
  4447. }
  4448. else{
  4449. if(recordingdata.length>0){
  4450. displayInChat("Any unsaved recording data is now cleared.","#DA0808","#1EBCC1");
  4451. }
  4452. recordingdata = JSON.parse(JSON.stringify(recorddata[text]));
  4453. displayInChat("Recording data is now loaded.","#DA0808","#1EBCC1");
  4454. }
  4455. return "";
  4456. }
  4457. else if (chat_val.substring(1,7)=="replay"){
  4458. if(recording){
  4459. displayInChat(playerids[recordingid].userName+" is not being recorded anymore.","#DA0808","#1EBCC1");
  4460. displayInChat("Type '/saverecording [text]' to save this recording.","#DA0808","#1EBCC1");
  4461. recordingid = -1;
  4462. recording = false;
  4463. recordingdata[0][1] = 0;
  4464. }
  4465. replay();
  4466. return "";
  4467. }
  4468. else if (chat_val.substring(1,5)=="msg " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  4469. if(private_chat_public_key[1][0] != 0 && private_chat_public_key[1][1] != 0 && private_chat_public_key[0] == private_chat){
  4470. var text = chat_val.substring(5).replace(/^\s+|\s+$/g, '');
  4471. pmlastmessage = text.slice(0,400);
  4472. ENCRYPT_MESSAGE(private_chat_public_key[1],text).then(function(e){
  4473. SEND("42"+JSON.stringify([4,{"type":"private chat","from":username,"to":private_chat,"message":e}]));
  4474. });
  4475. displayInChat("> "+username+": ","#DA0808","#1EBCC1",{sanitize:false},text,false);
  4476. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  4477. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  4478. Laster_message = lastmessage();
  4479. }
  4480. return "";
  4481. }
  4482. else if (chat_val.substring(1,10)=="ignorepm " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  4483. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  4484. if(ignorepmlist.includes(text)){
  4485. var index = ignorepmlist.indexOf(text);
  4486. ignorepmlist.splice(index,1);
  4487. displayInChat("You are not ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  4488. }
  4489. else{
  4490. ignorepmlist.push(text);
  4491. displayInChat("You are now ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  4492. }
  4493. return "";
  4494. }
  4495. else if (chat_val.substring(1,8)=="pmusers"){
  4496. pmusers = [];
  4497. SEND("42"+JSON.stringify([4,{"type":"request private chat users","from":username}]));
  4498. pmuserstimestamp = Date.now();
  4499. setTimeout(function(){if(pmusers.length == 0){displayInChat("You cannot private chat with anyone.","#DA0808","#1EBCC1");
  4500. }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">'+sanitize(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);
  4501. return "";
  4502. }
  4503. else if (chat_val.substring(1,6)=="lobby"){
  4504. lobby();
  4505. return "";
  4506. }
  4507. else if (chat_val.substring(1,7)=="style " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  4508. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  4509. var text2 = text.split(" ");
  4510. var array = [];
  4511. for(var i = 0;i<text2.length;i++){
  4512. var parsed = parseInt(text2[i]);
  4513. if(!isNaN(parsed)){
  4514. array.push(parsed);
  4515. }
  4516. }
  4517. if(array[0]+array[1]+array[2] == 0){
  4518. array = [1,1,1];
  4519. }
  4520. if(array.length == 3){
  4521. SEND("42"+JSON.stringify([4,{"type":"style","from":username,"style":array}]));
  4522. allstyles[username] = array;
  4523. mystyle = [...array];
  4524. displayInChat("Set style to ("+array.toString()+"). Type '/style' to reset style.","#DA0808","#1EBCC1");
  4525. }
  4526. else{
  4527. displayInChat("Please enter a valid RGB color code seperated by space. For example, white = '/style 255 255 255'. Type '/style' to reset style.","#DA0808","#1EBCC1");
  4528. }
  4529. return "";
  4530. }
  4531. else if (chat_val.substring(1,6)=="style"){
  4532. SEND("42"+JSON.stringify([4,{"type":"style","from":username,"style":[0,0,0]}]));
  4533. allstyles[username] = [0,0,0];
  4534. mystyle = [0,0,0];
  4535. displayInChat("Reset style.","#DA0808","#1EBCC1");
  4536. return "";
  4537. }
  4538. else if (chat_val.substring(1,6)=="lobby"){
  4539. lobby();
  4540. return "";
  4541. }
  4542. else if (chat_val.substring(1,9)=="debugger"){
  4543. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  4544. debuggeropen = true;
  4545. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  4546. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  4547. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  4548. }
  4549. else{
  4550. debuggeropen = false;
  4551. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  4552. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  4553. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  4554. }
  4555. return "";
  4556. }
  4557. else if (chat_val.substring(1,6)=="team " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  4558. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  4559. if(text == "r"){Gdocument.getElementById("newbonklobby_redbutton").click();}
  4560. else if(text == "g"){Gdocument.getElementById("newbonklobby_greenbutton").click();}
  4561. else if(text == "y"){Gdocument.getElementById("newbonklobby_yellowbutton").click();}
  4562. else if(text == "b"){Gdocument.getElementById("newbonklobby_bluebutton").click();}
  4563. else if(text == "s"){Gdocument.getElementById("newbonklobby_specbutton").click();}
  4564. else if(text == "f"){Gdocument.getElementById("newbonklobby_ffabutton").click();}
  4565. return "";
  4566. }
  4567. else if (chat_val.substring(1,7)=="notify"){
  4568. npermissions = 1;
  4569. return "";
  4570. }
  4571. else if (chat_val.substring(1,11)=="stopnotify"){
  4572. npermissions = 0;
  4573. return "";
  4574. }
  4575. else if (chat_val.substring(1,8)=="support"){
  4576. displayInChat("Thanks everyone for helping me make this mod - LEGENDBOSS123","#0000FF","#FFFFFF");
  4577. displayInChat("mastery3","#0000FF","#FFFFFF");
  4578. displayInChat("UnmatchedBracket aka Left Paren","#0000FF","#FFFFFF");
  4579. displayInChat("iNeonz","#0000FF","#FFFFFF");
  4580. return "";
  4581. }
  4582. else if (chat_val.substring(1,9)=="pollstat"){
  4583. if(pollactive[0] || pollactive2[0]){
  4584. var count = [0,0,0,0];
  4585. var keys = Object.keys(playerids);
  4586. for(var i = 0;i<keys.length;i++){
  4587. if(ishost){
  4588. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  4589. count[playerids[keys[i]].vote.poll]++;
  4590. }
  4591. }
  4592. else{
  4593. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive2[2].length-1){
  4594. count[playerids[keys[i]].vote.poll]++;
  4595. }
  4596. }
  4597. }
  4598. for(var i = 0;i<count.length;i++){
  4599. if(count[i]>1){
  4600. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  4601. }
  4602. if(count[i]==1){
  4603. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  4604. }
  4605. }
  4606. if(ishost){
  4607. displayInChat("The poll will end in: "+((pollactive[2]-Date.now())/1000).toString()+" seconds.","#DA0808","#1EBCC1");
  4608. }
  4609. displayInChat("The poll is:","#DA0808","#1EBCC1");
  4610. if(ishost){
  4611. for(var i = 0;i<pollactive[3].length;i++){
  4612. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  4613. }
  4614. }
  4615. else{
  4616. for(var i = 0;i<pollactive2[2].length;i++){
  4617. displayInChat(letters[i]+") "+pollactive2[2][i],"#DA0808","#1EBCC1");
  4618. }
  4619. }
  4620. }
  4621. else{
  4622. displayInChat("No poll has been started.","#DA0808","#1EBCC1");
  4623. if(ishost){
  4624. displayInChat("Type '/startpoll [seconds]' to start a poll.","#DA0808","#1EBCC1");
  4625. if(poll.length>0){
  4626. displayInChat("The poll is:","#DA0808","#1EBCC1");
  4627. for(var i = 0;i<poll.length;i++){
  4628. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  4629. }
  4630. }
  4631. }
  4632. }
  4633. return "";
  4634. }
  4635. else if (chat_val.substring(1,5)=="help" || chat_val.substring(1,2)=="?"){
  4636. for(var i = 0;i<help.length;i++){
  4637. if(help[i].startsWith("/")){
  4638. var splitted = help[i].substring(1).split(" ");
  4639. var command = splitted[0];
  4640. var rest = "";
  4641. if(splitted.length>1){
  4642. rest = " "+splitted.slice(1).join(" ");
  4643. }
  4644. displayInChat("/"+'<a onclick = \'Gwindow.displayadvhelp("'+command+'");\' style = "color:green;" href = "javascript:void(0);">'+command+'</a>'+rest,"#DA0808","#1EBCC1",{sanitize:false},"",false);
  4645. }
  4646. else if(help[i].startsWith("Alt ")){
  4647. displayInChat('<a onclick = \'Gwindow.displayadvhelp("'+help[i]+'");\' style = "color:green;" href = "javascript:void(0);">'+help[i]+'</a>',"#DA0808","#1EBCC1",{sanitize:false},"",false);
  4648. }
  4649. else{
  4650. displayInChat(help[i],"#DA0808","#1EBCC1");
  4651. }
  4652. }
  4653. return "";
  4654. }
  4655. else if (chat_val.substring(1,9)=="advhelp " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  4656. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  4657. if(typeof(adv_help[text])!='undefined'){
  4658. displayInChat(adv_help[text],"#DA0808","#1EBCC1");
  4659. }
  4660. return "";
  4661. }
  4662. else if (chat_val.substring(1,6)=="mode " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  4663. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  4664. var mode = "";
  4665. var text2 = text;
  4666. if(text == "arrows"){
  4667. text2 = "Arrows";
  4668. mode = "ar";
  4669. }
  4670. else if(text == "death arrows"){
  4671. mode = "ard";
  4672. text2 = "Death Arrows";
  4673. }
  4674. else if(text == "grapple"){
  4675. mode = "sp";
  4676. text2 = "Grapple";
  4677. }
  4678. else if(text == "classic"){
  4679. mode = "b";
  4680. text2 = "Classic";
  4681. }
  4682. else{
  4683. displayInChat("Mode options:","#DA0808","#1EBCC1");
  4684. displayInChat("classic","#DA0808","#1EBCC1");
  4685. displayInChat("arrows","#DA0808","#1EBCC1");
  4686. displayInChat("death arrows","#DA0808","#1EBCC1");
  4687. displayInChat("grapple","#DA0808","#1EBCC1");
  4688. }
  4689. if(mode != ""){
  4690. if(ishost){
  4691. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  4692. RECIEVE('42[26,"b","'+mode+'"]');
  4693. displayInChat("Changed mode to "+text+".","#DA0808","#1EBCC1");
  4694. }
  4695. else{
  4696. if(playerids[myid].ratelimit.mode+1000<Date.now()){
  4697. playerids[myid].ratelimit.mode=Date.now();
  4698. SEND("42"+JSON.stringify([4,{"type":"request mode","from":username,"mode":mode}]));
  4699. var code = 'if(!Gwindow.ishost){Gwindow.displayInChat("You must be host to change the mode.","#DA0808","#1EBCC1",{sanitize:false},"",true)}else{Gwindow.changemode("'+mode+'")}';
  4700. displayInChat('> '+username+' requests [<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+text2+'</a>]',"#DA0808","#1EBCC1",{sanitize:false}," mode.");
  4701. }
  4702. else{
  4703. displayInChat("You are requesting modes too quickly.","#DA0808","#1EBCC1");
  4704. }
  4705. }
  4706. }
  4707. return "";
  4708. }
  4709. else if(ishost){
  4710. if (chat_val.substring(1,11)=="nextafter " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  4711. var text = parseFloat(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  4712. if(isNaN(text)){
  4713. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  4714. return "";
  4715. }
  4716. else if(text<=0){
  4717. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  4718. return "";
  4719. }
  4720. nextafter = text;
  4721. displayInChat("Set next after to: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  4722. displayInChat("Type '/nextafter' to reset next after.","#DA0808","#1EBCC1");
  4723. return "";
  4724. }
  4725. else if (chat_val.substring(1,10)=="nextafter"){
  4726. nextafter = 0;
  4727. displayInChat("Reset next after.","#DA0808","#1EBCC1");
  4728. return "";
  4729. }
  4730. else if (chat_val.substring(1,5)=="next" && stopquickplay == 0){
  4731. roundsperqp2 = 0;
  4732. if(shuffle){
  4733. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4734. var available = [];
  4735. var availableindexes = [];
  4736. var notempty = false;
  4737. for(var i = 0; i<e.length;i++){
  4738. var a = false;
  4739. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4740. available.push(a);
  4741. if(a){
  4742. availableindexes.push(i);
  4743. notempty = true;
  4744. }
  4745. }
  4746. if(notempty){
  4747. if(availableindexes.length!=1){
  4748. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  4749. }
  4750. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  4751. }
  4752. }
  4753. else{
  4754. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4755. var available = [];
  4756. var availableindexes = [];
  4757. var notempty = false;
  4758. for(var i = 0; i<e.length;i++){
  4759. var a = false;
  4760. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4761. available.push(a);
  4762. if(a){
  4763. availableindexes.push(i);
  4764. notempty = true;
  4765. }
  4766. }
  4767. if(notempty){
  4768. var above = [];
  4769. for(var i = 0;i<availableindexes.length;i++){
  4770. if(availableindexes[i]>quicki && !reverseqp){
  4771. above.push(availableindexes[i]);
  4772. }
  4773. else if(availableindexes[i]<quicki && reverseqp){
  4774. above.push(availableindexes[i])
  4775. }
  4776. }
  4777. if(above.length>0){
  4778. quicki = above[0];
  4779. if(reverseqp){
  4780. quicki = above[above.length-1];
  4781. }
  4782. }
  4783. else{
  4784. quicki = availableindexes[0];
  4785. if(reverseqp){
  4786. quicki = availableindexes[availableindexes.length-1];
  4787. }
  4788. }
  4789. }
  4790. }
  4791. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  4792. displayInChat("Switched to next map.","#DA0808","#1EBCC1");
  4793. return "";
  4794. }
  4795. else if (chat_val.substring(1,9)=="freejoin"){
  4796. if(freejoin == false){
  4797. freejoin = true;
  4798. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  4799. }
  4800. else{
  4801. freejoin = false;
  4802. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  4803. }
  4804. return "";
  4805. }
  4806. else if (chat_val.substring(1,8)=="instaqp"){
  4807. if(instaqp == false){
  4808. instaqp = true;
  4809. displayInChat("Instaqp is now on.","#DA0808","#1EBCC1");
  4810. }
  4811. else{
  4812. instaqp = false;
  4813. displayInChat("Instaqp is now off.","#DA0808","#1EBCC1");
  4814. }
  4815. return "";
  4816. }
  4817. else if (chat_val.substring(1,9)=="previous" && stopquickplay == 0){
  4818. roundsperqp2 = 0;
  4819. if(shuffle){
  4820. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4821. var available = [];
  4822. var availableindexes = [];
  4823. var notempty = false;
  4824. for(var i = 0; i<e.length;i++){
  4825. var a = false;
  4826. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4827. available.push(a);
  4828. if(a){
  4829. availableindexes.push(i);
  4830. notempty = true;
  4831. }
  4832. }
  4833. if(notempty){
  4834. if(availableindexes.length!=1){
  4835. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  4836. }
  4837. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  4838. }
  4839. }
  4840. else{
  4841. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4842. var available = [];
  4843. var availableindexes = [];
  4844. var notempty = false;
  4845. for(var i = 0; i<e.length;i++){
  4846. var a = false;
  4847. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4848. available.push(a);
  4849. if(a){
  4850. availableindexes.push(i);
  4851. notempty = true;
  4852. }
  4853. }
  4854. if(notempty){
  4855. var above = [];
  4856. for(var i = 0;i<availableindexes.length;i++){
  4857. if(availableindexes[i]<quicki && !reverseqp){
  4858. above.push(availableindexes[i]);
  4859. }
  4860. else if(availableindexes[i]>quicki && reverseqp){
  4861. above.push(availableindexes[i])
  4862. }
  4863. }
  4864. if(above.length>0){
  4865. quicki = above[above.length-1];
  4866. if(reverseqp){
  4867. quicki = above[0];
  4868. }
  4869. }
  4870. else{
  4871. quicki = availableindexes[availableindexes.length-1];
  4872. if(reverseqp){
  4873. quicki = availableindexes[0];
  4874. }
  4875. }
  4876. }
  4877. }
  4878. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  4879. displayInChat("Switched to previous map.","#DA0808","#1EBCC1");
  4880. return "";
  4881. }
  4882. else if (chat_val.substring(1,6)=="start" && chat_val.length == 6){
  4883. if(Gdocument.getElementById("mapeditorcontainer").style["display"]!="block"){
  4884. Gdocument.getElementById("newbonklobby_editorbutton").click();
  4885. }
  4886. if(recmodebool && ishost){
  4887. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  4888. if(mode == "" && defaultmode!="d"){
  4889. mode = defaultmode;
  4890. }
  4891. if(mode != ""){
  4892. RECIEVE('42[26,"b","'+mode+'"]');
  4893. }
  4894. }
  4895. Gdocument.getElementById("mapeditor_close").click();
  4896. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  4897. roundsperqp2 = 0;
  4898. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  4899. return "";
  4900. }
  4901. else if (chat_val.substring(1,8)=="startqp" && stopquickplay == 1){
  4902. stopquickplay = 0;
  4903. quicki = 0;
  4904. qppaused = false;
  4905. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  4906. return "";
  4907. }
  4908. else if (chat_val.substring(1,7)=="stopqp" && stopquickplay == 0){
  4909. stopquickplay = 1;
  4910. quicki = 0;
  4911. qppaused = false;
  4912. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  4913. return "";
  4914. }
  4915. else if (chat_val.substring(1,8)=="pauseqp" && stopquickplay == 0){
  4916. if(qppaused == false){
  4917. qppaused = true;
  4918. displayInChat("Paused quickplay.","#DA0808","#1EBCC1");
  4919. }
  4920. else{
  4921. qppaused = false;
  4922. displayInChat("Unpaused quickplay.","#DA0808","#1EBCC1");
  4923. }
  4924. return "";
  4925. }
  4926. else if (chat_val.substring(1,6)=="revqp" && stopquickplay == 0){
  4927. if(reverseqp == false){
  4928. reverseqp = true;
  4929. displayInChat("Reverseqp is now on..","#DA0808","#1EBCC1");
  4930. }
  4931. else{
  4932. reverseqp = false;
  4933. displayInChat("Reverseqp is now off.","#DA0808","#1EBCC1");
  4934. }
  4935. return "";
  4936. }
  4937. else if (chat_val.substring(1,9)=="jukebox " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  4938. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  4939. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":text,"timestamp":Date.now()+2000,"to":[-1]}]));
  4940. displayInChat("Jukebox is loading... Please wait a few seconds.","#DA0808","#1EBCC1");
  4941. changeJukeboxURL(text,Date.now()+2000);
  4942. return "";
  4943. }
  4944. else if (chat_val.substring(1,13)=="pausejukebox"){
  4945. if(jukeboxplayer.src!="" && !jukeboxplayer.paused){
  4946. displayInChat("Jukebox is now paused.","#DA0808","#1EBCC1");
  4947. jukeboxplayer.pause();
  4948. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":"","timestamp":Date.now(),"to":[-1]}]));
  4949. }
  4950. return "";
  4951. }
  4952. else if (chat_val.substring(1,13)=="resetjukebox"){
  4953. if(jukeboxplayer.src!=""){
  4954. jukeboxplayer.currentTime = 0;
  4955. displayInChat("Jukebox has reset.","#DA0808","#1EBCC1");
  4956. changeJukeboxURL(jukeboxplayerURL,Date.now()+2000);
  4957. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":jukeboxplayerURL,"timestamp":Date.now()+2000,"to":[-1]}]));
  4958. }
  4959. return "";
  4960. }
  4961. else if (chat_val.substring(1,12)=="playjukebox"){
  4962. if(jukeboxplayer.src!="" && jukeboxplayer.paused){
  4963. changeJukeboxURL(jukeboxplayerURL,Date.now()-jukeboxplayer.currentTime*1000);
  4964. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":jukeboxplayerURL,"timestamp":Date.now()-jukeboxplayer.currentTime*1000,"to":[-1]}]));
  4965. }
  4966. return "";
  4967. }
  4968. else if (chat_val.substring(1,5)=="ban " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  4969. banned.push(chat_val.substring(5).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',""));
  4970. displayInChat("Banned "+chat_val.substring(5).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"")+".","#DA0808","#1EBCC1");
  4971. return "/kick '" + chat_val.substring(5).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"") + "'";
  4972. }
  4973. else if (chat_val.substring(1,6)=="kill " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  4974. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  4975. var keys = Object.keys(playerids);
  4976. var killid = undefined;
  4977. for(var i = 0; i<keys.length; i++){
  4978. if(playerids[keys[i]].userName == text){
  4979. killid = keys[i];
  4980. }
  4981. }
  4982. if(typeof(killid)!="undefined" && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(killid)){
  4983. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  4984. killedids.push(killid);
  4985. SEND('42[25,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  4986. RECIEVE('42[31,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  4987. }
  4988. return "";
  4989. }
  4990. else if (chat_val.substring(1,6)=="killA"){
  4991. var keys = Object.keys(playerids);
  4992. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4993. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  4994. SEND('42[25,{"a":{"playersLeft":['+keys.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  4995. RECIEVE('42[31,{"a":{"playersLeft":['+keys.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  4996. }
  4997. return "";
  4998. }
  4999. else if (chat_val.substring(1,10)=="balanceA " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  5000. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  5001. if(!isNaN(parseInt(text))){
  5002. if(parseInt(text)>=-100 && parseInt(text)<=100){
  5003. var keys = Object.keys(playerids);
  5004. for(var i = 0; i<keys.length;i++){
  5005. SEND('42[29,{"sid":'+keys[i]+',"bal":'+text+'}]');
  5006. RECIEVE('42[36,'+keys[i]+','+text+']');
  5007. }
  5008. }
  5009. }
  5010. return "";
  5011. }
  5012. else if (chat_val.substring(1, 10) == "brighten " && chat_val.replace(/^\s+|\s+$/g, '').length >= 11) {
  5013. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  5014. if (!isNaN(parseFloat(text))) {
  5015. var intText = parseFloat(text);
  5016. var f = function(x){
  5017. return x * intText;
  5018. };
  5019. loadMap(changeColor(currentmap[currentmap.length-1], f,f,f));
  5020. }
  5021. return "";
  5022. }
  5023. else if (chat_val.substring(1, 12) == "colorshift " && chat_val.replace(/^\s+|\s+$/g, '').length >= 13) {
  5024. var text = chat_val.substring(12).replace(/^\s+|\s+$/g, '');
  5025. if (!isNaN(parseFloat(text))) {
  5026. var intText = parseFloat(text);
  5027. var seed = [Math.random()-0.5, Math.random()-0.5, Math.random()-0.5, Math.random()-0.5];
  5028. var f = function(x, ind){
  5029. return x * 1 + seed[ind] * intText;
  5030. };
  5031. loadMap(changeColor(currentmap[currentmap.length-1], f,f,f));
  5032. }
  5033. return "";
  5034. }
  5035. else if (chat_val.substring(1,10)=="balanceT " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  5036. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  5037. var text2 = text.split(" ").filter(function(e){if(e!=""){return true;}return false;});
  5038. if(text2.length!=2 || isNaN(parseInt(text2[1])) || !["s","r","b","y","g","f"].includes(text2[0])){
  5039. displayInChat("Please enter a team letter and a number to balance.","#DA0808","#1EBCC1");
  5040. return "";
  5041. }
  5042. var teamdict = {"s":0,"f":1,"r":2,"b":3,"g":4,"y":5};
  5043. if(parseInt(text2[1])>=-100 && parseInt(text2[1])<=100){
  5044. var keys = Object.keys(playerids);
  5045. for(var i = 0; i<keys.length;i++){
  5046. if(playerids[keys[i]].team == teamdict[text2[0]]){
  5047. SEND('42[29,{"sid":'+keys[i]+',"bal":'+text2[1]+'}]');
  5048. RECIEVE('42[36,'+keys[i]+','+text2[1]+']');
  5049. }
  5050. }
  5051. }
  5052. return "";
  5053. }
  5054. else if (chat_val.substring(1,10)=="resetpoll"){
  5055. poll = [];
  5056. displayInChat("The poll has been reset.","#DA0808","#1EBCC1");
  5057. return "";
  5058. }
  5059. else if (chat_val.substring(1,11)=="addoption " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5060. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  5061. if(text.length>50){
  5062. displayInChat("Your option is greater than 50 characters.","#DA0808","#1EBCC1");
  5063. return "";
  5064. }
  5065. if(poll.includes(text)){
  5066. displayInChat("This option already exists.","#DA0808","#1EBCC1");
  5067. }
  5068. else if(poll.length>=4){
  5069. displayInChat("Your poll already has the max 4 amounts of options.","#DA0808","#1EBCC1");
  5070. displayInChat("Type '/deloption [letter]' to remove a option.","#DA0808","#1EBCC1");
  5071. displayInChat("The poll is:","#DA0808","#1EBCC1");
  5072. for(var i = 0;i<poll.length;i++){
  5073. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  5074. }
  5075. }
  5076. else{
  5077. poll.push(text);
  5078. displayInChat("The poll is now:","#DA0808","#1EBCC1");
  5079. for(var i = 0;i<poll.length;i++){
  5080. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  5081. }
  5082. }
  5083. return "";
  5084. }
  5085. else if (chat_val.substring(1,11)=="deloption " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5086. var text = letters.indexOf(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  5087. if(text==-1 || text>=poll.length){
  5088. if(poll.length>0){
  5089. displayInChat("Available options are:","#DA0808","#1EBCC1");
  5090. for(var i = 0;i<poll.length;i++){
  5091. displayInChat(letters[i],"#DA0808","#1EBCC1");
  5092. }
  5093. }
  5094. else{
  5095. displayInChat("Your poll is empty.","#DA0808","#1EBCC1");
  5096. displayInChat("Type '/addoption [text]' to add an option.","#DA0808","#1EBCC1");
  5097. }
  5098. }
  5099. else{
  5100. poll.splice(text,1);
  5101. displayInChat("The poll is now:","#DA0808","#1EBCC1");
  5102. for(var i = 0;i<poll.length;i++){
  5103. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  5104. }
  5105. }
  5106. return "";
  5107. }
  5108. else if (chat_val.substring(1,11)=="startpoll " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5109. var text = parseFloat(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  5110. if(isNaN(text)){
  5111. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5112. return "";
  5113. }
  5114. else if(text<=0){
  5115. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5116. return "";
  5117. }
  5118. else if(text<10){
  5119. displayInChat("Your poll has to last for at least 10 seconds.","#DA0808","#1EBCC1");
  5120. return "";
  5121. }
  5122. if(pollactive[0]){
  5123. displayInChat("There is already an ongoing poll.","#DA0808","#1EBCC1");
  5124. displayInChat("Type '/endpoll' to end the poll.","#DA0808","#1EBCC1");
  5125. return "";
  5126. }
  5127. if(poll.length<2){
  5128. displayInChat("Your poll needs at least 2 options.","#DA0808","#1EBCC1");
  5129. displayInChat("Type '/addoption' to add to the poll.","#DA0808","#1EBCC1");
  5130. return "";
  5131. }
  5132. var now = Date.now();
  5133. pollactive = [true,now,now+text*1000,[...poll]];
  5134. playerids[myid].ratelimit.poll = now;
  5135. var chatpoll = [...poll];
  5136. chatpoll.push("Cancel vote.");
  5137. pollactive[3].push("Cancel vote.");
  5138. for(var i = 0;i<chatpoll.length;i++){
  5139. chatpoll[i] = letters[i]+") "+chatpoll[i];
  5140. }
  5141. chat(chatpoll.join("     "));
  5142. setTimeout(function(){
  5143. if(pollactive[0]){
  5144. SEND("42"+JSON.stringify([4,{"type":"poll","from":username,"poll":pollactive[3]}]));
  5145. var keys = Object.keys(playerids);
  5146. for(var i = 0;i<keys.length;i++){
  5147. playerids[keys[i]].vote.poll = -1;
  5148. }
  5149. displayInChat("The poll will end in: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  5150. displayInChat("Type '/endpoll' to end the poll early.","#DA0808","#1EBCC1");
  5151. }
  5152. },200);
  5153. return "";
  5154. }
  5155. else if (chat_val.substring(1,8)=="endpoll"){
  5156. if(pollactive[0]){
  5157. if(playerids[myid].ratelimit.poll+10000>Date.now()){
  5158. displayInChat("Your poll has to be at least 10 seconds.","#DA0808","#1EBCC1");
  5159. displayInChat("There are "+((playerids[myid].ratelimit.poll+10000-Date.now())/1000).toString()+" seconds left until you can end the poll early.","#DA0808","#1EBCC1");
  5160. return "";
  5161. }
  5162. playerids[myid].ratelimit.poll = Date.now();
  5163. SEND("42"+JSON.stringify([4,{"type":"poll end","from":username}]));
  5164. displayInChat("The poll ended.","#DA0808","#1EBCC1");
  5165. var count = [0,0,0,0];
  5166. var keys = Object.keys(playerids);
  5167. for(var i = 0;i<keys.length;i++){
  5168. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  5169. count[playerids[keys[i]].vote.poll]++;
  5170. }
  5171. playerids[keys[i]].vote.poll = -1;
  5172. }
  5173. for(var i = 0;i<count.length;i++){
  5174. if(count[i]>1){
  5175. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  5176. }
  5177. if(count[i]==1){
  5178. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  5179. }
  5180. }
  5181. displayInChat("The poll was:","#DA0808","#1EBCC1");
  5182. for(var i = 0;i<pollactive[3].length;i++){
  5183. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  5184. }
  5185. pollactive = [false,0,0,[]];
  5186. }
  5187. else{
  5188. displayInChat("No poll has been started","#DA0808","#1EBCC1");
  5189. displayInChat("Type '/startpoll [seconds]' to start a poll.","#DA0808","#1EBCC1");
  5190. }
  5191. return "";
  5192. }
  5193. else if (chat_val.substring(1,7)=="moveA " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  5194. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  5195. var keys = Object.keys(playerids);
  5196. var t = -1;
  5197. if(text == "f"){
  5198. t = 1;
  5199. }
  5200. else if(text == "b"){
  5201. t = 3;
  5202. }
  5203. else if(text == "g"){
  5204. t = 4;
  5205. }
  5206. else if(text == "r"){
  5207. t = 2;
  5208. }
  5209. else if(text == "y"){
  5210. t = 5;
  5211. }
  5212. else if(text == "s"){
  5213. t = 0;
  5214. }
  5215. if(t == -1){
  5216. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  5217. displayInChat("/moveA [letter]","#DA0808","#1EBCC1");
  5218. displayInChat("For example: '/moveA r' would move everyone to red team.","#DA0808","#1EBCC1");
  5219. return "";
  5220. }
  5221. for(var i = 0;i<keys.length;i++){
  5222. SEND('42[26,{"targetID":'+keys[i].toString()+',"targetTeam":'+t.toString()+'}]');
  5223. if(playerids[keys[i]].peerID!="sandbox"){
  5224. RECIEVE('42[18,'+keys[i].toString()+','+t.toString()+']');
  5225. }
  5226. }
  5227. return "";
  5228. }
  5229. else if (chat_val.substring(1,7)=="moveT " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  5230. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '').split(" ").filter(function(i){if(i==""){return false}else{return true}});
  5231. if(text.length == 2){
  5232. var firstteam = -1;
  5233. var secondteam = -1;
  5234. for(var i = 0;i<2;i++){
  5235. var t = -1;
  5236. if(text[i] == "f"){
  5237. t = 1;
  5238. }
  5239. else if(text[i] == "b"){
  5240. t = 3;
  5241. }
  5242. else if(text[i] == "g"){
  5243. t = 4;
  5244. }
  5245. else if(text[i] == "r"){
  5246. t = 2;
  5247. }
  5248. else if(text[i] == "y"){
  5249. t = 5;
  5250. }
  5251. else if(text[i] == "s"){
  5252. t = 0;
  5253. }
  5254. if(t==-1){
  5255. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  5256. displayInChat("/moveT [letter] [letter]","#DA0808","#1EBCC1");
  5257. displayInChat("For example: '/moveT s r' would move everyone in spectate to red team.","#DA0808","#1EBCC1");
  5258. return "";
  5259. }
  5260. else{
  5261. if(i == 0){
  5262. firstteam = t;
  5263. }
  5264. else{
  5265. secondteam = t;
  5266. }
  5267. }
  5268. }
  5269. var keys = Object.keys(playerids);
  5270. for(var i = 0;i<keys.length;i++){
  5271. if(playerids[keys[i]].team == firstteam){
  5272. SEND('42[26,{"targetID":'+keys[i].toString()+',"targetTeam":'+secondteam.toString()+'}]');
  5273. if(playerids[keys[i]].peerID!="sandbox"){
  5274. RECIEVE('42[18,'+keys[i].toString()+','+secondteam.toString()+']');
  5275. }
  5276. }
  5277. }
  5278. }
  5279. else{
  5280. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  5281. displayInChat("/moveT [team] [team]","#DA0808","#1EBCC1");
  5282. displayInChat("For example: '/moveT s r' would move everyone in spectate to red team.","#DA0808","#1EBCC1");
  5283. return "";
  5284. }
  5285. return "";
  5286. }
  5287. if (chat_val.substring(1,13)=="roundsperqp " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  5288. var text = parseInt(chat_val.substring(13).replace(/^\s+|\s+$/g, ''));
  5289. if(isNaN(text)){
  5290. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5291. return "";
  5292. }
  5293. else if(text<=0){
  5294. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5295. return "";
  5296. }
  5297. roundsperqp = text;
  5298. roundsperqp2 = 0;
  5299. displayInChat("Set rounds per quickplay to: " + text.toString(),"#DA0808","#1EBCC1");
  5300. displayInChat("Type '/roundsperqp' to reset rounds per quickplay.","#DA0808","#1EBCC1");
  5301. return "";
  5302. }
  5303. else if (chat_val.substring(1,12)=="roundsperqp"){
  5304. roundsperqp = 1;
  5305. roundsperqp2 = 0;
  5306. displayInChat("Reset rounds per quickplay.","#DA0808","#1EBCC1");
  5307. return "";
  5308. }
  5309. else if (chat_val.substring(1,8)=="rounds " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  5310. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  5311. if(!isNaN(parseInt(text))){
  5312. text = parseInt(text).toString();
  5313. SEND('42[21,{"w":'+text+'}]');
  5314. RECIEVE('42[27,'+text+']');
  5315. }
  5316. return "";
  5317. }
  5318. else if (chat_val.substring(1,13)=="disablekeys " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  5319. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  5320. var keys = text.split(" ");
  5321. var disabledkeys2 = [];
  5322. var possiblekeys = ["left","right","up","down","heavy","special"];
  5323. for(var i = 0; i<keys.length; i++){
  5324. if(keys[i]!="" && !disabledkeys2.includes(keys[i])){
  5325. if(possiblekeys.includes(keys[i])){
  5326. disabledkeys2.push(keys[i]);
  5327. }
  5328. else{
  5329. displayInChat("Key options: " + possiblekeys.join(" ") + ".","#DA0808","#1EBCC1");
  5330. return "";
  5331. }
  5332. }
  5333. }
  5334. disabledkeys = disabledkeys2;
  5335. displayInChat("Set disabled keys to: " + disabledkeys.join(" ") + ".","#DA0808","#1EBCC1");
  5336. displayInChat("Type '/disablekeys' to reset disabled keys.","#DA0808","#1EBCC1");
  5337. return "";
  5338. }
  5339. else if (chat_val.substring(1,12)=="disablekeys"){
  5340. displayInChat("Reset disabled keys.","#DA0808","#1EBCC1");
  5341. disabledkeys = [];
  5342. return "";
  5343. }
  5344. else if (chat_val.substring(1,10)=="jointext " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  5345. jointext = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  5346. displayInChat("Set jointext to: " + jointext,"#DA0808","#1EBCC1");
  5347. displayInChat("Type '/jointext' to reset jointext.","#DA0808","#1EBCC1");
  5348. return "";
  5349. }
  5350. else if (chat_val.substring(1,9)=="jointext"){
  5351. jointext = "";
  5352. displayInChat("Reset jointext.","#DA0808","#1EBCC1");
  5353. return "";
  5354. }
  5355. else if (chat_val.substring(1,10)=="jointeam " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  5356. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  5357. var keys = Object.keys(playerids);
  5358. var t = -1;
  5359. if(text == "f"){
  5360. t = 1;
  5361. displayInChat("Set jointeam to FFA.","#DA0808","#1EBCC1");
  5362. }
  5363. else if(text == "b"){
  5364. t = 3;
  5365. displayInChat("Set jointeam to blue team.","#DA0808","#1EBCC1");
  5366. }
  5367. else if(text == "g"){
  5368. t = 4;
  5369. displayInChat("Set jointeam to green team.","#DA0808","#1EBCC1");
  5370. }
  5371. else if(text == "r"){
  5372. t = 2;
  5373. displayInChat("Set jointeam to red team.","#DA0808","#1EBCC1");
  5374. }
  5375. else if(text == "y"){
  5376. t = 5;
  5377. displayInChat("Set jointeam to yellow team.","#DA0808","#1EBCC1");
  5378. }
  5379. else if(text == "s"){
  5380. t = 0;
  5381. displayInChat("Set jointeam to spectate.","#DA0808","#1EBCC1");
  5382. }
  5383. if(t == -1){
  5384. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  5385. displayInChat("/jointeam [letter]","#DA0808","#1EBCC1");
  5386. displayInChat("For example: '/jointeam r' would move every joined person to red team.","#DA0808","#1EBCC1");
  5387. return "";
  5388. }
  5389. displayInChat("Type '/jointeam' to reset jointeam.","#DA0808","#1EBCC1");
  5390. jointeam = t;
  5391. return "";
  5392. }
  5393. else if (chat_val.substring(1,9)=="jointeam"){
  5394. jointeam = -1;
  5395. displayInChat("Reset jointeam.","#DA0808","#1EBCC1");
  5396. return "";
  5397. }
  5398. else if (chat_val.substring(1,9)=="wintext " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  5399. wintext = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  5400. displayInChat("Set wintext to: " + wintext,"#DA0808","#1EBCC1");
  5401. displayInChat("Type '/wintext' to reset wintext.","#DA0808","#1EBCC1");
  5402. return "";
  5403. }
  5404. else if (chat_val.substring(1,8)=="wintext"){
  5405. wintext = "";
  5406. displayInChat("Reset wintext.","#DA0808","#1EBCC1");
  5407. return "";
  5408. }
  5409. else if (chat_val.substring(1,11)=="autorecord"){
  5410. if(autorecord){
  5411. autorecord = false;
  5412. displayInChat("Autorecord is now off.","#DA0808","#1EBCC1");
  5413. }
  5414. else{
  5415. autorecord = true;
  5416. displayInChat("Autorecord is now on.","#DA0808","#1EBCC1");
  5417. }
  5418. return "";
  5419. }
  5420. else if (chat_val.substring(1,9)=="afkkill " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  5421. var text = parseFloat(chat_val.substring(9).replace(/^\s+|\s+$/g, ''));
  5422. if(!isNaN(text)){
  5423. if(text>0){
  5424. displayInChat("Set afk kill to: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  5425. displayInChat("Type '/afkkill' to reset afk kill.","#DA0808","#1EBCC1");
  5426. var keys = Object.keys(playerids);
  5427. var now = Date.now();
  5428. for(var i = 0;i<keys.length;i++){
  5429. playerids[keys[i]].lastmove = now;
  5430. }
  5431. afkkill = text;
  5432. }
  5433. else{
  5434. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5435. }
  5436. }
  5437. else{
  5438. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5439. }
  5440. return "";
  5441. }
  5442. else if (chat_val.substring(1,9)=="afkkill"){
  5443. afkkill = -1;
  5444. displayInChat("Reset afk kill.","#DA0808","#1EBCC1");
  5445. return "";
  5446. }
  5447. else if (chat_val.substring(1,13)=="defaultmode " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  5448. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  5449. if(text == "default"){
  5450. defaultmode = "";
  5451. displayInChat("Changed default mode to default.","#DA0808","#1EBCC1");
  5452. }
  5453. else if(text == "arrows"){
  5454. defaultmode = "ar";
  5455. displayInChat("Changed default mode to arrows.","#DA0808","#1EBCC1");
  5456. }
  5457. else if(text == "death arrows"){
  5458. defaultmode = "ard";
  5459. displayInChat("Changed default mode to death arrows.","#DA0808","#1EBCC1");
  5460. }
  5461. else if(text == "grapple"){
  5462. defaultmode = "sp";
  5463. displayInChat("Changed default mode to grapple.","#DA0808","#1EBCC1");
  5464. }
  5465. else if(text == "classic"){
  5466. defaultmode = "b";
  5467. displayInChat("Changed default mode to classic.","#DA0808","#1EBCC1");
  5468. }
  5469. else{
  5470. displayInChat("Default mode options:","#DA0808","#1EBCC1");
  5471. displayInChat("default","#DA0808","#1EBCC1");
  5472. displayInChat("classic","#DA0808","#1EBCC1");
  5473. displayInChat("arrows","#DA0808","#1EBCC1");
  5474. displayInChat("death arrows","#DA0808","#1EBCC1");
  5475. displayInChat("grapple","#DA0808","#1EBCC1");
  5476. }
  5477. return "";
  5478. }
  5479. else if (chat_val.substring(1,8)=="recmode"){
  5480. if(recmodebool == true){
  5481. recmodebool = false;
  5482. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  5483. }
  5484. else{
  5485. recmodebool = true;
  5486. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  5487. }
  5488. return "";
  5489. }
  5490. else if (chat_val.substring(1,8)=="recteam"){
  5491. if(recteams == true){
  5492. recteams = false;
  5493. displayInChat("Recteam is now off.","#DA0808","#1EBCC1");
  5494. }
  5495. else{
  5496. recteams = true;
  5497. displayInChat("Recteam is now on.","#DA0808","#1EBCC1");
  5498. }
  5499. return "";
  5500. }
  5501. else if (chat_val.substring(1,8)=="shuffle"){
  5502. if(shuffle == true){
  5503. shuffle = false;
  5504. displayInChat("Shuffle is now off.","#DA0808","#1EBCC1");
  5505. }
  5506. else{
  5507. shuffle = true;
  5508. displayInChat("Shuffle is now on.","#DA0808","#1EBCC1");
  5509. }
  5510. return "";
  5511. }
  5512. else if (chat_val.substring(1,9)=="autokick"){
  5513. if(autokickban == 0){
  5514. displayInChat("Autokick is now on.","#DA0808","#1EBCC1");
  5515. autokickban = 1;
  5516. }
  5517. else if(autokickban == 1){
  5518. autokickban = 0;
  5519. displayInChat("Autokick is now off.","#DA0808","#1EBCC1");
  5520. }
  5521. else{
  5522. autokickban = 1;
  5523. displayInChat("Autokick is now on, and Autoban is now off.","#DA0808","#1EBCC1");
  5524. }
  5525. return "";
  5526. }
  5527. else if (chat_val.substring(1,8)=="autoban"){
  5528. if(autokickban == 0){
  5529. displayInChat("Autoban is now on.","#DA0808","#1EBCC1");
  5530. autokickban = 2;
  5531. }
  5532. else if(autokickban == 2){
  5533. autokickban = 0;
  5534. displayInChat("Autoban is now off.","#DA0808","#1EBCC1");
  5535. }
  5536. else{
  5537. autokickban = 2;
  5538. displayInChat("Autoban is now on, and Autokick is now off.","#DA0808","#1EBCC1");
  5539. }
  5540. return "";
  5541. }
  5542. else if (chat_val.substring(1,8)=="sandbox"){
  5543. if(sandboxon == false){
  5544. displayInChat("This room is now a sandbox room.","#DA0808","#1EBCC1");
  5545. sandboxon = true;
  5546. SEND('42[4,{"type":"sandboxon"}]');
  5547. var sandboxkeys = Object.keys(sandboxplayerids);
  5548. var packets = [];
  5549. for(var i = 0;i<sandboxkeys.length;i++){
  5550. var p = playerids[sandboxkeys[i]];
  5551. var packet = '42'+JSON.stringify([4,sandboxkeys[i],p.peerID,p.userName,p.guest,p.level,p.team,p.avatar]);
  5552. packets.push(packet);
  5553. }
  5554. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":packets,to:[-1]}]));
  5555. SEND("42"+JSON.stringify([4,{"type":"sandboxid","from":username,"lastid":sandboxid,to:[-1]}]));
  5556. }
  5557. else{
  5558. displayInChat("You cannot turn a sandbox room back into a normal room.","#DA0808","#1EBCC1");
  5559. }
  5560. return "";
  5561. }
  5562. else if(sandboxon){
  5563. if (chat_val.substring(1,11)=="addplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5564. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  5565. if(!isNaN(parseInt(text))){
  5566. var text2 = parseInt(text);
  5567. if(text2>0){
  5568. for(var i = 0;i<text2;i++){
  5569. while(playerids[sandboxid]){
  5570. sandboxid+=1;
  5571. }
  5572. var color = Math.floor(Math.random() * 16777215).toString();
  5573. var packet = '42'+JSON.stringify([4,sandboxid,"sandbox",sandboxid.toString(),true,0,0,{"layers":[],"bc":color}]);
  5574. RECIEVE(packet);
  5575. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  5576. sandboxplayerids[sandboxid] = sandboxid.toString();
  5577. sandboxid+=1;
  5578. }
  5579. }
  5580. }
  5581. return "";
  5582. }
  5583. if (chat_val.substring(1,9)=="addname " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  5584. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  5585. while(playerids[sandboxid]){
  5586. sandboxid+=1;
  5587. }
  5588. var keys = Object.keys(playerids);
  5589. var addon = "";
  5590. var escape = false;
  5591. var keysi = -1;
  5592. while(!escape){
  5593. escape = true;
  5594. for(var i = 0;i<keys.length;i++){
  5595. if(playerids[keys[i]].userName == text+addon){
  5596. addon+="‎";
  5597. var escape = false;
  5598. }
  5599. if(playerids[keys[i]].userName == text){
  5600. keysi = keys[i];
  5601. }
  5602. }
  5603. }
  5604. if(keysi!=-1){
  5605. var packet = '42'+JSON.stringify([4,sandboxid,"sandbox",text+addon,playerids[keysi].guest,playerids[keysi].level,0,playerids[keysi].avatar]);
  5606. RECIEVE(packet);
  5607. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  5608. }
  5609. else{
  5610. var color = Math.floor(Math.random() * 16777215).toString();
  5611. var packet = '42'+JSON.stringify([4,sandboxid,"sandbox",text+addon,true,0,0,{"layers":[],"bc":color}]);
  5612. RECIEVE(packet);
  5613. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  5614. }
  5615. sandboxplayerids[sandboxid] = sandboxid.toString();
  5616. sandboxid+=1;
  5617. return "";
  5618. }
  5619. else if (chat_val.substring(1,11)=="delplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5620. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  5621. if(!isNaN(parseInt(text))){
  5622. var text2 = parseInt(text);
  5623. if(text2>0){
  5624. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
  5625. var jsonkeys = Object.keys(sandboxplayerids).reverse();
  5626. var packets = [];
  5627. for(var i = 0;i<text2 && i<jsonkeys.length;i++){
  5628. var packet = '42[5,'+jsonkeys[i]+',0]';
  5629. RECIEVE(packet);
  5630. packets.push(packet);
  5631. delete sandboxplayerids[jsonkeys[i]];
  5632. }
  5633. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":packets,to:[-1]}]));
  5634. }
  5635. else{
  5636. displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
  5637. }
  5638. }
  5639. }
  5640. return "";
  5641. }
  5642. else if (chat_val.substring(1,6)=="copy " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  5643. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  5644. var keys = Object.keys(playerids);
  5645. var keys2 = Object.keys(sandboxplayerids);
  5646. var copiedperson = -1;
  5647. for(var i = 0;i<keys.length;i++){
  5648. if(playerids[keys[i]].userName==text){
  5649. copiedperson = keys[i];
  5650. }
  5651. }
  5652. if(copiedperson==-1){
  5653. displayInChat(playerids[copiedperson].userName + " was not found in this room.","#DA0808","#1EBCC1");
  5654. return "";
  5655. }
  5656. if(keys2.includes(copiedperson.toString())){
  5657. displayInChat("Bots cannot copy a bot.","#DA0808","#1EBCC1");
  5658. return "";
  5659. }
  5660. displayInChat("All bots will now copy "+playerids[copiedperson].userName+".","#DA0808","#1EBCC1");
  5661. displayInChat("To reset copy, type '/copy'.","#DA0808","#1EBCC1");
  5662. sandboxcopyme = copiedperson;
  5663. return "";
  5664. }
  5665. else if (chat_val.substring(1,5)=="copy"){
  5666. sandboxcopyme = -1;
  5667. displayInChat("Copy is now off.","#DA0808","#1EBCC1");
  5668. return "";
  5669. }
  5670. }
  5671. }
  5672. return chat_val;
  5673. };
  5674. scope.flag_manage = function(t){
  5675. var text = t;
  5676. if(autocorrect == true){
  5677. var text2 = text.split(" ");
  5678. for(var i = 0;i<text2.length;i++){
  5679. text2[i] = closestWord(text2[i]);
  5680. }
  5681. text = text2.join(" ");
  5682. }
  5683. if(reverse_flag == true){
  5684. text = text.split("").reverse().join("")
  5685. }
  5686. if(rcaps_flag == true){
  5687. text = text.split('');
  5688. for(var i = 0; i<text.length;i++){
  5689. if(Math.floor(Math.random()*2)){
  5690. text[i] = text[i].toUpperCase();
  5691. }
  5692. else{
  5693. text[i] = text[i].toLowerCase();
  5694. }
  5695. }
  5696. text = text.join('');
  5697. }
  5698. if(space_flag == true){
  5699. text = text.split('').join(' ')
  5700. }
  5701. if(textmode!=-1){
  5702. newtext = "";
  5703. for(var i = 0;i<text.length;i++){
  5704. if(letter_dictionary[text[i]]){
  5705. newtext+=letter_dictionary[text[i]][textmode];
  5706. }
  5707. else{
  5708. newtext+=text[i];
  5709. }
  5710. }
  5711. text = newtext;
  5712. }
  5713. if(number_flag == true){
  5714. text = text.replace(/[t|T][Oo]+/g,"2");
  5715. text = text.replace(/[f|F][o|O][r|R]/g,"4");
  5716. text = text.replace(/[a|A][t|T][e|E]/g,"8");
  5717. text = text.replace(/[e|E]/g,"3");
  5718. text = text.replace(/[a|A]/g,"4");
  5719. text = text.replace(/[o|O]/g,"0");
  5720. text = text.replace(/[s|S]/g,"5");
  5721. text = text.replace(/[i|I|l|L]/g,"1");
  5722. }
  5723. return text;
  5724. };
  5725. Gdocument.getElementById("newbonklobby_chat_input").onkeydown = function(e){
  5726. if(e.keyCode==13){
  5727. var chat_val = Gdocument.getElementById("newbonklobby_chat_input").value;
  5728. if (chat_val!="" && chat_val[0]=="/"){
  5729. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  5730. chat2(commandhandle(chat_val));
  5731. }
  5732. else{
  5733. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  5734. chat2(flag_manage(chat_val));
  5735. }
  5736. }
  5737. };
  5738. Gdocument.getElementById("ingamechatinputtext").onkeydown = function(e){
  5739. if(e.keyCode==13){
  5740. var chat_val = Gdocument.getElementById("ingamechatinputtext").value;
  5741. if (chat_val!="" && chat_val[0]=="/"){
  5742. Gdocument.getElementById("ingamechatinputtext").value = "";
  5743. chat2(commandhandle(chat_val));
  5744. }
  5745. else{
  5746. Gdocument.getElementById("ingamechatinputtext").value = "";
  5747. chat2(flag_manage(chat_val));
  5748. }
  5749. }
  5750. };
  5751. scope.Last_message = "";
  5752. scope.Laster_message = "";
  5753. scope.new_message = false;
  5754. scope.changed_chat = false;
  5755. scope.injectedBonkCommandsScript = setInterval(timeout123,60);
  5756.  
  5757. scope.pan_enabled = false;
  5758. scope.pan = {"x":0,"y":0};
  5759. scope.pan_speed = 5;
  5760. scope.keys_being_held = {};
  5761. scope.hotkeys_keyup = function(e){
  5762. if(keys_being_held[e.code]){
  5763. keys_being_held[e.code] = false;
  5764. }
  5765. };
  5766. Gdocument.onkeyup = hotkeys_keyup;
  5767. scope.hotkeys = function(e){
  5768. var keycode = e.code;
  5769. if(!keys_being_held[keycode]){
  5770. keys_being_held[keycode] = true;
  5771. }
  5772. if(!e.altKey && e.shiftKey && !e.ctrlKey && !e.metaKey){
  5773. if(pan_enabled && Gdocument.getElementById("gamerenderer")?.childElementCount>0){
  5774. if(keycode == "ArrowUp"){
  5775. e.stopPropagation();
  5776. e.preventDefault();
  5777. }
  5778. else if(keycode == "ArrowDown"){
  5779. e.stopPropagation();
  5780. e.preventDefault();
  5781. }
  5782. else if(keycode == "ArrowLeft"){
  5783. e.stopPropagation();
  5784. e.preventDefault();
  5785. }
  5786. else if(keycode == "ArrowRight"){
  5787. e.stopPropagation();
  5788. e.preventDefault();
  5789. }
  5790. }
  5791. }
  5792.  
  5793. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  5794. if(keycode == "Period"){
  5795. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  5796. chatheight+=5;
  5797. if(chatheight>600){chatheight = 600;}
  5798. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  5799. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  5800. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  5801. }
  5802. e.preventDefault();
  5803. }
  5804. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  5805. if(keycode == "KeyG"){
  5806. var addto = 0;
  5807. for(var i = 0;i<parentDraw.children.length;i++){
  5808. if(parentDraw.children[i].constructor.name == "e"){
  5809. addto = parentDraw.children[i];
  5810. break;
  5811. }
  5812. }
  5813. var canv = 0;
  5814. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  5815. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  5816. canv = Gdocument.getElementById("gamerenderer").children[i];
  5817. break;
  5818. }
  5819. }
  5820. var width = parseInt(canv.style["width"]);
  5821. var height = parseInt(canv.style["height"]);
  5822. if(addto){
  5823. zoom *= 1.1;
  5824. }
  5825. addto.scale.x = zoom;
  5826. addto.scale.y = zoom;
  5827. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  5828. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  5829. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  5830. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  5831. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  5832. pixiCircle.visible = false;
  5833. }
  5834. else{
  5835. pixiCircle.visible = true;
  5836. }
  5837. e.preventDefault();
  5838. }
  5839. if(keycode == "KeyH"){
  5840. var addto = 0;
  5841. for(var i = 0;i<parentDraw.children.length;i++){
  5842. if(parentDraw.children[i].constructor.name == "e"){
  5843. addto = parentDraw.children[i];
  5844. break;
  5845. }
  5846. }
  5847. var canv = 0;
  5848. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  5849. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  5850. canv = Gdocument.getElementById("gamerenderer").children[i];
  5851. break;
  5852. }
  5853. }
  5854. var width = parseInt(canv.style["width"]);
  5855. var height = parseInt(canv.style["height"]);
  5856. if(addto){
  5857. zoom = 1;
  5858. }
  5859. addto.scale.x = zoom;
  5860. addto.scale.y = zoom;
  5861. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  5862. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  5863. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  5864. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  5865. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  5866. pixiCircle.visible = false;
  5867. }
  5868. else{
  5869. pixiCircle.visible = true;
  5870. }
  5871. e.preventDefault();
  5872. }
  5873. if(keycode == "KeyJ"){
  5874. var addto = 0;
  5875. for(var i = 0;i<parentDraw.children.length;i++){
  5876. if(parentDraw.children[i].constructor.name == "e"){
  5877. addto = parentDraw.children[i];
  5878. break;
  5879. }
  5880. }
  5881. var canv = 0;
  5882. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  5883. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  5884. canv = Gdocument.getElementById("gamerenderer").children[i];
  5885. break;
  5886. }
  5887. }
  5888. var width = parseInt(canv.style["width"]);
  5889. var height = parseInt(canv.style["height"]);
  5890. if(addto){
  5891. zoom /= 1.1;
  5892. }
  5893. addto.scale.x = zoom;
  5894. addto.scale.y = zoom;
  5895. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  5896. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  5897. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  5898. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  5899. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  5900. pixiCircle.visible = false;
  5901. }
  5902. else{
  5903. pixiCircle.visible = true;
  5904. }
  5905. e.preventDefault();
  5906. }
  5907. }
  5908. if(keycode == "Comma"){
  5909. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  5910. chatheight-=5;
  5911. if(chatheight<100){chatheight = 100;}
  5912. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  5913. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  5914. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  5915. }
  5916. e.preventDefault();
  5917. }
  5918. }
  5919. if(e.repeat){return;}
  5920. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  5921. if(ishost){
  5922. if(keycode == "KeyE"){
  5923. if(Gdocument.getElementById("newbonklobby").style["display"] == "block"){
  5924. Gdocument.getElementById("newbonklobby_editorbutton").click();
  5925. }
  5926. else if(Gdocument.getElementById("mapeditorcontainer").style["display"] == "block"){
  5927. Gdocument.getElementById("mapeditor_close").click();
  5928. }
  5929. e.preventDefault();
  5930. }
  5931. else if(keycode == "KeyT"){
  5932. Gdocument.getElementById("newbonklobby_teamsbutton").click();
  5933. e.preventDefault();
  5934. }
  5935. else if(keycode == "KeyM"){
  5936. Gdocument.getElementById("newbonklobby_modebutton").click();
  5937. e.preventDefault();
  5938. }
  5939. else if(keycode == "KeyK"){
  5940. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  5941. Gdocument.getElementById("pretty_top_exit").click();
  5942. }
  5943. e.preventDefault();
  5944. }
  5945. else if(keycode == "KeyS"){
  5946. if(Gdocument.getElementById("mapeditorcontainer").style["display"]!="block"){
  5947. Gdocument.getElementById("newbonklobby_editorbutton").click();
  5948. }
  5949. if(recmodebool && ishost){
  5950. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  5951. if(mode == "" && defaultmode!="d"){
  5952. mode = defaultmode;
  5953. }
  5954. if(mode != ""){
  5955. RECIEVE('42[26,"b","'+mode+'"]');
  5956. }
  5957. }
  5958. Gdocument.getElementById("mapeditor_close").click();
  5959. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  5960. roundsperqp2 = 0;
  5961. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  5962. e.preventDefault();
  5963. }
  5964. else if(keycode == "KeyD"){
  5965. roundsperqp2 = 0;
  5966. if(stopquickplay == 0){
  5967. if(shuffle){
  5968. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5969. var available = [];
  5970. var availableindexes = [];
  5971. var notempty = false;
  5972. for(var i = 0; i<e2.length;i++){
  5973. var a = false;
  5974. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5975. available.push(a);
  5976. if(a){
  5977. availableindexes.push(i);
  5978. notempty = true;
  5979. }
  5980. }
  5981. if(notempty){
  5982. if(availableindexes.length!=1){
  5983. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  5984. }
  5985. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  5986. }
  5987. }
  5988. else{
  5989. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5990. var available = [];
  5991. var availableindexes = [];
  5992. var notempty = false;
  5993. for(var i = 0; i<e2.length;i++){
  5994. var a = false;
  5995. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5996. available.push(a);
  5997. if(a){
  5998. availableindexes.push(i);
  5999. notempty = true;
  6000. }
  6001. }
  6002. if(notempty){
  6003. var above = [];
  6004. for(var i = 0;i<availableindexes.length;i++){
  6005. if(availableindexes[i]>quicki && !reverseqp){
  6006. above.push(availableindexes[i]);
  6007. }
  6008. else if(availableindexes[i]<quicki && reverseqp){
  6009. above.push(availableindexes[i])
  6010. }
  6011. }
  6012. if(above.length>0){
  6013. quicki = above[0];
  6014. if(reverseqp){
  6015. quicki = above[above.length-1];
  6016. }
  6017. }
  6018. else{
  6019. quicki = availableindexes[0];
  6020. if(reverseqp){
  6021. quicki = availableindexes[availableindexes.length-1];
  6022. }
  6023. }
  6024. }
  6025. }
  6026. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  6027. }
  6028. e.preventDefault();
  6029. }
  6030. else if(keycode == "KeyA"){
  6031. if(stopquickplay == 0){
  6032. roundsperqp2 = 0;
  6033. if(shuffle){
  6034. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6035. var available = [];
  6036. var availableindexes = [];
  6037. var notempty = false;
  6038. for(var i = 0; i<e2.length;i++){
  6039. var a = false;
  6040. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6041. available.push(a);
  6042. if(a){
  6043. availableindexes.push(i);
  6044. notempty = true;
  6045. }
  6046. }
  6047. if(notempty){
  6048. if(availableindexes.length!=1){
  6049. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  6050. }
  6051. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  6052. }
  6053. }
  6054. else{
  6055. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6056. var available = [];
  6057. var availableindexes = [];
  6058. var notempty = false;
  6059. for(var i = 0; i<e2.length;i++){
  6060. var a = false;
  6061. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6062. available.push(a);
  6063. if(a){
  6064. availableindexes.push(i);
  6065. notempty = true;
  6066. }
  6067. }
  6068. if(notempty){
  6069. var above = [];
  6070. for(var i = 0;i<availableindexes.length;i++){
  6071. if(availableindexes[i]<quicki && !reverseqp){
  6072. above.push(availableindexes[i]);
  6073. }
  6074. else if(availableindexes[i]>quicki && reverseqp){
  6075. above.push(availableindexes[i])
  6076. }
  6077. }
  6078. if(above.length>0){
  6079. quicki = above[above.length-1];
  6080. if(reverseqp){
  6081. quicki = above[0];
  6082. }
  6083. }
  6084. else{
  6085. quicki = availableindexes[availableindexes.length-1];
  6086. if(reverseqp){
  6087. quicki = availableindexes[0];
  6088. }
  6089. }
  6090. }
  6091. }
  6092. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  6093. }
  6094. e.preventDefault();
  6095. }
  6096. else if(keycode == "KeyQ"){
  6097. if(stopquickplay == 1){
  6098. stopquickplay = 0;
  6099. quicki = 0;
  6100. qppaused = false;
  6101. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  6102. }
  6103. else{
  6104. stopquickplay = 1;
  6105. quicki = 0;
  6106. qppaused = false;
  6107. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  6108. }
  6109. e.preventDefault();
  6110. }
  6111. else if(keycode == "KeyP" && stopquickplay==0){
  6112. if(qppaused == true){
  6113. qppaused = false;
  6114. displayInChat("Unpaused quickplay.","#DA0808","#1EBCC1");
  6115. }
  6116. else{
  6117. qppaused = true;
  6118. displayInChat("Paused quickplay.","#DA0808","#1EBCC1");
  6119. }
  6120. e.preventDefault();
  6121. }
  6122. else if(keycode == "KeyR"){
  6123. if(recmodebool == true){
  6124. recmodebool = false;
  6125. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  6126. }
  6127. else{
  6128. recmodebool = true;
  6129. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  6130. }
  6131. }
  6132. else if(keycode == "KeyF"){
  6133. if(freejoin == false){
  6134. freejoin = true;
  6135. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  6136. }
  6137. else{
  6138. freejoin = false;
  6139. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  6140. }
  6141. e.preventDefault();
  6142. }
  6143. }
  6144. else{
  6145. if(keycode == "KeyE"){
  6146. e.preventDefault();
  6147. }
  6148. else if(keycode == "KeyT"){
  6149. e.preventDefault();
  6150. }
  6151. else if(keycode == "KeyM"){
  6152. e.preventDefault();
  6153. }
  6154. else if(keycode == "KeyK"){
  6155. e.preventDefault();
  6156. }
  6157. else if(keycode == "KeyS"){
  6158. e.preventDefault();
  6159. }
  6160. else if(keycode == "KeyD"){
  6161. e.preventDefault();
  6162. }
  6163. else if(keycode == "KeyA"){
  6164. e.preventDefault();
  6165. }
  6166. else if(keycode == "KeyQ"){
  6167. e.preventDefault();
  6168. }
  6169. else if(keycode == "KeyP"){
  6170. e.preventDefault();
  6171. }
  6172. else if(keycode == "KeyF"){
  6173. e.preventDefault();
  6174. }
  6175. else if(keycode == "KeyR"){
  6176. e.preventDefault();
  6177. }
  6178. }
  6179. if(keycode == "KeyL"){
  6180. lobby();
  6181. e.preventDefault();
  6182. }
  6183. if(keycode == "KeyC"){
  6184. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  6185. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]=="0px"){
  6186. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  6187. }
  6188. else{
  6189. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  6190. }
  6191. }
  6192. e.preventDefault();
  6193. }
  6194. if(keycode == "KeyI"){
  6195. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  6196. debuggeropen = true;
  6197. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  6198. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  6199. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  6200. }
  6201. else{
  6202. debuggeropen = false;
  6203. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  6204. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  6205. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  6206. }
  6207. e.preventDefault();
  6208. }
  6209. if(keycode == "KeyB"){
  6210. var element = Gdocument.getElementById("ingamewinner_scores");
  6211. if(element.style["opacity"]<1){
  6212. element.style["opacity"] = 1;
  6213. element.style["visibility"] = "visible";
  6214. }
  6215. else{
  6216. element.style["opacity"] = 0;
  6217. element.style["visibility"] = "unset";
  6218. }
  6219. e.preventDefault();
  6220. }
  6221. if(keycode == "KeyY"){
  6222. Gdocument.getElementById("pretty_top_settings").click();
  6223. Gdocument.getElementById("settings_close").click();
  6224. if(Gdocument.getElementById("settings_graphicsquality").value==1){
  6225. displayInChat("You must have medium or high quality enabled to use this feature.","#DA0808","#1EBCC1");
  6226. return "";
  6227. }
  6228. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  6229. var addto = {"children":[]};
  6230. for(var i = 0;i<parentDraw.children.length;i++){
  6231. if(parentDraw.children[i].constructor.name == "e"){
  6232. addto = parentDraw.children[i];
  6233. break;
  6234. }
  6235. }
  6236. var addto2 = {"children":[]};
  6237. for(var i = 0;i<addto.children.length;i++){
  6238. if(addto.children[i].constructor.name == "e"){
  6239. addto2 = addto.children[i];
  6240. break;
  6241. }
  6242. }
  6243. var checkxray = addto2.children[0];
  6244. var addto3 = addto2.children[0].children;
  6245. if(addto3.length==1){
  6246. checkxray = checkxray.children[0];
  6247. addto3 = addto3[0].children;
  6248. }
  6249. var xrayon = false;
  6250. if(checkxray.xrayon){
  6251. checkxray.xrayon = false;
  6252. xrayon = false;
  6253. }
  6254. else{
  6255. checkxray.xrayon = true;
  6256. xrayon = true;
  6257. }
  6258. if(xrayon){
  6259. displayInChat("Xray is now on.","#DA0808","#1EBCC1");
  6260. for(var i = 0;i<addto3.length;i++){
  6261. if(addto3[i].children.length>0){
  6262. var ids = [];
  6263. var ids2 = [];
  6264. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  6265. addto3[i].children[i3].visible = false;
  6266. if(addto3[i].children[i3].children.length>0){
  6267. for(var i4 = 0;i4<addto3[i].children[i3].children.length;i4++){
  6268. if(addto3[i].children[i3].children[i4].geometry?.id){
  6269. ids.push(addto3[i].children[i3].children[i4].geometry.id);
  6270. }
  6271. else if(addto3[i].children[i3].children[i4].texture?.baseTexture?.uid){
  6272. ids2.push(addto3[i].children[i3].children[i4].texture.baseTexture.uid);
  6273. }
  6274. }
  6275. }
  6276. }
  6277. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  6278. if(addto3[i].children[i3].children.length==0){
  6279. if(addto3[i].children[i3].geometry?.id){
  6280. if(ids.includes(addto3[i].children[i3].geometry.id+1)){
  6281. addto3[i].children[i3].visible = true;
  6282. addto3[i].children[i3].alpha = 0.5;
  6283. }
  6284. }
  6285. else if(addto3[i].children[i3].texture?.baseTexture?.uid){
  6286. if(ids2.includes(addto3[i].children[i3].texture.baseTexture.uid+1)){
  6287. addto3[i].children[i3].visible = true;
  6288. addto3[i].children[i3].alpha = 0.5;
  6289. }
  6290. }
  6291. }
  6292. }
  6293. }
  6294. }
  6295. }
  6296. else{
  6297. displayInChat("Xray is now off.","#DA0808","#1EBCC1");
  6298. for(var i = 0;i<addto3.length;i++){
  6299. for(var i2 = 0;i2<addto3[i].children.length;i2++){
  6300. addto3[i].children[i2].visible = true;
  6301. addto3[i].children[i2].alpha = 1;
  6302. }
  6303. }
  6304. }
  6305. }
  6306. e.preventDefault();
  6307. }
  6308. if(keycode == "KeyN"){
  6309. if(FollowCam == true){
  6310. displayInChat("Follow Camera is now off.","#DA0808","#1EBCC1");
  6311. FollowCam = false;
  6312. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  6313. var addto = {"children":[]};
  6314. for(var i = 0;i<parentDraw.children.length;i++){
  6315. if(parentDraw.children[i].constructor.name == "e"){
  6316. addto = parentDraw.children[i];
  6317. break;
  6318. }
  6319. }
  6320. var canv = 0;
  6321. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  6322. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  6323. canv = Gdocument.getElementById("gamerenderer").children[i];
  6324. break;
  6325. }
  6326. }
  6327. var width = parseInt(canv.style["width"]);
  6328. var height = parseInt(canv.style["height"]);
  6329. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  6330. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  6331. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  6332. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  6333. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  6334. pixiCircle.visible = false;
  6335. }
  6336. else{
  6337. pixiCircle.visible = true;
  6338. }
  6339. }
  6340. }
  6341. else{
  6342. displayInChat("Follow Camera is now on.","#DA0808","#1EBCC1");
  6343. FollowCam = true;
  6344. }
  6345. e.preventDefault();
  6346. }
  6347. if(keycode == "KeyV"){
  6348. if(autocam == true){
  6349. displayInChat("Auto Cam is now off.","#DA0808","#1EBCC1");
  6350. autocam = false
  6351. }
  6352. else{
  6353. displayInChat("Auto Cam is now on.","#DA0808","#1EBCC1");
  6354. autocam = true;
  6355. }
  6356. e.preventDefault();
  6357. }
  6358. if (keycode == "BracketLeft"){
  6359. if(pan_enabled == true){
  6360. displayInChat("Pan is now off.","#DA0808","#1EBCC1");
  6361. pan = {"x":0,"y":0};
  6362. pan_enabled = false;
  6363. }
  6364. else{
  6365. displayInChat("Pan is now on. Shift + Arrow Keys to pan.","#DA0808","#1EBCC1");
  6366. pan_enabled = true;
  6367. }
  6368. return "";
  6369. }
  6370. if (keycode == "BracketRight"){
  6371. pan = {"x":0,"y":0};
  6372. displayInChat("Reset pan.","#DA0808","#1EBCC1");
  6373. return "";
  6374. }
  6375. if(keycode == "KeyO"){
  6376. if(heavybot == true){
  6377. displayInChat("Heavy bot is now off.","#DA0808","#1EBCC1");
  6378. heavybot = false;
  6379. }
  6380. else{
  6381. displayInChat("Heavy bot is now on.","#DA0808","#1EBCC1");
  6382. heavybot = true;
  6383. getplayerkeys();
  6384. }
  6385. e.preventDefault();
  6386. }
  6387. if(keycode == "KeyU"){
  6388. if(aimbot == true){
  6389. displayInChat("Aimbot is now off.","#DA0808","#1EBCC1");
  6390. aimbot = false;
  6391. }
  6392. else{
  6393. displayInChat("Aimbot is now on.","#DA0808","#1EBCC1");
  6394. aimbot = true;
  6395. getplayerkeys();
  6396. }
  6397. e.preventDefault();
  6398. }
  6399. if(keycode == "KeyW"){
  6400. if(staystill == true){
  6401. displayInChat("Still is now off.","#DA0808","#1EBCC1");
  6402. staystill = false;
  6403. staystillpos = [0,0];
  6404. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  6405. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  6406. }
  6407. else{
  6408. if(playerids[myid].playerData?.transform){
  6409. displayInChat("Still is now on.","#DA0808","#1EBCC1");
  6410. staystill = true;
  6411. staystillpos = [playerids[myid].playerData.transform.position.x/scale,playerids[myid].playerData.transform.position.y/scale];
  6412. getplayerkeys();
  6413. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  6414. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  6415. }
  6416. else{
  6417. displayInChat("You have to be alive to use this command.","#DA0808","#1EBCC1");
  6418. }
  6419. }
  6420. e.preventDefault();
  6421. }
  6422. }
  6423. if(!e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  6424. if(keycode == "Slash" && !(Gdocument.getElementById("gmeditor")?.style["transform"] == "scale(1)")){
  6425. 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"]==""){
  6426. Gdocument.getElementById("newbonklobby_chat_input").value = "/";
  6427. if(Gdocument.getElementById("newbonklobby_chat_input").style["pointer-events"] == "none"){
  6428. fire("keydown",{keyCode:13});
  6429. }
  6430. else{
  6431. Gdocument.getElementById("newbonklobby_chat_input").focus();
  6432. }
  6433. e.preventDefault();
  6434. }
  6435. else if(Gdocument.getElementById("ingamechatinputtext").style["visibility"]=="visible" && Gdocument.getElementById("ingamechatinputtext").style["display"]=="" && Gdocument.getElementById("mapeditorcontainer").style["display"]!="block" && Gdocument.getElementById("ingamechatinputtext").value == ""){
  6436. Gdocument.getElementById("ingamechatinputtext").value = "/";
  6437. if(!Gdocument.getElementById("ingamechatinputtext").classList.value.includes("ingamechatinputtextbg")){
  6438. fire("keydown",{keyCode:13});
  6439. }
  6440. else{
  6441. Gdocument.getElementById("ingamechatinputtext").focus();
  6442. }
  6443. e.preventDefault();
  6444. }
  6445. }
  6446. }
  6447. };
  6448. Gdocument.onkeydown = hotkeys;
  6449. Gwindow.addEventListener('resize',function(e){
  6450. debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
  6451. debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
  6452. scope.width = parseInt(Gdocument.getElementById("bonkiocontainer").style["width"])-20;
  6453. scope.height = parseInt(Gdocument.getElementById("bonkiocontainer").style["height"])-210;
  6454. logmenu.style["width"] = width.toString()+"px";
  6455. logmenu.style["height"] = height.toString()+"px";
  6456. logmenutopleft.style["width"] = (width/2).toString()+"px";
  6457. logmenutopright.style["width"] = (width/2).toString()+"px";
  6458. logmenutopright.style["left"] = (width/2).toString()+"px";
  6459. debuggerinput.style["width"] = width.toString()+"px";
  6460. debuggerinput.style["top"] = (height+90).toString()+"px";
  6461. debuggersendrecieve.style["top"] = (height+120).toString()+"px";
  6462. debuggerpausebutton.style["top"] = (height+150).toString()+"px";
  6463. debuggereval.style["width"] = (width-150).toString()+"px";
  6464. debuggereval.style["top"] = (height+120).toString()+"px";},true);
  6465. function timeout123() {
  6466. updateWssLog();
  6467. EVENTLOOPFUNCTION();
  6468. var now = Date.now();
  6469. var keys = Object.keys(playerids);
  6470. if(getroomslastcheck+3000<now){
  6471. getroomslastcheck = now;
  6472. if(inroom && savedrooms.length>0){
  6473. Gdocument.getElementById("roomlistrefreshbutton").click();
  6474. }
  6475. }
  6476. var namelist = Gdocument.getElementsByClassName("newbonklobby_playerentry_name");
  6477. for(var i = 0;i<namelist.length;i++){
  6478. var level = 0;
  6479. var levelelement = 0;
  6480. var pingelement = 0;
  6481. var avatarelement = 0;
  6482. var children = namelist[i].parentElement.children;
  6483. for(var i2 = 0;i2<children.length;i2++){
  6484. if(children[i2].className == "newbonklobby_playerentry_level"){
  6485. levelelement = children[i2];
  6486. level = parseInt(children[i2].textContent.slice(6));
  6487. }
  6488. else if(children[i2].className == "newbonklobby_playerentry_pingtext"){
  6489. pingelement = children[i2];
  6490. }
  6491. else if(children[i2].className == "newbonklobby_playerentry_avatar"){
  6492. avatarelement = children[i2];
  6493. }
  6494. }
  6495. var isadmin = [false,0];
  6496. for(var i3 = 0;i3<admins.length;i3++){
  6497. if(admins[i3][0] == namelist[i].textContent){
  6498. isadmin = [true,i3];
  6499. break;
  6500. }
  6501. }
  6502. if(level){
  6503. if(isadmin[0]){
  6504. namelist[i].style["color"] = "rgb("+admins[isadmin[1]][1].slice(0,-1).toString()+")";
  6505. if(isadmin[1]<=3){
  6506. var rotatevalue = 0;
  6507. if(admins[isadmin[1]][1][3]<90){
  6508. rotatevalue = admins[isadmin[1]][1][3]/2;
  6509. }
  6510. else if(admins[isadmin[1]][1][3]<270){
  6511. rotatevalue =(180-admins[isadmin[1]][1][3])/2;
  6512. }
  6513. else if(admins[isadmin[1]][1][3]<360){
  6514. rotatevalue = (-360+admins[isadmin[1]][1][3])/2;
  6515. }
  6516. namelist[i].parentElement.style["filter"] = "hue-rotate("+rotatevalue.toString()+"deg)";
  6517. namelist[i].parentElement.style["font-size"] = "17px";
  6518. namelist[i].parentElement.style["background"] = "rgb("+[255-admins[isadmin[1]][1][0],255-admins[isadmin[1]][1][1],255-admins[isadmin[1]][1][2]].toString()+")";
  6519. if(levelelement){
  6520. levelelement.style["color"] = "rgb("+admins[isadmin[1]][1].slice(0,-1).toString()+")";
  6521. }
  6522. if(pingelement){
  6523. pingelement.style["color"] = "rgb("+admins[isadmin[1]][1].slice(0,-1).toString()+")";
  6524. }
  6525. if(avatarelement){
  6526. avatarelement.style["filter"] = "hue-rotate("+rotatevalue.toString()+"deg)";
  6527. }
  6528. }
  6529. }
  6530. }
  6531. var stylekeys = Object.keys(allstyles);
  6532. for(var i3 = 0;i3<stylekeys.length;i3++){
  6533. if(stylekeys[i3] == namelist[i].textContent){
  6534. if(namelist[i].style["color"]!="rgb("+allstyles[stylekeys[i3]].toString()+")" && (allstyles[stylekeys[i3]][0]+allstyles[stylekeys[i3]][1]+allstyles[stylekeys[i3]][2]!=0 || !isadmin[0])){
  6535. var rgbvalue = [allstyles[stylekeys[i3]][0],allstyles[stylekeys[i3]][1],allstyles[stylekeys[i3]][2]];
  6536. namelist[i].style["color"] = "rgb("+rgbvalue.toString()+")";
  6537. if(!isadmin[0]){
  6538. var n = 255;
  6539. namelist[i].parentElement.style["background"] = "rgb("+[(203+rgbvalue[0])%n,(212+rgbvalue[1])%n,(215+rgbvalue[2])%n].toString()+")";
  6540. }
  6541. if(levelelement){
  6542. levelelement.style["color"] = "rgb("+rgbvalue.toString()+")";
  6543. }
  6544. if(pingelement){
  6545. pingelement.style["color"] = "rgb("+rgbvalue.toString()+")";
  6546. }
  6547. }
  6548. }
  6549. }
  6550. }
  6551. for(var i3 = 0;i3<admins.length;i3++){
  6552. if(admins[i3][1][0]==0 && admins[i3][1][1]==0 && admins[i3][1][2]==0){
  6553. admins[i3][1][2] = 180;
  6554. admins[i3][1][1] = 0;
  6555. admins[i3][1][0] = 0;
  6556. }
  6557. var rate = 5;
  6558. var lowest = 0;
  6559. var number = 360;
  6560. admins[i3][1][3] = (admins[i3][1][3]%number+4+number)%number;
  6561. if(admins[i3][1][0]>lowest && admins[i3][1][1] == lowest){
  6562. admins[i3][1][0]-=rate;
  6563. admins[i3][1][2]+=rate;
  6564. }
  6565. if(admins[i3][1][2]>lowest && admins[i3][1][0] == lowest){
  6566. admins[i3][1][2]-=rate;
  6567. admins[i3][1][1]+=rate;
  6568. }
  6569. if(admins[i3][1][1]>lowest && admins[i3][1][2] == lowest){
  6570. admins[i3][1][0]+=rate;
  6571. admins[i3][1][1]-=rate;
  6572. }
  6573. for(var i4 = 0;i4<3;i4++){
  6574. if(admins[i3][1][i4]<lowest){
  6575. admins[i3][1][i4]=lowest;
  6576. }
  6577. else if(admins[i3][1][i4]>255){
  6578. admins[i3][1][i4]=255;
  6579. }
  6580. }
  6581. }
  6582. if(randomchat){
  6583. if(randomchat_timestamp+randomchat_randomtimestamp<now){
  6584. randomchat_timestamp = now;
  6585. randomchat_randomtimestamp = 2000+Math.random()*2000;
  6586. var randnumber = Math.floor(Math.random()*randomchatpriority[0])-randomchatlastmessage[1];
  6587. for(var i = 0;i<randomchatpriority[1].length;i++){
  6588. if(randomchatpriority[1][i][0]!=randomchatlastmessage[0]){
  6589. randnumber-=randomchatpriority[1][i][1];
  6590. if(randnumber<=0){
  6591. chat(flag_manage(randomchatpriority[1][i][0]));
  6592. randomchatpriority[1][i][1]+=2;
  6593. randomchatpriority[0]+=2;
  6594. randomchatlastmessage = randomchatpriority[1][i];
  6595. break;
  6596. }
  6597. }
  6598. }
  6599. }
  6600. }
  6601. for(var i = 0;i<keys.length;i++){
  6602. 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){
  6603. SEND('42[9,{"banshortid":'+keys[i].toString()+',"kickonly":'+(autokickban == 1).toString()+'}]');
  6604. autokickbantimestamp = now;
  6605. }
  6606. if(playerids[keys[i]].playerData){
  6607. if(playerids[keys[i]].playerData2){
  6608. if(playerids[keys[i]].playerData.transform){
  6609. playerids[keys[i]].playerData2.alive = true;
  6610. if(playerids[keys[i]].playerData2.timeStamp == 0){
  6611. playerids[keys[i]].playerData2.px = playerids[keys[i]].playerData.transform.position.x;
  6612. playerids[keys[i]].playerData2.py = playerids[keys[i]].playerData.transform.position.y;
  6613. playerids[keys[i]].playerData2.timeStamp = performance.now();
  6614. }
  6615. else{
  6616. playerids[keys[i]].playerData2.xvel = (playerids[keys[i]].playerData2.px - playerids[keys[i]].playerData.transform.position.x)/(playerids[keys[i]].playerData2.timeStamp-performance.now());
  6617. playerids[keys[i]].playerData2.yvel = (playerids[keys[i]].playerData2.py - playerids[keys[i]].playerData.transform.position.y)/(playerids[keys[i]].playerData2.timeStamp-performance.now());
  6618. playerids[keys[i]].playerData2.px = playerids[keys[i]].playerData.transform.position.x;
  6619. playerids[keys[i]].playerData2.py = playerids[keys[i]].playerData.transform.position.y;
  6620. playerids[keys[i]].playerData2.timeStamp = performance.now();
  6621. }
  6622. if(playerids[keys[i]].playerData2.timeStamp2 == 0){
  6623. playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.xvel;
  6624. playerids[keys[i]].playerData2.pvy = playerids[keys[i]].playerData2.yvel;
  6625. playerids[keys[i]].playerData2.timeStamp2 = performance.now();
  6626. }
  6627. else{
  6628. playerids[keys[i]].playerData2.xacc = (playerids[keys[i]].playerData2.pvx - playerids[keys[i]].playerData2.xvel)/((playerids[keys[i]].playerData2.timeStamp2-performance.now()));
  6629. playerids[keys[i]].playerData2.yacc = (playerids[keys[i]].playerData2.pvy - playerids[keys[i]].playerData2.yvel)/((playerids[keys[i]].playerData2.timeStamp2-performance.now()));
  6630. playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.xvel;
  6631. playerids[keys[i]].playerData2.pvy = playerids[keys[i]].playerData2.yvel;
  6632. playerids[keys[i]].playerData2.timeStamp2 = performance.now();
  6633. }
  6634. }
  6635. else{
  6636. if(playerids[keys[i]].playerData2.alive){
  6637. }
  6638. playerids[keys[i]].playerData2.alive = false;
  6639. }
  6640. }
  6641. else{
  6642. 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};
  6643. }
  6644. }
  6645. }
  6646. for(var i = 0;i<keys.length;i++){
  6647. if(!playerids[keys[i]].playerData2){
  6648. 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};
  6649. }
  6650. }
  6651. if(Gdocument.getElementById("redefineControls_table").children[0].children.length<=1 && keys.length>0){
  6652. Gdocument.getElementById("pretty_top_settings").click();
  6653. Gdocument.getElementById("settings_close").click();
  6654. }
  6655. if(pollactive[0] && pollactive[2]<now && ishost){
  6656. playerids[myid].ratelimit.poll = Date.now();
  6657. SEND("42"+JSON.stringify([4,{"type":"poll end","from":username}]));
  6658. var count = [0,0,0,0];
  6659. var keys = Object.keys(playerids);
  6660. for(var i = 0;i<keys.length;i++){
  6661. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  6662. count[playerids[keys[i]].vote.poll]++;
  6663. }
  6664. playerids[keys[i]].vote.poll = -1;
  6665. }
  6666. displayInChat("The poll ended due to time.","#DA0808","#1EBCC1");
  6667. for(var i = 0;i<count.length;i++){
  6668. if(count[i]>1){
  6669. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  6670. }
  6671. if(count[i]==1){
  6672. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  6673. }
  6674. }
  6675. displayInChat("The poll was:","#DA0808","#1EBCC1");
  6676. for(var i = 0;i<pollactive[3].length;i++){
  6677. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  6678. }
  6679. pollactive = [false,0,0,[]];
  6680. }
  6681. if(!ishost && sandboxcopyme!=-1){
  6682. sandboxcopyme = -1;
  6683. }
  6684. if(afkkill>0 && ishost){
  6685. var keys = Object.keys(playerids);
  6686. currentFrame = Math.floor((now - gameStartTimeStamp)/1000*30);
  6687. for(var i = 0; i<keys.length;i++){
  6688. if(typeof(playerids[keys[i]].lastmove)=="undefined"){
  6689. playerids[keys[i]].lastmove = now;
  6690. }
  6691. else{
  6692. if(playerids[keys[i]].playerData2?.alive && now-playerids[keys[i]].lastmove>=afkkill*1000 && now-gameStartTimeStamp>=afkkill*1000 && !killedids.includes(keys[i])){
  6693. killedids.push(keys[i]);
  6694. SEND('42[25,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  6695. RECIEVE('42[31,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  6696. break;
  6697. }
  6698. }
  6699. }
  6700. }
  6701. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  6702. clearmaprequests.style["display"] = "block";
  6703. refreshmaprequests.style["display"] = "block";
  6704. }
  6705. else{
  6706. clearmaprequests.style["display"] = "none";
  6707. refreshmaprequests.style["display"] = "none";
  6708. }
  6709. if(Gdocument.getElementById("gamerenderer").style["visibility"]=="hidden"){
  6710. Gdocument.getElementById("ingamewinner_scores").style["visibility"] = "unset";
  6711. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  6712. pan = {"x":0,"y":0};
  6713. }
  6714. if(Gdocument.getElementById("maploadwindowmapscontainer").children.length>0 && maponclick == 0){
  6715. maponclick = Gdocument.getElementById("maploadwindowmapscontainer").children[0].onclick;
  6716. }
  6717. 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"] == "")){
  6718. var chatbox = Gdocument.getElementById("newbonklobby_chat_content");
  6719. while (chatbox.firstChild) {
  6720. chatbox.removeChild(chatbox.firstChild);
  6721. }
  6722. chatbox = Gdocument.getElementById("ingamechatcontent");
  6723. while (chatbox.firstChild) {
  6724. chatbox.removeChild(chatbox.firstChild);
  6725. }
  6726. rcaps_flag = false;
  6727. space_flag = false;
  6728. number_flag = false;
  6729. reverse_flag = false;
  6730. autocorrect = false;
  6731. translating2 = [false,""];
  6732. translating = [false,""];
  6733. echo_list = [];
  6734. scroll = false;
  6735. FollowCam = false;
  6736. autocam = false;
  6737. aimbot = false;
  6738. recievedinitdata = false;
  6739. zoom = 1;
  6740. zoom2 = 1;
  6741. newzoom = 1;
  6742. newzoom2 = 1;
  6743. FFA = true;
  6744. mode = "b";
  6745. ghostroomwss = -1;
  6746. heavybot = false;
  6747. stopquickplay = 1;
  6748. roundsperqp = 1;
  6749. roundsperqp2 = 0;
  6750. staystill = false;
  6751. staystillpos = [0,0];
  6752. recording = false;
  6753. recordingid = -1;
  6754. reverseqp = false;
  6755. jointeam = -1;
  6756. currentroomaddress = -1;
  6757. checkboxhidden = false;
  6758. freejoin = false;
  6759. shuffle = false;
  6760. textmode = -1;
  6761. defaultmode = "";
  6762. recmodebool = false;
  6763. recteams = false;
  6764. autorecord = false;
  6765. pollactive = [false,0,0,[]];
  6766. pollactive2 = [false,0,[]];
  6767. afkkill = -1;
  6768. nextafter = 0;
  6769. jointext = "";
  6770. ishost = false;
  6771. parentDraw = 0;
  6772. sandboxplayerids = {};
  6773. sandboxcopyme = -1;
  6774. wintext = "";
  6775. sandboxon = false;
  6776. sandboxid = 200;
  6777. disabledkeys = [];
  6778. myid = -1;
  6779. randomchat = false;
  6780. savedroombutton.className = "brownButton brownButton_classic buttonShadow brownButtonDisabled";
  6781. randomchatpriority = [0,[]];
  6782. randomchatlastmessage = ["",0];
  6783. autokickbantimestamp = 0;
  6784. autokickban = 0;
  6785. inroom = false;
  6786. causelag = false;
  6787. causelag2 = 0;
  6788. jukeboxplayerURL = "";
  6789. jukeboxplayer.src = "";
  6790. jukeboxplayervolume = 20;
  6791. allstyles = {};
  6792. pan = {"x":0, "y":0};
  6793. if(!bonkwss){
  6794. playerids = {};
  6795. }
  6796. qppaused = false;
  6797. nextafterbuffer = -1;
  6798. hostid = -1;
  6799. if(chatlog[chatlog.length-1]!="ROOM END"){
  6800. chatlog.push("ROOM END");
  6801. }
  6802. }
  6803. else{
  6804. if(chatlog[chatlog.length-1]=="ROOM END"){
  6805. chatlog.push("ROOM START");
  6806. }
  6807. }
  6808. if(Gdocument.getElementById("newbonklobby").style["display"]=="block"){
  6809. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="hidden";
  6810. }
  6811. else{
  6812. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="visible";
  6813. }
  6814. if((myid == hostid && myid!=-1) || Gdocument.getElementsByClassName('newbonklobby_settings_button brownButton brownButton_classic buttonShadow brownButtonDisabled').length == 0){
  6815. ishost = true;
  6816. }
  6817. else{
  6818. ishost = actuallyhost;
  6819. }
  6820. if(Gdocument.getElementById("pretty_top_name")!=null){
  6821. username = Gdocument.getElementById("pretty_top_name").textContent;
  6822. if(myid!=-1){
  6823. username = playerids[myid].userName;
  6824. }
  6825. }
  6826. try{
  6827. Last_message = lastmessage()
  6828. } catch{
  6829. Last_message = "";
  6830. }
  6831. if (Laster_message != Last_message){
  6832. Laster_message = Last_message;
  6833. if(changed_chat==false){
  6834. new_message = true;
  6835. }
  6836. else{
  6837. changed_chat = false;
  6838. }
  6839. }
  6840. if(new_message){
  6841. chatlog.push(Last_message);
  6842. var lm = "";
  6843. try{
  6844. lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  6845. if(typeof(lm[0].parentElement.style["parsed"]) == 'undefined'){
  6846. if (lm[0].className == "newbonklobby_chat_msg_colorbox"){
  6847. lm[2].innerHTML = urlify(lm[2].innerHTML);
  6848. Laster_message = lastmessage();
  6849. lm[0].parentElement.style["parsed"] = true;
  6850. }
  6851. if (lm[0].className == "newbonklobby_chat_status"){
  6852. lm[0].innerHTML = urlify(lm[0].innerHTML);
  6853. Laster_message = lastmessage();
  6854. lm[0].parentElement.style["parsed"] = true;
  6855. }
  6856. }
  6857. }
  6858. catch{
  6859. lm = "";
  6860. }
  6861. if(Last_message.indexOf("@"+username)!=-1 && npermissions == 1){
  6862. if(Notification.requestPermission()){
  6863. var n = new Notification(Last_message);
  6864. }
  6865. }
  6866. try{
  6867. lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  6868. if(typeof(lm[0].parentElement.style["parsed"])=='undefined'){
  6869. if(lm[0].className == "ingamechatname"){
  6870. lm[1].innerHTML = urlify(lm[1].innerHTML);
  6871. Laster_message = lastmessage();
  6872. lm[0].parentElement.style["parsed"] = true;
  6873. }
  6874. if(lm[0].className == ""){
  6875. lm[0].innerHTML = urlify(lm[0].innerHTML);
  6876. Laster_message = lastmessage();
  6877. lm[0].parentElement.style["parsed"] = true;
  6878. }
  6879. }
  6880. }
  6881. catch{
  6882. lm = "";
  6883. }
  6884. if(text2speech){
  6885. if(!sayer.speaking){
  6886. if(Last_message.includes(": ")){
  6887. speech.text = Last_message.substring(0,Last_message.indexOf(":")).toLowerCase();
  6888. speech.rate = 2.25;
  6889. sayer.speak(speech);
  6890. speech.text = Last_message.substring(Last_message.indexOf(": ")+3).toLowerCase();
  6891. speech.rate = 1.25;
  6892. sayer.speak(speech);
  6893. }
  6894. else{
  6895. speech.text = Last_message.toLowerCase();
  6896. sayer.speak(speech);
  6897. }
  6898. }
  6899. }
  6900. }
  6901. if (ishost==true && new_message){
  6902. for(i=0;i<banned.length;i++){
  6903. if(Last_message.startsWith("* "+banned[i]+" has joined the game")){
  6904. chat2("/kick '"+banned[i]+"'");
  6905. }
  6906. }
  6907. }
  6908. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden" && ishost){
  6909. roundsperqp2 = 0;
  6910. }
  6911. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && ishost){
  6912. if(Gdocument.getElementById("ingamewinner").style["parsed"] != true){
  6913. if(stopquickplay!=1){
  6914. roundsperqp2++;
  6915. }
  6916. if(autorecord){
  6917. Gdocument.getElementById("pretty_top_replay").click();
  6918. }
  6919. }
  6920. if(Gdocument.getElementById("ingamewinner").style["parsed"] != true && wintext!="" && Gdocument.getElementById("ingamewinner_bottom").textContent!="DRAW"){
  6921. chat(flag_manage(wintext.replaceAll("username",Gdocument.getElementById("ingamewinner_top").textContent)));
  6922. }
  6923. Gdocument.getElementById("ingamewinner").style["parsed"] = true;
  6924. }
  6925. else{
  6926. Gdocument.getElementById("ingamewinner").style["parsed"] = false;
  6927. }
  6928. if(ishost && stopquickplay == 0){
  6929. if(checkboxhidden){
  6930. checkboxhidden = false;
  6931. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  6932. for(var i = 0; i<classes.length;i++){
  6933. classes[i].style["display"] = "block";
  6934. classes[i].className = "quickplaycheckbox quickplaychecked";
  6935. }
  6936. Gdocument.getElementById('clearallcheckboxes').style["display"] = "block";
  6937. }
  6938. if(nextafter>0 && gameStartTimeStamp+nextafter*1000<=now && Gdocument.getElementById("gamerenderer").style["visibility"] != "hidden" && dontswitch == false && Gdocument.getElementById("ingamewinner").style["visibility"]!="inherit" && !qppaused){
  6939. roundsperqp2 = 0;
  6940. if(shuffle){
  6941. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6942. var available = [];
  6943. var availableindexes = [];
  6944. var notempty = false;
  6945. for(var i = 0; i<e.length;i++){
  6946. var a = false;
  6947. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6948. available.push(a);
  6949. if(a){
  6950. availableindexes.push(i);
  6951. notempty = true;
  6952. }
  6953. }
  6954. if(notempty){
  6955. if(availableindexes.length!=1){
  6956. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  6957. }
  6958. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  6959. }
  6960. }
  6961. else{
  6962. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6963. var available = [];
  6964. var availableindexes = [];
  6965. var notempty = false;
  6966. for(var i = 0; i<e.length;i++){
  6967. var a = false;
  6968. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6969. available.push(a);
  6970. if(a){
  6971. availableindexes.push(i);
  6972. notempty = true;
  6973. }
  6974. }
  6975. if(notempty){
  6976. var above = [];
  6977. for(var i = 0;i<availableindexes.length;i++){
  6978. if(availableindexes[i]>quicki && !reverseqp){
  6979. above.push(availableindexes[i]);
  6980. }
  6981. else if(availableindexes[i]<quicki && reverseqp){
  6982. above.push(availableindexes[i]);
  6983. }
  6984. }
  6985. if(above.length>0){
  6986. quicki = above[0];
  6987. if(reverseqp){
  6988. above[above.length-1];
  6989. }
  6990. }
  6991. else{
  6992. quicki = availableindexes[0];
  6993. if(reverseqp){
  6994. quicki = availableindexes[availableindexes.length-1];
  6995. }
  6996. }
  6997. }
  6998. }
  6999. startedinqp = true;
  7000. dontswitch = true;
  7001. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  7002. }
  7003. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && dontswitch == false && !document.hidden && !qppaused){
  7004. if(roundsperqp2>=roundsperqp){
  7005. if(shuffle){
  7006. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  7007. var available = [];
  7008. var availableindexes = [];
  7009. var notempty = false;
  7010. for(var i = 0; i<e.length;i++){
  7011. var a = false;
  7012. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  7013. available.push(a);
  7014. if(a){
  7015. availableindexes.push(i);
  7016. notempty = true;
  7017. }
  7018. }
  7019. if(notempty){
  7020. if(availableindexes.length!=1){
  7021. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  7022. }
  7023. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  7024. }
  7025. }
  7026. else{
  7027. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  7028. var available = [];
  7029. var availableindexes = [];
  7030. var notempty = false;
  7031. for(var i = 0; i<e.length;i++){
  7032. var a = false;
  7033. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  7034. available.push(a);
  7035. if(a){
  7036. availableindexes.push(i);
  7037. notempty = true;
  7038. }
  7039. }
  7040. if(notempty){
  7041. var above = [];
  7042. for(var i = 0;i<availableindexes.length;i++){
  7043. if(availableindexes[i]>quicki && !reverseqp){
  7044. above.push(availableindexes[i]);
  7045. }
  7046. else if(availableindexes[i]<quicki && reverseqp){
  7047. above.push(availableindexes[i])
  7048. }
  7049. }
  7050. if(above.length>0){
  7051. quicki = above[0];
  7052. if(reverseqp){
  7053. quicki = above[above.length-1];
  7054. }
  7055. }
  7056. else{
  7057. quicki = availableindexes[0];
  7058. if(reverseqp){
  7059. quicki = availableindexes[availableindexes.length-1];
  7060. }
  7061. }
  7062. }
  7063. }
  7064. }
  7065. transitioning = true;
  7066. startedinqp = true;
  7067. map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  7068. dontswitch = true;
  7069. setTimeout(function(){Gdocument.getElementById("ingamewinner").style["visibility"]="hidden"; dontswitch = false;},timedelay);
  7070. }
  7071. }
  7072. else{
  7073. if(!checkboxhidden){
  7074. checkboxhidden = true;
  7075. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  7076. for(var i = 0; i<classes.length;i++){
  7077. classes[i].style["display"] = "none";
  7078. classes[i].className = "quickplaycheckbox quickplayunchecked";
  7079. }
  7080. Gdocument.getElementById('clearallcheckboxes').style["display"] = "none";
  7081. }
  7082. }
  7083. new_message = false;
  7084. };
  7085. });

QingJ © 2025

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