Bonk Commands

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

当前为 2024-08-21 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Bonk Commands
  3. // @namespace https://greasyfork.org/en/scripts/451341-bonk-commands
  4. // @version 20.5
  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://greasyfork.org/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. // r = Math.max(0, Math.min(255, r));
  3169. // g = Math.max(0, Math.min(255, g));
  3170. // b = Math.max(0, Math.min(255, b));
  3171. f.f = Math.floor(r) * 256 * 256 + Math.floor(g) * 256 + Math.floor(b);
  3172. }
  3173. return x;
  3174. }
  3175. scope.autokickban = 0;
  3176. scope.ghostroomwss = -1;
  3177. scope.autokickbantimestamp = 0;
  3178. scope.getroomslastcheck = 0;
  3179. scope.causelag = false;
  3180. scope.causelag2 = 0;
  3181. scope.overideDate = [false,0];
  3182. scope.scale = 1;
  3183. scope.translating = [false,""];
  3184. scope.translating2 = [false,""];
  3185. scope.translatingkeys = {"english":"en","chinese":"zh","japanese":"ja","dutch":"nl","hindi":"hi","spanish":"es","portugese":"pt","french":"fr","arabic":"ar","russian":"ru","korean":"ko"};
  3186. scope.translate = function(text,fromL,toL) {
  3187. var fL = fromL || 'en';
  3188. var tL = toL || 'de';
  3189. var url = 'https://translate.googleapis.com/translate_a/single?client=gtx&sl='+ fL + "&tl=" + tL + "&dt=t&q=" + encodeURI(text);
  3190. var parseJSON = txt => JSON.parse(txt.split(',').map( x => x || 'null').join(',')) ;
  3191. var joinSnippets = json => json[0].map( x => x[0] ).join('');
  3192. return fetch(url).then(function(res){
  3193. return res.text();
  3194. }).then(function(text){
  3195. return joinSnippets(parseJSON(text));
  3196. });
  3197. };
  3198. scope.positive = function(angle){
  3199. if(angle<0){
  3200. angle += 2*Math.PI;
  3201. }
  3202. return angle%(Math.PI*2);
  3203. };
  3204. scope.angle_between = function(angle,angle2){
  3205. return Math.min(Math.abs(positive(angle)-positive(angle2)),Math.PI*2-Math.abs(positive(angle)-positive(angle2)));
  3206. };
  3207. scope.angle_between2 = function(angle,angle2){
  3208. if(angle_between(angle,angle2+Math.PI/2)<Math.PI/2){
  3209. return 1;
  3210. }
  3211. return -1;
  3212. };
  3213. scope.stringdistance = function(s1,s2){
  3214. s1 = s1.toLowerCase();
  3215. s2 = s2.toLowerCase();
  3216. var matrix = Array(s1.length+1);
  3217. for(var i = 0;i<matrix.length;i++){
  3218. matrix[i] = Array(s2.length+1);
  3219. matrix[i][0] = i;
  3220. }
  3221. for(var i = 0;i<matrix[0].length;i++){
  3222. matrix[0][i] = i;
  3223. }
  3224. for(var i = 1;i<s1.length+1;i++){
  3225. for(var i2 = 1;i2<s2.length+1;i2++){
  3226. if(s1[i-1]==s2[i2-1]){
  3227. matrix[i][i2] = matrix[i-1][i2-1];
  3228. }
  3229. else{
  3230. matrix[i][i2] = Math.min(matrix[i][i2-1],matrix[i-1][i2],matrix[i-1][i2-1])+1;
  3231. }
  3232. }
  3233. }
  3234. return matrix[s1.length][s2.length];
  3235. };
  3236. scope.closestWord = function(word){
  3237. if(word.length>20 || word.length<2){
  3238. return word;
  3239. }
  3240. var distances = [word.length,""];
  3241. var playernamelist = [];
  3242. var keys = Object.keys(playerids);
  3243. for(var i = 0;i<keys.length;i++){
  3244. playernamelist.push(playerids[keys[i]].userName);
  3245. }
  3246. var wordlist2 = playernamelist.concat(wordlist);
  3247. for(var i = 0;i<wordlist2.length;i++){
  3248. var distance = stringdistance(word,wordlist2[i]);
  3249. if(distance<=distances[0]){
  3250. distances[0] = distance;
  3251. distances[1] = wordlist2[i];
  3252. if(distance == 0){
  3253. return wordlist2[i];
  3254. }
  3255. }
  3256. };
  3257. if(distances[1] == ""){
  3258. return word;
  3259. }
  3260. return distances[1];
  3261. };
  3262. scope.replay = function(){
  3263. var frame = getCurrentFrame();
  3264. /*var replaycounter = 0;
  3265. while(1){
  3266. if(replaycounter != recordingdata.length-1){
  3267. for(var i = 0;i<recordingdata[replaycounter+1][1]-recordingdata[replaycounter][1];i++){
  3268. RECIEVE('42[7,'+myid+',{"i":'+recordingdata[replaycounter][0]+',"f":'+(frame+i+recordingdata[replaycounter][1]).toString()+',"c":'+playerids[myid].movecount+'}]');
  3269. playerids[myid].movecount+=1;
  3270. }
  3271. replaycounter+=1;
  3272. }
  3273. else{
  3274. break;
  3275. }
  3276. }*/
  3277. for(var i = 0;i<recordingdata.length;i++){
  3278. SEND('42[4,{"i":'+recordingdata[i][0]+',"f":'+(frame+recordingdata[i][1]).toString()+',"c":'+playerids[myid].movecount+'}]');
  3279. }
  3280. };
  3281. scope.presskeys = function(x,y){
  3282. if(!x.left && y.left){
  3283. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  3284. }
  3285. else if(x.left && !y.left){
  3286. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  3287. }
  3288. if(!x.right && y.right){
  3289. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  3290. }
  3291. else if(x.right && !y.right){
  3292. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  3293. }
  3294. if(!x.up && y.up){
  3295. fire("keydown",{"keyCode":upDown[0]},Gdocument.getElementById("gamerenderer"));
  3296. }
  3297. else if(x.up && !y.up){
  3298. fire("keyup",{"keyCode":upDown[0]},Gdocument.getElementById("gamerenderer"));
  3299. }
  3300. if(!x.down && y.down){
  3301. fire("keydown",{"keyCode":upDown[1]},Gdocument.getElementById("gamerenderer"));
  3302. }
  3303. else if(x.down && !y.down){
  3304. fire("keyup",{"keyCode":upDown[1]},Gdocument.getElementById("gamerenderer"));
  3305. }
  3306. if(!x.heavy && y.heavy){
  3307. fire("keydown",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  3308. }
  3309. else if(x.heavy && !y.heavy){
  3310. fire("keyup",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  3311. }
  3312. if(!x.special && y.special){
  3313. fire("keydown",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  3314. }
  3315. else if(x.special && !y.special){
  3316. fire("keyup",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  3317. }
  3318. };
  3319. scope.getplayerkeys = function(){
  3320. var keykeys = Object.keys(keyCodes);
  3321. var keyslist = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[1].children).slice(1);
  3322. var keyslist2 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[2].children).slice(1);
  3323. var keyslist3 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[3].children).slice(1);
  3324. var keyslist4 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[4].children).slice(1);
  3325. var keyslist5 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[5].children).slice(1);
  3326. var keyslist6 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[6].children).slice(1);
  3327. for(var i = 0;i<keyslist.length;i++){
  3328. if(keykeys.includes(keyslist[i].textContent)){
  3329. leftRight[0] = keyCodes[keyslist[i].textContent];
  3330. break;
  3331. }
  3332. else{
  3333. leftRight[0] = keyslist[i].textContent.charCodeAt(0);
  3334. break
  3335. }
  3336. }
  3337. for(var i = 0;i<keyslist2.length;i++){
  3338. if(keykeys.includes(keyslist2[i].textContent)){
  3339. leftRight[1] = keyCodes[keyslist2[i].textContent];
  3340. break;
  3341. }
  3342. else{
  3343. leftRight[1] = keyslist2[i].textContent.charCodeAt(0);
  3344. break
  3345. }
  3346. }
  3347. for(var i = 0;i<keyslist3.length;i++){
  3348. if(keykeys.includes(keyslist3[i].textContent)){
  3349. upDown[0] = keyCodes[keyslist3[i].textContent];
  3350. break;
  3351. }
  3352. else{
  3353. upDown[0] = keyslist3[i].textContent.charCodeAt(0);
  3354. break
  3355. }
  3356. }
  3357. for(var i = 0;i<keyslist4.length;i++){
  3358. if(keykeys.includes(keyslist4[i].textContent)){
  3359. upDown[1] = keyCodes[keyslist4[i].textContent];
  3360. break;
  3361. }
  3362. else{
  3363. upDown[1] = keyslist4[i].textContent.charCodeAt(0);
  3364. break
  3365. }
  3366. }
  3367. for(var i = 0;i<keyslist5.length;i++){
  3368. if(keykeys.includes(keyslist5[i].textContent)){
  3369. heavy = keyCodes[keyslist5[i].textContent];
  3370. break;
  3371. }
  3372. else{
  3373. heavy = keyslist5[i].textContent.charCodeAt(0);
  3374. break
  3375. }
  3376. }
  3377. for(var i = 0;i<keyslist6.length;i++){
  3378. if(keykeys.includes(keyslist6[i].textContent)){
  3379. special = keyCodes[keyslist6[i].textContent];
  3380. break;
  3381. }
  3382. else{
  3383. special = keyslist6[i].textContent.charCodeAt(0);
  3384. break
  3385. }
  3386. }
  3387. };
  3388. scope.changeJukeboxURL = function(url,timestamp = 0){
  3389. if(pipedurllist.length == 0){
  3390. displayInChat("The jukebox is still being set up.","#DA0808","#1EBCC1");
  3391. return;
  3392. }
  3393. if(url == ""){
  3394. jukeboxplayer.pause();
  3395. jukeboxplayer.src = '';
  3396. displayInChat("The jukebox has been paused.","#DA0808","#1EBCC1");
  3397. }
  3398. else if(url == jukeboxplayerURL && Date.now()-timestamp >= 2000){
  3399. jukeboxplayer.volume = jukeboxplayervolume/100;
  3400. displayInChat("The jukebox has been unpaused or reset.","#DA0808","#1EBCC1",{sanitize:false});
  3401. jukeboxplayer.play();
  3402. jukeboxplayer.currentTime = (Date.now()-timestamp)/1000;
  3403. }
  3404. else{
  3405. var id = url.match(/youtu\.?be.com\/watch\?.*v=[a-z|A-Z|0-9|_|-]{11}/)[0].split("?v=");
  3406. id = id[id.length-1];
  3407. var loaded = false;
  3408. var loaded2 = 0;
  3409. for(var inst = 0;inst<pipedindexes.length;inst++){
  3410. checkJukeboxStream(pipedindexes[inst],id).then(function(value){
  3411. loaded2+=1;
  3412. if(value!=-1 && !loaded){
  3413. loaded = true;
  3414. jukeboxplayer.src = value[0];
  3415. jukeboxplayer.volume = jukeboxplayervolume/100;
  3416. jukeboxplayerURL = url;
  3417. jukeboxplayer.oncanplaythrough = function(){
  3418. displayInChat("The jukebox has been changed to: ","#DA0808","#1EBCC1",{sanitize:false},url);
  3419. displayInChat("Jukebox is now playing: "+value[1]+" by "+value[2]+".","#DA0808","#1EBCC1");
  3420. jukeboxplayer.play();
  3421. jukeboxplayer.currentTime = (Date.now()-timestamp)/1000;
  3422. jukeboxplayer.oncanplaythrough = null;
  3423. };
  3424. jukeboxplayer.onerror = function(){
  3425. displayInChat("The jukebox failed to load. Please try again.","#DA0808","#1EBCC1");
  3426. };
  3427. }
  3428. });
  3429. }
  3430. new Promise(function(r){
  3431. var interv = setInterval(function(){
  3432. if(loaded2>=pipedindexes.length){
  3433. if(!loaded){
  3434. displayInChat("The jukebox failed to load. Please try again.","#DA0808","#1EBCC1");
  3435. }
  3436. clearInterval(interv);
  3437. }
  3438. },60)
  3439. });
  3440. }
  3441. };
  3442. 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 ]"];
  3443. scope.adv_help = {"help":"Shows all command names.",
  3444. "?":"Shows all command names.",
  3445. "advhelp":"Shows a command in detail.",
  3446. "space":"Toggles space. When space is on, whatever you type will be spaced apart.",
  3447. "rcaps":"Toggles rcaps. When rcaps is on, each letter will randomly get capitalized.",
  3448. "number":"Toggles number. When number is on, 'a' becomes 4, 'e' becomes 3, 's' becomes 5, 'o' becomes 0, 'l' and 'i' become 1.",
  3449. "speech":"Turns on text to speech for the chat.",
  3450. "savedroom":"Displays all the rooms you have saved, you can remove individual ones from the saved rooms by clicking \"Remove\".",
  3451. "maxfps":"Toggles maxfps. When maxfps is on, your fps will be increased.",
  3452. "clearsavedroom":"Clears all the saved rooms.",
  3453. "echo":"Echoes a username. It copies the username's chat messages.",
  3454. "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.",
  3455. "remove":"Removes username from echo list. You will not echo that username anymore.",
  3456. "clearecho":"Clears echo list. You will not echo anyone anymore.",
  3457. "chatw":"It private chats with username. Type /msg to message that username.",
  3458. "msg":"Messages with what username you are chatting with. Type /chatw to chat with a username.",
  3459. "ignorepm":"Ignores the username's private chat messages. To unignore, type '/ignorepm [username]'.",
  3460. "pmusers":"Dispays who you can private chat with.",
  3461. "pollstat":"Displays the current poll and its votes.",
  3462. "textmode":"Changes the text font.",
  3463. "eval":"Evaluates code. Only use this if you are experienced in javascript.",
  3464. "debugger":"Opens debugger.",
  3465. "style":"Change the color of your username, level, and background. For example, '/style 255 0 0' will make your username red.",
  3466. "translate":"Translates peoples texts to the chosen language.",
  3467. "translateto":"You will now speak the chosen language.",
  3468. "autocorrect":"Fixes spelling mistakes.",
  3469. "randomchat":"Spams random chat messages from the past.",
  3470. "lobby":"Makes lobby visible when you are ingame. Type '/lobby' again to close lobby.",
  3471. "score":"Displays the current score while ingame. Type '/score' again to hide the score.",
  3472. "pan":"Toggles pan mode. Use Shift+Arrow Keys to move the camera around.",
  3473. "resetpan":"Resets pan.",
  3474. "team":"Joins a specific team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3475. "scroll":"Toggles a scrollbar in ingame chat.",
  3476. "followcam":"Enables follow camera. Your character will be centered on the screen.",
  3477. "autocam":"Zooms in/out enough for you to see everyone on the screen.",
  3478. "zoom":"Zooms in, out, or resets zoom.",
  3479. "xray":"Removes all shapes that don't have a shadow. This means all non-physics shapes will be hidden.",
  3480. "aimbot":"Toggles aimbot. Aimbot will aim for you in arrows or death arrows mode.",
  3481. "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.",
  3482. "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.",
  3483. "lagbot":"Makes your movements very laggy. Type '/lagbot 0' to turn it off.",
  3484. "hidechat":"Hides ingame chat. Type '/showchat' to show it again.",
  3485. "showchat":"Shows ingame chat. '/hidechat' hides the chat.",
  3486. "notify":"You will be notified if a person types @username",
  3487. "stopnotify":"You will not be notified if a person types @username",
  3488. "support":"Displays all the people who have supported this mod.",
  3489. "startqp":"Starts cycling maps in your map menu.",
  3490. "stopqp":"Stops cycling maps in your map menu.",
  3491. "revqp":"Reverses the order of quickplay. '/next', '/previous' will be inverted.",
  3492. "pauseqp":"Only pauses or unpauses the quickplay cycle due to round end. '/next', '/previous' still work. Type 'pauseqp' to unpause quickplay.",
  3493. "next":"Skips the map. Usable only with '/startqp'.",
  3494. "nextafter":"Skips the map if no one is able to win/draw within a certain amount of time.",
  3495. "previous":"Goes to previous map. Usable only with '/startqp'.",
  3496. "shuffle":"Makes quickplay play random maps instead of in order.",
  3497. "freejoin":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  3498. "recmode":"In quickplay, it switches mode to recommended mode, according to editor.",
  3499. "recteam":"In quickplay, it sorts people into teams when teams are necessary.",
  3500. "defaultmode":"Switches mode to defaultmode if there is no recmode.",
  3501. "start":"Starts game instantly.",
  3502. "instaqp":"Rounds will instantly start without a countdown.",
  3503. "balanceA":"Balances everyone with balance number.",
  3504. "colorshift": "Shifts the color of the map.",
  3505. "brighten": "Brightens the map by the number.",
  3506. "moveA":"Sets everyones team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3507. "balanceT":"Sets everyones balance to the number. The team is 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3508. "killA":"Kills everyone.",
  3509. "jointeam":"Sets the team of anyone who joins. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3510. "moveT":"Sets everyone in one team to another team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3511. "rounds":"Sets rounds to win.",
  3512. "replay":"Replays the movements that were recorded",
  3513. "record":"Records movements of the username",
  3514. "delrecording":"Deletes the recording with the name.",
  3515. "saverecording":"Saves the recording with the name.",
  3516. "loadrecording":"Loads the recording with the name. Type '/replay' to replay it.",
  3517. "stoprecord":"Stops recording the player. Type '/saverecording [text]' to save it.",
  3518. "jukebox":"Sets the jukebox to a link. That link will play for everyone who has this mod.",
  3519. "volume":"Sets the volume of the jukebox.",
  3520. "pausejukebox":"If the jukebox is playing, it pauses it.",
  3521. "resetjukebox":"Resets the jukebox, so it starts from the very beginning.",
  3522. "playjukebox":"If the jukebox is paused, it plays it.",
  3523. "roundsperqp":"After that many rounds, the map will change. Normally, the map will change after 1 round.",
  3524. "autorecord":"After a round ends, automatically records the last 15 seconds.",
  3525. "mode":"If host, switches mode. Otherwise, it requests the host to switch mode, as long as the host has this mod.",
  3526. "disablekeys":"If anyone presses a disabled key, they get killed. Key options: left right up down heavy special.",
  3527. "jointext":"Chats the jointext whenever someone joins. \"username\" will get replaced by the joining person's username.",
  3528. "wintext":"Chats the wintext whenever someone wins. \"username\" will get replaced by the winning person's username.",
  3529. "afkkill":"If a person stays afk for that many seconds, they get automatically killed.",
  3530. "ban":"Bans username from lobby. If they rejoin, it automatically bans.",
  3531. "kill":"Kills the person ingame.",
  3532. "resetpoll":"Clears the poll.",
  3533. "addoption":"Adds the option to the poll. You can only have 4 maximum options. Type '/deloption [letter]' to remove an option.",
  3534. "deloption":"Removes the option with that letter.",
  3535. "startpoll":"Starts a poll that lasts for at least 10 seconds. Type '/endpoll' to end it early.",
  3536. "endpoll":"Ends the poll early if the poll lasted for at least 10 seconds.",
  3537. "addplayer":"In sandbox, it adds bots.",
  3538. "addname":"Adds a bot with a specific name. If that name already exists, it will copy the skin of that player to the bot.",
  3539. "delplayer":"In sandbox, it deletes bots.",
  3540. "copy":"In sandbox, it makes all bots copy the username's movements.",
  3541. "sandbox":"Turns a normal lobby into a sandbox lobby. You cannot turn a sandbox lobby back into a normal lobby.",
  3542. "autokick":"Automatically kicks everyone who is not using this mod.",
  3543. "autoban":"Automatically bans everyone who is not using this mod.",
  3544. "Alt L":"Makes lobby visible when you are ingame. Press Alt L again to close lobby.",
  3545. "Alt C":"Hides ingame chat. Press Alt C again to show ingame chat.",
  3546. "Alt S":"Starts game instantly.",
  3547. "Alt T":"Toggles teams.",
  3548. "Alt N":"Enables follow camera. Your character will be centered on the screen.",
  3549. "Alt G":"Zooms in.",
  3550. "Alt H":"Resets zoom.",
  3551. "Alt J":"Zooms out.",
  3552. "Alt Y":"Enables xray. Removes all shapes that don't have a shadow. This means all non-physics shapes will be hidden.",
  3553. "Alt E":"Toggles editor.",
  3554. "Alt K":"Exits ingame and returns to lobby.",
  3555. "Alt M":"Switches modes.",
  3556. "Alt V":"Toggles autocam. Autocam zooms in/out enough for you to see everyone on the screen.",
  3557. "Alt Q":"Toggles quickplay.",
  3558. "Alt B":"Displays the current score while ingame. Press Alt B again to hide the score.",
  3559. "Alt A":"Skips the map if quickplay is on.",
  3560. "Alt D":"Goes to previous map if quickplay is on.",
  3561. "Alt F":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  3562. "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.",
  3563. "Alt U":"Toggles aimbot. Aimbot will aim for you in arrows or death arrows mode.",
  3564. "Alt P":"Only pauses or unpauses the quickplay cycle due to round end. '/next', '/previous' still work. Type 'pauseqp' to unpause quickplay.",
  3565. "Alt R":"In quickplay, it switches mode to recommended mode, according to editor.",
  3566. "Alt I":"Opens debugger.",
  3567. "Alt W":"Saves your position, and tries to reach it constantly. This is useful in parkour if you want to go afk.",
  3568. "Alt <":"Lowers ingame chat height.",
  3569. "Alt >":"Highers ingame chat height.",
  3570. "Alt [":"Toggles pan mode. Use Shift+Arrow Keys to move the camera around.",
  3571. "Alt ]":"Resets pan."
  3572. };
  3573. scope.displayadvhelp = function(command){
  3574. displayInChat(adv_help[command],"#009398","#DA0808",{sanitize:true},"",true);
  3575. };
  3576. scope.changemode = function(mode){
  3577. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  3578. RECIEVE('42[26,"b","'+mode+'"]');
  3579. };
  3580. Gdocument.getElementById("ingamechatcontent").style["pointer-events"]="all";
  3581. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  3582. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  3583. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  3584. document.getElementById('adboxverticalCurse').style["display"] = "none";
  3585. document.getElementById('adboxverticalleftCurse').style["display"] = "none";
  3586. elem.onclick=function(e){
  3587. if(stopquickplay==0 && ishost == true && e.isTrusted == true){
  3588. quicki = (Array.from(e.target.parentElement.parentNode.children).indexOf(e.target.parentNode)-1)%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  3589. if(reverseqp){
  3590. quicki+=2;
  3591. quicki = quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  3592. }
  3593. }
  3594. };
  3595. scope.getCurrentFrame = function(){
  3596. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  3597. return currentFrame;
  3598. };
  3599. scope.urlify = function(text) {
  3600. if(!Gdocument.getElementById('bl_Menu')){
  3601. return text.replace(/[(http(s)?):\/\/(www\.)?a-zA-Z0-9@:;%.\-_\+~#=]{2,256}\.[\-a-z]{2,6}\b([\-a-zA-Z0-9@:;%_\+.~#?&//=]*)/ig, function(url) {
  3602. var extratext = "";
  3603. var matches = url.match(/youtu\.?be.com\/watch\?.*v=[a-z|A-Z|0-9|_|-]{11}/);
  3604. if(matches){
  3605. var button = Gdocument.createElement("a");
  3606. button.style["color"] = "green";
  3607. button.textContent = "Play";
  3608. button.href = "javascript:void(0)";
  3609. button.setAttribute("onclick",function(){
  3610. if(Gwindow.ishost){
  3611. Gwindow.SEND("42"+JSON.stringify([4,{"type":"video player","from":Gwindow.username,"url":"URL INSERT HERE","timestamp":Gwindow.Date.now()+2000,"to":[-1]}]));
  3612. Gwindow.displayInChat("Jukebox is loading... Please wait a few seconds.","#DA0808","#1EBCC1");
  3613. Gwindow.changeJukeboxURL("URL INSERT HERE",Gwindow.Date.now()+2000);
  3614. }
  3615. else{
  3616. Gwindow.displayInChat("You need to be host.","#DA0808","#1EBCC1");
  3617. }
  3618. });
  3619. button.attributes["onclick"].nodeValue = button.attributes["onclick"].nodeValue.slice(11,-1).replaceAll("URL INSERT HERE","https://www."+matches[0]);
  3620. var extratext = ' ['+button.outerHTML+']';
  3621. }
  3622. if(url.startsWith('https://') || url.startsWith('http://')){return '<a href="' + url + '" target="_blank" style = "color:orange">' + sanitize(url) + '</a>'+extratext;}
  3623. else{return '<a href="https://' + url + '" target="_blank" style = "color:orange">' + sanitize(url) + '</a>'+extratext;}
  3624. })}return text;
  3625. };
  3626. scope.fire = function(type,options,d = Gdocument){
  3627. var event= document.createEvent("HTMLEvents");
  3628. event.initEvent(type,true,false);
  3629. for(var p in options){
  3630. event[p]=options[p];
  3631. }
  3632. d.dispatchEvent(event);
  3633. };
  3634. scope.chat = function(message){
  3635. SEND('42[10,{"message":'+JSON.stringify(message)+'}]');
  3636. };
  3637. scope.chat2 = function(message,enteragain=false){
  3638. mess = Gdocument.getElementById("newbonklobby_chat_input").value;
  3639. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  3640. Gdocument.getElementById("newbonklobby_chat_input").value = message;
  3641. Gdocument.getElementById("ingamechatinputtext").value = message;
  3642. fire("keydown",{keyCode:13});
  3643. if(!enteragain){
  3644. fire("keydown",{keyCode:13});
  3645. }
  3646. Gdocument.getElementById("newbonklobby_chat_input").value = mess;
  3647. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  3648. };
  3649. scope.sanitize = function(message){
  3650. return message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;');
  3651. };
  3652. scope.displayInChat = function(message, LobbyColor, InGameColor, options, message2, BringDown) {
  3653. options = options ?? {};
  3654. BringDown = BringDown ?? false;
  3655. message2 = message2 ?? "";
  3656. LobbyColor = LobbyColor ?? "#8800FF";
  3657. InGameColor = InGameColor ?? "#AA88FF";
  3658. var A = Gdocument.createElement("div");
  3659. var B = Gdocument.createElement("span");
  3660. B.className = "newbonklobby_chat_status";
  3661. B.style.color = LobbyColor;
  3662. A.appendChild(B);
  3663. B.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  3664. B.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  3665. var C = Gdocument.createElement("div");
  3666. var D = Gdocument.createElement("span");
  3667. D.style.color = InGameColor;
  3668. C.appendChild(D);
  3669. D.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  3670. D.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  3671. var a = BringDown;
  3672. if(Gdocument.getElementById("newbonklobby_chat_content").clientHeight + Gdocument.getElementById("newbonklobby_chat_content").scrollTop >= Gdocument.getElementById("newbonklobby_chat_content").scrollHeight-1) {
  3673. a = true;
  3674. }
  3675. var b = BringDown;
  3676. if(Gdocument.getElementById("ingamechatcontent").clientHeight + Gdocument.getElementById("ingamechatcontent").scrollTop >= Gdocument.getElementById("ingamechatcontent").scrollHeight-1) {
  3677. b = true;
  3678. }
  3679. A.style["parsed"] = true;
  3680. C.style["parsed"] = true;
  3681. Gdocument.getElementById("newbonklobby_chat_content").appendChild(A);
  3682. Gdocument.getElementById("ingamechatcontent").appendChild(C);
  3683. if (a) { Gdocument.getElementById("newbonklobby_chat_content").scrollTop = Gdocument.getElementById("newbonklobby_chat_content").scrollHeight;};
  3684. if (b) { Gdocument.getElementById("ingamechatcontent").scrollTop = Gdocument.getElementById("ingamechatcontent").scrollHeight;};
  3685. if(Gdocument.getElementById("newbonklobby_chat_input").style["pointer-events"]!="auto" && !Gdocument.getElementById("ingamechatinputtext").classList.value.includes("ingamechatinputtextbg")){
  3686. chat2("");
  3687. }
  3688. };
  3689. scope.lobby = function(){
  3690. if (Gdocument.getElementById("newbonklobby").style["display"]=="none"){
  3691. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3692. Gdocument.getElementById("mapeditor_close").click();
  3693. if(Gdocument.getElementById("newbonklobby_playerbox_elementcontainer").children.length+Gdocument.getElementById("newbonklobby_specbox_elementcontainer").children.length-3>0){
  3694. Gdocument.getElementById("newbonklobby").style["z-index"]=1;
  3695. Gdocument.getElementById("maploadwindowcontainer").style["z-index"]=1;
  3696. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=1;
  3697. Gdocument.getElementById("pretty_top").style["z-index"]=3;
  3698. Gdocument.getElementById("settingsContainer").style["z-index"]=3;
  3699. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=3;
  3700. Gdocument.getElementById("hostleaveconfirmwindow").style["z-index"]=3;
  3701. debuggermenu.style["z-index"] = 2;
  3702. }
  3703. else{
  3704. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  3705. Gdocument.getElementById("newbonklobby").style["display"]="none";
  3706. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  3707. }
  3708. }
  3709. else if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  3710. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  3711. Gdocument.getElementById("newbonklobby").style["display"]="none";
  3712. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  3713. }
  3714. };
  3715. scope.lastmessage = function(){
  3716. if(Gdocument.getElementById("newbonklobby_chat_content").children.length!=0){
  3717. var lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  3718. var lm2 = "";
  3719. for(var i = 0; i<lm.length;i++){
  3720. lm2+=" "+lm[i].textContent.trim();
  3721. }
  3722. lm2 = lm2.trim();
  3723. if(lm2.startsWith("*")){
  3724. return lm2;
  3725. }
  3726. }
  3727. if(Gdocument.getElementById("ingamechatcontent").children.length!=0){
  3728. var lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  3729. var lm2 = "";
  3730. for(var i = 0; i<lm.length;i++){
  3731. lm2+=" "+lm[i].textContent.trim();
  3732. }
  3733. return lm2.trim();
  3734. }
  3735. return "";
  3736. };
  3737. scope.map = function(e,t=timedelay){
  3738. if(e<0){
  3739. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  3740. quicki = 0;
  3741. return;
  3742. }
  3743. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  3744. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  3745. return;
  3746. }
  3747. setTimeout(function(){if(!canceled){
  3748. startedinqp = true;
  3749. if(roundsperqp2>=roundsperqp){
  3750. roundsperqp2 = 0;
  3751. }
  3752. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  3753. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3754. if(recmodebool && ishost){
  3755. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  3756. if(mode == "" && defaultmode!="d"){
  3757. mode = defaultmode;
  3758. }
  3759. if(mode != ""){
  3760. RECIEVE('42[26,"b","'+mode+'"]');
  3761. }
  3762. }
  3763. var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  3764. Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  3765. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  3766. if(displayblock){
  3767. Gdocument.getElementById("newbonklobby").style["display"] = "block";
  3768. }
  3769. Gdocument.getElementById("mapeditor_midbox_testbutton").click();}
  3770. canceled = false;
  3771. transitioning = false;
  3772. },t);
  3773. };
  3774. scope.gotonextmap = function(e){
  3775. if(e<0){
  3776. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  3777. quicki = 0;
  3778. return;
  3779. }
  3780. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  3781. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  3782. return;
  3783. }
  3784. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  3785. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3786. if(recmodebool && ishost){
  3787. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  3788. if(mode == "" && defaultmode!="d"){
  3789. mode = defaultmode;
  3790. }
  3791. if(mode != ""){
  3792. RECIEVE('42[26,"b","'+mode+'"]');
  3793. }
  3794. }
  3795. startedinqp = true;
  3796. if(roundsperqp2>=roundsperqp){
  3797. roundsperqp2 = 0;
  3798. }
  3799. var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  3800. Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  3801. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  3802. if(displayblock){
  3803. Gdocument.getElementById("newbonklobby").style["display"] = "block";
  3804. }
  3805. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  3806. Gdocument.getElementById("newbonklobby").style["visibility"] = "visible";
  3807. };
  3808. scope.commandhandle = function(chat_val){
  3809. if (chat_val.substring(1,6)=="echo " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3810. if (chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"")==username){
  3811. displayInChat("You cannot echo yourself.","#DA0808","#1EBCC1");
  3812. return "";
  3813. }
  3814. else if (echo_list.indexOf(chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',""))===-1) {
  3815. echo_list.push(chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',""));
  3816. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"") + " is being echoed.","#DA0808","#1EBCC1");
  3817. return "";
  3818. }
  3819. else{
  3820. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"") + " is already being echoed.","#DA0808","#1EBCC1");
  3821. return "";
  3822. }
  3823. }
  3824. else if (chat_val.substring(1,8)=="remove " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3825. if (echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',""))!==-1){
  3826. echo_list.splice(echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"")),1);
  3827. displayInChat(chat_val.substring(7).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"")+" is not being echoed.","#DA0808","#1EBCC1");
  3828. return "";
  3829. }
  3830. else{
  3831. displayInChat("You cannot remove someone that you didn't echo.","#DA0808","#1EBCC1");
  3832. return "";
  3833. }
  3834. }
  3835. else if (chat_val.substring(1,10)=="echotext " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  3836. echotext = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  3837. displayInChat("Set echotext as: "+echotext,"#DA0808","#1EBCC1");
  3838. displayInChat("Type '/echotext' to reset echotext.","#DA0808","#1EBCC1");
  3839. return "";
  3840. }
  3841. else if (chat_val.substring(1,9)=="echotext"){
  3842. echotext = "message";
  3843. displayInChat("Reset echotext.","#DA0808","#1EBCC1");
  3844. return "";
  3845. }
  3846. else if (chat_val.substring(1,10)=="clearecho"){
  3847. echo_list = [];
  3848. displayInChat("Cleared the echo list.","#DA0808","#1EBCC1");
  3849. return "";
  3850. }
  3851. else if (chat_val.substring(1,11)=="randomchat"){
  3852. if(randomchat == true){
  3853. displayInChat("Random chat is now off.","#DA0808","#1EBCC1");
  3854. randomchat = false;
  3855. }
  3856. else{
  3857. displayInChat("Random chat is now on.","#DA0808","#1EBCC1");
  3858. randomchat = true;
  3859. }
  3860. return "";
  3861. }
  3862. else if (chat_val.substring(1,12)=="autocorrect"){
  3863. if(autocorrect == true){
  3864. displayInChat("Autocorrect is now off.","#DA0808","#1EBCC1");
  3865. autocorrect = false;
  3866. }
  3867. else{
  3868. displayInChat("Autocorrect is now on.","#DA0808","#1EBCC1");
  3869. autocorrect = true;
  3870. }
  3871. return "";
  3872. }
  3873. else if (chat_val.substring(1,13)=="translateto " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  3874. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '').toLowerCase();
  3875. var keys = Object.keys(translatingkeys);
  3876. if(keys.includes(text)){
  3877. translating2 = [true,translatingkeys[text]];
  3878. displayInChat("You will now speak the "+text+" language.","#DA0808","#1EBCC1");
  3879. }
  3880. else{
  3881. displayInChat("Invalid language. Here are the current language options:","#DA0808","#1EBCC1");
  3882. for(var i = 0;i<keys.length;i++){
  3883. displayInChat(keys[i],"#DA0808","#1EBCC1");
  3884. }
  3885. }
  3886. return "";
  3887. }
  3888. else if (chat_val.substring(1,12)=="translateto"){
  3889. translating2 = [false,""];
  3890. displayInChat("You will not speak another language anymore.","#DA0808","#1EBCC1");
  3891. return "";
  3892. }
  3893. else if (chat_val.substring(1,11)=="translate " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  3894. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '').toLowerCase();
  3895. var keys = Object.keys(translatingkeys);
  3896. if(keys.includes(text)){
  3897. translating = [true,translatingkeys[text]];
  3898. displayInChat("Translator has been set to the "+text+" language.","#DA0808","#1EBCC1");
  3899. }
  3900. else{
  3901. displayInChat("Invalid language. Here are the current language options:","#DA0808","#1EBCC1");
  3902. for(var i = 0;i<keys.length;i++){
  3903. displayInChat(keys[i],"#DA0808","#1EBCC1");
  3904. }
  3905. }
  3906. return "";
  3907. }
  3908. else if (chat_val.substring(1,10)=="translate"){
  3909. translating = [false,""];
  3910. displayInChat("Translator has been turned off.","#DA0808","#1EBCC1");
  3911. return "";
  3912. }
  3913. else if (chat_val.substring(1,6)=="space"){
  3914. if(space_flag == true){
  3915. displayInChat("Space is now off.","#DA0808","#1EBCC1");
  3916. space_flag = false;
  3917. }
  3918. else{
  3919. displayInChat("Space is now on.","#DA0808","#1EBCC1");
  3920. space_flag = true;
  3921. }
  3922. return "";
  3923. }
  3924. else if (chat_val.substring(1,6)=="rcaps"){
  3925. if(rcaps_flag == true){
  3926. displayInChat("Rcaps is now off.","#DA0808","#1EBCC1");
  3927. rcaps_flag = false;
  3928. }
  3929. else{
  3930. displayInChat("Rcaps is now on.","#DA0808","#1EBCC1");
  3931. rcaps_flag = true;
  3932. }
  3933. return "";
  3934. }
  3935. else if (chat_val.substring(1,7)=="number"){
  3936. if(number_flag == true){
  3937. displayInChat("Number is now off.","#DA0808","#1EBCC1");
  3938. number_flag = false;
  3939. }
  3940. else{
  3941. displayInChat("Number is now on.","#DA0808","#1EBCC1");
  3942. number_flag = true;
  3943. }
  3944. return "";
  3945. }
  3946. else if (chat_val.substring(1,8)=="reverse"){
  3947. if(reverse_flag == true){
  3948. displayInChat("Reverse is now off.","#DA0808","#1EBCC1");
  3949. reverse_flag = false;
  3950. }
  3951. else{
  3952. displayInChat("Reverse is now on.","#DA0808","#1EBCC1");
  3953. reverse_flag = true;
  3954. }
  3955. return "";
  3956. }
  3957. else if (chat_val.substring(1,7)=="speech"){
  3958. if(text2speech == true){
  3959. displayInChat("Text to speech is now off.","#DA0808","#1EBCC1");
  3960. text2speech = false;
  3961. }
  3962. else{
  3963. displayInChat("Text to speech is now on.","#DA0808","#1EBCC1");
  3964. text2speech = true;
  3965. }
  3966. return "";
  3967. }
  3968. else if (chat_val.substring(1,7)=="maxfps"){
  3969. if(maxfps){
  3970. displayInChat("Max FPS is now off.","#DA0808","#1EBCC1");
  3971. maxfps = false;
  3972. }
  3973. else{
  3974. displayInChat("Max FPS is now on.","#DA0808","#1EBCC1");
  3975. maxfps = true;
  3976. }
  3977. return "";
  3978. }
  3979. else if (chat_val.substring(1,6)=="eval " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3980. var ev = "";
  3981. try{
  3982. ev = eval(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  3983. }
  3984. catch(e){
  3985. displayInChat(e.message,"#DA0808","#1EBCC1");
  3986. }
  3987. try{
  3988. displayInChat(ev.toString(),"#DA0808","#1EBCC1");
  3989. }
  3990. catch{
  3991. }
  3992. return "";
  3993. }
  3994. else if (chat_val.substring(1,10)=="textmode " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  3995. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  3996. var parsed = parseInt(text);
  3997. if(!isNaN(parsed)){
  3998. if(parsed<=7 && parsed>=1){
  3999. textmode = parsed-1;
  4000. displayInChat("Type '/textmode' to reset textmode.","#DA0808","#1EBCC1");
  4001. }
  4002. else{
  4003. displayInChat("Please enter a integer from 1-7 inclusive.","#DA0808","#1EBCC1");
  4004. }
  4005. }
  4006. else{
  4007. displayInChat("Please enter a integer from 1-7 inclusive.","#DA0808","#1EBCC1");
  4008. }
  4009. return "";
  4010.  
  4011. }
  4012. else if (chat_val.substring(1,9)=="textmode"){
  4013. textmode = -1;
  4014. displayInChat("Reset textmode.","#DA0808","#1EBCC1");
  4015. return "";
  4016. }
  4017. else if (chat_val.substring(1,10)=="savedroom"){
  4018. if(savedrooms.length == 0){
  4019. displayInChat("You do not have any saved rooms.","#DA0808","#1EBCC1");
  4020. return "";
  4021. }
  4022. else{
  4023. var keys = Object.keys(savedroomsdata);
  4024. for(var i = 0;i<keys.length;i++){
  4025. var code = 'this.parentElement.remove();delete Gwindow.savedroomsdata["'+keys[i]+'"];Gwindow.savedrooms.splice(Gwindow.savedrooms.indexOf('+keys[i]+'),1);';
  4026. 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.");
  4027. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  4028. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  4029. Laster_message = lastmessage();
  4030. }
  4031. }
  4032. return "";
  4033. }
  4034. else if (chat_val.substring(1,15)=="clearsavedroom"){
  4035. if(savedrooms.length == 0){
  4036. displayInChat("You do not have any saved rooms.","#DA0808","#1EBCC1");
  4037. return "";
  4038. }
  4039. else{
  4040. var keys = Object.keys(savedroomsdata);
  4041. for(var i = 0;i<keys.length;i++){
  4042. savedrooms.splice(savedrooms.indexOf(parseInt(keys[i])),1);
  4043. delete savedroomsdata[keys[i]];
  4044. }
  4045. }
  4046. return "";
  4047. }
  4048. else if (chat_val.substring(1,10)=="followcam"){
  4049. if(FollowCam == true){
  4050. displayInChat("Follow Camera is now off.","#DA0808","#1EBCC1");
  4051. FollowCam = false;
  4052. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4053. var addto = {"children":[]};
  4054. for(var i = 0;i<parentDraw.children.length;i++){
  4055. if(parentDraw.children[i].constructor.name == "e"){
  4056. addto = parentDraw.children[i];
  4057. break;
  4058. }
  4059. }
  4060. var canv = 0;
  4061. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  4062. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  4063. canv = Gdocument.getElementById("gamerenderer").children[i];
  4064. break;
  4065. }
  4066. }
  4067. var width = parseInt(canv.style["width"]);
  4068. var height = parseInt(canv.style["height"]);
  4069. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  4070. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  4071. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  4072. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  4073. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  4074. pixiCircle.visible = false;
  4075. }
  4076. else{
  4077. pixiCircle.visible = true;
  4078. }
  4079. }
  4080. }
  4081. else{
  4082. displayInChat("Follow Camera is now on.","#DA0808","#1EBCC1");
  4083. FollowCam = true;
  4084. }
  4085. return "";
  4086. }
  4087. else if (chat_val.substring(1,8)=="autocam"){
  4088. if(autocam == true){
  4089. displayInChat("Auto Cam is now off.","#DA0808","#1EBCC1");
  4090. autocam = false
  4091. }
  4092. else{
  4093. displayInChat("Auto Cam is now on.","#DA0808","#1EBCC1");
  4094. autocam = true;
  4095. }
  4096. return "";
  4097. }
  4098. else if (chat_val.substring(1,4)=="pan"){
  4099. if(pan_enabled == true){
  4100. displayInChat("Pan is now off.","#DA0808","#1EBCC1");
  4101. pan_enabled = false;
  4102. pan = {"x":0,"y":0};
  4103. }
  4104. else{
  4105. displayInChat("Pan is now on. Shift + Arrow Keys to pan.","#DA0808","#1EBCC1");
  4106. pan_enabled = true;
  4107. }
  4108. return "";
  4109. }
  4110. else if (chat_val.substring(1,9)=="resetpan"){
  4111. pan = {"x":0,"y":0};
  4112. displayInChat("Reset pan.","#DA0808","#1EBCC1");
  4113. return "";
  4114. }
  4115. else if (chat_val.substring(1,7)=="aimbot"){
  4116. if(aimbot == true){
  4117. displayInChat("Aimbot is now off.","#DA0808","#1EBCC1");
  4118. aimbot = false;
  4119. }
  4120. else{
  4121. displayInChat("Aimbot is now on.","#DA0808","#1EBCC1");
  4122. aimbot = true;
  4123. getplayerkeys();
  4124. }
  4125. return "";
  4126. }
  4127. else if (chat_val.substring(1,8)=="volume " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  4128. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  4129. if(!isNaN(parseInt(text))){
  4130. int_text = parseInt(text);
  4131. if(int_text>=0 && int_text<=100){
  4132. jukeboxplayer.volume = int_text/100;
  4133. jukeboxplayervolume = int_text;
  4134. displayInChat("Jukebox volume set to: "+int_text.toString()+" percent.","#DA0808","#1EBCC1");
  4135. }
  4136. else{
  4137. displayInChat("Volume must be between 0 and 100 percent.","#DA0808","#1EBCC1");
  4138. }
  4139. }
  4140. return "";
  4141. }
  4142. else if (chat_val.substring(1,6)=="still"){
  4143. if(staystill == true){
  4144. displayInChat("Still is now off.","#DA0808","#1EBCC1");
  4145. staystill = false;
  4146. staystillpos = [0,0];
  4147. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  4148. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  4149. }
  4150. else{
  4151. if(playerids[myid].playerData?.transform){
  4152. displayInChat("Still is now on.","#DA0808","#1EBCC1");
  4153. staystill = true;
  4154. staystillpos = [playerids[myid].playerData.transform.position.x/scale,playerids[myid].playerData.transform.position.y/scale];
  4155. getplayerkeys();
  4156. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  4157. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  4158. }
  4159. else{
  4160. displayInChat("You have to be alive to use this command.","#DA0808","#1EBCC1");
  4161. }
  4162. }
  4163. return "";
  4164. }
  4165. else if (chat_val.substring(1,9)=="heavybot"){
  4166. if(heavybot == true){
  4167. displayInChat("Heavy bot is now off.","#DA0808","#1EBCC1");
  4168. heavybot = false;
  4169. }
  4170. else{
  4171. displayInChat("Heavy bot is now on.","#DA0808","#1EBCC1");
  4172. heavybot = true;
  4173. getplayerkeys();
  4174. }
  4175. return "";
  4176. }
  4177. else if (chat_val.substring(1,5)=="xray"){
  4178. Gdocument.getElementById("pretty_top_settings").click();
  4179. Gdocument.getElementById("settings_close").click();
  4180. if(Gdocument.getElementById("settings_graphicsquality").value==1){
  4181. displayInChat("You must have medium or high quality enabled to use this feature.","#DA0808","#1EBCC1");
  4182. return "";
  4183. }
  4184. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4185. var addto = {"children":[]};
  4186. for(var i = 0;i<parentDraw.children.length;i++){
  4187. if(parentDraw.children[i].constructor.name == "e"){
  4188. addto = parentDraw.children[i];
  4189. break;
  4190. }
  4191. }
  4192. var addto2 = {"children":[]};
  4193. for(var i = 0;i<addto.children.length;i++){
  4194. if(addto.children[i].constructor.name == "e"){
  4195. addto2 = addto.children[i];
  4196. break;
  4197. }
  4198. }
  4199. var checkxray = addto2.children[0];
  4200. var addto3 = addto2.children[0].children;
  4201. if(addto3.length==1){
  4202. checkxray = checkxray.children[0];
  4203. addto3 = addto3[0].children;
  4204. }
  4205. var xrayon = false;
  4206. if(checkxray.xrayon){
  4207. checkxray.xrayon = false;
  4208. xrayon = false;
  4209. }
  4210. else{
  4211. checkxray.xrayon = true;
  4212. xrayon = true;
  4213. }
  4214. if(xrayon){
  4215. displayInChat("Xray is now on.","#DA0808","#1EBCC1");
  4216. for(var i = 0;i<addto3.length;i++){
  4217. if(addto3[i].children.length>0){
  4218. var ids = [];
  4219. var ids2 = [];
  4220. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  4221. addto3[i].children[i3].visible = false;
  4222. if(addto3[i].children[i3].children.length>0){
  4223. for(var i4 = 0;i4<addto3[i].children[i3].children.length;i4++){
  4224. if(addto3[i].children[i3].children[i4].geometry?.id){
  4225. ids.push(addto3[i].children[i3].children[i4].geometry.id);
  4226. }
  4227. else if(addto3[i].children[i3].children[i4].texture?.baseTexture?.uid){
  4228. ids2.push(addto3[i].children[i3].children[i4].texture.baseTexture.uid);
  4229. }
  4230. }
  4231. }
  4232. }
  4233. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  4234. if(addto3[i].children[i3].children.length==0){
  4235. if(addto3[i].children[i3].geometry?.id){
  4236. if(ids.includes(addto3[i].children[i3].geometry.id+1)){
  4237. addto3[i].children[i3].visible = true;
  4238. addto3[i].children[i3].alpha = 0.5;
  4239. }
  4240. }
  4241. else if(addto3[i].children[i3].texture?.baseTexture?.uid){
  4242. if(ids2.includes(addto3[i].children[i3].texture.baseTexture.uid+1)){
  4243. addto3[i].children[i3].visible = true;
  4244. addto3[i].children[i3].alpha = 0.5;
  4245. }
  4246. }
  4247. }
  4248. }
  4249. }
  4250. }
  4251. }
  4252. else{
  4253. displayInChat("Xray is now off.","#DA0808","#1EBCC1");
  4254. for(var i = 0;i<addto3.length;i++){
  4255. for(var i2 = 0;i2<addto3[i].children.length;i2++){
  4256. addto3[i].children[i2].visible = true;
  4257. addto3[i].children[i2].alpha = 1;
  4258. }
  4259. }
  4260. }
  4261. }
  4262. return "";
  4263. }
  4264. else if (chat_val.substring(1,6)=="zoom "){
  4265. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  4266. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4267. var addto = 0;
  4268. for(var i = 0;i<parentDraw.children.length;i++){
  4269. if(parentDraw.children[i].constructor.name == "e"){
  4270. addto = parentDraw.children[i];
  4271. break;
  4272. }
  4273. }
  4274. var canv = 0;
  4275. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  4276. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  4277. canv = Gdocument.getElementById("gamerenderer").children[i];
  4278. break;
  4279. }
  4280. }
  4281. var width = parseInt(canv.style["width"]);
  4282. var height = parseInt(canv.style["height"]);
  4283. if(addto){
  4284. if(text == "in"){
  4285. zoom *= 1.1;
  4286. }
  4287. else if(text == "out"){
  4288. zoom /= 1.1;
  4289. }
  4290. else if(text == "reset"){
  4291. zoom = 1;
  4292. }
  4293. else{
  4294. displayInChat("Options for zooming:","#DA0808","#1EBCC1");
  4295. displayInChat("in","#DA0808","#1EBCC1");
  4296. displayInChat("out","#DA0808","#1EBCC1");
  4297. displayInChat("reset","#DA0808","#1EBCC1");
  4298. return "";
  4299. }
  4300. addto.scale.x=zoom;
  4301. addto.scale.y=zoom;
  4302. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  4303. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  4304. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  4305. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  4306. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  4307. pixiCircle.visible = false;
  4308. }
  4309. else{
  4310. pixiCircle.visible = true;
  4311. }
  4312. }
  4313. }
  4314. return "";
  4315. }
  4316. else if (chat_val.substring(1,9)=="hidechat"){
  4317. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  4318. return "";
  4319. }
  4320. else if (chat_val.substring(1,9)=="showchat"){
  4321. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  4322. return "";
  4323. }
  4324. else if (chat_val.substring(1,6)=="score"){
  4325. var element = Gdocument.getElementById("ingamewinner_scores");
  4326. if(element.style["opacity"]<1){
  4327. element.style["opacity"] = 1;
  4328. element.style["visibility"] = "visible";
  4329. }
  4330. else{
  4331. element.style["opacity"] = 0;
  4332. element.style["visibility"] = "unset";
  4333. }
  4334. return "";
  4335. }
  4336. else if (chat_val.substring(1,7)=="scroll"){
  4337. if(scroll==false){
  4338. scroll = true;
  4339. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="scroll";
  4340. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  4341. }
  4342. else if(scroll==true){
  4343. scroll = false;
  4344. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="hidden";
  4345. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  4346. }
  4347. return "";
  4348. }
  4349. else if (chat_val.substring(1,7)=="chatw "){
  4350. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  4351. if(username == text){
  4352. displayInChat("You cannot private chat with yourself.","#DA0808","#1EBCC1");
  4353. return "";
  4354. }
  4355. private_chat = text;
  4356. SEND("42"+JSON.stringify([4,{"type":"request public key","from":username,"to":private_chat}]));
  4357. request_public_key_time_stamp = Date.now();
  4358. 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);
  4359. return "";
  4360. }
  4361. else if (chat_val.substring(1,8)=="lagbot " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  4362. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  4363. if(!isNaN(parseInt(text))){
  4364. int_text = parseInt(text);
  4365. if(int_text == 0){
  4366. causelag = false;
  4367. causelag2 = 0;
  4368. displayInChat("Lagbot is now off.","#DA0808","#1EBCC1");
  4369. displayInChat("To enable lagbot, type '/lagbot [number]' with a number between 1 and 10.","#DA0808","#1EBCC1");
  4370. }
  4371. else if(int_text>0 && int_text<=10){
  4372. causelag = true;
  4373. causelag2 = 45*int_text;
  4374. displayInChat("Lagbot is now on with a lag setting of "+int_text.toString()+" (~"+(45*int_text).toString()+"MS).","#DA0808","#1EBCC1");
  4375. displayInChat("Type '/lagbot 0' to turn off lagbot.","#DA0808","#1EBCC1");
  4376. }
  4377. else{
  4378. displayInChat("To enable lagbot, type '/lagbot [number]' with a number between 1 and 10.","#DA0808","#1EBCC1");
  4379. displayInChat("Type '/lagbot 0' to turn off lagbot.","#DA0808","#1EBCC1");
  4380. }
  4381. return "";
  4382. }
  4383. }
  4384. else if (chat_val.substring(1,8)=="record " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  4385. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  4386. var keys = Object.keys(playerids);
  4387. var recordingid2 = -1;
  4388. for(var i = 0;i<keys.length;i++){
  4389. if(playerids[keys[i]].userName == text){
  4390. recordingid2 = keys[i];
  4391. }
  4392. }
  4393. if(recordingid2 == -1){
  4394. displayInChat("Player not found. Please type a valid username.","#DA0808","#1EBCC1");
  4395. return "";
  4396. }
  4397. else{
  4398. recording = true;
  4399. recordingid = recordingid2;
  4400. displayInChat(playerids[recordingid].userName+" is now being recorded.","#DA0808","#1EBCC1");
  4401. if(recordingdata.length>0){
  4402. displayInChat("Any unsaved recording data is now cleared.","#DA0808","#1EBCC1");
  4403. }
  4404. recordingdata = [];
  4405. }
  4406. return "";
  4407. }
  4408. else if (chat_val.substring(1,11)=="stoprecord"){
  4409. if(recording){
  4410. displayInChat(playerids[recordingid].userName+" is not being recorded anymore.","#DA0808","#1EBCC1");
  4411. displayInChat("Type '/saverecording [text]' to save this recording.","#DA0808","#1EBCC1");
  4412. recording = false;
  4413. recordingid = -1;
  4414. recordingdata[0][1] = 0;
  4415. }
  4416. else{
  4417. displayInChat("No one is being recorded.","#DA0808","#1EBCC1");
  4418. }
  4419. return "";
  4420. }
  4421. else if (chat_val.substring(1,15)=="saverecording " && chat_val.replace(/^\s+|\s+$/g, '').length>=16){
  4422. var text = chat_val.substring(15).replace(/^\s+|\s+$/g, '');
  4423. if(Object.keys(recorddata).includes(text)){
  4424. displayInChat("This recording already exists. Please use a different name or type '/delrecording "+text+"'.","#DA0808","#1EBCC1");
  4425. }
  4426. else if(recordingdata.length>0){
  4427. recorddata[text] = JSON.parse(JSON.stringify(recordingdata));
  4428. displayInChat("Recording saved as: "+text,"#DA0808","#1EBCC1");
  4429. }
  4430. else{
  4431. displayInChat("There is no recording data to save. Please record data using '/record [username]'","#DA0808","#1EBCC1");
  4432. }
  4433. return "";
  4434. }
  4435. else if (chat_val.substring(1,14)=="delrecording " && chat_val.replace(/^\s+|\s+$/g, '').length>=15){
  4436. var text = chat_val.substring(14).replace(/^\s+|\s+$/g, '');
  4437. if(Object.keys(recorddata).includes(text)){
  4438. displayInChat("Recording deleted.","#DA0808","#1EBCC1");
  4439. delete recorddata[text];
  4440. }
  4441. else{
  4442. displayInChat("This recording does not exist.","#DA0808","#1EBCC1");
  4443. }
  4444. return "";
  4445. }
  4446. else if (chat_val.substring(1,15)=="loadrecording " && chat_val.replace(/^\s+|\s+$/g, '').length>=16){
  4447. var text = chat_val.substring(15).replace(/^\s+|\s+$/g, '');
  4448. if(!Object.keys(recorddata).includes(text)){
  4449. displayInChat("This recording does not exist.","#DA0808","#1EBCC1");
  4450. }
  4451. else{
  4452. if(recordingdata.length>0){
  4453. displayInChat("Any unsaved recording data is now cleared.","#DA0808","#1EBCC1");
  4454. }
  4455. recordingdata = JSON.parse(JSON.stringify(recorddata[text]));
  4456. displayInChat("Recording data is now loaded.","#DA0808","#1EBCC1");
  4457. }
  4458. return "";
  4459. }
  4460. else if (chat_val.substring(1,7)=="replay"){
  4461. if(recording){
  4462. displayInChat(playerids[recordingid].userName+" is not being recorded anymore.","#DA0808","#1EBCC1");
  4463. displayInChat("Type '/saverecording [text]' to save this recording.","#DA0808","#1EBCC1");
  4464. recordingid = -1;
  4465. recording = false;
  4466. recordingdata[0][1] = 0;
  4467. }
  4468. replay();
  4469. return "";
  4470. }
  4471. else if (chat_val.substring(1,5)=="msg " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  4472. if(private_chat_public_key[1][0] != 0 && private_chat_public_key[1][1] != 0 && private_chat_public_key[0] == private_chat){
  4473. var text = chat_val.substring(5).replace(/^\s+|\s+$/g, '');
  4474. pmlastmessage = text.slice(0,400);
  4475. ENCRYPT_MESSAGE(private_chat_public_key[1],text).then(function(e){
  4476. SEND("42"+JSON.stringify([4,{"type":"private chat","from":username,"to":private_chat,"message":e}]));
  4477. });
  4478. displayInChat("> "+username+": ","#DA0808","#1EBCC1",{sanitize:false},text,false);
  4479. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  4480. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  4481. Laster_message = lastmessage();
  4482. }
  4483. return "";
  4484. }
  4485. else if (chat_val.substring(1,10)=="ignorepm " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  4486. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  4487. if(ignorepmlist.includes(text)){
  4488. var index = ignorepmlist.indexOf(text);
  4489. ignorepmlist.splice(index,1);
  4490. displayInChat("You are not ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  4491. }
  4492. else{
  4493. ignorepmlist.push(text);
  4494. displayInChat("You are now ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  4495. }
  4496. return "";
  4497. }
  4498. else if (chat_val.substring(1,8)=="pmusers"){
  4499. pmusers = [];
  4500. SEND("42"+JSON.stringify([4,{"type":"request private chat users","from":username}]));
  4501. pmuserstimestamp = Date.now();
  4502. setTimeout(function(){if(pmusers.length == 0){displayInChat("You cannot private chat with anyone.","#DA0808","#1EBCC1");
  4503. }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);
  4504. return "";
  4505. }
  4506. else if (chat_val.substring(1,6)=="lobby"){
  4507. lobby();
  4508. return "";
  4509. }
  4510. else if (chat_val.substring(1,7)=="style " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  4511. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  4512. var text2 = text.split(" ");
  4513. var array = [];
  4514. for(var i = 0;i<text2.length;i++){
  4515. var parsed = parseInt(text2[i]);
  4516. if(!isNaN(parsed)){
  4517. array.push(parsed);
  4518. }
  4519. }
  4520. if(array[0]+array[1]+array[2] == 0){
  4521. array = [1,1,1];
  4522. }
  4523. if(array.length == 3){
  4524. SEND("42"+JSON.stringify([4,{"type":"style","from":username,"style":array}]));
  4525. allstyles[username] = array;
  4526. mystyle = [...array];
  4527. displayInChat("Set style to ("+array.toString()+"). Type '/style' to reset style.","#DA0808","#1EBCC1");
  4528. }
  4529. else{
  4530. 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");
  4531. }
  4532. return "";
  4533. }
  4534. else if (chat_val.substring(1,6)=="style"){
  4535. SEND("42"+JSON.stringify([4,{"type":"style","from":username,"style":[0,0,0]}]));
  4536. allstyles[username] = [0,0,0];
  4537. mystyle = [0,0,0];
  4538. displayInChat("Reset style.","#DA0808","#1EBCC1");
  4539. return "";
  4540. }
  4541. else if (chat_val.substring(1,6)=="lobby"){
  4542. lobby();
  4543. return "";
  4544. }
  4545. else if (chat_val.substring(1,9)=="debugger"){
  4546. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  4547. debuggeropen = true;
  4548. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  4549. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  4550. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  4551. }
  4552. else{
  4553. debuggeropen = false;
  4554. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  4555. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  4556. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  4557. }
  4558. return "";
  4559. }
  4560. else if (chat_val.substring(1,6)=="team " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  4561. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  4562. if(text == "r"){Gdocument.getElementById("newbonklobby_redbutton").click();}
  4563. else if(text == "g"){Gdocument.getElementById("newbonklobby_greenbutton").click();}
  4564. else if(text == "y"){Gdocument.getElementById("newbonklobby_yellowbutton").click();}
  4565. else if(text == "b"){Gdocument.getElementById("newbonklobby_bluebutton").click();}
  4566. else if(text == "s"){Gdocument.getElementById("newbonklobby_specbutton").click();}
  4567. else if(text == "f"){Gdocument.getElementById("newbonklobby_ffabutton").click();}
  4568. return "";
  4569. }
  4570. else if (chat_val.substring(1,7)=="notify"){
  4571. npermissions = 1;
  4572. return "";
  4573. }
  4574. else if (chat_val.substring(1,11)=="stopnotify"){
  4575. npermissions = 0;
  4576. return "";
  4577. }
  4578. else if (chat_val.substring(1,8)=="support"){
  4579. displayInChat("Thanks everyone for helping me make this mod - LEGENDBOSS123","#0000FF","#FFFFFF");
  4580. displayInChat("mastery3","#0000FF","#FFFFFF");
  4581. displayInChat("UnmatchedBracket aka Left Paren","#0000FF","#FFFFFF");
  4582. displayInChat("iNeonz","#0000FF","#FFFFFF");
  4583. return "";
  4584. }
  4585. else if (chat_val.substring(1,9)=="pollstat"){
  4586. if(pollactive[0] || pollactive2[0]){
  4587. var count = [0,0,0,0];
  4588. var keys = Object.keys(playerids);
  4589. for(var i = 0;i<keys.length;i++){
  4590. if(ishost){
  4591. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  4592. count[playerids[keys[i]].vote.poll]++;
  4593. }
  4594. }
  4595. else{
  4596. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive2[2].length-1){
  4597. count[playerids[keys[i]].vote.poll]++;
  4598. }
  4599. }
  4600. }
  4601. for(var i = 0;i<count.length;i++){
  4602. if(count[i]>1){
  4603. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  4604. }
  4605. if(count[i]==1){
  4606. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  4607. }
  4608. }
  4609. if(ishost){
  4610. displayInChat("The poll will end in: "+((pollactive[2]-Date.now())/1000).toString()+" seconds.","#DA0808","#1EBCC1");
  4611. }
  4612. displayInChat("The poll is:","#DA0808","#1EBCC1");
  4613. if(ishost){
  4614. for(var i = 0;i<pollactive[3].length;i++){
  4615. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  4616. }
  4617. }
  4618. else{
  4619. for(var i = 0;i<pollactive2[2].length;i++){
  4620. displayInChat(letters[i]+") "+pollactive2[2][i],"#DA0808","#1EBCC1");
  4621. }
  4622. }
  4623. }
  4624. else{
  4625. displayInChat("No poll has been started.","#DA0808","#1EBCC1");
  4626. if(ishost){
  4627. displayInChat("Type '/startpoll [seconds]' to start a poll.","#DA0808","#1EBCC1");
  4628. if(poll.length>0){
  4629. displayInChat("The poll is:","#DA0808","#1EBCC1");
  4630. for(var i = 0;i<poll.length;i++){
  4631. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  4632. }
  4633. }
  4634. }
  4635. }
  4636. return "";
  4637. }
  4638. else if (chat_val.substring(1,5)=="help" || chat_val.substring(1,2)=="?"){
  4639. for(var i = 0;i<help.length;i++){
  4640. if(help[i].startsWith("/")){
  4641. var splitted = help[i].substring(1).split(" ");
  4642. var command = splitted[0];
  4643. var rest = "";
  4644. if(splitted.length>1){
  4645. rest = " "+splitted.slice(1).join(" ");
  4646. }
  4647. displayInChat("/"+'<a onclick = \'Gwindow.displayadvhelp("'+command+'");\' style = "color:green;" href = "javascript:void(0);">'+command+'</a>'+rest,"#DA0808","#1EBCC1",{sanitize:false},"",false);
  4648. }
  4649. else if(help[i].startsWith("Alt ")){
  4650. displayInChat('<a onclick = \'Gwindow.displayadvhelp("'+help[i]+'");\' style = "color:green;" href = "javascript:void(0);">'+help[i]+'</a>',"#DA0808","#1EBCC1",{sanitize:false},"",false);
  4651. }
  4652. else{
  4653. displayInChat(help[i],"#DA0808","#1EBCC1");
  4654. }
  4655. }
  4656. return "";
  4657. }
  4658. else if (chat_val.substring(1,9)=="advhelp " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  4659. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  4660. if(typeof(adv_help[text])!='undefined'){
  4661. displayInChat(adv_help[text],"#DA0808","#1EBCC1");
  4662. }
  4663. return "";
  4664. }
  4665. else if (chat_val.substring(1,6)=="mode " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  4666. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  4667. var mode = "";
  4668. var text2 = text;
  4669. if(text == "arrows"){
  4670. text2 = "Arrows";
  4671. mode = "ar";
  4672. }
  4673. else if(text == "death arrows"){
  4674. mode = "ard";
  4675. text2 = "Death Arrows";
  4676. }
  4677. else if(text == "grapple"){
  4678. mode = "sp";
  4679. text2 = "Grapple";
  4680. }
  4681. else if(text == "classic"){
  4682. mode = "b";
  4683. text2 = "Classic";
  4684. }
  4685. else{
  4686. displayInChat("Mode options:","#DA0808","#1EBCC1");
  4687. displayInChat("classic","#DA0808","#1EBCC1");
  4688. displayInChat("arrows","#DA0808","#1EBCC1");
  4689. displayInChat("death arrows","#DA0808","#1EBCC1");
  4690. displayInChat("grapple","#DA0808","#1EBCC1");
  4691. }
  4692. if(mode != ""){
  4693. if(ishost){
  4694. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  4695. RECIEVE('42[26,"b","'+mode+'"]');
  4696. displayInChat("Changed mode to "+text+".","#DA0808","#1EBCC1");
  4697. }
  4698. else{
  4699. if(playerids[myid].ratelimit.mode+1000<Date.now()){
  4700. playerids[myid].ratelimit.mode=Date.now();
  4701. SEND("42"+JSON.stringify([4,{"type":"request mode","from":username,"mode":mode}]));
  4702. var code = 'if(!Gwindow.ishost){Gwindow.displayInChat("You must be host to change the mode.","#DA0808","#1EBCC1",{sanitize:false},"",true)}else{Gwindow.changemode("'+mode+'")}';
  4703. displayInChat('> '+username+' requests [<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+text2+'</a>]',"#DA0808","#1EBCC1",{sanitize:false}," mode.");
  4704. }
  4705. else{
  4706. displayInChat("You are requesting modes too quickly.","#DA0808","#1EBCC1");
  4707. }
  4708. }
  4709. }
  4710. return "";
  4711. }
  4712. else if(ishost){
  4713. if (chat_val.substring(1,11)=="nextafter " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  4714. var text = parseFloat(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  4715. if(isNaN(text)){
  4716. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  4717. return "";
  4718. }
  4719. else if(text<=0){
  4720. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  4721. return "";
  4722. }
  4723. nextafter = text;
  4724. displayInChat("Set next after to: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  4725. displayInChat("Type '/nextafter' to reset next after.","#DA0808","#1EBCC1");
  4726. return "";
  4727. }
  4728. else if (chat_val.substring(1,10)=="nextafter"){
  4729. nextafter = 0;
  4730. displayInChat("Reset next after.","#DA0808","#1EBCC1");
  4731. return "";
  4732. }
  4733. else if (chat_val.substring(1,5)=="next" && stopquickplay == 0){
  4734. roundsperqp2 = 0;
  4735. if(shuffle){
  4736. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4737. var available = [];
  4738. var availableindexes = [];
  4739. var notempty = false;
  4740. for(var i = 0; i<e.length;i++){
  4741. var a = false;
  4742. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4743. available.push(a);
  4744. if(a){
  4745. availableindexes.push(i);
  4746. notempty = true;
  4747. }
  4748. }
  4749. if(notempty){
  4750. if(availableindexes.length!=1){
  4751. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  4752. }
  4753. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  4754. }
  4755. }
  4756. else{
  4757. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4758. var available = [];
  4759. var availableindexes = [];
  4760. var notempty = false;
  4761. for(var i = 0; i<e.length;i++){
  4762. var a = false;
  4763. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4764. available.push(a);
  4765. if(a){
  4766. availableindexes.push(i);
  4767. notempty = true;
  4768. }
  4769. }
  4770. if(notempty){
  4771. var above = [];
  4772. for(var i = 0;i<availableindexes.length;i++){
  4773. if(availableindexes[i]>quicki && !reverseqp){
  4774. above.push(availableindexes[i]);
  4775. }
  4776. else if(availableindexes[i]<quicki && reverseqp){
  4777. above.push(availableindexes[i])
  4778. }
  4779. }
  4780. if(above.length>0){
  4781. quicki = above[0];
  4782. if(reverseqp){
  4783. quicki = above[above.length-1];
  4784. }
  4785. }
  4786. else{
  4787. quicki = availableindexes[0];
  4788. if(reverseqp){
  4789. quicki = availableindexes[availableindexes.length-1];
  4790. }
  4791. }
  4792. }
  4793. }
  4794. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  4795. displayInChat("Switched to next map.","#DA0808","#1EBCC1");
  4796. return "";
  4797. }
  4798. else if (chat_val.substring(1,9)=="freejoin"){
  4799. if(freejoin == false){
  4800. freejoin = true;
  4801. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  4802. }
  4803. else{
  4804. freejoin = false;
  4805. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  4806. }
  4807. return "";
  4808. }
  4809. else if (chat_val.substring(1,8)=="instaqp"){
  4810. if(instaqp == false){
  4811. instaqp = true;
  4812. displayInChat("Instaqp is now on.","#DA0808","#1EBCC1");
  4813. }
  4814. else{
  4815. instaqp = false;
  4816. displayInChat("Instaqp is now off.","#DA0808","#1EBCC1");
  4817. }
  4818. return "";
  4819. }
  4820. else if (chat_val.substring(1,9)=="previous" && stopquickplay == 0){
  4821. roundsperqp2 = 0;
  4822. if(shuffle){
  4823. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4824. var available = [];
  4825. var availableindexes = [];
  4826. var notempty = false;
  4827. for(var i = 0; i<e.length;i++){
  4828. var a = false;
  4829. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4830. available.push(a);
  4831. if(a){
  4832. availableindexes.push(i);
  4833. notempty = true;
  4834. }
  4835. }
  4836. if(notempty){
  4837. if(availableindexes.length!=1){
  4838. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  4839. }
  4840. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  4841. }
  4842. }
  4843. else{
  4844. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4845. var available = [];
  4846. var availableindexes = [];
  4847. var notempty = false;
  4848. for(var i = 0; i<e.length;i++){
  4849. var a = false;
  4850. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4851. available.push(a);
  4852. if(a){
  4853. availableindexes.push(i);
  4854. notempty = true;
  4855. }
  4856. }
  4857. if(notempty){
  4858. var above = [];
  4859. for(var i = 0;i<availableindexes.length;i++){
  4860. if(availableindexes[i]<quicki && !reverseqp){
  4861. above.push(availableindexes[i]);
  4862. }
  4863. else if(availableindexes[i]>quicki && reverseqp){
  4864. above.push(availableindexes[i])
  4865. }
  4866. }
  4867. if(above.length>0){
  4868. quicki = above[above.length-1];
  4869. if(reverseqp){
  4870. quicki = above[0];
  4871. }
  4872. }
  4873. else{
  4874. quicki = availableindexes[availableindexes.length-1];
  4875. if(reverseqp){
  4876. quicki = availableindexes[0];
  4877. }
  4878. }
  4879. }
  4880. }
  4881. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  4882. displayInChat("Switched to previous map.","#DA0808","#1EBCC1");
  4883. return "";
  4884. }
  4885. else if (chat_val.substring(1,6)=="start" && chat_val.length == 6){
  4886. if(Gdocument.getElementById("mapeditorcontainer").style["display"]!="block"){
  4887. Gdocument.getElementById("newbonklobby_editorbutton").click();
  4888. }
  4889. if(recmodebool && ishost){
  4890. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  4891. if(mode == "" && defaultmode!="d"){
  4892. mode = defaultmode;
  4893. }
  4894. if(mode != ""){
  4895. RECIEVE('42[26,"b","'+mode+'"]');
  4896. }
  4897. }
  4898. Gdocument.getElementById("mapeditor_close").click();
  4899. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  4900. roundsperqp2 = 0;
  4901. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  4902. return "";
  4903. }
  4904. else if (chat_val.substring(1,8)=="startqp" && stopquickplay == 1){
  4905. stopquickplay = 0;
  4906. quicki = 0;
  4907. qppaused = false;
  4908. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  4909. return "";
  4910. }
  4911. else if (chat_val.substring(1,7)=="stopqp" && stopquickplay == 0){
  4912. stopquickplay = 1;
  4913. quicki = 0;
  4914. qppaused = false;
  4915. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  4916. return "";
  4917. }
  4918. else if (chat_val.substring(1,8)=="pauseqp" && stopquickplay == 0){
  4919. if(qppaused == false){
  4920. qppaused = true;
  4921. displayInChat("Paused quickplay.","#DA0808","#1EBCC1");
  4922. }
  4923. else{
  4924. qppaused = false;
  4925. displayInChat("Unpaused quickplay.","#DA0808","#1EBCC1");
  4926. }
  4927. return "";
  4928. }
  4929. else if (chat_val.substring(1,6)=="revqp" && stopquickplay == 0){
  4930. if(reverseqp == false){
  4931. reverseqp = true;
  4932. displayInChat("Reverseqp is now on..","#DA0808","#1EBCC1");
  4933. }
  4934. else{
  4935. reverseqp = false;
  4936. displayInChat("Reverseqp is now off.","#DA0808","#1EBCC1");
  4937. }
  4938. return "";
  4939. }
  4940. else if (chat_val.substring(1,9)=="jukebox " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  4941. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  4942. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":text,"timestamp":Date.now()+2000,"to":[-1]}]));
  4943. displayInChat("Jukebox is loading... Please wait a few seconds.","#DA0808","#1EBCC1");
  4944. changeJukeboxURL(text,Date.now()+2000);
  4945. return "";
  4946. }
  4947. else if (chat_val.substring(1,13)=="pausejukebox"){
  4948. if(jukeboxplayer.src!="" && !jukeboxplayer.paused){
  4949. displayInChat("Jukebox is now paused.","#DA0808","#1EBCC1");
  4950. jukeboxplayer.pause();
  4951. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":"","timestamp":Date.now(),"to":[-1]}]));
  4952. }
  4953. return "";
  4954. }
  4955. else if (chat_val.substring(1,13)=="resetjukebox"){
  4956. if(jukeboxplayer.src!=""){
  4957. jukeboxplayer.currentTime = 0;
  4958. displayInChat("Jukebox has reset.","#DA0808","#1EBCC1");
  4959. changeJukeboxURL(jukeboxplayerURL,Date.now()+2000);
  4960. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":jukeboxplayerURL,"timestamp":Date.now()+2000,"to":[-1]}]));
  4961. }
  4962. return "";
  4963. }
  4964. else if (chat_val.substring(1,12)=="playjukebox"){
  4965. if(jukeboxplayer.src!="" && jukeboxplayer.paused){
  4966. changeJukeboxURL(jukeboxplayerURL,Date.now()-jukeboxplayer.currentTime*1000);
  4967. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":jukeboxplayerURL,"timestamp":Date.now()-jukeboxplayer.currentTime*1000,"to":[-1]}]));
  4968. }
  4969. return "";
  4970. }
  4971. else if (chat_val.substring(1,5)=="ban " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  4972. banned.push(chat_val.substring(5).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',""));
  4973. displayInChat("Banned "+chat_val.substring(5).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"")+".","#DA0808","#1EBCC1");
  4974. return "/kick '" + chat_val.substring(5).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"") + "'";
  4975. }
  4976. else if (chat_val.substring(1,6)=="kill " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  4977. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  4978. var keys = Object.keys(playerids);
  4979. var killid = undefined;
  4980. for(var i = 0; i<keys.length; i++){
  4981. if(playerids[keys[i]].userName == text){
  4982. killid = keys[i];
  4983. }
  4984. }
  4985. if(typeof(killid)!="undefined" && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(killid)){
  4986. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  4987. killedids.push(killid);
  4988. SEND('42[25,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  4989. RECIEVE('42[31,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  4990. }
  4991. return "";
  4992. }
  4993. else if (chat_val.substring(1,6)=="killA"){
  4994. var keys = Object.keys(playerids);
  4995. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4996. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  4997. SEND('42[25,{"a":{"playersLeft":['+keys.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  4998. RECIEVE('42[31,{"a":{"playersLeft":['+keys.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  4999. }
  5000. return "";
  5001. }
  5002. else if (chat_val.substring(1,10)=="balanceA " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  5003. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  5004. if(!isNaN(parseInt(text))){
  5005. if(parseInt(text)>=-100 && parseInt(text)<=100){
  5006. var keys = Object.keys(playerids);
  5007. for(var i = 0; i<keys.length;i++){
  5008. SEND('42[29,{"sid":'+keys[i]+',"bal":'+text+'}]');
  5009. RECIEVE('42[36,'+keys[i]+','+text+']');
  5010. }
  5011. }
  5012. }
  5013. return "";
  5014. }
  5015. else if (chat_val.substring(1, 10) == "brighten " && chat_val.replace(/^\s+|\s+$/g, '').length >= 11) {
  5016. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  5017. if (!isNaN(parseFloat(text))) {
  5018. var intText = parseFloat(text);
  5019. var f = function(x){
  5020. return x * intText;
  5021. }
  5022. loadMap(changeColor(currentmap[currentmap.length-1], f,f,f));
  5023. }
  5024. return "";
  5025. }
  5026. else if (chat_val.substring(1, 12) == "colorshift " && chat_val.replace(/^\s+|\s+$/g, '').length >= 13) {
  5027. var text = chat_val.substring(12).replace(/^\s+|\s+$/g, '');
  5028. if (!isNaN(parseFloat(text))) {
  5029. var intText = parseFloat(text);
  5030. var seed = [Math.random()-0.5, Math.random()-0.5, Math.random()-0.5];
  5031. var f = function(x, ind){
  5032. return x * (1-(Math.abs(seed[ind]) * 2) ** 3) + seed[ind] * intText
  5033. }
  5034. loadMap(changeColor(currentmap[currentmap.length-1], f,f,f));
  5035. }
  5036. return "";
  5037. }
  5038. else if (chat_val.substring(1,10)=="balanceT " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  5039. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  5040. var text2 = text.split(" ").filter(function(e){if(e!=""){return true;}return false;});
  5041. if(text2.length!=2 || isNaN(parseInt(text2[1])) || !["s","r","b","y","g","f"].includes(text2[0])){
  5042. displayInChat("Please enter a team letter and a number to balance.","#DA0808","#1EBCC1");
  5043. return "";
  5044. }
  5045. var teamdict = {"s":0,"f":1,"r":2,"b":3,"g":4,"y":5};
  5046. if(parseInt(text2[1])>=-100 && parseInt(text2[1])<=100){
  5047. var keys = Object.keys(playerids);
  5048. for(var i = 0; i<keys.length;i++){
  5049. if(playerids[keys[i]].team == teamdict[text2[0]]){
  5050. SEND('42[29,{"sid":'+keys[i]+',"bal":'+text2[1]+'}]');
  5051. RECIEVE('42[36,'+keys[i]+','+text2[1]+']');
  5052. }
  5053. }
  5054. }
  5055. return "";
  5056. }
  5057. else if (chat_val.substring(1,10)=="resetpoll"){
  5058. poll = [];
  5059. displayInChat("The poll has been reset.","#DA0808","#1EBCC1");
  5060. return "";
  5061. }
  5062. else if (chat_val.substring(1,11)=="addoption " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5063. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  5064. if(text.length>50){
  5065. displayInChat("Your option is greater than 50 characters.","#DA0808","#1EBCC1");
  5066. return "";
  5067. }
  5068. if(poll.includes(text)){
  5069. displayInChat("This option already exists.","#DA0808","#1EBCC1");
  5070. }
  5071. else if(poll.length>=4){
  5072. displayInChat("Your poll already has the max 4 amounts of options.","#DA0808","#1EBCC1");
  5073. displayInChat("Type '/deloption [letter]' to remove a option.","#DA0808","#1EBCC1");
  5074. displayInChat("The poll is:","#DA0808","#1EBCC1");
  5075. for(var i = 0;i<poll.length;i++){
  5076. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  5077. }
  5078. }
  5079. else{
  5080. poll.push(text);
  5081. displayInChat("The poll is now:","#DA0808","#1EBCC1");
  5082. for(var i = 0;i<poll.length;i++){
  5083. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  5084. }
  5085. }
  5086. return "";
  5087. }
  5088. else if (chat_val.substring(1,11)=="deloption " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5089. var text = letters.indexOf(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  5090. if(text==-1 || text>=poll.length){
  5091. if(poll.length>0){
  5092. displayInChat("Available options are:","#DA0808","#1EBCC1");
  5093. for(var i = 0;i<poll.length;i++){
  5094. displayInChat(letters[i],"#DA0808","#1EBCC1");
  5095. }
  5096. }
  5097. else{
  5098. displayInChat("Your poll is empty.","#DA0808","#1EBCC1");
  5099. displayInChat("Type '/addoption [text]' to add an option.","#DA0808","#1EBCC1");
  5100. }
  5101. }
  5102. else{
  5103. poll.splice(text,1);
  5104. displayInChat("The poll is now:","#DA0808","#1EBCC1");
  5105. for(var i = 0;i<poll.length;i++){
  5106. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  5107. }
  5108. }
  5109. return "";
  5110. }
  5111. else if (chat_val.substring(1,11)=="startpoll " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5112. var text = parseFloat(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  5113. if(isNaN(text)){
  5114. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5115. return "";
  5116. }
  5117. else if(text<=0){
  5118. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5119. return "";
  5120. }
  5121. else if(text<10){
  5122. displayInChat("Your poll has to last for at least 10 seconds.","#DA0808","#1EBCC1");
  5123. return "";
  5124. }
  5125. if(pollactive[0]){
  5126. displayInChat("There is already an ongoing poll.","#DA0808","#1EBCC1");
  5127. displayInChat("Type '/endpoll' to end the poll.","#DA0808","#1EBCC1");
  5128. return "";
  5129. }
  5130. if(poll.length<2){
  5131. displayInChat("Your poll needs at least 2 options.","#DA0808","#1EBCC1");
  5132. displayInChat("Type '/addoption' to add to the poll.","#DA0808","#1EBCC1");
  5133. return "";
  5134. }
  5135. var now = Date.now();
  5136. pollactive = [true,now,now+text*1000,[...poll]];
  5137. playerids[myid].ratelimit.poll = now;
  5138. var chatpoll = [...poll];
  5139. chatpoll.push("Cancel vote.");
  5140. pollactive[3].push("Cancel vote.");
  5141. for(var i = 0;i<chatpoll.length;i++){
  5142. chatpoll[i] = letters[i]+") "+chatpoll[i];
  5143. }
  5144. chat(chatpoll.join("     "));
  5145. setTimeout(function(){
  5146. if(pollactive[0]){
  5147. SEND("42"+JSON.stringify([4,{"type":"poll","from":username,"poll":pollactive[3]}]));
  5148. var keys = Object.keys(playerids);
  5149. for(var i = 0;i<keys.length;i++){
  5150. playerids[keys[i]].vote.poll = -1;
  5151. }
  5152. displayInChat("The poll will end in: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  5153. displayInChat("Type '/endpoll' to end the poll early.","#DA0808","#1EBCC1");
  5154. }
  5155. },200);
  5156. return "";
  5157. }
  5158. else if (chat_val.substring(1,8)=="endpoll"){
  5159. if(pollactive[0]){
  5160. if(playerids[myid].ratelimit.poll+10000>Date.now()){
  5161. displayInChat("Your poll has to be at least 10 seconds.","#DA0808","#1EBCC1");
  5162. displayInChat("There are "+((playerids[myid].ratelimit.poll+10000-Date.now())/1000).toString()+" seconds left until you can end the poll early.","#DA0808","#1EBCC1");
  5163. return "";
  5164. }
  5165. playerids[myid].ratelimit.poll = Date.now();
  5166. SEND("42"+JSON.stringify([4,{"type":"poll end","from":username}]));
  5167. displayInChat("The poll ended.","#DA0808","#1EBCC1");
  5168. var count = [0,0,0,0];
  5169. var keys = Object.keys(playerids);
  5170. for(var i = 0;i<keys.length;i++){
  5171. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  5172. count[playerids[keys[i]].vote.poll]++;
  5173. }
  5174. playerids[keys[i]].vote.poll = -1;
  5175. }
  5176. for(var i = 0;i<count.length;i++){
  5177. if(count[i]>1){
  5178. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  5179. }
  5180. if(count[i]==1){
  5181. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  5182. }
  5183. }
  5184. displayInChat("The poll was:","#DA0808","#1EBCC1");
  5185. for(var i = 0;i<pollactive[3].length;i++){
  5186. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  5187. }
  5188. pollactive = [false,0,0,[]];
  5189. }
  5190. else{
  5191. displayInChat("No poll has been started","#DA0808","#1EBCC1");
  5192. displayInChat("Type '/startpoll [seconds]' to start a poll.","#DA0808","#1EBCC1");
  5193. }
  5194. return "";
  5195. }
  5196. else if (chat_val.substring(1,7)=="moveA " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  5197. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  5198. var keys = Object.keys(playerids);
  5199. var t = -1;
  5200. if(text == "f"){
  5201. t = 1;
  5202. }
  5203. else if(text == "b"){
  5204. t = 3;
  5205. }
  5206. else if(text == "g"){
  5207. t = 4;
  5208. }
  5209. else if(text == "r"){
  5210. t = 2;
  5211. }
  5212. else if(text == "y"){
  5213. t = 5;
  5214. }
  5215. else if(text == "s"){
  5216. t = 0;
  5217. }
  5218. if(t == -1){
  5219. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  5220. displayInChat("/moveA [letter]","#DA0808","#1EBCC1");
  5221. displayInChat("For example: '/moveA r' would move everyone to red team.","#DA0808","#1EBCC1");
  5222. return "";
  5223. }
  5224. for(var i = 0;i<keys.length;i++){
  5225. SEND('42[26,{"targetID":'+keys[i].toString()+',"targetTeam":'+t.toString()+'}]');
  5226. if(playerids[keys[i]].peerID!="sandbox"){
  5227. RECIEVE('42[18,'+keys[i].toString()+','+t.toString()+']');
  5228. }
  5229. }
  5230. return "";
  5231. }
  5232. else if (chat_val.substring(1,7)=="moveT " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  5233. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '').split(" ").filter(function(i){if(i==""){return false}else{return true}});
  5234. if(text.length == 2){
  5235. var firstteam = -1;
  5236. var secondteam = -1;
  5237. for(var i = 0;i<2;i++){
  5238. var t = -1;
  5239. if(text[i] == "f"){
  5240. t = 1;
  5241. }
  5242. else if(text[i] == "b"){
  5243. t = 3;
  5244. }
  5245. else if(text[i] == "g"){
  5246. t = 4;
  5247. }
  5248. else if(text[i] == "r"){
  5249. t = 2;
  5250. }
  5251. else if(text[i] == "y"){
  5252. t = 5;
  5253. }
  5254. else if(text[i] == "s"){
  5255. t = 0;
  5256. }
  5257. if(t==-1){
  5258. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  5259. displayInChat("/moveT [letter] [letter]","#DA0808","#1EBCC1");
  5260. displayInChat("For example: '/moveT s r' would move everyone in spectate to red team.","#DA0808","#1EBCC1");
  5261. return "";
  5262. }
  5263. else{
  5264. if(i == 0){
  5265. firstteam = t;
  5266. }
  5267. else{
  5268. secondteam = t;
  5269. }
  5270. }
  5271. }
  5272. var keys = Object.keys(playerids);
  5273. for(var i = 0;i<keys.length;i++){
  5274. if(playerids[keys[i]].team == firstteam){
  5275. SEND('42[26,{"targetID":'+keys[i].toString()+',"targetTeam":'+secondteam.toString()+'}]');
  5276. if(playerids[keys[i]].peerID!="sandbox"){
  5277. RECIEVE('42[18,'+keys[i].toString()+','+secondteam.toString()+']');
  5278. }
  5279. }
  5280. }
  5281. }
  5282. else{
  5283. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  5284. displayInChat("/moveT [team] [team]","#DA0808","#1EBCC1");
  5285. displayInChat("For example: '/moveT s r' would move everyone in spectate to red team.","#DA0808","#1EBCC1");
  5286. return "";
  5287. }
  5288. return "";
  5289. }
  5290. if (chat_val.substring(1,13)=="roundsperqp " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  5291. var text = parseInt(chat_val.substring(13).replace(/^\s+|\s+$/g, ''));
  5292. if(isNaN(text)){
  5293. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5294. return "";
  5295. }
  5296. else if(text<=0){
  5297. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5298. return "";
  5299. }
  5300. roundsperqp = text;
  5301. roundsperqp2 = 0;
  5302. displayInChat("Set rounds per quickplay to: " + text.toString(),"#DA0808","#1EBCC1");
  5303. displayInChat("Type '/roundsperqp' to reset rounds per quickplay.","#DA0808","#1EBCC1");
  5304. return "";
  5305. }
  5306. else if (chat_val.substring(1,12)=="roundsperqp"){
  5307. roundsperqp = 1;
  5308. roundsperqp2 = 0;
  5309. displayInChat("Reset rounds per quickplay.","#DA0808","#1EBCC1");
  5310. return "";
  5311. }
  5312. else if (chat_val.substring(1,8)=="rounds " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  5313. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  5314. if(!isNaN(parseInt(text))){
  5315. text = parseInt(text).toString();
  5316. SEND('42[21,{"w":'+text+'}]');
  5317. RECIEVE('42[27,'+text+']');
  5318. }
  5319. return "";
  5320. }
  5321. else if (chat_val.substring(1,13)=="disablekeys " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  5322. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  5323. var keys = text.split(" ");
  5324. var disabledkeys2 = [];
  5325. var possiblekeys = ["left","right","up","down","heavy","special"];
  5326. for(var i = 0; i<keys.length; i++){
  5327. if(keys[i]!="" && !disabledkeys2.includes(keys[i])){
  5328. if(possiblekeys.includes(keys[i])){
  5329. disabledkeys2.push(keys[i]);
  5330. }
  5331. else{
  5332. displayInChat("Key options: " + possiblekeys.join(" ") + ".","#DA0808","#1EBCC1");
  5333. return "";
  5334. }
  5335. }
  5336. }
  5337. disabledkeys = disabledkeys2;
  5338. displayInChat("Set disabled keys to: " + disabledkeys.join(" ") + ".","#DA0808","#1EBCC1");
  5339. displayInChat("Type '/disablekeys' to reset disabled keys.","#DA0808","#1EBCC1");
  5340. return "";
  5341. }
  5342. else if (chat_val.substring(1,12)=="disablekeys"){
  5343. displayInChat("Reset disabled keys.","#DA0808","#1EBCC1");
  5344. disabledkeys = [];
  5345. return "";
  5346. }
  5347. else if (chat_val.substring(1,10)=="jointext " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  5348. jointext = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  5349. displayInChat("Set jointext to: " + jointext,"#DA0808","#1EBCC1");
  5350. displayInChat("Type '/jointext' to reset jointext.","#DA0808","#1EBCC1");
  5351. return "";
  5352. }
  5353. else if (chat_val.substring(1,9)=="jointext"){
  5354. jointext = "";
  5355. displayInChat("Reset jointext.","#DA0808","#1EBCC1");
  5356. return "";
  5357. }
  5358. else if (chat_val.substring(1,10)=="jointeam " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  5359. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  5360. var keys = Object.keys(playerids);
  5361. var t = -1;
  5362. if(text == "f"){
  5363. t = 1;
  5364. displayInChat("Set jointeam to FFA.","#DA0808","#1EBCC1");
  5365. }
  5366. else if(text == "b"){
  5367. t = 3;
  5368. displayInChat("Set jointeam to blue team.","#DA0808","#1EBCC1");
  5369. }
  5370. else if(text == "g"){
  5371. t = 4;
  5372. displayInChat("Set jointeam to green team.","#DA0808","#1EBCC1");
  5373. }
  5374. else if(text == "r"){
  5375. t = 2;
  5376. displayInChat("Set jointeam to red team.","#DA0808","#1EBCC1");
  5377. }
  5378. else if(text == "y"){
  5379. t = 5;
  5380. displayInChat("Set jointeam to yellow team.","#DA0808","#1EBCC1");
  5381. }
  5382. else if(text == "s"){
  5383. t = 0;
  5384. displayInChat("Set jointeam to spectate.","#DA0808","#1EBCC1");
  5385. }
  5386. if(t == -1){
  5387. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  5388. displayInChat("/jointeam [letter]","#DA0808","#1EBCC1");
  5389. displayInChat("For example: '/jointeam r' would move every joined person to red team.","#DA0808","#1EBCC1");
  5390. return "";
  5391. }
  5392. displayInChat("Type '/jointeam' to reset jointeam.","#DA0808","#1EBCC1");
  5393. jointeam = t;
  5394. return "";
  5395. }
  5396. else if (chat_val.substring(1,9)=="jointeam"){
  5397. jointeam = -1;
  5398. displayInChat("Reset jointeam.","#DA0808","#1EBCC1");
  5399. return "";
  5400. }
  5401. else if (chat_val.substring(1,9)=="wintext " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  5402. wintext = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  5403. displayInChat("Set wintext to: " + wintext,"#DA0808","#1EBCC1");
  5404. displayInChat("Type '/wintext' to reset wintext.","#DA0808","#1EBCC1");
  5405. return "";
  5406. }
  5407. else if (chat_val.substring(1,8)=="wintext"){
  5408. wintext = "";
  5409. displayInChat("Reset wintext.","#DA0808","#1EBCC1");
  5410. return "";
  5411. }
  5412. else if (chat_val.substring(1,11)=="autorecord"){
  5413. if(autorecord){
  5414. autorecord = false;
  5415. displayInChat("Autorecord is now off.","#DA0808","#1EBCC1");
  5416. }
  5417. else{
  5418. autorecord = true;
  5419. displayInChat("Autorecord is now on.","#DA0808","#1EBCC1");
  5420. }
  5421. return "";
  5422. }
  5423. else if (chat_val.substring(1,9)=="afkkill " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  5424. var text = parseFloat(chat_val.substring(9).replace(/^\s+|\s+$/g, ''));
  5425. if(!isNaN(text)){
  5426. if(text>0){
  5427. displayInChat("Set afk kill to: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  5428. displayInChat("Type '/afkkill' to reset afk kill.","#DA0808","#1EBCC1");
  5429. var keys = Object.keys(playerids);
  5430. var now = Date.now();
  5431. for(var i = 0;i<keys.length;i++){
  5432. playerids[keys[i]].lastmove = now;
  5433. }
  5434. afkkill = text;
  5435. }
  5436. else{
  5437. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5438. }
  5439. }
  5440. else{
  5441. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5442. }
  5443. return "";
  5444. }
  5445. else if (chat_val.substring(1,9)=="afkkill"){
  5446. afkkill = -1;
  5447. displayInChat("Reset afk kill.","#DA0808","#1EBCC1");
  5448. return "";
  5449. }
  5450. else if (chat_val.substring(1,13)=="defaultmode " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  5451. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  5452. if(text == "default"){
  5453. defaultmode = "";
  5454. displayInChat("Changed default mode to default.","#DA0808","#1EBCC1");
  5455. }
  5456. else if(text == "arrows"){
  5457. defaultmode = "ar";
  5458. displayInChat("Changed default mode to arrows.","#DA0808","#1EBCC1");
  5459. }
  5460. else if(text == "death arrows"){
  5461. defaultmode = "ard";
  5462. displayInChat("Changed default mode to death arrows.","#DA0808","#1EBCC1");
  5463. }
  5464. else if(text == "grapple"){
  5465. defaultmode = "sp";
  5466. displayInChat("Changed default mode to grapple.","#DA0808","#1EBCC1");
  5467. }
  5468. else if(text == "classic"){
  5469. defaultmode = "b";
  5470. displayInChat("Changed default mode to classic.","#DA0808","#1EBCC1");
  5471. }
  5472. else{
  5473. displayInChat("Default mode options:","#DA0808","#1EBCC1");
  5474. displayInChat("default","#DA0808","#1EBCC1");
  5475. displayInChat("classic","#DA0808","#1EBCC1");
  5476. displayInChat("arrows","#DA0808","#1EBCC1");
  5477. displayInChat("death arrows","#DA0808","#1EBCC1");
  5478. displayInChat("grapple","#DA0808","#1EBCC1");
  5479. }
  5480. return "";
  5481. }
  5482. else if (chat_val.substring(1,8)=="recmode"){
  5483. if(recmodebool == true){
  5484. recmodebool = false;
  5485. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  5486. }
  5487. else{
  5488. recmodebool = true;
  5489. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  5490. }
  5491. return "";
  5492. }
  5493. else if (chat_val.substring(1,8)=="recteam"){
  5494. if(recteams == true){
  5495. recteams = false;
  5496. displayInChat("Recteam is now off.","#DA0808","#1EBCC1");
  5497. }
  5498. else{
  5499. recteams = true;
  5500. displayInChat("Recteam is now on.","#DA0808","#1EBCC1");
  5501. }
  5502. return "";
  5503. }
  5504. else if (chat_val.substring(1,8)=="shuffle"){
  5505. if(shuffle == true){
  5506. shuffle = false;
  5507. displayInChat("Shuffle is now off.","#DA0808","#1EBCC1");
  5508. }
  5509. else{
  5510. shuffle = true;
  5511. displayInChat("Shuffle is now on.","#DA0808","#1EBCC1");
  5512. }
  5513. return "";
  5514. }
  5515. else if (chat_val.substring(1,9)=="autokick"){
  5516. if(autokickban == 0){
  5517. displayInChat("Autokick is now on.","#DA0808","#1EBCC1");
  5518. autokickban = 1;
  5519. }
  5520. else if(autokickban == 1){
  5521. autokickban = 0;
  5522. displayInChat("Autokick is now off.","#DA0808","#1EBCC1");
  5523. }
  5524. else{
  5525. autokickban = 1;
  5526. displayInChat("Autokick is now on, and Autoban is now off.","#DA0808","#1EBCC1");
  5527. }
  5528. return "";
  5529. }
  5530. else if (chat_val.substring(1,8)=="autoban"){
  5531. if(autokickban == 0){
  5532. displayInChat("Autoban is now on.","#DA0808","#1EBCC1");
  5533. autokickban = 2;
  5534. }
  5535. else if(autokickban == 2){
  5536. autokickban = 0;
  5537. displayInChat("Autoban is now off.","#DA0808","#1EBCC1");
  5538. }
  5539. else{
  5540. autokickban = 2;
  5541. displayInChat("Autoban is now on, and Autokick is now off.","#DA0808","#1EBCC1");
  5542. }
  5543. return "";
  5544. }
  5545. else if (chat_val.substring(1,8)=="sandbox"){
  5546. if(sandboxon == false){
  5547. displayInChat("This room is now a sandbox room.","#DA0808","#1EBCC1");
  5548. sandboxon = true;
  5549. SEND('42[4,{"type":"sandboxon"}]');
  5550. var sandboxkeys = Object.keys(sandboxplayerids);
  5551. var packets = [];
  5552. for(var i = 0;i<sandboxkeys.length;i++){
  5553. var p = playerids[sandboxkeys[i]];
  5554. var packet = '42'+JSON.stringify([4,sandboxkeys[i],p.peerID,p.userName,p.guest,p.level,p.team,p.avatar]);
  5555. packets.push(packet);
  5556. }
  5557. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":packets,to:[-1]}]));
  5558. SEND("42"+JSON.stringify([4,{"type":"sandboxid","from":username,"lastid":sandboxid,to:[-1]}]));
  5559. }
  5560. else{
  5561. displayInChat("You cannot turn a sandbox room back into a normal room.","#DA0808","#1EBCC1");
  5562. }
  5563. return "";
  5564. }
  5565. else if(sandboxon){
  5566. if (chat_val.substring(1,11)=="addplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5567. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  5568. if(!isNaN(parseInt(text))){
  5569. var text2 = parseInt(text);
  5570. if(text2>0){
  5571. for(var i = 0;i<text2;i++){
  5572. while(playerids[sandboxid]){
  5573. sandboxid+=1;
  5574. }
  5575. var color = Math.floor(Math.random() * 16777215).toString();
  5576. var packet = '42'+JSON.stringify([4,sandboxid,"sandbox",sandboxid.toString(),true,0,0,{"layers":[],"bc":color}]);
  5577. RECIEVE(packet);
  5578. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  5579. sandboxplayerids[sandboxid] = sandboxid.toString();
  5580. sandboxid+=1;
  5581. }
  5582. }
  5583. }
  5584. return "";
  5585. }
  5586. if (chat_val.substring(1,9)=="addname " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  5587. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  5588. while(playerids[sandboxid]){
  5589. sandboxid+=1;
  5590. }
  5591. var keys = Object.keys(playerids);
  5592. var addon = "";
  5593. var escape = false;
  5594. var keysi = -1;
  5595. while(!escape){
  5596. escape = true;
  5597. for(var i = 0;i<keys.length;i++){
  5598. if(playerids[keys[i]].userName == text+addon){
  5599. addon+="‎";
  5600. var escape = false;
  5601. }
  5602. if(playerids[keys[i]].userName == text){
  5603. keysi = keys[i];
  5604. }
  5605. }
  5606. }
  5607. if(keysi!=-1){
  5608. var packet = '42'+JSON.stringify([4,sandboxid,"sandbox",text+addon,playerids[keysi].guest,playerids[keysi].level,0,playerids[keysi].avatar]);
  5609. RECIEVE(packet);
  5610. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  5611. }
  5612. else{
  5613. var color = Math.floor(Math.random() * 16777215).toString();
  5614. var packet = '42'+JSON.stringify([4,sandboxid,"sandbox",text+addon,true,0,0,{"layers":[],"bc":color}]);
  5615. RECIEVE(packet);
  5616. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  5617. }
  5618. sandboxplayerids[sandboxid] = sandboxid.toString();
  5619. sandboxid+=1;
  5620. return "";
  5621. }
  5622. else if (chat_val.substring(1,11)=="delplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5623. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  5624. if(!isNaN(parseInt(text))){
  5625. var text2 = parseInt(text);
  5626. if(text2>0){
  5627. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
  5628. var jsonkeys = Object.keys(sandboxplayerids).reverse();
  5629. var packets = [];
  5630. for(var i = 0;i<text2 && i<jsonkeys.length;i++){
  5631. var packet = '42[5,'+jsonkeys[i]+',0]';
  5632. RECIEVE(packet);
  5633. packets.push(packet);
  5634. delete sandboxplayerids[jsonkeys[i]];
  5635. }
  5636. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":packets,to:[-1]}]));
  5637. }
  5638. else{
  5639. displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
  5640. }
  5641. }
  5642. }
  5643. return "";
  5644. }
  5645. else if (chat_val.substring(1,6)=="copy " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  5646. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  5647. var keys = Object.keys(playerids);
  5648. var keys2 = Object.keys(sandboxplayerids);
  5649. var copiedperson = -1;
  5650. for(var i = 0;i<keys.length;i++){
  5651. if(playerids[keys[i]].userName==text){
  5652. copiedperson = keys[i];
  5653. }
  5654. }
  5655. if(copiedperson==-1){
  5656. displayInChat(playerids[copiedperson].userName + " was not found in this room.","#DA0808","#1EBCC1");
  5657. return "";
  5658. }
  5659. if(keys2.includes(copiedperson.toString())){
  5660. displayInChat("Bots cannot copy a bot.","#DA0808","#1EBCC1");
  5661. return "";
  5662. }
  5663. displayInChat("All bots will now copy "+playerids[copiedperson].userName+".","#DA0808","#1EBCC1");
  5664. displayInChat("To reset copy, type '/copy'.","#DA0808","#1EBCC1");
  5665. sandboxcopyme = copiedperson;
  5666. return "";
  5667. }
  5668. else if (chat_val.substring(1,5)=="copy"){
  5669. sandboxcopyme = -1;
  5670. displayInChat("Copy is now off.","#DA0808","#1EBCC1");
  5671. return "";
  5672. }
  5673. }
  5674. }
  5675. return chat_val;
  5676. };
  5677. scope.flag_manage = function(t){
  5678. var text = t;
  5679. if(autocorrect == true){
  5680. var text2 = text.split(" ");
  5681. for(var i = 0;i<text2.length;i++){
  5682. text2[i] = closestWord(text2[i]);
  5683. }
  5684. text = text2.join(" ");
  5685. }
  5686. if(reverse_flag == true){
  5687. text = text.split("").reverse().join("")
  5688. }
  5689. if(rcaps_flag == true){
  5690. text = text.split('');
  5691. for(var i = 0; i<text.length;i++){
  5692. if(Math.floor(Math.random()*2)){
  5693. text[i] = text[i].toUpperCase();
  5694. }
  5695. else{
  5696. text[i] = text[i].toLowerCase();
  5697. }
  5698. }
  5699. text = text.join('');
  5700. }
  5701. if(space_flag == true){
  5702. text = text.split('').join(' ')
  5703. }
  5704. if(textmode!=-1){
  5705. newtext = "";
  5706. for(var i = 0;i<text.length;i++){
  5707. if(letter_dictionary[text[i]]){
  5708. newtext+=letter_dictionary[text[i]][textmode];
  5709. }
  5710. else{
  5711. newtext+=text[i];
  5712. }
  5713. }
  5714. text = newtext;
  5715. }
  5716. if(number_flag == true){
  5717. text = text.replace(/[t|T][Oo]+/g,"2");
  5718. text = text.replace(/[f|F][o|O][r|R]/g,"4");
  5719. text = text.replace(/[a|A][t|T][e|E]/g,"8");
  5720. text = text.replace(/[e|E]/g,"3");
  5721. text = text.replace(/[a|A]/g,"4");
  5722. text = text.replace(/[o|O]/g,"0");
  5723. text = text.replace(/[s|S]/g,"5");
  5724. text = text.replace(/[i|I|l|L]/g,"1");
  5725. }
  5726. return text;
  5727. };
  5728. Gdocument.getElementById("newbonklobby_chat_input").onkeydown = function(e){
  5729. if(e.keyCode==13){
  5730. var chat_val = Gdocument.getElementById("newbonklobby_chat_input").value;
  5731. if (chat_val!="" && chat_val[0]=="/"){
  5732. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  5733. chat2(commandhandle(chat_val));
  5734. }
  5735. else{
  5736. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  5737. chat2(flag_manage(chat_val));
  5738. }
  5739. }
  5740. };
  5741. Gdocument.getElementById("ingamechatinputtext").onkeydown = function(e){
  5742. if(e.keyCode==13){
  5743. var chat_val = Gdocument.getElementById("ingamechatinputtext").value;
  5744. if (chat_val!="" && chat_val[0]=="/"){
  5745. Gdocument.getElementById("ingamechatinputtext").value = "";
  5746. chat2(commandhandle(chat_val));
  5747. }
  5748. else{
  5749. Gdocument.getElementById("ingamechatinputtext").value = "";
  5750. chat2(flag_manage(chat_val));
  5751. }
  5752. }
  5753. };
  5754. scope.Last_message = "";
  5755. scope.Laster_message = "";
  5756. scope.new_message = false;
  5757. scope.changed_chat = false;
  5758. scope.injectedBonkCommandsScript = setInterval(timeout123,60);
  5759.  
  5760. scope.pan_enabled = false;
  5761. scope.pan = {"x":0,"y":0};
  5762. scope.pan_speed = 5;
  5763. scope.keys_being_held = {};
  5764. scope.hotkeys_keyup = function(e){
  5765. if(keys_being_held[e.code]){
  5766. keys_being_held[e.code] = false;
  5767. }
  5768. };
  5769. Gdocument.onkeyup = hotkeys_keyup;
  5770. scope.hotkeys = function(e){
  5771. var keycode = e.code;
  5772. if(!keys_being_held[keycode]){
  5773. keys_being_held[keycode] = true;
  5774. }
  5775. if(!e.altKey && e.shiftKey && !e.ctrlKey && !e.metaKey){
  5776. if(pan_enabled && Gdocument.getElementById("gamerenderer")?.childElementCount>0){
  5777. if(keycode == "ArrowUp"){
  5778. e.stopPropagation();
  5779. e.preventDefault();
  5780. }
  5781. else if(keycode == "ArrowDown"){
  5782. e.stopPropagation();
  5783. e.preventDefault();
  5784. }
  5785. else if(keycode == "ArrowLeft"){
  5786. e.stopPropagation();
  5787. e.preventDefault();
  5788. }
  5789. else if(keycode == "ArrowRight"){
  5790. e.stopPropagation();
  5791. e.preventDefault();
  5792. }
  5793. }
  5794. }
  5795.  
  5796. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  5797. if(keycode == "Period"){
  5798. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  5799. chatheight+=5;
  5800. if(chatheight>600){chatheight = 600;}
  5801. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  5802. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  5803. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  5804. }
  5805. e.preventDefault();
  5806. }
  5807. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  5808. if(keycode == "KeyG"){
  5809. var addto = 0;
  5810. for(var i = 0;i<parentDraw.children.length;i++){
  5811. if(parentDraw.children[i].constructor.name == "e"){
  5812. addto = parentDraw.children[i];
  5813. break;
  5814. }
  5815. }
  5816. var canv = 0;
  5817. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  5818. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  5819. canv = Gdocument.getElementById("gamerenderer").children[i];
  5820. break;
  5821. }
  5822. }
  5823. var width = parseInt(canv.style["width"]);
  5824. var height = parseInt(canv.style["height"]);
  5825. if(addto){
  5826. zoom *= 1.1;
  5827. }
  5828. addto.scale.x = zoom;
  5829. addto.scale.y = zoom;
  5830. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  5831. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  5832. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  5833. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  5834. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  5835. pixiCircle.visible = false;
  5836. }
  5837. else{
  5838. pixiCircle.visible = true;
  5839. }
  5840. e.preventDefault();
  5841. }
  5842. if(keycode == "KeyH"){
  5843. var addto = 0;
  5844. for(var i = 0;i<parentDraw.children.length;i++){
  5845. if(parentDraw.children[i].constructor.name == "e"){
  5846. addto = parentDraw.children[i];
  5847. break;
  5848. }
  5849. }
  5850. var canv = 0;
  5851. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  5852. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  5853. canv = Gdocument.getElementById("gamerenderer").children[i];
  5854. break;
  5855. }
  5856. }
  5857. var width = parseInt(canv.style["width"]);
  5858. var height = parseInt(canv.style["height"]);
  5859. if(addto){
  5860. zoom = 1;
  5861. }
  5862. addto.scale.x = zoom;
  5863. addto.scale.y = zoom;
  5864. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  5865. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  5866. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  5867. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  5868. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  5869. pixiCircle.visible = false;
  5870. }
  5871. else{
  5872. pixiCircle.visible = true;
  5873. }
  5874. e.preventDefault();
  5875. }
  5876. if(keycode == "KeyJ"){
  5877. var addto = 0;
  5878. for(var i = 0;i<parentDraw.children.length;i++){
  5879. if(parentDraw.children[i].constructor.name == "e"){
  5880. addto = parentDraw.children[i];
  5881. break;
  5882. }
  5883. }
  5884. var canv = 0;
  5885. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  5886. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  5887. canv = Gdocument.getElementById("gamerenderer").children[i];
  5888. break;
  5889. }
  5890. }
  5891. var width = parseInt(canv.style["width"]);
  5892. var height = parseInt(canv.style["height"]);
  5893. if(addto){
  5894. zoom /= 1.1;
  5895. }
  5896. addto.scale.x = zoom;
  5897. addto.scale.y = zoom;
  5898. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  5899. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  5900. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  5901. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  5902. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  5903. pixiCircle.visible = false;
  5904. }
  5905. else{
  5906. pixiCircle.visible = true;
  5907. }
  5908. e.preventDefault();
  5909. }
  5910. }
  5911. if(keycode == "Comma"){
  5912. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  5913. chatheight-=5;
  5914. if(chatheight<100){chatheight = 100;}
  5915. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  5916. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  5917. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  5918. }
  5919. e.preventDefault();
  5920. }
  5921. }
  5922. if(e.repeat){return;}
  5923. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  5924. if(ishost){
  5925. if(keycode == "KeyE"){
  5926. if(Gdocument.getElementById("newbonklobby").style["display"] == "block"){
  5927. Gdocument.getElementById("newbonklobby_editorbutton").click();
  5928. }
  5929. else if(Gdocument.getElementById("mapeditorcontainer").style["display"] == "block"){
  5930. Gdocument.getElementById("mapeditor_close").click();
  5931. }
  5932. e.preventDefault();
  5933. }
  5934. else if(keycode == "KeyT"){
  5935. Gdocument.getElementById("newbonklobby_teamsbutton").click();
  5936. e.preventDefault();
  5937. }
  5938. else if(keycode == "KeyM"){
  5939. Gdocument.getElementById("newbonklobby_modebutton").click();
  5940. e.preventDefault();
  5941. }
  5942. else if(keycode == "KeyK"){
  5943. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  5944. Gdocument.getElementById("pretty_top_exit").click();
  5945. }
  5946. e.preventDefault();
  5947. }
  5948. else if(keycode == "KeyS"){
  5949. if(Gdocument.getElementById("mapeditorcontainer").style["display"]!="block"){
  5950. Gdocument.getElementById("newbonklobby_editorbutton").click();
  5951. }
  5952. if(recmodebool && ishost){
  5953. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  5954. if(mode == "" && defaultmode!="d"){
  5955. mode = defaultmode;
  5956. }
  5957. if(mode != ""){
  5958. RECIEVE('42[26,"b","'+mode+'"]');
  5959. }
  5960. }
  5961. Gdocument.getElementById("mapeditor_close").click();
  5962. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  5963. roundsperqp2 = 0;
  5964. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  5965. e.preventDefault();
  5966. }
  5967. else if(keycode == "KeyD"){
  5968. roundsperqp2 = 0;
  5969. if(stopquickplay == 0){
  5970. if(shuffle){
  5971. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5972. var available = [];
  5973. var availableindexes = [];
  5974. var notempty = false;
  5975. for(var i = 0; i<e2.length;i++){
  5976. var a = false;
  5977. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5978. available.push(a);
  5979. if(a){
  5980. availableindexes.push(i);
  5981. notempty = true;
  5982. }
  5983. }
  5984. if(notempty){
  5985. if(availableindexes.length!=1){
  5986. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  5987. }
  5988. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  5989. }
  5990. }
  5991. else{
  5992. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5993. var available = [];
  5994. var availableindexes = [];
  5995. var notempty = false;
  5996. for(var i = 0; i<e2.length;i++){
  5997. var a = false;
  5998. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5999. available.push(a);
  6000. if(a){
  6001. availableindexes.push(i);
  6002. notempty = true;
  6003. }
  6004. }
  6005. if(notempty){
  6006. var above = [];
  6007. for(var i = 0;i<availableindexes.length;i++){
  6008. if(availableindexes[i]>quicki && !reverseqp){
  6009. above.push(availableindexes[i]);
  6010. }
  6011. else if(availableindexes[i]<quicki && reverseqp){
  6012. above.push(availableindexes[i])
  6013. }
  6014. }
  6015. if(above.length>0){
  6016. quicki = above[0];
  6017. if(reverseqp){
  6018. quicki = above[above.length-1];
  6019. }
  6020. }
  6021. else{
  6022. quicki = availableindexes[0];
  6023. if(reverseqp){
  6024. quicki = availableindexes[availableindexes.length-1];
  6025. }
  6026. }
  6027. }
  6028. }
  6029. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  6030. }
  6031. e.preventDefault();
  6032. }
  6033. else if(keycode == "KeyA"){
  6034. if(stopquickplay == 0){
  6035. roundsperqp2 = 0;
  6036. if(shuffle){
  6037. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6038. var available = [];
  6039. var availableindexes = [];
  6040. var notempty = false;
  6041. for(var i = 0; i<e2.length;i++){
  6042. var a = false;
  6043. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6044. available.push(a);
  6045. if(a){
  6046. availableindexes.push(i);
  6047. notempty = true;
  6048. }
  6049. }
  6050. if(notempty){
  6051. if(availableindexes.length!=1){
  6052. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  6053. }
  6054. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  6055. }
  6056. }
  6057. else{
  6058. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6059. var available = [];
  6060. var availableindexes = [];
  6061. var notempty = false;
  6062. for(var i = 0; i<e2.length;i++){
  6063. var a = false;
  6064. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6065. available.push(a);
  6066. if(a){
  6067. availableindexes.push(i);
  6068. notempty = true;
  6069. }
  6070. }
  6071. if(notempty){
  6072. var above = [];
  6073. for(var i = 0;i<availableindexes.length;i++){
  6074. if(availableindexes[i]<quicki && !reverseqp){
  6075. above.push(availableindexes[i]);
  6076. }
  6077. else if(availableindexes[i]>quicki && reverseqp){
  6078. above.push(availableindexes[i])
  6079. }
  6080. }
  6081. if(above.length>0){
  6082. quicki = above[above.length-1];
  6083. if(reverseqp){
  6084. quicki = above[0];
  6085. }
  6086. }
  6087. else{
  6088. quicki = availableindexes[availableindexes.length-1];
  6089. if(reverseqp){
  6090. quicki = availableindexes[0];
  6091. }
  6092. }
  6093. }
  6094. }
  6095. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  6096. }
  6097. e.preventDefault();
  6098. }
  6099. else if(keycode == "KeyQ"){
  6100. if(stopquickplay == 1){
  6101. stopquickplay = 0;
  6102. quicki = 0;
  6103. qppaused = false;
  6104. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  6105. }
  6106. else{
  6107. stopquickplay = 1;
  6108. quicki = 0;
  6109. qppaused = false;
  6110. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  6111. }
  6112. e.preventDefault();
  6113. }
  6114. else if(keycode == "KeyP" && stopquickplay==0){
  6115. if(qppaused == true){
  6116. qppaused = false;
  6117. displayInChat("Unpaused quickplay.","#DA0808","#1EBCC1");
  6118. }
  6119. else{
  6120. qppaused = true;
  6121. displayInChat("Paused quickplay.","#DA0808","#1EBCC1");
  6122. }
  6123. e.preventDefault();
  6124. }
  6125. else if(keycode == "KeyR"){
  6126. if(recmodebool == true){
  6127. recmodebool = false;
  6128. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  6129. }
  6130. else{
  6131. recmodebool = true;
  6132. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  6133. }
  6134. }
  6135. else if(keycode == "KeyF"){
  6136. if(freejoin == false){
  6137. freejoin = true;
  6138. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  6139. }
  6140. else{
  6141. freejoin = false;
  6142. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  6143. }
  6144. e.preventDefault();
  6145. }
  6146. }
  6147. else{
  6148. if(keycode == "KeyE"){
  6149. e.preventDefault();
  6150. }
  6151. else if(keycode == "KeyT"){
  6152. e.preventDefault();
  6153. }
  6154. else if(keycode == "KeyM"){
  6155. e.preventDefault();
  6156. }
  6157. else if(keycode == "KeyK"){
  6158. e.preventDefault();
  6159. }
  6160. else if(keycode == "KeyS"){
  6161. e.preventDefault();
  6162. }
  6163. else if(keycode == "KeyD"){
  6164. e.preventDefault();
  6165. }
  6166. else if(keycode == "KeyA"){
  6167. e.preventDefault();
  6168. }
  6169. else if(keycode == "KeyQ"){
  6170. e.preventDefault();
  6171. }
  6172. else if(keycode == "KeyP"){
  6173. e.preventDefault();
  6174. }
  6175. else if(keycode == "KeyF"){
  6176. e.preventDefault();
  6177. }
  6178. else if(keycode == "KeyR"){
  6179. e.preventDefault();
  6180. }
  6181. }
  6182. if(keycode == "KeyL"){
  6183. lobby();
  6184. e.preventDefault();
  6185. }
  6186. if(keycode == "KeyC"){
  6187. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  6188. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]=="0px"){
  6189. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  6190. }
  6191. else{
  6192. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  6193. }
  6194. }
  6195. e.preventDefault();
  6196. }
  6197. if(keycode == "KeyI"){
  6198. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  6199. debuggeropen = true;
  6200. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  6201. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  6202. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  6203. }
  6204. else{
  6205. debuggeropen = false;
  6206. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  6207. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  6208. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  6209. }
  6210. e.preventDefault();
  6211. }
  6212. if(keycode == "KeyB"){
  6213. var element = Gdocument.getElementById("ingamewinner_scores");
  6214. if(element.style["opacity"]<1){
  6215. element.style["opacity"] = 1;
  6216. element.style["visibility"] = "visible";
  6217. }
  6218. else{
  6219. element.style["opacity"] = 0;
  6220. element.style["visibility"] = "unset";
  6221. }
  6222. e.preventDefault();
  6223. }
  6224. if(keycode == "KeyY"){
  6225. Gdocument.getElementById("pretty_top_settings").click();
  6226. Gdocument.getElementById("settings_close").click();
  6227. if(Gdocument.getElementById("settings_graphicsquality").value==1){
  6228. displayInChat("You must have medium or high quality enabled to use this feature.","#DA0808","#1EBCC1");
  6229. return "";
  6230. }
  6231. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  6232. var addto = {"children":[]};
  6233. for(var i = 0;i<parentDraw.children.length;i++){
  6234. if(parentDraw.children[i].constructor.name == "e"){
  6235. addto = parentDraw.children[i];
  6236. break;
  6237. }
  6238. }
  6239. var addto2 = {"children":[]};
  6240. for(var i = 0;i<addto.children.length;i++){
  6241. if(addto.children[i].constructor.name == "e"){
  6242. addto2 = addto.children[i];
  6243. break;
  6244. }
  6245. }
  6246. var checkxray = addto2.children[0];
  6247. var addto3 = addto2.children[0].children;
  6248. if(addto3.length==1){
  6249. checkxray = checkxray.children[0];
  6250. addto3 = addto3[0].children;
  6251. }
  6252. var xrayon = false;
  6253. if(checkxray.xrayon){
  6254. checkxray.xrayon = false;
  6255. xrayon = false;
  6256. }
  6257. else{
  6258. checkxray.xrayon = true;
  6259. xrayon = true;
  6260. }
  6261. if(xrayon){
  6262. displayInChat("Xray is now on.","#DA0808","#1EBCC1");
  6263. for(var i = 0;i<addto3.length;i++){
  6264. if(addto3[i].children.length>0){
  6265. var ids = [];
  6266. var ids2 = [];
  6267. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  6268. addto3[i].children[i3].visible = false;
  6269. if(addto3[i].children[i3].children.length>0){
  6270. for(var i4 = 0;i4<addto3[i].children[i3].children.length;i4++){
  6271. if(addto3[i].children[i3].children[i4].geometry?.id){
  6272. ids.push(addto3[i].children[i3].children[i4].geometry.id);
  6273. }
  6274. else if(addto3[i].children[i3].children[i4].texture?.baseTexture?.uid){
  6275. ids2.push(addto3[i].children[i3].children[i4].texture.baseTexture.uid);
  6276. }
  6277. }
  6278. }
  6279. }
  6280. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  6281. if(addto3[i].children[i3].children.length==0){
  6282. if(addto3[i].children[i3].geometry?.id){
  6283. if(ids.includes(addto3[i].children[i3].geometry.id+1)){
  6284. addto3[i].children[i3].visible = true;
  6285. addto3[i].children[i3].alpha = 0.5;
  6286. }
  6287. }
  6288. else if(addto3[i].children[i3].texture?.baseTexture?.uid){
  6289. if(ids2.includes(addto3[i].children[i3].texture.baseTexture.uid+1)){
  6290. addto3[i].children[i3].visible = true;
  6291. addto3[i].children[i3].alpha = 0.5;
  6292. }
  6293. }
  6294. }
  6295. }
  6296. }
  6297. }
  6298. }
  6299. else{
  6300. displayInChat("Xray is now off.","#DA0808","#1EBCC1");
  6301. for(var i = 0;i<addto3.length;i++){
  6302. for(var i2 = 0;i2<addto3[i].children.length;i2++){
  6303. addto3[i].children[i2].visible = true;
  6304. addto3[i].children[i2].alpha = 1;
  6305. }
  6306. }
  6307. }
  6308. }
  6309. e.preventDefault();
  6310. }
  6311. if(keycode == "KeyN"){
  6312. if(FollowCam == true){
  6313. displayInChat("Follow Camera is now off.","#DA0808","#1EBCC1");
  6314. FollowCam = false;
  6315. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  6316. var addto = {"children":[]};
  6317. for(var i = 0;i<parentDraw.children.length;i++){
  6318. if(parentDraw.children[i].constructor.name == "e"){
  6319. addto = parentDraw.children[i];
  6320. break;
  6321. }
  6322. }
  6323. var canv = 0;
  6324. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  6325. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  6326. canv = Gdocument.getElementById("gamerenderer").children[i];
  6327. break;
  6328. }
  6329. }
  6330. var width = parseInt(canv.style["width"]);
  6331. var height = parseInt(canv.style["height"]);
  6332. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  6333. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  6334. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  6335. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  6336. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  6337. pixiCircle.visible = false;
  6338. }
  6339. else{
  6340. pixiCircle.visible = true;
  6341. }
  6342. }
  6343. }
  6344. else{
  6345. displayInChat("Follow Camera is now on.","#DA0808","#1EBCC1");
  6346. FollowCam = true;
  6347. }
  6348. e.preventDefault();
  6349. }
  6350. if(keycode == "KeyV"){
  6351. if(autocam == true){
  6352. displayInChat("Auto Cam is now off.","#DA0808","#1EBCC1");
  6353. autocam = false
  6354. }
  6355. else{
  6356. displayInChat("Auto Cam is now on.","#DA0808","#1EBCC1");
  6357. autocam = true;
  6358. }
  6359. e.preventDefault();
  6360. }
  6361. if (keycode == "BracketLeft"){
  6362. if(pan_enabled == true){
  6363. displayInChat("Pan is now off.","#DA0808","#1EBCC1");
  6364. pan = {"x":0,"y":0};
  6365. pan_enabled = false;
  6366. }
  6367. else{
  6368. displayInChat("Pan is now on. Shift + Arrow Keys to pan.","#DA0808","#1EBCC1");
  6369. pan_enabled = true;
  6370. }
  6371. return "";
  6372. }
  6373. if (keycode == "BracketRight"){
  6374. pan = {"x":0,"y":0};
  6375. displayInChat("Reset pan.","#DA0808","#1EBCC1");
  6376. return "";
  6377. }
  6378. if(keycode == "KeyO"){
  6379. if(heavybot == true){
  6380. displayInChat("Heavy bot is now off.","#DA0808","#1EBCC1");
  6381. heavybot = false;
  6382. }
  6383. else{
  6384. displayInChat("Heavy bot is now on.","#DA0808","#1EBCC1");
  6385. heavybot = true;
  6386. getplayerkeys();
  6387. }
  6388. e.preventDefault();
  6389. }
  6390. if(keycode == "KeyU"){
  6391. if(aimbot == true){
  6392. displayInChat("Aimbot is now off.","#DA0808","#1EBCC1");
  6393. aimbot = false;
  6394. }
  6395. else{
  6396. displayInChat("Aimbot is now on.","#DA0808","#1EBCC1");
  6397. aimbot = true;
  6398. getplayerkeys();
  6399. }
  6400. e.preventDefault();
  6401. }
  6402. if(keycode == "KeyW"){
  6403. if(staystill == true){
  6404. displayInChat("Still is now off.","#DA0808","#1EBCC1");
  6405. staystill = false;
  6406. staystillpos = [0,0];
  6407. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  6408. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  6409. }
  6410. else{
  6411. if(playerids[myid].playerData?.transform){
  6412. displayInChat("Still is now on.","#DA0808","#1EBCC1");
  6413. staystill = true;
  6414. staystillpos = [playerids[myid].playerData.transform.position.x/scale,playerids[myid].playerData.transform.position.y/scale];
  6415. getplayerkeys();
  6416. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  6417. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  6418. }
  6419. else{
  6420. displayInChat("You have to be alive to use this command.","#DA0808","#1EBCC1");
  6421. }
  6422. }
  6423. e.preventDefault();
  6424. }
  6425. }
  6426. if(!e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  6427. if(keycode == "Slash" && !(Gdocument.getElementById("gmeditor")?.style["transform"] == "scale(1)")){
  6428. 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"]==""){
  6429. Gdocument.getElementById("newbonklobby_chat_input").value = "/";
  6430. if(Gdocument.getElementById("newbonklobby_chat_input").style["pointer-events"] == "none"){
  6431. fire("keydown",{keyCode:13});
  6432. }
  6433. else{
  6434. Gdocument.getElementById("newbonklobby_chat_input").focus();
  6435. }
  6436. e.preventDefault();
  6437. }
  6438. else if(Gdocument.getElementById("ingamechatinputtext").style["visibility"]=="visible" && Gdocument.getElementById("ingamechatinputtext").style["display"]=="" && Gdocument.getElementById("mapeditorcontainer").style["display"]!="block" && Gdocument.getElementById("ingamechatinputtext").value == ""){
  6439. Gdocument.getElementById("ingamechatinputtext").value = "/";
  6440. if(!Gdocument.getElementById("ingamechatinputtext").classList.value.includes("ingamechatinputtextbg")){
  6441. fire("keydown",{keyCode:13});
  6442. }
  6443. else{
  6444. Gdocument.getElementById("ingamechatinputtext").focus();
  6445. }
  6446. e.preventDefault();
  6447. }
  6448. }
  6449. }
  6450. };
  6451. Gdocument.onkeydown = hotkeys;
  6452. Gwindow.addEventListener('resize',function(e){
  6453. debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
  6454. debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
  6455. scope.width = parseInt(Gdocument.getElementById("bonkiocontainer").style["width"])-20;
  6456. scope.height = parseInt(Gdocument.getElementById("bonkiocontainer").style["height"])-210;
  6457. logmenu.style["width"] = width.toString()+"px";
  6458. logmenu.style["height"] = height.toString()+"px";
  6459. logmenutopleft.style["width"] = (width/2).toString()+"px";
  6460. logmenutopright.style["width"] = (width/2).toString()+"px";
  6461. logmenutopright.style["left"] = (width/2).toString()+"px";
  6462. debuggerinput.style["width"] = width.toString()+"px";
  6463. debuggerinput.style["top"] = (height+90).toString()+"px";
  6464. debuggersendrecieve.style["top"] = (height+120).toString()+"px";
  6465. debuggerpausebutton.style["top"] = (height+150).toString()+"px";
  6466. debuggereval.style["width"] = (width-150).toString()+"px";
  6467. debuggereval.style["top"] = (height+120).toString()+"px";},true);
  6468. function timeout123() {
  6469. updateWssLog();
  6470. EVENTLOOPFUNCTION();
  6471. var now = Date.now();
  6472. var keys = Object.keys(playerids);
  6473. if(getroomslastcheck+3000<now){
  6474. getroomslastcheck = now;
  6475. if(inroom && savedrooms.length>0){
  6476. Gdocument.getElementById("roomlistrefreshbutton").click();
  6477. }
  6478. }
  6479. var namelist = Gdocument.getElementsByClassName("newbonklobby_playerentry_name");
  6480. for(var i = 0;i<namelist.length;i++){
  6481. var level = 0;
  6482. var levelelement = 0;
  6483. var pingelement = 0;
  6484. var avatarelement = 0;
  6485. var children = namelist[i].parentElement.children;
  6486. for(var i2 = 0;i2<children.length;i2++){
  6487. if(children[i2].className == "newbonklobby_playerentry_level"){
  6488. levelelement = children[i2];
  6489. level = parseInt(children[i2].textContent.slice(6));
  6490. }
  6491. else if(children[i2].className == "newbonklobby_playerentry_pingtext"){
  6492. pingelement = children[i2];
  6493. }
  6494. else if(children[i2].className == "newbonklobby_playerentry_avatar"){
  6495. avatarelement = children[i2];
  6496. }
  6497. }
  6498. var isadmin = [false,0];
  6499. for(var i3 = 0;i3<admins.length;i3++){
  6500. if(admins[i3][0] == namelist[i].textContent){
  6501. isadmin = [true,i3];
  6502. break;
  6503. }
  6504. }
  6505. if(level){
  6506. if(isadmin[0]){
  6507. namelist[i].style["color"] = "rgb("+admins[isadmin[1]][1].slice(0,-1).toString()+")";
  6508. if(isadmin[1]<=3){
  6509. var rotatevalue = 0;
  6510. if(admins[isadmin[1]][1][3]<90){
  6511. rotatevalue = admins[isadmin[1]][1][3]/2;
  6512. }
  6513. else if(admins[isadmin[1]][1][3]<270){
  6514. rotatevalue =(180-admins[isadmin[1]][1][3])/2;
  6515. }
  6516. else if(admins[isadmin[1]][1][3]<360){
  6517. rotatevalue = (-360+admins[isadmin[1]][1][3])/2;
  6518. }
  6519. namelist[i].parentElement.style["filter"] = "hue-rotate("+rotatevalue.toString()+"deg)";
  6520. namelist[i].parentElement.style["font-size"] = "17px";
  6521. 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()+")";
  6522. if(levelelement){
  6523. levelelement.style["color"] = "rgb("+admins[isadmin[1]][1].slice(0,-1).toString()+")";
  6524. }
  6525. if(pingelement){
  6526. pingelement.style["color"] = "rgb("+admins[isadmin[1]][1].slice(0,-1).toString()+")";
  6527. }
  6528. if(avatarelement){
  6529. avatarelement.style["filter"] = "hue-rotate("+rotatevalue.toString()+"deg)";
  6530. }
  6531. }
  6532. }
  6533. }
  6534. var stylekeys = Object.keys(allstyles);
  6535. for(var i3 = 0;i3<stylekeys.length;i3++){
  6536. if(stylekeys[i3] == namelist[i].textContent){
  6537. 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])){
  6538. var rgbvalue = [allstyles[stylekeys[i3]][0],allstyles[stylekeys[i3]][1],allstyles[stylekeys[i3]][2]];
  6539. namelist[i].style["color"] = "rgb("+rgbvalue.toString()+")";
  6540. if(!isadmin[0]){
  6541. var n = 255;
  6542. namelist[i].parentElement.style["background"] = "rgb("+[(203+rgbvalue[0])%n,(212+rgbvalue[1])%n,(215+rgbvalue[2])%n].toString()+")";
  6543. }
  6544. if(levelelement){
  6545. levelelement.style["color"] = "rgb("+rgbvalue.toString()+")";
  6546. }
  6547. if(pingelement){
  6548. pingelement.style["color"] = "rgb("+rgbvalue.toString()+")";
  6549. }
  6550. }
  6551. }
  6552. }
  6553. }
  6554. for(var i3 = 0;i3<admins.length;i3++){
  6555. if(admins[i3][1][0]==0 && admins[i3][1][1]==0 && admins[i3][1][2]==0){
  6556. admins[i3][1][2] = 180;
  6557. admins[i3][1][1] = 0;
  6558. admins[i3][1][0] = 0;
  6559. }
  6560. var rate = 5;
  6561. var lowest = 0;
  6562. var number = 360;
  6563. admins[i3][1][3] = (admins[i3][1][3]%number+4+number)%number;
  6564. if(admins[i3][1][0]>lowest && admins[i3][1][1] == lowest){
  6565. admins[i3][1][0]-=rate;
  6566. admins[i3][1][2]+=rate;
  6567. }
  6568. if(admins[i3][1][2]>lowest && admins[i3][1][0] == lowest){
  6569. admins[i3][1][2]-=rate;
  6570. admins[i3][1][1]+=rate;
  6571. }
  6572. if(admins[i3][1][1]>lowest && admins[i3][1][2] == lowest){
  6573. admins[i3][1][0]+=rate;
  6574. admins[i3][1][1]-=rate;
  6575. }
  6576. for(var i4 = 0;i4<3;i4++){
  6577. if(admins[i3][1][i4]<lowest){
  6578. admins[i3][1][i4]=lowest;
  6579. }
  6580. else if(admins[i3][1][i4]>255){
  6581. admins[i3][1][i4]=255;
  6582. }
  6583. }
  6584. }
  6585. if(randomchat){
  6586. if(randomchat_timestamp+randomchat_randomtimestamp<now){
  6587. randomchat_timestamp = now;
  6588. randomchat_randomtimestamp = 2000+Math.random()*2000;
  6589. var randnumber = Math.floor(Math.random()*randomchatpriority[0])-randomchatlastmessage[1];
  6590. for(var i = 0;i<randomchatpriority[1].length;i++){
  6591. if(randomchatpriority[1][i][0]!=randomchatlastmessage[0]){
  6592. randnumber-=randomchatpriority[1][i][1];
  6593. if(randnumber<=0){
  6594. chat(flag_manage(randomchatpriority[1][i][0]));
  6595. randomchatpriority[1][i][1]+=2;
  6596. randomchatpriority[0]+=2;
  6597. randomchatlastmessage = randomchatpriority[1][i];
  6598. break;
  6599. }
  6600. }
  6601. }
  6602. }
  6603. }
  6604. for(var i = 0;i<keys.length;i++){
  6605. 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){
  6606. SEND('42[9,{"banshortid":'+keys[i].toString()+',"kickonly":'+(autokickban == 1).toString()+'}]');
  6607. autokickbantimestamp = now;
  6608. }
  6609. if(playerids[keys[i]].playerData){
  6610. if(playerids[keys[i]].playerData2){
  6611. if(playerids[keys[i]].playerData.transform){
  6612. playerids[keys[i]].playerData2.alive = true;
  6613. if(playerids[keys[i]].playerData2.timeStamp == 0){
  6614. playerids[keys[i]].playerData2.px = playerids[keys[i]].playerData.transform.position.x;
  6615. playerids[keys[i]].playerData2.py = playerids[keys[i]].playerData.transform.position.y;
  6616. playerids[keys[i]].playerData2.timeStamp = performance.now();
  6617. }
  6618. else{
  6619. playerids[keys[i]].playerData2.xvel = (playerids[keys[i]].playerData2.px - playerids[keys[i]].playerData.transform.position.x)/(playerids[keys[i]].playerData2.timeStamp-performance.now());
  6620. playerids[keys[i]].playerData2.yvel = (playerids[keys[i]].playerData2.py - playerids[keys[i]].playerData.transform.position.y)/(playerids[keys[i]].playerData2.timeStamp-performance.now());
  6621. playerids[keys[i]].playerData2.px = playerids[keys[i]].playerData.transform.position.x;
  6622. playerids[keys[i]].playerData2.py = playerids[keys[i]].playerData.transform.position.y;
  6623. playerids[keys[i]].playerData2.timeStamp = performance.now();
  6624. }
  6625. if(playerids[keys[i]].playerData2.timeStamp2 == 0){
  6626. playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.xvel;
  6627. playerids[keys[i]].playerData2.pvy = playerids[keys[i]].playerData2.yvel;
  6628. playerids[keys[i]].playerData2.timeStamp2 = performance.now();
  6629. }
  6630. else{
  6631. playerids[keys[i]].playerData2.xacc = (playerids[keys[i]].playerData2.pvx - playerids[keys[i]].playerData2.xvel)/((playerids[keys[i]].playerData2.timeStamp2-performance.now()));
  6632. playerids[keys[i]].playerData2.yacc = (playerids[keys[i]].playerData2.pvy - playerids[keys[i]].playerData2.yvel)/((playerids[keys[i]].playerData2.timeStamp2-performance.now()));
  6633. playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.xvel;
  6634. playerids[keys[i]].playerData2.pvy = playerids[keys[i]].playerData2.yvel;
  6635. playerids[keys[i]].playerData2.timeStamp2 = performance.now();
  6636. }
  6637. }
  6638. else{
  6639. if(playerids[keys[i]].playerData2.alive){
  6640. }
  6641. playerids[keys[i]].playerData2.alive = false;
  6642. }
  6643. }
  6644. else{
  6645. 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};
  6646. }
  6647. }
  6648. }
  6649. for(var i = 0;i<keys.length;i++){
  6650. if(!playerids[keys[i]].playerData2){
  6651. 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};
  6652. }
  6653. }
  6654. if(Gdocument.getElementById("redefineControls_table").children[0].children.length<=1 && keys.length>0){
  6655. Gdocument.getElementById("pretty_top_settings").click();
  6656. Gdocument.getElementById("settings_close").click();
  6657. }
  6658. if(pollactive[0] && pollactive[2]<now && ishost){
  6659. playerids[myid].ratelimit.poll = Date.now();
  6660. SEND("42"+JSON.stringify([4,{"type":"poll end","from":username}]));
  6661. var count = [0,0,0,0];
  6662. var keys = Object.keys(playerids);
  6663. for(var i = 0;i<keys.length;i++){
  6664. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  6665. count[playerids[keys[i]].vote.poll]++;
  6666. }
  6667. playerids[keys[i]].vote.poll = -1;
  6668. }
  6669. displayInChat("The poll ended due to time.","#DA0808","#1EBCC1");
  6670. for(var i = 0;i<count.length;i++){
  6671. if(count[i]>1){
  6672. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  6673. }
  6674. if(count[i]==1){
  6675. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  6676. }
  6677. }
  6678. displayInChat("The poll was:","#DA0808","#1EBCC1");
  6679. for(var i = 0;i<pollactive[3].length;i++){
  6680. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  6681. }
  6682. pollactive = [false,0,0,[]];
  6683. }
  6684. if(!ishost && sandboxcopyme!=-1){
  6685. sandboxcopyme = -1;
  6686. }
  6687. if(afkkill>0 && ishost){
  6688. var keys = Object.keys(playerids);
  6689. currentFrame = Math.floor((now - gameStartTimeStamp)/1000*30);
  6690. for(var i = 0; i<keys.length;i++){
  6691. if(typeof(playerids[keys[i]].lastmove)=="undefined"){
  6692. playerids[keys[i]].lastmove = now;
  6693. }
  6694. else{
  6695. if(playerids[keys[i]].playerData2?.alive && now-playerids[keys[i]].lastmove>=afkkill*1000 && now-gameStartTimeStamp>=afkkill*1000 && !killedids.includes(keys[i])){
  6696. killedids.push(keys[i]);
  6697. SEND('42[25,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  6698. RECIEVE('42[31,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  6699. break;
  6700. }
  6701. }
  6702. }
  6703. }
  6704. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  6705. clearmaprequests.style["display"] = "block";
  6706. refreshmaprequests.style["display"] = "block";
  6707. }
  6708. else{
  6709. clearmaprequests.style["display"] = "none";
  6710. refreshmaprequests.style["display"] = "none";
  6711. }
  6712. if(Gdocument.getElementById("gamerenderer").style["visibility"]=="hidden"){
  6713. Gdocument.getElementById("ingamewinner_scores").style["visibility"] = "unset";
  6714. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  6715. pan = {"x":0,"y":0};
  6716. }
  6717. if(Gdocument.getElementById("maploadwindowmapscontainer").children.length>0 && maponclick == 0){
  6718. maponclick = Gdocument.getElementById("maploadwindowmapscontainer").children[0].onclick;
  6719. }
  6720. 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"] == "")){
  6721. var chatbox = Gdocument.getElementById("newbonklobby_chat_content");
  6722. while (chatbox.firstChild) {
  6723. chatbox.removeChild(chatbox.firstChild);
  6724. }
  6725. chatbox = Gdocument.getElementById("ingamechatcontent");
  6726. while (chatbox.firstChild) {
  6727. chatbox.removeChild(chatbox.firstChild);
  6728. }
  6729. rcaps_flag = false;
  6730. space_flag = false;
  6731. number_flag = false;
  6732. reverse_flag = false;
  6733. autocorrect = false;
  6734. translating2 = [false,""];
  6735. translating = [false,""];
  6736. echo_list = [];
  6737. scroll = false;
  6738. FollowCam = false;
  6739. autocam = false;
  6740. aimbot = false;
  6741. recievedinitdata = false;
  6742. zoom = 1;
  6743. zoom2 = 1;
  6744. newzoom = 1;
  6745. newzoom2 = 1;
  6746. FFA = true;
  6747. mode = "b";
  6748. ghostroomwss = -1;
  6749. heavybot = false;
  6750. stopquickplay = 1;
  6751. roundsperqp = 1;
  6752. roundsperqp2 = 0;
  6753. staystill = false;
  6754. staystillpos = [0,0];
  6755. recording = false;
  6756. recordingid = -1;
  6757. reverseqp = false;
  6758. jointeam = -1;
  6759. currentroomaddress = -1;
  6760. checkboxhidden = false;
  6761. freejoin = false;
  6762. shuffle = false;
  6763. textmode = -1;
  6764. defaultmode = "";
  6765. recmodebool = false;
  6766. recteams = false;
  6767. autorecord = false;
  6768. pollactive = [false,0,0,[]];
  6769. pollactive2 = [false,0,[]];
  6770. afkkill = -1;
  6771. nextafter = 0;
  6772. jointext = "";
  6773. ishost = false;
  6774. parentDraw = 0;
  6775. sandboxplayerids = {};
  6776. sandboxcopyme = -1;
  6777. wintext = "";
  6778. sandboxon = false;
  6779. sandboxid = 200;
  6780. disabledkeys = [];
  6781. myid = -1;
  6782. randomchat = false;
  6783. savedroombutton.className = "brownButton brownButton_classic buttonShadow brownButtonDisabled";
  6784. randomchatpriority = [0,[]];
  6785. randomchatlastmessage = ["",0];
  6786. autokickbantimestamp = 0;
  6787. autokickban = 0;
  6788. inroom = false;
  6789. causelag = false;
  6790. causelag2 = 0;
  6791. jukeboxplayerURL = "";
  6792. jukeboxplayer.src = "";
  6793. jukeboxplayervolume = 20;
  6794. allstyles = {};
  6795. pan = {"x":0, "y":0};
  6796. if(!bonkwss){
  6797. playerids = {};
  6798. }
  6799. qppaused = false;
  6800. nextafterbuffer = -1;
  6801. hostid = -1;
  6802. if(chatlog[chatlog.length-1]!="ROOM END"){
  6803. chatlog.push("ROOM END");
  6804. }
  6805. }
  6806. else{
  6807. if(chatlog[chatlog.length-1]=="ROOM END"){
  6808. chatlog.push("ROOM START");
  6809. }
  6810. }
  6811. if(Gdocument.getElementById("newbonklobby").style["display"]=="block"){
  6812. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="hidden";
  6813. }
  6814. else{
  6815. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="visible";
  6816. }
  6817. if((myid == hostid && myid!=-1) || Gdocument.getElementsByClassName('newbonklobby_settings_button brownButton brownButton_classic buttonShadow brownButtonDisabled').length == 0){
  6818. ishost = true;
  6819. }
  6820. else{
  6821. ishost = actuallyhost;
  6822. }
  6823. if(Gdocument.getElementById("pretty_top_name")!=null){
  6824. username = Gdocument.getElementById("pretty_top_name").textContent;
  6825. if(myid!=-1){
  6826. username = playerids[myid].userName;
  6827. }
  6828. }
  6829. try{
  6830. Last_message = lastmessage()
  6831. } catch{
  6832. Last_message = "";
  6833. }
  6834. if (Laster_message != Last_message){
  6835. Laster_message = Last_message;
  6836. if(changed_chat==false){
  6837. new_message = true;
  6838. }
  6839. else{
  6840. changed_chat = false;
  6841. }
  6842. }
  6843. if(new_message){
  6844. chatlog.push(Last_message);
  6845. var lm = "";
  6846. try{
  6847. lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  6848. if(typeof(lm[0].parentElement.style["parsed"]) == 'undefined'){
  6849. if (lm[0].className == "newbonklobby_chat_msg_colorbox"){
  6850. lm[2].innerHTML = urlify(lm[2].innerHTML);
  6851. Laster_message = lastmessage();
  6852. lm[0].parentElement.style["parsed"] = true;
  6853. }
  6854. if (lm[0].className == "newbonklobby_chat_status"){
  6855. lm[0].innerHTML = urlify(lm[0].innerHTML);
  6856. Laster_message = lastmessage();
  6857. lm[0].parentElement.style["parsed"] = true;
  6858. }
  6859. }
  6860. }
  6861. catch{
  6862. lm = "";
  6863. }
  6864. if(Last_message.indexOf("@"+username)!=-1 && npermissions == 1){
  6865. if(Notification.requestPermission()){
  6866. var n = new Notification(Last_message);
  6867. }
  6868. }
  6869. try{
  6870. lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  6871. if(typeof(lm[0].parentElement.style["parsed"])=='undefined'){
  6872. if(lm[0].className == "ingamechatname"){
  6873. lm[1].innerHTML = urlify(lm[1].innerHTML);
  6874. Laster_message = lastmessage();
  6875. lm[0].parentElement.style["parsed"] = true;
  6876. }
  6877. if(lm[0].className == ""){
  6878. lm[0].innerHTML = urlify(lm[0].innerHTML);
  6879. Laster_message = lastmessage();
  6880. lm[0].parentElement.style["parsed"] = true;
  6881. }
  6882. }
  6883. }
  6884. catch{
  6885. lm = "";
  6886. }
  6887. if(text2speech){
  6888. if(!sayer.speaking){
  6889. if(Last_message.includes(": ")){
  6890. speech.text = Last_message.substring(0,Last_message.indexOf(":")).toLowerCase();
  6891. speech.rate = 2.25;
  6892. sayer.speak(speech);
  6893. speech.text = Last_message.substring(Last_message.indexOf(": ")+3).toLowerCase();
  6894. speech.rate = 1.25;
  6895. sayer.speak(speech);
  6896. }
  6897. else{
  6898. speech.text = Last_message.toLowerCase();
  6899. sayer.speak(speech);
  6900. }
  6901. }
  6902. }
  6903. }
  6904. if (ishost==true && new_message){
  6905. for(i=0;i<banned.length;i++){
  6906. if(Last_message.startsWith("* "+banned[i]+" has joined the game")){
  6907. chat2("/kick '"+banned[i]+"'");
  6908. }
  6909. }
  6910. }
  6911. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden" && ishost){
  6912. roundsperqp2 = 0;
  6913. }
  6914. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && ishost){
  6915. if(Gdocument.getElementById("ingamewinner").style["parsed"] != true){
  6916. if(stopquickplay!=1){
  6917. roundsperqp2++;
  6918. }
  6919. if(autorecord){
  6920. Gdocument.getElementById("pretty_top_replay").click();
  6921. }
  6922. }
  6923. if(Gdocument.getElementById("ingamewinner").style["parsed"] != true && wintext!="" && Gdocument.getElementById("ingamewinner_bottom").textContent!="DRAW"){
  6924. chat(flag_manage(wintext.replaceAll("username",Gdocument.getElementById("ingamewinner_top").textContent)));
  6925. }
  6926. Gdocument.getElementById("ingamewinner").style["parsed"] = true;
  6927. }
  6928. else{
  6929. Gdocument.getElementById("ingamewinner").style["parsed"] = false;
  6930. }
  6931. if(ishost && stopquickplay == 0){
  6932. if(checkboxhidden){
  6933. checkboxhidden = false;
  6934. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  6935. for(var i = 0; i<classes.length;i++){
  6936. classes[i].style["display"] = "block";
  6937. classes[i].className = "quickplaycheckbox quickplaychecked";
  6938. }
  6939. Gdocument.getElementById('clearallcheckboxes').style["display"] = "block";
  6940. }
  6941. if(nextafter>0 && gameStartTimeStamp+nextafter*1000<=now && Gdocument.getElementById("gamerenderer").style["visibility"] != "hidden" && dontswitch == false && Gdocument.getElementById("ingamewinner").style["visibility"]!="inherit" && !qppaused){
  6942. roundsperqp2 = 0;
  6943. if(shuffle){
  6944. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6945. var available = [];
  6946. var availableindexes = [];
  6947. var notempty = false;
  6948. for(var i = 0; i<e.length;i++){
  6949. var a = false;
  6950. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6951. available.push(a);
  6952. if(a){
  6953. availableindexes.push(i);
  6954. notempty = true;
  6955. }
  6956. }
  6957. if(notempty){
  6958. if(availableindexes.length!=1){
  6959. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  6960. }
  6961. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  6962. }
  6963. }
  6964. else{
  6965. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6966. var available = [];
  6967. var availableindexes = [];
  6968. var notempty = false;
  6969. for(var i = 0; i<e.length;i++){
  6970. var a = false;
  6971. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6972. available.push(a);
  6973. if(a){
  6974. availableindexes.push(i);
  6975. notempty = true;
  6976. }
  6977. }
  6978. if(notempty){
  6979. var above = [];
  6980. for(var i = 0;i<availableindexes.length;i++){
  6981. if(availableindexes[i]>quicki && !reverseqp){
  6982. above.push(availableindexes[i]);
  6983. }
  6984. else if(availableindexes[i]<quicki && reverseqp){
  6985. above.push(availableindexes[i]);
  6986. }
  6987. }
  6988. if(above.length>0){
  6989. quicki = above[0];
  6990. if(reverseqp){
  6991. above[above.length-1];
  6992. }
  6993. }
  6994. else{
  6995. quicki = availableindexes[0];
  6996. if(reverseqp){
  6997. quicki = availableindexes[availableindexes.length-1];
  6998. }
  6999. }
  7000. }
  7001. }
  7002. startedinqp = true;
  7003. dontswitch = true;
  7004. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  7005. }
  7006. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && dontswitch == false && !document.hidden && !qppaused){
  7007. if(roundsperqp2>=roundsperqp){
  7008. if(shuffle){
  7009. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  7010. var available = [];
  7011. var availableindexes = [];
  7012. var notempty = false;
  7013. for(var i = 0; i<e.length;i++){
  7014. var a = false;
  7015. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  7016. available.push(a);
  7017. if(a){
  7018. availableindexes.push(i);
  7019. notempty = true;
  7020. }
  7021. }
  7022. if(notempty){
  7023. if(availableindexes.length!=1){
  7024. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  7025. }
  7026. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  7027. }
  7028. }
  7029. else{
  7030. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  7031. var available = [];
  7032. var availableindexes = [];
  7033. var notempty = false;
  7034. for(var i = 0; i<e.length;i++){
  7035. var a = false;
  7036. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  7037. available.push(a);
  7038. if(a){
  7039. availableindexes.push(i);
  7040. notempty = true;
  7041. }
  7042. }
  7043. if(notempty){
  7044. var above = [];
  7045. for(var i = 0;i<availableindexes.length;i++){
  7046. if(availableindexes[i]>quicki && !reverseqp){
  7047. above.push(availableindexes[i]);
  7048. }
  7049. else if(availableindexes[i]<quicki && reverseqp){
  7050. above.push(availableindexes[i])
  7051. }
  7052. }
  7053. if(above.length>0){
  7054. quicki = above[0];
  7055. if(reverseqp){
  7056. quicki = above[above.length-1];
  7057. }
  7058. }
  7059. else{
  7060. quicki = availableindexes[0];
  7061. if(reverseqp){
  7062. quicki = availableindexes[availableindexes.length-1];
  7063. }
  7064. }
  7065. }
  7066. }
  7067. }
  7068. transitioning = true;
  7069. startedinqp = true;
  7070. map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  7071. dontswitch = true;
  7072. setTimeout(function(){Gdocument.getElementById("ingamewinner").style["visibility"]="hidden"; dontswitch = false;},timedelay);
  7073. }
  7074. }
  7075. else{
  7076. if(!checkboxhidden){
  7077. checkboxhidden = true;
  7078. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  7079. for(var i = 0; i<classes.length;i++){
  7080. classes[i].style["display"] = "none";
  7081. classes[i].className = "quickplaycheckbox quickplayunchecked";
  7082. }
  7083. Gdocument.getElementById('clearallcheckboxes').style["display"] = "none";
  7084. }
  7085. }
  7086. new_message = false;
  7087. };
  7088. });