Bonk Commands

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

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

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

QingJ © 2025

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