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

QingJ © 2025

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