Guest User

xd

a guest
Nov 17th, 2019
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 356.13 KB | None | 0 0
  1. function init(window, ogario, JQuery) {
  2. window.server = {
  3. host: 'ws://localhost:8083'
  4. }
  5. class Writer {
  6. constructor(size){
  7. this.dataView = new DataView(new ArrayBuffer(size))
  8. this.byteOffset = 0
  9. }
  10. writeUint8(value){
  11. this.dataView.setUint8(this.byteOffset++, value)
  12. }
  13. writeInt32(value){
  14. this.dataView.setInt32(this.byteOffset, value, true)
  15. this.byteOffset += 4
  16. }
  17. writeUint32(value){
  18. this.dataView.setUint32(this.byteOffset, value, true)
  19. this.byteOffset += 4
  20. }
  21. writeString(string){
  22. for(let i = 0; i < string.length; i++) this.writeUint8(string.charCodeAt(i))
  23. this.writeUint8(0)
  24. }
  25. }
  26. window.recaptchaExecuteLoop = function() {
  27. grecaptcha.reset();
  28. grecaptcha.execute(0, {
  29. 'action': 'play'
  30. }).then(() => {
  31. if (window.myTurn) return Connection._sendNick(window.lastNick, grecaptcha.getResponse());
  32. let botServerIsOnline = (window.connection && window.connection.ws && window.connection.ws.readyState === 1);
  33. if (botServerIsOnline) window.connection.sendToken(grecaptcha.getResponse());
  34. else return;
  35. console.log("got new token :)")
  36. recaptchaExecuteLoop();
  37. });
  38. }
  39. window.buffers = {
  40. startBots(url, protocolVersion, clientVersion, userStatus, botsName, botsAmount){
  41. const writer = new Writer(13 + url.length + botsName.length)
  42. writer.writeUint8(0)
  43. writer.writeString(url)
  44. writer.writeUint32(protocolVersion)
  45. writer.writeUint32(clientVersion)
  46. writer.writeUint8(Number(userStatus))
  47. writer.writeString(botsName)
  48. writer.writeUint8(botsAmount)
  49. return writer.dataView.buffer
  50. },
  51. mousePosition(x, y){
  52. const writer = new Writer(9)
  53. writer.writeUint8(6)
  54. writer.writeInt32(x)
  55. writer.writeInt32(y)
  56. return writer.dataView.buffer
  57. }
  58. }
  59. window.connection = {
  60. ws: null,
  61. connect(){
  62. this.ws = new WebSocket(`${window.server.host}`)
  63. this.ws.binaryType = 'arraybuffer'
  64. this.ws.onopen = this.onopen.bind(this)
  65. this.ws.onmessage = this.onmessage.bind(this)
  66. this.ws.onclose = this.onclose.bind(this)
  67. },
  68. send(buffer){
  69. if(this.ws && this.ws.readyState === WebSocket.OPEN) this.ws.send(buffer)
  70. },
  71. onopen(){
  72. recaptchaExecuteLoop();
  73. document.getElementById('userStatus').style.color = '#00C02E'
  74. document.getElementById('userStatus').innerText = 'Connected'
  75. toastr["info"]('Connected: Server Online!')
  76. document.getElementById('connect').disabled = true
  77. document.getElementById('startBots').disabled = false
  78. document.getElementById('stopBots').disabled = false
  79. },
  80. sendToken(token) {
  81. if (token === undefined) return;
  82. let buf = new Writer(2 + token.length);
  83. buf.writeUint8(7);
  84. buf.writeString(token);
  85. window.connection.send(buf.dataView.buffer)
  86. },
  87. onmessage(message){
  88. const dataView = new DataView(message.data)
  89. switch(dataView.getUint8(0)){
  90. case 0:
  91. document.getElementById('startBots').disabled = true
  92. document.getElementById('stopBots').disabled = false
  93. document.getElementById('startBots').style.display = 'none'
  94. document.getElementById('stopBots').style.display = 'inline'
  95. document.getElementById('stopBots').innerText = 'Stop Bots'
  96. window.user.startedBots = true
  97. toastr["info"]('Server: Bots Started!')
  98. break
  99. case 1:
  100. document.getElementById('stopBots').disabled = true
  101. document.getElementById('stopBots').innerText = 'Stopping Bots...'
  102. toastr["info"]('Server: Stopping Bots...')
  103. break
  104. case 2:
  105. document.getElementById('botsAI').style.color = '#DA0A00'
  106. document.getElementById('botsAI').innerText = 'Disabled'
  107. document.getElementById('startBots').disabled = false
  108. document.getElementById('stopBots').disabled = true
  109. document.getElementById('startBots').style.display = 'inline'
  110. document.getElementById('stopBots').style.display = 'none'
  111. document.getElementById('stopBots').innerText = 'Stop Bots'
  112. window.user.startedBots = false
  113. window.bots.ai = false
  114. break
  115. case 3:
  116. toastr.info('Your IP has captcha and bots are unable to spawn, change your ip with a VPN or something to one that doesn\'t has captcha in order to use the bots')
  117. break
  118. case 4:
  119. //Connected Bot count = getUint8(1)
  120. //Spawned Bot count = getUint8(2)
  121. //Server player amount = getUint8(3)
  122. $('#botCount').html(`${dataView.getUint8(1)}/${dataView.getUint8(2)}/${window.bots.amount}`)
  123. $('#slots').html(dataView.getUint8(3) + "/200")
  124. break;
  125. }
  126. },
  127. onclose(){
  128. document.getElementById('userStatus').style.color = '#DA0A00'
  129. document.getElementById('userStatus').innerText = 'Disconnected'
  130. document.getElementById('botsAI').style.color = '#DA0A00'
  131. document.getElementById('botsAI').innerText = 'Disabled'
  132. document.getElementById('connect').disabled = false
  133. document.getElementById('startBots').disabled = true
  134. document.getElementById('stopBots').disabled = true
  135. document.getElementById('startBots').style.display = 'inline'
  136. document.getElementById('stopBots').style.display = 'none'
  137. window.user.startedBots = false
  138. window.bots.ai = false
  139. }
  140. }
  141. window.game = {
  142. url: '',
  143. protocolVersion: 0,
  144. clientVersion: 0
  145. }
  146. window.user = {
  147. startedBots: false,
  148. isAlive: false,
  149. mouseX: 0,
  150. mouseY: 0,
  151. offsetX: 0,
  152. offsetY: 0,
  153. macroFeedInterval: null
  154. }
  155. window.bots = {
  156. name: '',
  157. amount: 0,
  158. ai: false
  159. }
  160. const displayText = {
  161. pl: {
  162. start: `Start`,
  163. settings: `Ustawienia`,
  164. restoreSettings: `Przywróc ustawienia domyślne`,
  165. animationGroup: `Animacja`,
  166. zoomGroup: `Zoom`,
  167. respGroup: `Odrodzenie`,
  168. namesGroup: 'Nazwy',
  169. massGroup: 'Masa',
  170. skinsGroup: `Skiny`,
  171. foodGroup: `Pokarm`,
  172. transparencyGroup: `Przezroczystość / kolory`,
  173. gridGroup: `Siatka / sektory`,
  174. miniMapGroup: `Minimapa`,
  175. helpersGroup: `Wspomagacze`,
  176. mouseGroup: `Sterowanie myszkÄ…`,
  177. hudGroup: `HUD`,
  178. chatGroup: `Czat`,
  179. statsGroup: 'Statystyki',
  180. extrasGroup: `Dodatkowe`,
  181. noSkins: `Wyłącz skiny`,
  182. noNames: 'Wyłącz nazwy',
  183. noColors: `Wyłącz kolory`,
  184. showMass: 'Pokaż masę',
  185. skipStats: `Pomiń statystyki po śmierci`,
  186. showQuest: `Pokaż zadanie (quest)`,
  187. autoZoom: `Auto zoom`,
  188. animation: `Opóźnienie animacji`,
  189. zoomSpeedValue: `Szybkość zoomu`,
  190. quickResp: `Szybkie odrodzenie (klawisz)`,
  191. autoResp: 'Auto odrodzenie',
  192. autoHideCellsInfo: `Autoukrywanie nazw i masy`,
  193. autoHideNames: `Autoukrywanie nazw`,
  194. autoHideMass: `Autoukrywanie masy`,
  195. autoHideFood: `Autoukrywanie pokarmu (masa)`,
  196. autoHideFoodOnZoom: `Autoukrywanie pokarmu (zoom)`,
  197. optimizedNames: `Zoptymalizowane nazwy`,
  198. hideMyName: `Ukryj własną nazwę`,
  199. hideTeammatesNames: `Ukryj nazwy graczy teamu`,
  200. optimizedMass: `Zoptymalizowana masa (+/-2%)`,
  201. shortMass: `Skrócona masa (k)`,
  202. virMassShots: `Licznik strzałów (wirusy)`,
  203. hideMyMass: `Ukryj własną masę`,
  204. hideEnemiesMass: 'Ukryj masę przeciwników',
  205. vanillaSkins: `Podstawowe skiny`,
  206. customSkins: 'WÅ‚asne skiny',
  207. myTransparentSkin: `Mój przezroczysty skin`,
  208. myCustomColor: `Mój własny kolor`,
  209. transparentCells: `Przezroczyste kulki`,
  210. transparentViruses: `Przezroczyste wirusy`,
  211. transparentSkins: 'Przezroczyste skiny',
  212. showGrid: `Siatka`,
  213. showBgSectors: 'Sektory w tle',
  214. showMapBorders: `Granice mapy`,
  215. showGhostCells: `Duchy kulek`,
  216. showMiniMap: `Pokaż minimapę`,
  217. showMiniMapGrid: `Pokaż siatkę minimapy`,
  218. showMiniMapGuides: 'Pokaż prowadnice na minimapie',
  219. showMiniMapGhostCells: `Pokaż duchy kulek na minimapie`,
  220. oneColoredTeammates: `Jednokolorowi gracze`,
  221. optimizedFood: 'Zoptymalizowany pokarm',
  222. rainbowFood: `Kolorowy pokarm`,
  223. oppColors: 'Kolory przeciwników',
  224. oppRings: `Ringi przeciwników`,
  225. virColors: `Kolory wirusów`,
  226. splitRange: `Zasięg podziału`,
  227. virusesRange: `Zasięg wirusów`,
  228. textStroke: `Obwódki nazw i masy`,
  229. namesStroke: `Obwódki nazw`,
  230. massStroke: `Obwódki masy`,
  231. cursorTracking: 'Åšledzenie kursora',
  232. teammatesInd: `Wskaźniki graczy teamu`,
  233. mouseSplit: `LPM - Split myszkÄ…`,
  234. mouseFeed: `PPM - Feed myszkÄ…`,
  235. mouseInvert: `Odwróć klawisze myszki`,
  236. disableChat: `Wyłącz czat`,
  237. hideChat: `Ukryj czat`,
  238. chatSounds: 'Powiadomienia dźwiękowe',
  239. chatEmoticons: `Emotikony`,
  240. showChatImages: 'Pokaż obrazki na czacie',
  241. showChatVideos: 'Pokaż filmiki na czacie',
  242. showChatBox: `Czatbox zamiast wyskakujących wiadomości`,
  243. messageSound: `Dźwięk powiadomienia o wiadomości`,
  244. commandSound: `Dźwięk powiadomienia o komendzie`,
  245. showTop5: `Pokaż top 5 teamu`,
  246. showTargeting: 'Pokaż namierzanie',
  247. showTime: `Pokaż aktualny czas`,
  248. showLbData: 'Pokaż masę w topce',
  249. normalLb: `Nagłówek "Topka"`,
  250. centeredLb: `Wyśrodkowana topka`,
  251. fpsAtTop: `Statystyki na górze`,
  252. showStats: `Pokaż statystyki`,
  253. showStatsMass: `Statystyki: Masa`,
  254. showStatsSTE: `Statystyki: STE`,
  255. showStatsN16: `Statystyki: n/16`,
  256. showStatsFPS: `Statystyki: FPS`,
  257. blockPopups: `Blokuj popupy (reklamy/sklep/zadanie)`,
  258. hotkeys: 'Skróty klawiszowe',
  259. 'hk-inst-assign': `Aby ustawić skrót klawiszowy kliknij na polu skrótu i naciśnij wybrany klawisz.`,
  260. 'hk-inst-delete': `Aby usunąć skrót klawiszowy kliknij na polu skrótu i naciśnij klawisz DELETE.`,
  261. 'hk-inst-keys': `Możliwe kombinacje skrótów klawiszowych z użyciem klawiszy CTRL oraz ALT.`,
  262. 'hk-bots-split': 'Bots split',
  263. 'hk-bots-feed': 'Bots feed',
  264. 'hk-bots-ai': 'Bots AI toggle',
  265. 'hk-feed': `Feed`,
  266. 'hk-macroFeed': 'Szybki feed',
  267. 'hk-split': `Podział`,
  268. 'hk-doubleSplit': `Podwójny podział`,
  269. 'hk-split16': `Podział na 16`,
  270. 'hk-pause': `Pauza kulki`,
  271. 'hk-showTop5': `Pokaż/ukryj top 5 teamu`,
  272. 'hk-showTime': `Pokaż/ukryj aktualny czas`,
  273. 'hk-showSplitRange': `Pokaż/ukryj zasięg podziału`,
  274. 'hk-showSplitInd': `Pokaż/ukryj zasięg podziału z ringami`,
  275. 'hk-showTeammatesInd': `Pokaż/ukryj wskaźniki graczy teamu`,
  276. 'hk-showOppColors': `Pokaż/ukryj kolory przeciwników`,
  277. 'hk-toggleSkins': `Przełącz skiny (własne/standardowe)`,
  278. 'hk-showSkins': `Pokaż/ukryj skiny`,
  279. 'hk-transparentSkins': `Włącz/wyłącz przezroczyste skiny`,
  280. 'hk-showStats': `Pokaż/ukryj statystyki gry`,
  281. 'hk-toggleCells': `Przełącz kulkę (najmniejsza/największa)`,
  282. 'hk-showFood': 'Pokaż/ukryj pokarm',
  283. 'hk-showGrid': 'Pokaż/ukryj siatkę',
  284. 'hk-showMiniMapGuides': `Pokaż/ukryj prowadnice na minimapie`,
  285. 'hk-hideChat': `Pokaż/ukryj czat`,
  286. 'hk-showHUD': `Pokaż/ukryj HUD`,
  287. 'hk-copyLb': `Kopiuj topkÄ™`,
  288. 'hk-showLb': `Pokaż/ukryj topkę`,
  289. 'hk-toggleAutoZoom': 'Włącz/wyłącz auto zoom',
  290. 'hk-resetZoom': `Reset zoomu`,
  291. 'hk-zoomLevel': `Zoom - poziom`,
  292. 'hk-toggleDeath': `Przełącz miejsce śmierci`,
  293. 'hk-clearChat': `Pokaż historię czatu / Czyść czat`,
  294. 'hk-showBgSectors': 'Pokaż/ukryj sektory w tle',
  295. 'hk-hideBots': 'Pokaż/ukryj małe boty',
  296. 'hk-showNames': `Pokaż/ukryj nazwy`,
  297. 'hk-hideTeammatesNames': `Pokaż/ukryj nazwy graczy teamu`,
  298. 'hk-showMass': 'Pokaż/ukryj masę',
  299. 'hk-showMiniMap': `Pokaż/ukryj minimapę`,
  300. 'hk-chatMessage': `Napisz wiadomość na czacie`,
  301. 'hk-quickResp': `Szybkie odrodzenie (respawn)`,
  302. 'hk-autoResp': `Włącz/wyłacz auto odrodzenie`,
  303. 'hk-switchServerMode': `Przełącz serwer [publiczny/prywatny]`,
  304. 'hk-showTargeting': `Pokaż/ukryj panel namierzania`,
  305. 'hk-setTargeting': 'Włącz/wyłącz namierzanie (śledzenie)',
  306. 'hk-cancelTargeting': `Zatrzymaj namierzanie`,
  307. 'hk-changeTarget': `Zmień cel`,
  308. 'hk-privateMiniMap': `Pokaż cel na minimapie`,
  309. 'hk-showQuest': `Pokaż/ukryj zadanie`,
  310. commands: `Komendy`,
  311. comm1: 'Feeduj!',
  312. comm2: 'Dziel siÄ™!',
  313. comm3: `Pomocy na %currentSector%!`,
  314. comm4: `Wróg na %currentSector%!`,
  315. comm5: `Zabij pomocnika!`,
  316. comm6: `Strzel z wirusa!`,
  317. comm7: `Zjedz wirusa!`,
  318. comm8: `Zjebałem, wybacz.`,
  319. comm9: `Ja pierdolÄ™...`,
  320. comm0: `Kurwa mać!`,
  321. comm10: 'Trick!',
  322. comm11: `Lewo!`,
  323. comm12: `Góra!`,
  324. comm13: `Prawo!`,
  325. comm14: `Dół!`,
  326. saveComm: `Zapisz komendy`,
  327. theme: 'WyglÄ…d',
  328. restoreThemeSettings: `Przywróc ustawienia domyślne wyglądu`,
  329. basicTheming: `Podstawowy`,
  330. themePreset: `Motyw`,
  331. themeType: 'Typ motywu',
  332. darkTheme: `Ciemny motyw`,
  333. lightTheme: 'Jasny motyw',
  334. mainColor: `Kolor główny`,
  335. bgColor: 'TÅ‚o',
  336. bordersColor: `Granice mapy`,
  337. gridColor: `Siatka`,
  338. sectorsColor: `Czcionka sektorów`,
  339. namesColor: `Nazwy`,
  340. namesStrokeColor: `Obwódki nazw`,
  341. massColor: `Masa`,
  342. massStrokeColor: `Obwódki masy`,
  343. virusColor: `Wirusy`,
  344. virusStrokeColor: 'Obwódki wirusów',
  345. foodColor: `Pokarm`,
  346. namesFont: 'Czcionka nazw',
  347. massFont: `Czcionka masy`,
  348. sectorsFont: `Czcionka sektorów`,
  349. namesScale: 'Skala nazw',
  350. massScale: 'Skala masy',
  351. virMassScale: `Skala masy wirusów`,
  352. strokeScale: `Skala obwódek tekstu`,
  353. foodSize: 'Wielkość pokarmu',
  354. bordersWidth: 'Grubość granic mapy',
  355. sectorsWidth: `Grubość siatki sektorów`,
  356. sectorsFontSize: `Rozmiar czcionki sektorów`,
  357. cellsAlpha: `Przezroczystość kulek`,
  358. skinsAlpha: `Przezroczystość skinów`,
  359. virusAlpha: `Przezroczystość wirusów`,
  360. textAlpha: 'Przezroczystość nazw i masy',
  361. virusStrokeSize: `Grubość obwódki wirusów`,
  362. teammatesIndColor: `Wskaźnik gracza`,
  363. cursorTrackingColor: 'Åšledzenie kursora',
  364. splitRangeColor: `Zasięg podziału`,
  365. safeAreaColor: `Bezpieczna strefa`,
  366. dangerAreaColor: 'Strefa zagrożenia',
  367. ghostCellsColor: `Duchy kulek`,
  368. ghostCellsAlpha: 'Przezroczystość duchów kulek',
  369. menuTheming: `Menu`,
  370. menuPreset: `Motyw menu`,
  371. menuMainColor: `Kolor główny`,
  372. menuBtnTextColor: 'Tekst przycisku',
  373. menuPanelColor: `Panel`,
  374. menuPanelColor2: `Panel (2)`,
  375. menuTextColor: `Tekst panelu`,
  376. menuTextColor2: 'Tekst panelu (2)',
  377. btn1Color: `Przycisk #1`,
  378. btn1Color2: 'Przycisk #1 (2)',
  379. btn2Color: `Przycisk #2`,
  380. btn2Color2: `Przycisk #2 (2)`,
  381. btn3Color: `Przycisk #3`,
  382. btn3Color2: 'Przycisk #3 (2)',
  383. btn4Color: `Przycisk #4`,
  384. btn4Color2: `Przycisk #4 (2)`,
  385. menuBg: 'Grafika tła panelu',
  386. menuOpacity: 'Przezroczystość',
  387. hudTheming: `HUD`,
  388. hudMainColor: `Kolor główny`,
  389. hudColor: `TÅ‚o`,
  390. hudTextColor: 'Tekst',
  391. statsHudColor: `Statystyki`,
  392. timeHudColor: 'Czas',
  393. top5MassColor: `Masa`,
  394. lbMeColor: `Topka - ja`,
  395. lbTeammateColor: `Topka - team`,
  396. hudFont: `Czcionka HUD`,
  397. hudScale: `Skala HUD`,
  398. chatTheming: 'Czat',
  399. messageColor: 'Tło wiadomości',
  400. messageTextColor: 'Tekst wiadomości',
  401. messageTimeColor: `Czas wiadomości`,
  402. messageNickColor: `Nick wiadomości`,
  403. commandsColor: `TÅ‚o komendy`,
  404. commandsTextColor: `Tekst komendy`,
  405. commandsTimeColor: 'Czas komendy',
  406. commandsNickColor: `Nick komendy`,
  407. chatBoxColor: `TÅ‚o czatboxu`,
  408. chatScale: `Skala czatu`,
  409. miniMapTheming: `Minimapa`,
  410. miniMapSectorsColor: `Sektory`,
  411. miniMapSectorColor: `Aktualny sektor`,
  412. miniMapGuidesColor: `Prowadnice`,
  413. miniMapNickColor: 'Nick',
  414. miniMapNickStrokeColor: `Obwódka nicku`,
  415. miniMapMyCellColor: 'Moja kulka',
  416. miniMapMyCellStrokeColor: `Obwódka mojej kulki`,
  417. miniMapTeammatesColor: 'Gracze',
  418. miniMapDeathLocationColor: `Miejsce śmierci`,
  419. miniMapFont: `Czcionka minimapy`,
  420. miniMapNickFont: `Czcionka nicku`,
  421. miniMapWidth: `Szerokość minimapy`,
  422. miniMapSectorsOpacity: 'Przezroczystość sektorów',
  423. miniMapNickSize: `Rozmiar nicku`,
  424. miniMapNickStrokeSize: `Grubość obwódki nicku`,
  425. miniMapMyCellSize: `Wielkość mojej kulki`,
  426. miniMapMyCellStrokeSize: `Grubość obwódki mojej kulki`,
  427. miniMapTeammatesSize: `Wielkość graczy`,
  428. miniMapGhostCellsColor: `Duchy kulek`,
  429. miniMapGhostCellsAlpha: `Przezroczystość duchów kulek`,
  430. imagesTheming: 'Grafika / kursory',
  431. customBackground: `Grafika tła`,
  432. customCursor: `Grafika kursora`,
  433. hideChatMsgA: `Czat został włączony!`,
  434. hideChatMsgB: `Czat został ukryty!`,
  435. showSkinsMsgA: 'Skiny zostały włączone!',
  436. showSkinsMsgB: `Skiny zostały ukryte!`,
  437. hideSmallBotsMsgA: 'Małe boty stały się widoczne!',
  438. hideSmallBotsMsgB: 'Małe boty zostały ukryte!',
  439. autoRespMsgA: `Auto odrodzenie zostało włączone!`,
  440. autoRespMsgB: `Auto odrodzenie zostało wyłączone!`,
  441. autoZoomMsgA: `Auto zoom został włączony!`,
  442. autoZoomMsgB: 'Auto zoom został wyłączony!',
  443. targetNotSet: `Brak celu`,
  444. targetDead: `Nie żyje`,
  445. targetDistance: 'Dystans',
  446. targetMass: `Masa razem`,
  447. totalPartyPlayers: 'Aktywnych graczy',
  448. totalPartyMass: 'Łącznie masy',
  449. exportImport: `Eksport / import ustawień`,
  450. exportSettings: `Eksportuj ustawienia`,
  451. exportInfo: 'Aby wyeksportować wybrane ustawienia skopiuj poniższy kod i zapisz go w pliku tekstowym z kodowaniem Unicode.',
  452. importSettings: 'Importuj ustawienia',
  453. importInfo: `Aby zaimportować wybrane ustawienia wklej poniżej wyeksportowany wcześniej kod i naciśnij przycisk "Importuj ustawienia".`,
  454. profile: `Profil`,
  455. profiles: `Profile`,
  456. skins: 'Skiny',
  457. moreSkins: `Dodaj skiny`,
  458. thanks: `Dzięki Awesome!`,
  459. saveSett: `Zapisz ustawienia`,
  460. saved: 'Zapisano!',
  461. resetSett: `Resetuj ustawienia`,
  462. close: `Zamknij`,
  463. enterChatMsg: `Napisz wiadomość`,
  464. activeParties: `Aktywne party`,
  465. noActiveParties: `Brak aktywnych party ;(`,
  466. playlist: `Playlista`,
  467. pause: `PAUZA!`,
  468. visit: `Odwiedź`,
  469. exit: 'OGARio by szymy: Czy na pewno chcesz opuścic grę?',
  470. blockWarn: `UWAGA! Popupy zostały zablokowane w ustawieniach.`,
  471. unblockPopups: `Odblokuj tymczasowo`,
  472. mass: `Masa`,
  473. score: `Top`,
  474. leaderboard: `Topka`,
  475. user: `Użytkownik`,
  476. userMuted: `Użytkownik %user% został wyciszony.`,
  477. userUnmuted: `Wyłączono wyciszenie użytkownika %user%.`,
  478. mute: `Wycisz`,
  479. unmute: 'Wyłącz wyciszenie',
  480. mutedUsers: `Wyciszeni użytkownicy`,
  481. activeUsers: `Aktywni użytkownicy`,
  482. showActiveUsers: 'Pokaż aktywnych użytkowników',
  483. none: `Brak`,
  484. sounds: 'Dźwięki',
  485. page_back_button: `Wróć`,
  486. page_create_party: `Stwórz party`,
  487. page_join_party: `Dołącz`,
  488. page_login_and_play: `Zaloguj`,
  489. page_logout: `Wyloguj`,
  490. page_menu_login_facebook: `Zaloguj z Facebook`,
  491. page_menu_login_google: 'Zaloguj z Google',
  492. page_menu_main_free_coins: `Darmowe Monety`,
  493. page_menu_main_gifts: 'Prezenty',
  494. page_menu_main_dailyquests: `Zadania`,
  495. page_party_join_error: 'Nie można dołączyć do tego party. Upewnij się, że token jest prawidłowy lub stwórz nowy.',
  496. page_play: `Graj`,
  497. page_play_as_guest: `Graj jako gość`,
  498. page_shop: `Sklep`,
  499. page_spectate: `Obserwuj`,
  500. page_stats: `Statystyki`
  501. },
  502. en: {
  503. start: `Home`,
  504. settings: `Settings`,
  505. restoreSettings: `Restore default settings`,
  506. animationGroup: `Animation`,
  507. zoomGroup: `Zoom`,
  508. respGroup: `Respawn`,
  509. namesGroup: `Names`,
  510. massGroup: 'Mass',
  511. skinsGroup: `Skins`,
  512. foodGroup: `Food`,
  513. transparencyGroup: 'Transparency / colors',
  514. gridGroup: 'Grid / sectors',
  515. miniMapGroup: `Minimap`,
  516. helpersGroup: `Helpers`,
  517. mouseGroup: `Mouse control`,
  518. hudGroup: `HUD`,
  519. chatGroup: `Chat`,
  520. statsGroup: `Stats`,
  521. extrasGroup: `Extras`,
  522. noSkins: `No skins`,
  523. noNames: 'No names',
  524. noColors: 'No colors',
  525. showMass: `Show mass`,
  526. skipStats: 'Skip stats after death',
  527. showQuest: `Show quest`,
  528. autoZoom: `Auto zoom`,
  529. animation: `Animation delay`,
  530. zoomSpeedValue: `Zoom speed`,
  531. quickResp: `Quick respawn (hotkey)`,
  532. autoResp: `Auto respawn`,
  533. autoHideCellsInfo: `Auto hide names and mass`,
  534. autoHideNames: `Auto hide names`,
  535. autoHideMass: `Auto hide mass`,
  536. autoHideFood: `Auto hide food (mass)`,
  537. autoHideFoodOnZoom: 'Auto hide food (zoom)',
  538. optimizedNames: `Optimized names`,
  539. hideMyName: `Hide my name`,
  540. hideTeammatesNames: `Hide teammates names`,
  541. optimizedMass: `Optimized mass (+/-2%)`,
  542. shortMass: `Short mass (k)`,
  543. virMassShots: `Virus shots`,
  544. hideMyMass: `Hide my mass`,
  545. hideEnemiesMass: `Hide enemies mass`,
  546. vanillaSkins: `Vanilla skins`,
  547. customSkins: `Custom skins`,
  548. myTransparentSkin: `My transparent skin`,
  549. myCustomColor: `My custom color`,
  550. transparentCells: `Transparent cells`,
  551. transparentViruses: 'Transparent viruses',
  552. transparentSkins: 'Transparent skins',
  553. showGrid: 'Show grid',
  554. showBgSectors: `Show background sectors`,
  555. showMapBorders: `Show map borders`,
  556. showGhostCells: `Ghost cells`,
  557. showMiniMap: `Show minimap`,
  558. showMiniMapGrid: `Show minimap grid`,
  559. showMiniMapGuides: `Show minimap guides`,
  560. showMiniMapGhostCells: `Show ghost cells`,
  561. oneColoredTeammates: 'One-colored teammates',
  562. optimizedFood: `Optimized food`,
  563. rainbowFood: `Rainbow food`,
  564. oppColors: `Opponents colors`,
  565. oppRings: `Opponents rings`,
  566. virColors: `Viruses colors`,
  567. splitRange: `Split range`,
  568. virusesRange: 'Viruses range',
  569. textStroke: `Names and mass stroke`,
  570. namesStroke: 'Names stroke',
  571. massStroke: `Mass stroke`,
  572. cursorTracking: 'Cursor tracking',
  573. teammatesInd: `Teammates indicators`,
  574. mouseSplit: `LMB - Mouse split`,
  575. mouseFeed: `RMB - Mouse feed`,
  576. mouseInvert: `Invert mouse buttons`,
  577. disableChat: 'Disable chat',
  578. hideChat: `Hide chat`,
  579. chatSounds: `Sound notifications`,
  580. chatEmoticons: `Emoticons`,
  581. showChatImages: 'Show images on chat',
  582. showChatVideos: `Show videos on chat`,
  583. showChatBox: `Chatbox instead of popups`,
  584. messageSound: `Message notification sound`,
  585. commandSound: `Command notification sound`,
  586. showTop5: 'Show team top 5',
  587. showTargeting: `Show targeting`,
  588. showTime: 'Show current time',
  589. showLbData: `Show leaderboard mass`,
  590. normalLb: `"Leaderboard" header`,
  591. centeredLb: `Centered leaderboard`,
  592. fpsAtTop: `Game stats at the top`,
  593. showStats: `Show game stats`,
  594. showStatsMass: `Game stats: Mass`,
  595. showStatsSTE: `Game stats: STE`,
  596. showStatsN16: `Game stats: n/16`,
  597. showStatsFPS: `Game stats: FPS`,
  598. blockPopups: `Block popups (ads/shop/quest)`,
  599. hotkeys: 'Hotkeys',
  600. 'hk-inst-assign': `To assign a hotkey click on the input field and press your chosen key.`,
  601. 'hk-inst-delete': `To delete a hotkey click on the input field and press the DELETE key.`,
  602. 'hk-inst-keys': `Possible key combinations with the CTRL and ALT keys.`,
  603. 'hk-bots-split': 'Bots split',
  604. 'hk-bots-feed': 'Bots feed',
  605. 'hk-bots-ai': 'Bots AI toggle',
  606. 'hk-feed': 'Feed',
  607. 'hk-macroFeed': 'Macro feed',
  608. 'hk-split': `Split`,
  609. 'hk-doubleSplit': `Double split`,
  610. 'hk-split16': `Split 16`,
  611. 'hk-pause': `Cell pause`,
  612. 'hk-showTop5': `Show/hide team top 5`,
  613. 'hk-showTime': `Show/hide current time`,
  614. 'hk-showSplitRange': `Show/hide split range`,
  615. 'hk-showSplitInd': 'Show/hide split indicators',
  616. 'hk-showTeammatesInd': 'Show/hide teammates indicators',
  617. 'hk-showOppColors': `Show/hide opponents colors`,
  618. 'hk-toggleSkins': 'Toggle skins (custom/default)',
  619. 'hk-showSkins': `Show/hide skins`,
  620. 'hk-transparentSkins': 'Toggle transparent skins',
  621. 'hk-showStats': `Show/hide game stats`,
  622. 'hk-toggleCells': `Toggle own cells (smallest/biggest)`,
  623. 'hk-showFood': `Show/hide food`,
  624. 'hk-showGrid': `Show/hide grid`,
  625. 'hk-showMiniMapGuides': 'Show/hide minimap guides',
  626. 'hk-hideChat': `Show/hide chat`,
  627. 'hk-showHUD': `Show/hide HUD`,
  628. 'hk-copyLb': `Copy leaderboard`,
  629. 'hk-showLb': 'Show/hide leaderboard',
  630. 'hk-toggleAutoZoom': `Toggle auto zoom`,
  631. 'hk-resetZoom': `Reset zoom`,
  632. 'hk-zoomLevel': 'Zoom level',
  633. 'hk-toggleDeath': `Toggle death location`,
  634. 'hk-clearChat': `Show chat history / Clear chat`,
  635. 'hk-showBgSectors': `Show/hide background sectors`,
  636. 'hk-hideBots': `Show/hide small bots`,
  637. 'hk-showNames': 'Show/hide names',
  638. 'hk-hideTeammatesNames': `Show/hide teammates names`,
  639. 'hk-showMass': `Show/hide mass`,
  640. 'hk-showMiniMap': 'Show/hide minimap',
  641. 'hk-chatMessage': `Enter chat message`,
  642. 'hk-quickResp': `Quick respawn`,
  643. 'hk-autoResp': `Toggle auto respawn`,
  644. 'hk-switchServerMode': `Switch server [public/private]`,
  645. 'hk-showTargeting': 'Show/hide targeting panel',
  646. 'hk-setTargeting': `Start/stop targeting (following)`,
  647. 'hk-cancelTargeting': 'Cancel targeting',
  648. 'hk-changeTarget': 'Change target',
  649. 'hk-privateMiniMap': 'Show target on the minimap',
  650. 'hk-showQuest': 'Show/hide quest',
  651. commands: `Commands`,
  652. comm1: `Feed me!`,
  653. comm2: `Split into me!`,
  654. comm3: 'Need backup at %currentSector%!',
  655. comm4: 'Enemy spotted at %currentSector%!',
  656. comm5: `Need a teammate!`,
  657. comm6: 'Tank the virus!',
  658. comm7: `Eat the virus!`,
  659. comm8: `Let's bait!`,
  660. comm9: `Fake tricksplit!`,
  661. comm0: `Fuck!`,
  662. comm10: `Tricksplit!`,
  663. comm11: `Left!`,
  664. comm12: `Up!`,
  665. comm13: 'Right!',
  666. comm14: 'Bottom!',
  667. saveComm: 'Save commands',
  668. theme: `Theme`,
  669. restoreThemeSettings: `Restore theme default settings`,
  670. basicTheming: 'Basic theming',
  671. themePreset: `Theme preset`,
  672. themeType: 'Theme type',
  673. darkTheme: 'Dark theme',
  674. lightTheme: `Light theme`,
  675. mainColor: 'Main color',
  676. bgColor: `Background`,
  677. bordersColor: 'Map borders',
  678. gridColor: `Grid`,
  679. sectorsColor: `Sectors font`,
  680. namesColor: `Names`,
  681. namesStrokeColor: `Names stroke`,
  682. massColor: 'Mass',
  683. massStrokeColor: `Mass stroke`,
  684. virusColor: `Virus`,
  685. virusStrokeColor: `Virus stroke`,
  686. foodColor: `Food`,
  687. namesFont: 'Names font',
  688. massFont: `Mass font`,
  689. sectorsFont: 'Sectors font',
  690. namesScale: `Names scale`,
  691. massScale: 'Mass scale',
  692. virMassScale: 'Virus mass scale',
  693. strokeScale: `Text stroke scale`,
  694. foodSize: `Food size`,
  695. bordersWidth: 'Map borders width',
  696. sectorsWidth: `Sectors grid width`,
  697. sectorsFontSize: `Sectors font size`,
  698. cellsAlpha: `Cells transparency`,
  699. skinsAlpha: 'Skins transparency',
  700. virusAlpha: `Virus transparency`,
  701. textAlpha: `Names & mass transparency`,
  702. virusStrokeSize: `Virus stroke size`,
  703. teammatesIndColor: `Teammate indicator`,
  704. cursorTrackingColor: `Cursor tracking`,
  705. splitRangeColor: `Split range`,
  706. safeAreaColor: `Safe area`,
  707. dangerAreaColor: `Danger area`,
  708. ghostCellsColor: `Ghost cells`,
  709. ghostCellsAlpha: 'Ghost cells transparency',
  710. menuTheming: `Menu`,
  711. menuPreset: `Menu theme`,
  712. menuMainColor: `Main color`,
  713. menuBtnTextColor: `Button text`,
  714. menuPanelColor: `Panel`,
  715. menuPanelColor2: `Panel (2)`,
  716. menuTextColor: 'Panel text',
  717. menuTextColor2: `Panel text (2)`,
  718. btn1Color: `Button #1`,
  719. btn1Color2: `Button #1 (2)`,
  720. btn2Color: 'Button #2',
  721. btn2Color2: `Button #2 (2)`,
  722. btn3Color: `Button #3`,
  723. btn3Color2: `Button #3 (2)`,
  724. btn4Color: `Button #4`,
  725. btn4Color2: `Button #4 (2)`,
  726. menuBg: 'Panel background image',
  727. menuOpacity: `Transparency`,
  728. hudTheming: `HUD`,
  729. hudMainColor: `Main color`,
  730. hudColor: 'Background',
  731. hudTextColor: `Text`,
  732. statsHudColor: `Stats`,
  733. timeHudColor: 'Time',
  734. top5MassColor: `Mass`,
  735. lbMeColor: `Leaderboard - me`,
  736. lbTeammateColor: `Leaderboard - teammate`,
  737. hudFont: `HUD font`,
  738. hudScale: `HUD scale`,
  739. chatTheming: `Chat`,
  740. messageColor: 'Message background',
  741. messageTextColor: 'Message text',
  742. messageTimeColor: `Message time`,
  743. messageNickColor: `Message nick`,
  744. commandsColor: `Command background`,
  745. commandsTextColor: 'Command text',
  746. commandsTimeColor: `Command time`,
  747. commandsNickColor: `Command nick`,
  748. chatBoxColor: `Chatbox color`,
  749. chatScale: `Chat scale`,
  750. miniMapTheming: `Minimap`,
  751. miniMapSectorsColor: `Sectors`,
  752. miniMapSectorColor: `Current sector`,
  753. miniMapGuidesColor: `Guides`,
  754. miniMapNickColor: `Nick`,
  755. miniMapNickStrokeColor: `Nick stroke`,
  756. miniMapMyCellColor: `My cell`,
  757. miniMapMyCellStrokeColor: `My cell stroke`,
  758. miniMapTeammatesColor: `Teammates`,
  759. miniMapDeathLocationColor: `Death location`,
  760. miniMapFont: `Minimap font`,
  761. miniMapNickFont: `Nick font`,
  762. miniMapWidth: `Minimap width`,
  763. miniMapSectorsOpacity: `Sectors transparency`,
  764. miniMapNickSize: 'Nick size',
  765. miniMapNickStrokeSize: 'Nick stroke size',
  766. miniMapMyCellSize: `My cell size`,
  767. miniMapMyCellStrokeSize: `My cell stroke size`,
  768. miniMapTeammatesSize: 'Teammates size',
  769. miniMapGhostCellsColor: `Ghost cells`,
  770. miniMapGhostCellsAlpha: `Ghost cells transparency`,
  771. imagesTheming: `Graphics / cursors`,
  772. customBackground: `Custom background image`,
  773. customCursor: `Custom cursor image`,
  774. hideChatMsgA: `Chat is visible!`,
  775. hideChatMsgB: `Chat is hidden!`,
  776. showSkinsMsgA: `Skins are visible!`,
  777. showSkinsMsgB: `Skins are hidden!`,
  778. hideSmallBotsMsgA: `Small bots are visible!`,
  779. hideSmallBotsMsgB: `Small bots are hidden!`,
  780. autoRespMsgA: `Auto respawn is on!`,
  781. autoRespMsgB: `Auto respawn is off!`,
  782. autoZoomMsgA: `Auto zoom is on!`,
  783. autoZoomMsgB: `Auto zoom is off!`,
  784. targetNotSet: `Target not set`,
  785. targetDead: 'Dead',
  786. targetDistance: 'Distance',
  787. targetMass: `Mass altogether`,
  788. totalPartyPlayers: `Active players`,
  789. totalPartyMass: `Total mass`,
  790. exportImport: `Export / import settings`,
  791. exportSettings: 'Export settings',
  792. exportInfo: 'To export selected settings copy the code below and save it to a text file encoded in Unicode.',
  793. importSettings: `Import settings`,
  794. importInfo: `To import selected settings paste an exported code below and press the "Import settings" button.`,
  795. profile: `Profile`,
  796. profiles: 'Profiles',
  797. skins: `Skins`,
  798. moreSkins: `Add skins`,
  799. thanks: `Thanks to Awesome!`,
  800. saveSett: 'Save settings',
  801. saved: `Saved!`,
  802. resetSett: `Reset to default`,
  803. close: `Close`,
  804. enterChatMsg: `Enter chat message`,
  805. activeParties: `Active parties`,
  806. noActiveParties: `No active parties ;(`,
  807. playlist: `Playlist`,
  808. pause: `PAUSE!`,
  809. visit: 'Visit',
  810. exit: 'OGARio by szymy: Are you sure you want to quit the game?',
  811. blockWarn: `WARNING! Popups are blocked in the settings.`,
  812. unblockPopups: `Temporary unblock`,
  813. mass: 'Mass',
  814. score: `Score`,
  815. leaderboard: `Leaderboard`,
  816. user: 'User',
  817. userMuted: 'User %user% has been muted.',
  818. userUnmuted: `User %user% has been unmuted.`,
  819. mute: `Mute`,
  820. unmute: 'Unmute',
  821. mutedUsers: `Muted users`,
  822. activeUsers: `Active users`,
  823. showActiveUsers: `Show active users`,
  824. none: `None`,
  825. sounds: `Sounds`,
  826. page_menu_main_free_coins: 'Free Coins',
  827. page_menu_main_gifts: 'Gifts',
  828. page_menu_main_dailyquests: `Daily Quest`,
  829. page_shop: `Shop`
  830. }
  831. };
  832. let lang = 'en';
  833. const userLanguage = window.navigator.language || window.navigator.userLanguage;
  834. if (userLanguage && displayText.hasOwnProperty(userLanguage)) {
  835. lang = userLanguage;
  836. }
  837. const textLanguage = displayText[lang];
  838. let chatCommand = {
  839. comm1: textLanguage.comm1,
  840. comm2: textLanguage.comm2,
  841. comm3: textLanguage.comm3,
  842. comm4: textLanguage.comm4,
  843. comm5: textLanguage.comm5,
  844. comm6: textLanguage.comm6,
  845. comm7: textLanguage.comm7,
  846. comm8: textLanguage.comm8,
  847. comm9: textLanguage.comm9,
  848. comm0: textLanguage.comm0,
  849. comm10: textLanguage.comm10,
  850. comm11: textLanguage.comm11,
  851. comm12: textLanguage.comm12,
  852. comm13: textLanguage.comm13,
  853. comm14: textLanguage.comm14
  854. };
  855. const escapeChar = {
  856. '&': `&amp;`,
  857. '<': `&lt;`,
  858. '>': `&gt;`,
  859. '"': `&quot;`,
  860. '\'': '&#39;',
  861. '/': `&#x2F;`
  862. };
  863. const emojiChar = {
  864. ':)': `smile.svg`,
  865. ';)': `wink.svg`,
  866. '=)': 'smirk.svg',
  867. ':D': `grin.svg`,
  868. 'X-D': `xgrin.svg`,
  869. '=D': `joy.svg`,
  870. ':(': 'sad.svg',
  871. ';(': `cry.svg`,
  872. ':P': `tongue.svg`,
  873. ';P': 'tonguew.svg',
  874. ':*': 'kiss.svg',
  875. '$)': 'smileh.svg',
  876. '<3': `heart.svg`,
  877. '8=)': 'cool.svg',
  878. ':o': `astonished.svg`,
  879. '(:|': `sweat.svg`,
  880. ':|': `neutral.svg`,
  881. ':': 'unamused.svg',
  882. ':@': 'pouting.svg',
  883. '|-)': 'sleep.svg',
  884. '^_^': 'relaxed.svg',
  885. '-_-': `expressionless.svg`,
  886. '$_$': `money.svg`,
  887. 'O:)': `angel.svg`,
  888. '3:)': `devil.svg`,
  889. '(poop)': `poo.svg`,
  890. '(fuck)': 'finger.svg',
  891. '(clap)': `clap.svg`,
  892. '(ok)': `ok.svg`,
  893. '(victory)': 'victory.svg',
  894. '(y)': 'thumb.svg',
  895. '(n)': `thumbd.svg`
  896. };
  897. const SkinExplain = [{
  898. name: `imgur.com`,
  899. url: `https://imgur.com/`,
  900. example: `https://i.imgur.com/xdmUp5N.png`,
  901. pattern: `https?:\/\/\w+\.imgur\.com\/\w{6,}\.(?:%file_ext%)\??\d*`
  902. }, {
  903. name: `put.re`,
  904. url: 'https://put.re/',
  905. example: 'https://s.put.re/iYHAW65g.png',
  906. pattern: `https?:\/\/\w+\.put\.re\/\w{8,}\.(?:%file_ext%)`
  907. }, {
  908. name: `postimages.org`,
  909. url: `https://postimages.org/`,
  910. example: 'https://i.postimg.cc/zzK0sRPg/xdmUp5N.png',
  911. pattern: 'https?:\/\/\w+\.postimg\.cc\/\w{8,}\/\w+\.(?:%file_ext%)'
  912. }];
  913. const gameTheme = {
  914. 'ogario-v3': {
  915. name: `OGARio v3`,
  916. darkTheme: true,
  917. mainColor: '#01d9cc',
  918. bgColor: '#000a11',
  919. bordersColor: `#01d9cc`,
  920. gridColor: `#00243e`,
  921. sectorsColor: `#00243e`,
  922. namesColor: '#ffffff',
  923. namesStrokeColor: `#000000`,
  924. massColor: `#ffffff`,
  925. massStrokeColor: '#000000',
  926. virusColor: `#002f52`,
  927. virusStrokeColor: `#00b9e8`,
  928. foodColor: `#5000ff`,
  929. teammatesIndColor: `#ffffff`,
  930. cursorTrackingColor: `#ffffff`,
  931. splitRangeColor: `#ffffff`,
  932. safeAreaColor: `#ffffff`,
  933. dangerAreaColor: `#bf00aa`,
  934. namesFont: 'ubuntu-bold',
  935. massFont: `ubuntu-bold`,
  936. sectorsFont: 'ubuntu',
  937. namesScale: 1,
  938. massScale: 3,
  939. foodSize: 5,
  940. bordersWidth: 40,
  941. sectorsWidth: 40,
  942. sectorsFontSize: 1200,
  943. cellsAlpha: 0.9,
  944. skinsAlpha: 0.7,
  945. virusAlpha: 0.6,
  946. textAlpha: 1,
  947. virusStrokeSize: 14,
  948. menuPreset: `ogario-v3`,
  949. menuMainColor: `#01d9cc`,
  950. menuBtnTextColor: `#ffffff`,
  951. menuPanelColor: `#00243e`,
  952. menuPanelColor2: '#002f52',
  953. menuTextColor: `#ffffff`,
  954. menuTextColor2: `#8096a7`,
  955. btn1Color: `#018cf6`,
  956. btn1Color2: '#0176ce',
  957. btn2Color: `#00b9e8`,
  958. btn2Color2: `#0099c0`,
  959. btn3Color: '#8d5fe6',
  960. btn3Color2: `#814ee3`,
  961. btn4Color: `#bf00aa`,
  962. btn4Color2: '#a80096',
  963. menuBg: `https://cdn.ogario.ovh/static/img/pattern.png`,
  964. menuOpacity: 0.96,
  965. hudMainColor: `#01d9cc`,
  966. hudColor: `rgba(0,0,0,0.4)`,
  967. hudTextColor: `#ffffff`,
  968. statsHudColor: `#ffffff`,
  969. timeHudColor: `#01d9cc`,
  970. top5MassColor: '#bf00aa',
  971. lbMeColor: '#bf00aa',
  972. lbTeammateColor: `#018cf6`,
  973. hudFont: 'ubuntu-bold',
  974. hudScale: 1,
  975. messageColor: `rgba(0,0,0,0.4)`,
  976. messageTextColor: `#ffffff`,
  977. messageTimeColor: '#018cf6',
  978. messageNickColor: `#01d9cc`,
  979. commandsColor: 'rgba(191,0,170,0.9)',
  980. commandsTextColor: `#ffffff`,
  981. commandsTimeColor: `#bf00aa`,
  982. commandsNickColor: `#ffffff`,
  983. chatBoxColor: 'rgba(0,0,0,0.4)',
  984. chatScale: 1,
  985. miniMapSectorsColor: '#ffffff',
  986. miniMapSectorColor: `#01d9cc`,
  987. miniMapGuidesColor: `#bf00aa`,
  988. miniMapNickColor: `#ffffff`,
  989. miniMapNickStrokeColor: '#000000',
  990. miniMapMyCellColor: `#ffffff`,
  991. miniMapMyCellStrokeColor: `#bf00aa`,
  992. miniMapTeammatesColor: `#01d9cc`,
  993. miniMapDeathLocationColor: `#bf00aa`,
  994. miniMapFont: `ubuntu-bold`,
  995. miniMapNickFont: `ubuntu-bold`,
  996. miniMapWidth: 240,
  997. miniMapSectorsOpacity: 0.1,
  998. miniMapNickSize: 11,
  999. miniMapNickStrokeSize: 2,
  1000. miniMapMyCellSize: 7.5,
  1001. miniMapMyCellStrokeSize: 4,
  1002. miniMapTeammatesSize: 5.5,
  1003. customBackground: '',
  1004. customCursor: `https://cdn.ogario.ovh/static/img/cursors/cursor_02.cur`
  1005. },
  1006. 'ogario-orange': {
  1007. name: `OGARio v2`,
  1008. darkTheme: true,
  1009. mainColor: `#ff7800`,
  1010. bgColor: `#111111`,
  1011. bordersColor: `#ff7800`,
  1012. gridColor: '#292929',
  1013. sectorsColor: `#292929`,
  1014. namesColor: '#ffffff',
  1015. namesStrokeColor: `#000000`,
  1016. massColor: `#ffffff`,
  1017. massStrokeColor: '#000000',
  1018. virusColor: `#666666`,
  1019. virusStrokeColor: `#666666`,
  1020. foodColor: `#e16400`,
  1021. hudMainColor: '#ff7800',
  1022. statsHudColor: `#ff7800`,
  1023. top5MassColor: `#ff7800`,
  1024. timeHudColor: `#ff7800`,
  1025. messageNickColor: `#ff7800`,
  1026. commandsColor: `rgba(255,120,0,0.9)`,
  1027. commandsTimeColor: `#ff7800`,
  1028. commandsTextColor: `#ffffff`,
  1029. miniMapSectorsColor: `#ffffff`,
  1030. miniMapSectorColor: `#ff7800`,
  1031. miniMapGuidesColor: `#ff7800`,
  1032. miniMapMyCellColor: `#ffffff`,
  1033. miniMapMyCellStrokeColor: `#ff7800`,
  1034. miniMapTeammatesColor: '#ff7800',
  1035. miniMapDeathLocationColor: `#ff7800`,
  1036. miniMapSectorsOpacity: 0.1
  1037. },
  1038. 'ogario-gold': {
  1039. name: `OGARio LE`,
  1040. darkTheme: true,
  1041. mainColor: `#b5a642`,
  1042. bgColor: `#000000`,
  1043. bordersColor: `#b5a642`,
  1044. gridColor: `#111111`,
  1045. sectorsColor: `#111111`,
  1046. namesColor: '#ffffff',
  1047. namesStrokeColor: `#000000`,
  1048. massColor: `#ffffff`,
  1049. massStrokeColor: '#000000',
  1050. virusColor: `#666666`,
  1051. virusStrokeColor: '#666666',
  1052. foodColor: `#998c36`,
  1053. hudMainColor: '#b5a642',
  1054. statsHudColor: `#b5a642`,
  1055. top5MassColor: `#b5a642`,
  1056. timeHudColor: '#b5a642',
  1057. messageNickColor: '#b5a642',
  1058. commandsColor: 'rgba(181,166,66,0.9)',
  1059. commandsTimeColor: `#b5a642`,
  1060. commandsTextColor: `#ffffff`,
  1061. miniMapSectorsColor: `#ffffff`,
  1062. miniMapSectorColor: `#b5a642`,
  1063. miniMapGuidesColor: `#b5a642`,
  1064. miniMapMyCellColor: `#ffffff`,
  1065. miniMapMyCellStrokeColor: `#b5a642`,
  1066. miniMapTeammatesColor: `#b5a642`,
  1067. miniMapDeathLocationColor: `#b5a642`,
  1068. miniMapSectorsOpacity: 0.1
  1069. },
  1070. 'ref-style': {
  1071. name: "ReF's Style",
  1072. bgColor: "#000000",
  1073. bordersColor: "#0074fc",
  1074. bordersWidth: 80,
  1075. btn1Color: "#0074fc",
  1076. btn1Color2: "#3592ff",
  1077. btn2Color: "#3592ff",
  1078. btn2Color2: "#3592ff",
  1079. btn3Color: "#3592ff",
  1080. btn3Color2: "#3592ff",
  1081. btn4Color: "#3592ff",
  1082. btn4Color2: "#3592ff",
  1083. cellsAlpha: 0.99,
  1084. chatBoxColor: "rgba(0,0,0,0.4)",
  1085. chatScale: 1,
  1086. commandsColor: "rgba(0,116,252,1)",
  1087. commandsNickColor: "#ffffff",
  1088. commandsTextColor: "#ffffff",
  1089. commandsTimeColor: "#000000",
  1090. cursorTrackingColor: "#ffffff",
  1091. customBackground: "",
  1092. customCursor: "",
  1093. dangerAreaColor: "#0074fc",
  1094. darkTheme: true,
  1095. foodColor: "#0074fc",
  1096. foodSize: 1,
  1097. ghostCellsAlpha: 0.3,
  1098. ghostCellsColor: "#ffffff",
  1099. gridColor: "#0094ff",
  1100. hudColor: "rgba(0,0,0,0.49)",
  1101. hudFont: "ubuntu-bold",
  1102. hudFontFamily: "Ubuntu",
  1103. hudFontWeight: 700,
  1104. hudMainColor: "#0074fc",
  1105. hudScale: 1.15,
  1106. hudTextColor: "#ffffff",
  1107. lbMeColor: "#0074fc",
  1108. lbTeammateColor: "#0074fc",
  1109. mainColor: "#01d9cc",
  1110. massColor: "#ffffff",
  1111. massFont: "ubuntu-bold",
  1112. massFontFamily: "Ubuntu",
  1113. massFontWeight: 700,
  1114. massScale: 0.9,
  1115. massStrokeColor: "#000000",
  1116. menuBg: "",
  1117. menuBtnTextColor: "#ffffff",
  1118. menuMainColor: "#0074fc",
  1119. menuOpacity: 1,
  1120. menuPanelColor: "#050008",
  1121. menuPanelColor2: "#1d0526",
  1122. menuPreset: "ogario-v3",
  1123. menuTextColor: "#ffffff",
  1124. menuTextColor2: "#65458f",
  1125. messageColor: "rgba(0,0,0,0.4)",
  1126. messageNickColor: "#0074fc",
  1127. messageTextColor: "#e8e8e8",
  1128. messageTimeColor: "#545454",
  1129. miniMapDeathLocationColor: "#2b2b2b",
  1130. miniMapFont: "ubuntu-bold",
  1131. miniMapFontFamily: "Ubuntu",
  1132. miniMapFontWeight: 700,
  1133. miniMapGhostCellsAlpha: 0.15,
  1134. miniMapGhostCellsColor: "#ffffff",
  1135. miniMapGuidesColor: "#ff00a8",
  1136. miniMapMyCellColor: "#f0ff3d",
  1137. miniMapMyCellSize: 5,
  1138. miniMapMyCellStrokeColor: "#acba07",
  1139. miniMapMyCellStrokeSize: 0,
  1140. miniMapNickColor: "#ffffff",
  1141. miniMapNickFont: "ubuntu-bold",
  1142. miniMapNickFontFamily: "Ubuntu",
  1143. miniMapNickFontWeight: 700,
  1144. miniMapNickSize: 9,
  1145. miniMapNickStrokeColor: "#4d4d4d",
  1146. miniMapNickStrokeSize: 0,
  1147. miniMapSectorColor: "#000000",
  1148. miniMapSectorsColor: "#ffffff",
  1149. miniMapSectorsOpacity: 0.1,
  1150. miniMapTeammatesColor: "#305eff",
  1151. miniMapTeammatesSize: 5,
  1152. miniMapTop: 25,
  1153. miniMapWidth: 250,
  1154. namesColor: "#ffffff",
  1155. namesFont: "ubuntu-bold",
  1156. namesFontFamily: "Ubuntu",
  1157. namesFontWeight: 700,
  1158. namesScale: 0.9,
  1159. namesStrokeColor: "#000000",
  1160. safeAreaColor: "#ffffff",
  1161. sectorsColor: "#0074fc",
  1162. sectorsFont: "ubuntu",
  1163. sectorsFontFamily: "Ubuntu",
  1164. sectorsFontSize: 940,
  1165. sectorsFontWeight: 400,
  1166. sectorsWidth: 6,
  1167. sectorsX: 5,
  1168. sectorsY: 5,
  1169. skinsAlpha: 0.7,
  1170. splitRangeColor: "#ffffff",
  1171. statsHudColor: "#ffffff",
  1172. strokeScale: 1,
  1173. teammatesIndColor: "#ffffff",
  1174. textAlpha: 1,
  1175. timeHudColor: "#0074fc",
  1176. top5MassColor: "#0074fc",
  1177. virMassScale: 2,
  1178. virusAlpha: 0.4,
  1179. virusColor: "#3b3b3b",
  1180. virusStrokeColor: "#ffffff",
  1181. virusStrokeSize: 10,
  1182. customBackground: '',
  1183. customCursor: ``
  1184. },
  1185. 'turbo-style': {
  1186. name: "Turbo's Style",
  1187. bgColor: "#000000",
  1188. bordersColor: "#ff2b77",
  1189. bordersWidth: 80,
  1190. btn1Color: "#ff2b77",
  1191. btn1Color2: "#ff005b",
  1192. btn2Color: "#ff2b77",
  1193. btn2Color2: "#ff005b",
  1194. btn3Color: "#ff2b77",
  1195. btn3Color2: "#ff005b",
  1196. btn4Color: "#ff2b77",
  1197. btn4Color2: "#ff005b",
  1198. cellsAlpha: 0.99,
  1199. chatBoxColor: "rgba(0,0,0,0.4)",
  1200. chatScale: 1,
  1201. commandsColor: "rgba(255,43,119,1)",
  1202. commandsNickColor: "#ffffff",
  1203. commandsTextColor: "#ffffff",
  1204. commandsTimeColor: "#000000",
  1205. cursorTrackingColor: "#ffffff",
  1206. customBackground: "",
  1207. customCursor: "",
  1208. dangerAreaColor: "#ff2b77",
  1209. darkTheme: true,
  1210. foodColor: "#ff2b77",
  1211. foodSize: 1,
  1212. ghostCellsAlpha: 0.3,
  1213. ghostCellsColor: "#ffffff",
  1214. gridColor: "#ff2b77",
  1215. hudColor: "rgba(0,0,0,0.49)",
  1216. hudFont: "ubuntu-bold",
  1217. hudFontFamily: "Ubuntu",
  1218. hudFontWeight: 700,
  1219. hudMainColor: "#ff2b77",
  1220. hudScale: 1.15,
  1221. hudTextColor: "#ffffff",
  1222. lbMeColor: "#ff2b77",
  1223. lbTeammateColor: "#ff2b77",
  1224. mainColor: "#ff2b77",
  1225. massColor: "#000000",
  1226. massFont: "ubuntu-bold",
  1227. massFontFamily: "Ubuntu",
  1228. massFontWeight: 700,
  1229. massScale: 0.9,
  1230. massStrokeColor: "#ffffff",
  1231. menuBg: "",
  1232. menuBtnTextColor: "#ffffff",
  1233. menuMainColor: "#ff2b77",
  1234. menuOpacity: 1,
  1235. menuPanelColor: "#23192c",
  1236. menuPanelColor2: "#382946",
  1237. menuPreset: "ogario-v3",
  1238. menuTextColor: "#ffffff",
  1239. menuTextColor2: "#65458f",
  1240. messageColor: "rgba(0,0,0,0.4)",
  1241. messageNickColor: "#ff2b77",
  1242. messageTextColor: "#e8e8e8",
  1243. messageTimeColor: "#545454",
  1244. miniMapDeathLocationColor: "#2b2b2b",
  1245. miniMapFont: "ubuntu-bold",
  1246. miniMapFontFamily: "Ubuntu",
  1247. miniMapFontWeight: 700,
  1248. miniMapGhostCellsAlpha: 0.15,
  1249. miniMapGhostCellsColor: "#ffffff",
  1250. miniMapGuidesColor: "#ff2b77",
  1251. miniMapMyCellColor: "#ffdd56",
  1252. miniMapMyCellSize: 5,
  1253. miniMapMyCellStrokeColor: "#ff9a6b",
  1254. miniMapMyCellStrokeSize: 0,
  1255. miniMapNickColor: "#ffffff",
  1256. miniMapNickFont: "ubuntu-bold",
  1257. miniMapNickFontFamily: "Ubuntu",
  1258. miniMapNickFontWeight: 700,
  1259. miniMapNickSize: 9,
  1260. miniMapNickStrokeColor: "#4d4d4d",
  1261. miniMapNickStrokeSize: 0,
  1262. miniMapSectorColor: "#000000",
  1263. miniMapSectorsColor: "#ffffff",
  1264. miniMapSectorsOpacity: 0.1,
  1265. miniMapTeammatesColor: "#ff005b",
  1266. miniMapTeammatesSize: 5,
  1267. miniMapTop: 25,
  1268. miniMapWidth: 250,
  1269. namesColor: "#000000",
  1270. namesFont: "ubuntu-bold",
  1271. namesFontFamily: "Ubuntu",
  1272. namesFontWeight: 700,
  1273. namesScale: 0.9,
  1274. namesStrokeColor: "#ffffff",
  1275. safeAreaColor: "#ffffff",
  1276. sectorsColor: "#ff2b77",
  1277. sectorsFont: "ubuntu",
  1278. sectorsFontFamily: "Ubuntu",
  1279. sectorsFontSize: 940,
  1280. sectorsFontWeight: 400,
  1281. sectorsWidth: 6,
  1282. sectorsX: 5,
  1283. sectorsY: 5,
  1284. skinsAlpha: 0.7,
  1285. splitRangeColor: "#ffffff",
  1286. statsHudColor: "#ffffff",
  1287. strokeScale: 1,
  1288. teammatesIndColor: "#ffffff",
  1289. textAlpha: 1,
  1290. timeHudColor: "#ff2b77",
  1291. top5MassColor: "#ff2b77",
  1292. virMassScale: 2,
  1293. virusAlpha: 0.4,
  1294. virusColor: "#3b3b3b",
  1295. virusStrokeColor: "#ff2b77",
  1296. virusStrokeSize: 10,
  1297. customBackground: '',
  1298. customCursor: ``
  1299. },
  1300. 'sniikz-style': {
  1301. name: `SniiKz's Style`,
  1302. darkTheme: true,
  1303. mainColor: `#01d9cc`,
  1304. bgColor: `#000000`,
  1305. bordersColor: '#ffffff',
  1306. gridColor: `#00243e`,
  1307. sectorsColor: '#00243e',
  1308. namesColor: `#ffffff`,
  1309. namesStrokeColor: '#000000',
  1310. massColor: '#ffffff',
  1311. massStrokeColor: `#000000`,
  1312. virusColor: '#3b3b3b',
  1313. virusStrokeColor: `#ffffff`,
  1314. foodColor: `#5000ff`,
  1315. teammatesIndColor: `#ffffff`,
  1316. cursorTrackingColor: `#ffffff`,
  1317. splitRangeColor: '#ffffff',
  1318. safeAreaColor: `#ffffff`,
  1319. dangerAreaColor: '#bf00aa',
  1320. massScale: 4,
  1321. foodSize: 1,
  1322. bordersWidth: 40,
  1323. sectorsWidth: 40,
  1324. sectorsFontSize: 1200,
  1325. cellsAlpha: 0.99,
  1326. skinsAlpha: 0.7,
  1327. virusAlpha: 0.4,
  1328. virusStrokeSize: 10,
  1329. menuPreset: `ogario-v3`,
  1330. menuMainColor: `#fc0079`,
  1331. menuBtnTextColor: `#ffffff`,
  1332. menuPanelColor: '#050008',
  1333. menuPanelColor2: `#1d0526`,
  1334. menuTextColor: `#ffffff`,
  1335. menuTextColor2: `#65458f`,
  1336. btn1Color: '#4f0242',
  1337. btn1Color2: `#3b0431`,
  1338. btn2Color: `#6b0036`,
  1339. btn2Color2: `#4d0227`,
  1340. btn3Color: `#aa084e`,
  1341. btn3Color2: `#80063b`,
  1342. btn4Color: `#aa084e`,
  1343. btn4Color2: '#8a063f',
  1344. menuBg: `https://cdn.ogario.ovh/static/img/pattern.png`,
  1345. menuOpacity: 1,
  1346. hudMainColor: '#5974ff',
  1347. hudColor: 'rgba(36,36,36,0.49)',
  1348. hudTextColor: `#ffffff`,
  1349. statsHudColor: `#ffffff`,
  1350. timeHudColor: '#737373',
  1351. top5MassColor: `#1fe000`,
  1352. lbMeColor: '#bf00aa',
  1353. lbTeammateColor: `#018cf6`,
  1354. hudScale: 1.15,
  1355. messageColor: 'rgba(0,0,0,0.4)',
  1356. messageTextColor: `#e8e8e8`,
  1357. messageTimeColor: '#545454',
  1358. messageNickColor: '#05ff00',
  1359. commandsColor: `rgba(36,36,36,0.9)`,
  1360. commandsTextColor: `#ffffff`,
  1361. commandsTimeColor: '#545454',
  1362. commandsNickColor: `#ffffff`,
  1363. chatBoxColor: `rgba(0,0,0,0.4)`,
  1364. chatScale: 1,
  1365. miniMapSectorsColor: '#ffffff',
  1366. miniMapSectorColor: `#000000`,
  1367. miniMapGuidesColor: `#ff00a8`,
  1368. miniMapNickColor: `#ffffff`,
  1369. miniMapNickStrokeColor: `#4d4d4d`,
  1370. miniMapMyCellColor: '#f0ff3d',
  1371. miniMapMyCellStrokeColor: `#acba07`,
  1372. miniMapTeammatesColor: '#305eff',
  1373. miniMapDeathLocationColor: '#2b2b2b',
  1374. miniMapWidth: 250,
  1375. miniMapSectorsOpacity: 0.1,
  1376. miniMapNickSize: 9,
  1377. miniMapNickStrokeSize: 0,
  1378. miniMapMyCellSize: 5,
  1379. miniMapMyCellStrokeSize: 0,
  1380. miniMapTeammatesSize: 5,
  1381. customBackground: '',
  1382. customCursor: `https://cdn.ogario.ovh/static/img/cursors/cursor_01.cur`
  1383. },
  1384. 'hkg-style': {
  1385. name: `HKG Style`,
  1386. darkTheme: true,
  1387. mainColor: '#651fff',
  1388. bgColor: `#000000`,
  1389. bordersColor: `#ffffff`,
  1390. gridColor: `#111111`,
  1391. sectorsColor: `#111111`,
  1392. namesColor: `#ffffff`,
  1393. namesStrokeColor: `#000000`,
  1394. massColor: `#ffffff`,
  1395. massStrokeColor: `#000000`,
  1396. virusColor: `#666666`,
  1397. virusStrokeColor: `#666666`,
  1398. foodColor: `#651fff`,
  1399. hudMainColor: `#651fff`,
  1400. statsHudColor: '#651fff',
  1401. top5MassColor: '#651fff',
  1402. timeHudColor: `#651fff`,
  1403. messageNickColor: `#651fff`,
  1404. commandsColor: `rgba(101,31,255,0.9)`,
  1405. commandsTimeColor: `#651fff`,
  1406. commandsTextColor: `#ffffff`,
  1407. miniMapSectorsColor: '#ffffff',
  1408. miniMapSectorColor: `#651fff`,
  1409. miniMapGuidesColor: `#651fff`,
  1410. miniMapMyCellColor: `#ffffff`,
  1411. miniMapMyCellStrokeColor: `#651fff`,
  1412. miniMapTeammatesColor: '#651fff',
  1413. miniMapDeathLocationColor: '#651fff',
  1414. miniMapSectorsOpacity: 0.1
  1415. },
  1416. 'agario-light': {
  1417. name: `Agar.io Light`,
  1418. darkTheme: false,
  1419. mainColor: `#ffffff`,
  1420. bgColor: `#f2fbff`,
  1421. bordersColor: `#858a8c`,
  1422. gridColor: `#ced6d9`,
  1423. sectorsColor: '#ced6d9',
  1424. namesColor: '#ffffff',
  1425. namesStrokeColor: '#000000',
  1426. massColor: `#ffffff`,
  1427. massStrokeColor: '#000000',
  1428. virusColor: `#33ff33`,
  1429. virusStrokeColor: `#2de52d`,
  1430. foodColor: '#2de52d',
  1431. hudMainColor: `#ffffff`,
  1432. statsHudColor: `#ffffff`,
  1433. top5MassColor: `#ffffff`,
  1434. timeHudColor: `#ffffff`,
  1435. messageNickColor: '#ffffff',
  1436. commandsColor: `rgba(255,255,255,0.9)`,
  1437. commandsTimeColor: `#ffffff`,
  1438. commandsTextColor: `#000000`,
  1439. miniMapSectorsColor: `#ffffff`,
  1440. miniMapSectorColor: '#ffffff',
  1441. miniMapGuidesColor: '#ffffff',
  1442. miniMapMyCellColor: `#ffffff`,
  1443. miniMapMyCellStrokeColor: '#ffffff',
  1444. miniMapTeammatesColor: `#ffffff`,
  1445. miniMapDeathLocationColor: `#ffffff`,
  1446. miniMapSectorsOpacity: 0.25
  1447. },
  1448. 'agario-dark': {
  1449. name: `Agar.io Dark`,
  1450. darkTheme: true,
  1451. mainColor: `#ffffff`,
  1452. bgColor: `#111111`,
  1453. bordersColor: `#999999`,
  1454. gridColor: `#333333`,
  1455. sectorsColor: `#333333`,
  1456. namesColor: `#ffffff`,
  1457. namesStrokeColor: `#000000`,
  1458. massColor: `#ffffff`,
  1459. massStrokeColor: `#000000`,
  1460. virusColor: `#33ff33`,
  1461. virusStrokeColor: `#2de52d`,
  1462. foodColor: `#2de52d`,
  1463. hudMainColor: `#ffffff`,
  1464. statsHudColor: '#ffffff',
  1465. top5MassColor: `#ffffff`,
  1466. timeHudColor: `#ffffff`,
  1467. messageNickColor: `#ffffff`,
  1468. commandsColor: `rgba(255,255,255,0.9)`,
  1469. commandsTimeColor: `#ffffff`,
  1470. commandsTextColor: '#ffffff',
  1471. miniMapSectorsColor: `#ffffff`,
  1472. miniMapSectorColor: `#ffffff`,
  1473. miniMapGuidesColor: `#ffffff`,
  1474. miniMapMyCellColor: `#ffffff`,
  1475. miniMapMyCellStrokeColor: '#ffffff',
  1476. miniMapTeammatesColor: `#ffffff`,
  1477. miniMapDeathLocationColor: `#ffffff`,
  1478. miniMapSectorsOpacity: 0.1
  1479. }
  1480. };
  1481. const themeSetup = {
  1482. 'ogario-v3': {
  1483. name: `OGARio v3`,
  1484. menuMainColor: '#01d9cc',
  1485. menuBtnTextColor: `#ffffff`,
  1486. menuPanelColor: `#00243e`,
  1487. menuPanelColor2: `#002f52`,
  1488. menuTextColor: `#ffffff`,
  1489. menuTextColor2: `#8096a7`,
  1490. btn1Color: `#018cf6`,
  1491. btn1Color2: '#0176ce',
  1492. btn2Color: `#00b9e8`,
  1493. btn2Color2: `#0099c0`,
  1494. btn3Color: `#8d5fe6`,
  1495. btn3Color2: '#814ee3',
  1496. btn4Color: `#f300d8`,
  1497. btn4Color2: `#df00c6`,
  1498. menuBg: 'https://cdn.ogario.ovh/static/img/pattern.png'
  1499. },
  1500. 'ogario-v2': {
  1501. name: `OGARio v2`,
  1502. menuMainColor: `#ff7800`,
  1503. menuBtnTextColor: '#ffffff',
  1504. menuPanelColor: `#222222`,
  1505. menuPanelColor2: `#333333`,
  1506. menuTextColor: `#bbbbbb`,
  1507. menuTextColor2: `#bbbbbb`,
  1508. btn1Color: `#428bca`,
  1509. btn1Color2: `#3071a9`,
  1510. btn2Color: `#5cb85c`,
  1511. btn2Color2: `#449d44`,
  1512. btn3Color: `#f0ad4e`,
  1513. btn3Color2: `#ec971f`,
  1514. btn4Color: `#d9534f`,
  1515. btn4Color2: `#c9302c`,
  1516. menuBg: ''
  1517. },
  1518. agario: {
  1519. name: `Agar.io`,
  1520. menuMainColor: '#5bc0de',
  1521. menuBtnTextColor: '#ffffff',
  1522. menuPanelColor: `#ffffff`,
  1523. menuPanelColor2: '#cccccc',
  1524. menuTextColor: '#333333',
  1525. menuTextColor2: '#999999',
  1526. btn1Color: `#428bca`,
  1527. btn1Color2: `#3071a9`,
  1528. btn2Color: '#5cb85c',
  1529. btn2Color2: `#449d44`,
  1530. btn3Color: `#f0ad4e`,
  1531. btn3Color2: `#ec971f`,
  1532. btn4Color: '#d9534f',
  1533. btn4Color2: `#c9302c`,
  1534. menuBg: ''
  1535. }
  1536. };
  1537. const gameSetupTheme = {
  1538. preset: `ogario-v3`,
  1539. darkTheme: true,
  1540. mainColor: '#01d9cc',
  1541. bgColor: `#000a11`,
  1542. bordersColor: `#01d9cc`,
  1543. gridColor: '#00243e',
  1544. sectorsColor: `#00243e`,
  1545. namesColor: `#ffffff`,
  1546. namesStrokeColor: `#000000`,
  1547. massColor: `#ffffff`,
  1548. massStrokeColor: `#000000`,
  1549. virusColor: `#002f52`,
  1550. virusStrokeColor: '#00b9e8',
  1551. foodColor: '#5000ff',
  1552. teammatesIndColor: `#ffffff`,
  1553. cursorTrackingColor: `#ffffff`,
  1554. splitRangeColor: `#ffffff`,
  1555. ghostCellsColor: `#ffffff`,
  1556. safeAreaColor: `#ffffff`,
  1557. dangerAreaColor: `#bf00aa`,
  1558. namesFont: `ubuntu-bold`,
  1559. namesFontFamily: `Ubuntu`,
  1560. namesFontWeight: 700,
  1561. massFont: 'ubuntu-bold',
  1562. massFontFamily: `Ubuntu`,
  1563. massFontWeight: 700,
  1564. sectorsFont: `ubuntu`,
  1565. sectorsFontFamily: `Ubuntu`,
  1566. sectorsFontWeight: 400,
  1567. sectorsX: 5,
  1568. sectorsY: 5,
  1569. namesScale: 1,
  1570. massScale: 3,
  1571. virMassScale: 3,
  1572. strokeScale: 1,
  1573. foodSize: 5,
  1574. bordersWidth: 40,
  1575. sectorsWidth: 40,
  1576. sectorsFontSize: 1200,
  1577. cellsAlpha: 0.9,
  1578. skinsAlpha: 0.7,
  1579. virusAlpha: 0.6,
  1580. textAlpha: 1,
  1581. ghostCellsAlpha: 0.3,
  1582. virusStrokeSize: 14,
  1583. menuPreset: `ogario-v3`,
  1584. menuMainColor: `#01d9cc`,
  1585. menuBtnTextColor: `#ffffff`,
  1586. menuPanelColor: '#00243e',
  1587. menuPanelColor2: `#002f52`,
  1588. menuTextColor: '#ffffff',
  1589. menuTextColor2: `#8096a7`,
  1590. btn1Color: `#018cf6`,
  1591. btn1Color2: '#0176ce',
  1592. btn2Color: '#00b9e8',
  1593. btn2Color2: `#0099c0`,
  1594. btn3Color: `#8d5fe6`,
  1595. btn3Color2: '#814ee3',
  1596. btn4Color: '#bf00aa',
  1597. btn4Color2: '#a80096',
  1598. menuBg: `https://cdn.ogario.ovh/static/img/pattern.png`,
  1599. menuOpacity: 0.96,
  1600. hudMainColor: `#01d9cc`,
  1601. hudColor: 'rgba(0,0,0,0.4)',
  1602. hudTextColor: '#ffffff',
  1603. statsHudColor: `#ffffff`,
  1604. timeHudColor: `#01d9cc`,
  1605. top5MassColor: `#bf00aa`,
  1606. lbMeColor: '#bf00aa',
  1607. lbTeammateColor: `#018cf6`,
  1608. hudFont: `ubuntu-bold`,
  1609. hudFontFamily: `Ubuntu`,
  1610. hudFontWeight: 700,
  1611. hudScale: 1,
  1612. messageColor: `rgba(0,0,0,0.4)`,
  1613. messageTextColor: `#ffffff`,
  1614. messageTimeColor: `#018cf6`,
  1615. messageNickColor: '#01d9cc',
  1616. commandsColor: `rgba(191,0,170,0.9)`,
  1617. commandsTextColor: `#ffffff`,
  1618. commandsTimeColor: '#bf00aa',
  1619. commandsNickColor: `#ffffff`,
  1620. chatBoxColor: `rgba(0,0,0,0.4)`,
  1621. chatScale: 1,
  1622. miniMapSectorsColor: `#ffffff`,
  1623. miniMapSectorColor: `#01d9cc`,
  1624. miniMapGuidesColor: '#bf00aa',
  1625. miniMapNickColor: '#ffffff',
  1626. miniMapNickStrokeColor: `#000000`,
  1627. miniMapMyCellColor: `#ffffff`,
  1628. miniMapMyCellStrokeColor: `#bf00aa`,
  1629. miniMapTeammatesColor: `#01d9cc`,
  1630. miniMapDeathLocationColor: `#bf00aa`,
  1631. miniMapGhostCellsColor: `#ffffff`,
  1632. miniMapFont: `ubuntu-bold`,
  1633. miniMapFontFamily: 'Ubuntu',
  1634. miniMapFontWeight: 700,
  1635. miniMapNickFont: `ubuntu-bold`,
  1636. miniMapNickFontFamily: `Ubuntu`,
  1637. miniMapNickFontWeight: 700,
  1638. miniMapWidth: 240,
  1639. miniMapTop: 24,
  1640. miniMapSectorsOpacity: 0.1,
  1641. miniMapNickSize: 11,
  1642. miniMapNickStrokeSize: 2,
  1643. miniMapMyCellSize: 7.5,
  1644. miniMapMyCellStrokeSize: 4,
  1645. miniMapTeammatesSize: 5.5,
  1646. miniMapGhostCellsAlpha: 0.15,
  1647. customBackground: '',
  1648. customCursor: 'https://cdn.ogario.ovh/static/img/cursors/cursor_02.cur'
  1649. };
  1650. const OgarioSettings = {
  1651. menuMainColorCSS: null,
  1652. menuPanelColorCSS: null,
  1653. menuTextlColorCSS: null,
  1654. menuButtonsCSS: null,
  1655. hudCSS: null,
  1656. chatCSS: null,
  1657. chatScaleCSS: null,
  1658. cursorCSS: null,
  1659. loadThemeSettings() {
  1660. let storage = null;
  1661. if (window.localStorage.getItem('ogarioThemeSettings') !== null) {
  1662. storage = JSON.parse(window.localStorage.getItem('ogarioThemeSettings'));
  1663. }
  1664. for (const setup in gameSetupTheme) {
  1665. if (gameSetupTheme.hasOwnProperty(setup)) {
  1666. if (storage && storage.hasOwnProperty(setup)) {
  1667. gameSetupTheme[setup] = storage[setup];
  1668. }
  1669. if (ogario.hasOwnProperty(setup)) {
  1670. ogario[setup] = gameSetupTheme[setup];
  1671. }
  1672. }
  1673. }
  1674. },
  1675. saveThemeSettings() {
  1676. window.localStorage.setItem(`ogarioThemeSettings`, JSON.stringify(gameSetupTheme));
  1677. },
  1678. restoreThemeSettings() {
  1679. if (window.localStorage.getItem(`ogarioThemeSettings`) !== null) {
  1680. window.localStorage.removeItem('ogarioThemeSettings');
  1681. window.location.reload();
  1682. }
  1683. },
  1684. addCustomCSS(name, css) {
  1685. if (!this[name]) {
  1686. this[name] = JQuery(`<style type='text/css'>`).appendTo('head');
  1687. }
  1688. this[name].html(css);
  1689. },
  1690. addPresetBox(id, name, options, value, callback) {
  1691. JQuery(id).append(`<div class="preset-box"><span class="title-box">` + textLanguage[name] + `</span><div class="select-wrapper"><select id="` + name + `" class="form-control"></select></div></div>`);
  1692. for (const option in options) {
  1693. if (options.hasOwnProperty(option)) {
  1694. JQuery(`#${name}`).append(`${`<option value="` + option}">${options[option].name}${`</option>`}`);
  1695. }
  1696. }
  1697. JQuery(`#${name}`).val(gameSetupTheme[value]);
  1698. const app = this;
  1699. JQuery(`#${name}`).on(`change`, function() {
  1700. const optionValue = this.value;
  1701. gameSetupTheme[value] = optionValue;
  1702. app[callback](optionValue);
  1703. });
  1704. },
  1705. addColorBox(id, name, callback) {
  1706. JQuery(id).append(`${`<div class="color-box"><span class="title-box">` + textLanguage[name] + `</span><div class="input-group ` + name}-picker"><input type="text" value="${gameSetupTheme[name]}${`" id="`}${name}${`" class="form-control" /><span class="input-group-addon"><i></i></span></div></div>`}`);
  1707. if (callback) {
  1708. const app = this;
  1709. JQuery(`${id} .${name}-picker`).colorpicker({
  1710. format: `hex`
  1711. }).on(`changeColor.colorpicker`, event => {
  1712. gameSetupTheme[name] = event.color.toHex();
  1713. if (ogario.hasOwnProperty(name)) {
  1714. ogario[name] = gameSetupTheme[name];
  1715. }
  1716. app[callback]();
  1717. });
  1718. } else {
  1719. JQuery(`${id} .${name}${`-picker`}`).colorpicker({
  1720. format: `hex`
  1721. }).on(`changeColor.colorpicker`, event => {
  1722. gameSetupTheme[name] = event.color.toHex();
  1723. if (ogario.hasOwnProperty(name)) {
  1724. ogario[name] = gameSetupTheme[name];
  1725. }
  1726. });
  1727. }
  1728. },
  1729. addRgbaColorBox(id, name, callback) {
  1730. JQuery(id).append(`<div class="color-box"><span class="title-box">${textLanguage[name]}${`</span><div class="input-group `}${name}${`-picker"><input type="text" value="`}${gameSetupTheme[name]}${`" id="`}${name}${`" class="form-control" /><span class="input-group-addon"><i></i></span></div></div>`}`);
  1731. if (callback) {
  1732. const app = this;
  1733. JQuery(`${id} .${name}-picker`).colorpicker({
  1734. format: `rgba`
  1735. }).on('changeColor.colorpicker', event => {
  1736. const color = event.color.toRGB();
  1737. gameSetupTheme[name] = `rgba(${color.r},${color.g},${color.b},${color.a})`;
  1738. if (ogario.hasOwnProperty(name)) {
  1739. ogario[name] = gameSetupTheme[name];
  1740. }
  1741. app[callback]();
  1742. });
  1743. } else {
  1744. JQuery(`${id} .${name}-picker`).colorpicker({
  1745. format: `rgba`
  1746. }).on(`changeColor.colorpicker`, event => {
  1747. const color = event.color.toRGB();
  1748. gameSetupTheme[name] = `${`rgba(` + color.r},${color.g},${color.b},${color.a})`;
  1749. if (ogario.hasOwnProperty(name)) {
  1750. ogario[name] = gameSetupTheme[name];
  1751. }
  1752. });
  1753. }
  1754. },
  1755. addSliderBox(id, name, min, max, step, callback) {
  1756. JQuery(id).append(`<div class="slider-box"><div class="box-label"><span class="value-label">${textLanguage[name]}: </span><span id="${name}${`-value" class="value">`}${gameSetupTheme[name]}${`</span></div><input id="`}${name}-slider" type="range" min="${min}" max="${max}${`" step="`}${step}${`" value="`}${gameSetupTheme[name]}${`"></div>`}`);
  1757. if (callback) {
  1758. const app = this;
  1759. JQuery(`#${name}${`-slider`}`).on(`input`, function() {
  1760. const parse = parseFloat(JQuery(this).val());
  1761. JQuery(`#${name}-value`).text(parse);
  1762. gameSetupTheme[name] = parse;
  1763. if (ogario.hasOwnProperty(name)) {
  1764. ogario[name] = parse;
  1765. }
  1766. app[callback]();
  1767. });
  1768. } else {
  1769. JQuery(`#${name}${`-slider`}`).on('input', function() {
  1770. const parse = parseFloat(JQuery(this).val());
  1771. JQuery(`#${name}${`-value`}`).text(parse);
  1772. gameSetupTheme[name] = parse;
  1773. if (ogario.hasOwnProperty(name)) {
  1774. ogario[name] = parse;
  1775. }
  1776. });
  1777. }
  1778. },
  1779. addInputBox(id, name, holder, callback) {
  1780. JQuery(id).append(`${`<div class="input-box"><span class="title-box">` + textLanguage[name] + `</span><input id="` + name + `" class="form-control" placeholder="` + holder}" value="${gameSetupTheme[name]}${`" /></div>`}`);
  1781. const app = this;
  1782. JQuery(`#${name}`).on(`input`, function() {
  1783. gameSetupTheme[name] = this.value;
  1784. app[callback]();
  1785. });
  1786. },
  1787. addCursorBox(id, url) {
  1788. if (url === gameSetupTheme.customCursor) {
  1789. JQuery(id).append(`<div class="cursor-box"><a href="#" class="active"><img src="` + url + `"></a></div>`);
  1790. } else {
  1791. JQuery(id).append(`<div class="cursor-box"><a href="#"><img src="` + url + `"></a></div>`);
  1792. }
  1793. },
  1794. setFont(name, fontFamily) {
  1795. gameSetupTheme[name] = fontFamily;
  1796. gameSetupTheme[`${name}Family`] = this.setFontFamily(fontFamily);
  1797. gameSetupTheme[name + `Weight`] = this.setFontWeight(fontFamily);
  1798. if (ogario.hasOwnProperty(name + `Family`)) {
  1799. ogario[name + `Family`] = gameSetupTheme[name + `Family`];
  1800. }
  1801. if (ogario.hasOwnProperty(`${name}Weight`)) {
  1802. ogario[`${name}Weight`] = gameSetupTheme[`${name}Weight`];
  1803. }
  1804. },
  1805. addFontBox(id, name, callback) {
  1806. JQuery(id).append(`${`<div class="font-box"><span class="title-box">` + textLanguage[name]}</span><div class="select-wrapper"><select id="${name}" class="form-control"></select></div></div>`);
  1807. JQuery(`#${name}`).append(`<option value="ubuntu">Ubuntu</option><option value="ubuntu-bold">Ubuntu Bold</option>`);
  1808. JQuery(`#${name}`).append(`<option value="roboto">Roboto</option><option value="roboto-bold">Roboto Bold</option>`);
  1809. JQuery(`#${name}`).append('<option value="oswald">Oswald</option><option value="oswald-bold">Oswald Bold</option>');
  1810. JQuery(`#${name}`).val(gameSetupTheme[name]);
  1811. const app = this;
  1812. if (callback) {
  1813. JQuery(`#${name}`).on('change', function() {
  1814. const value = this.value;
  1815. app.setFont(name, value);
  1816. app[callback]();
  1817. });
  1818. } else {
  1819. JQuery(`#${name}`).on(`change`, function() {
  1820. const value = this.value;
  1821. app.setFont(name, value);
  1822. });
  1823. }
  1824. },
  1825. setFontFamily(name) {
  1826. if (name.indexOf(`roboto`) != -1) {
  1827. return `Roboto`;
  1828. } else if (name.indexOf(`oswald`) != -1) {
  1829. return `Oswald`;
  1830. } else {
  1831. return 'Ubuntu';
  1832. }
  1833. },
  1834. setFontWeight(name) {
  1835. if (name.indexOf(`bold`) != -1) {
  1836. return 700;
  1837. }
  1838. return 400;
  1839. },
  1840. setThemeMenu() {
  1841. const app = this;
  1842. JQuery(`#theme`).append(`<ul class="submenu-tabs"><li class="theme-main-tab active"><a href="#theme-main" class="active ogicon-paint-format" data-toggle="tab-tooltip" title="${textLanguage.basicTheming}${`"></a></li><li class="theme-menu-tab"><a href="#theme-menu" class="ogicon-menu" data-toggle="tab-tooltip" title="`}${textLanguage.menuTheming}${`"></a></li><li class="theme-hud-tab"><a href="#theme-hud" class="ogicon-display" data-toggle="tab-tooltip" title="`}${textLanguage.hudTheming}${`"></a></li><li class="theme-chat-tab"><a href="#theme-chat" class="ogicon-bubbles" data-toggle="tab-tooltip" title="`}${textLanguage.chatTheming}"></a></li><li class="theme-minimap-tab"><a href="#theme-minimap" class="ogicon-location2" data-toggle="tab-tooltip" title="${textLanguage.miniMapTheming}${`"></a></li><li class="theme-images-tab"><a href="#theme-images" class="ogicon-compass" data-toggle="tab-tooltip" title="`}${textLanguage.imagesTheming}"></a></li></ul><div id="theme-main" class="submenu-panel"></div><div id="theme-menu" class="submenu-panel"></div><div id="theme-hud" class="submenu-panel"></div><div id="theme-chat" class="submenu-panel"></div><div id="theme-minimap" class="submenu-panel"></div><div id="theme-images" class="submenu-panel"></div>`);
  1843. this.addPresetBox(`#theme-main`, `themePreset`, gameTheme, `preset`, `changeThemePreset`);
  1844. this.addColorBox('#theme-main', `bgColor`, `setBgColor`);
  1845. this.addColorBox(`#theme-main`, `bordersColor`);
  1846. this.addColorBox(`#theme-main`, `gridColor`);
  1847. this.addColorBox('#theme-main', `sectorsColor`);
  1848. this.addColorBox(`#theme-main`, 'namesColor');
  1849. this.addColorBox('#theme-main', `namesStrokeColor`);
  1850. this.addColorBox(`#theme-main`, `massColor`);
  1851. this.addColorBox(`#theme-main`, `massStrokeColor`);
  1852. this.addColorBox(`#theme-main`, `virusColor`);
  1853. this.addColorBox(`#theme-main`, `virusStrokeColor`);
  1854. this.addColorBox(`#theme-main`, 'foodColor', `setFoodColor`);
  1855. this.addColorBox(`#theme-main`, `teammatesIndColor`, 'setIndicatorColor');
  1856. this.addColorBox(`#theme-main`, `cursorTrackingColor`);
  1857. this.addColorBox(`#theme-main`, `splitRangeColor`);
  1858. this.addColorBox('#theme-main', `safeAreaColor`);
  1859. this.addColorBox(`#theme-main`, `dangerAreaColor`);
  1860. this.addFontBox(`#theme-main`, 'namesFont');
  1861. this.addFontBox(`#theme-main`, `massFont`);
  1862. this.addFontBox(`#theme-main`, `sectorsFont`);
  1863. this.addSliderBox(`#theme-main`, `sectorsFontSize`, 200, 2000, 10);
  1864. this.addSliderBox(`#theme-main`, `namesScale`, 0.5, 2, 0.1);
  1865. this.addSliderBox(`#theme-main`, `massScale`, 1, 5, 1);
  1866. this.addSliderBox(`#theme-main`, `virMassScale`, 1, 5, 1);
  1867. this.addSliderBox('#theme-main', 'strokeScale', 1, 4, 0.1);
  1868. this.addSliderBox(`#theme-main`, 'foodSize', 1, 50, 1, `setFoodColor`);
  1869. this.addSliderBox(`#theme-main`, `virusStrokeSize`, 2, 40, 1);
  1870. this.addSliderBox('#theme-main', `bordersWidth`, 2, 200, 2);
  1871. this.addSliderBox(`#theme-main`, `sectorsWidth`, 2, 200, 2);
  1872. this.addSliderBox(`#theme-main`, `cellsAlpha`, 0.01, 0.99, 0.01);
  1873. this.addSliderBox(`#theme-main`, `skinsAlpha`, 0.01, 0.99, 0.01);
  1874. this.addSliderBox('#theme-main', `virusAlpha`, 0, 1, 0.01);
  1875. this.addSliderBox(`#theme-main`, 'textAlpha', 0.1, 1, 0.01);
  1876. this.addPresetBox(`#theme-menu`, 'menuPreset', themeSetup, `menuPreset`, 'changeMenuPreset');
  1877. this.addSliderBox(`#theme-menu`, `menuOpacity`, 0.1, 1, 0.01, `setMenuOpacity`);
  1878. this.addColorBox(`#theme-menu`, `menuMainColor`, `setMenuMainColor`);
  1879. this.addColorBox(`#theme-menu`, `menuBtnTextColor`, `setMenuButtons`);
  1880. this.addColorBox(`#theme-menu`, `menuPanelColor`, `setMenuPanelColor`);
  1881. this.addColorBox('#theme-menu', `menuPanelColor2`, `setMenuPanelColor`);
  1882. this.addColorBox(`#theme-menu`, `menuTextColor`, `setMenuTextColor`);
  1883. this.addColorBox(`#theme-menu`, 'menuTextColor2', `setMenuTextColor`);
  1884. this.addColorBox(`#theme-menu`, `btn1Color`, `setMenuButtons`);
  1885. this.addColorBox(`#theme-menu`, `btn1Color2`, `setMenuButtons`);
  1886. this.addColorBox(`#theme-menu`, 'btn2Color', `setMenuButtons`);
  1887. this.addColorBox(`#theme-menu`, `btn2Color2`, `setMenuButtons`);
  1888. this.addColorBox(`#theme-menu`, `btn3Color`, 'setMenuButtons');
  1889. this.addColorBox(`#theme-menu`, `btn3Color2`, `setMenuButtons`);
  1890. this.addColorBox(`#theme-menu`, `btn4Color`, `setMenuButtons`);
  1891. this.addColorBox(`#theme-menu`, `btn4Color2`, `setMenuButtons`);
  1892. this.addInputBox(`#theme-menu`, `menuBg`, `Image URL`, `setMenuBg`);
  1893. this.addColorBox(`#theme-hud`, `hudMainColor`, `setHudColors`);
  1894. this.addRgbaColorBox(`#theme-hud`, 'hudColor', 'setHudColors');
  1895. this.addColorBox(`#theme-hud`, 'hudTextColor', 'setHudColors');
  1896. this.addColorBox('#theme-hud', `statsHudColor`, `setHudColors`);
  1897. this.addColorBox(`#theme-hud`, `timeHudColor`, 'setHudColors');
  1898. this.addColorBox(`#theme-hud`, `top5MassColor`, `setHudColors`);
  1899. this.addColorBox(`#theme-hud`, `lbMeColor`, 'setHudColors');
  1900. this.addColorBox(`#theme-hud`, `lbTeammateColor`, `setHudColors`);
  1901. this.addFontBox(`#theme-hud`, `hudFont`, `setHudFont`);
  1902. this.addSliderBox('#theme-hud', 'hudScale', 1, 2, 0.01, `setHudScale`);
  1903. this.addRgbaColorBox('#theme-chat', `messageColor`, `setChatColors`);
  1904. this.addColorBox(`#theme-chat`, `messageTextColor`, 'setChatColors');
  1905. this.addColorBox(`#theme-chat`, `messageTimeColor`, `setChatColors`);
  1906. this.addColorBox('#theme-chat', `messageNickColor`, `setChatColors`);
  1907. this.addRgbaColorBox(`#theme-chat`, `commandsColor`, 'setChatColors');
  1908. this.addColorBox('#theme-chat', `commandsTextColor`, 'setChatColors');
  1909. this.addColorBox(`#theme-chat`, `commandsTimeColor`, 'setChatColors');
  1910. this.addColorBox(`#theme-chat`, `commandsNickColor`, `setChatColors`);
  1911. this.addRgbaColorBox(`#theme-chat`, `chatBoxColor`, `setChatColors`);
  1912. this.addSliderBox(`#theme-chat`, `chatScale`, 1, 2, 0.01, `setChatScale`);
  1913. this.addColorBox(`#theme-minimap`, `miniMapSectorsColor`, `setMiniMapSectorsColor`);
  1914. this.addColorBox(`#theme-minimap`, `miniMapSectorColor`);
  1915. this.addColorBox(`#theme-minimap`, `miniMapNickColor`);
  1916. this.addColorBox(`#theme-minimap`, `miniMapNickStrokeColor`);
  1917. this.addColorBox(`#theme-minimap`, `miniMapMyCellColor`);
  1918. this.addColorBox(`#theme-minimap`, `miniMapMyCellStrokeColor`);
  1919. this.addColorBox(`#theme-minimap`, `miniMapTeammatesColor`);
  1920. this.addColorBox(`#theme-minimap`, `miniMapDeathLocationColor`);
  1921. this.addColorBox(`#theme-minimap`, `miniMapGuidesColor`);
  1922. this.addFontBox(`#theme-minimap`, `miniMapFont`, `setMiniMapFont`);
  1923. this.addFontBox(`#theme-minimap`, 'miniMapNickFont');
  1924. this.addSliderBox('#theme-minimap', 'miniMapWidth', 200, 400, 2, 'setMiniMapWidth');
  1925. this.addSliderBox(`#theme-minimap`, `miniMapSectorsOpacity`, 0, 1, 0.01, `setMiniMapSectorsOpacity`);
  1926. this.addSliderBox(`#theme-minimap`, `miniMapNickSize`, 8, 16, 1);
  1927. this.addSliderBox(`#theme-minimap`, `miniMapNickStrokeSize`, 0, 6, 1);
  1928. this.addSliderBox(`#theme-minimap`, `miniMapMyCellSize`, 4, 10, 0.5);
  1929. this.addSliderBox(`#theme-minimap`, `miniMapMyCellStrokeSize`, 0, 10, 1);
  1930. this.addSliderBox(`#theme-minimap`, 'miniMapTeammatesSize', 4, 10, 0.5);
  1931. this.addInputBox(`#theme-images`, `customBackground`, `Image URL`, `setCustomBackground`);
  1932. this.addInputBox(`#theme-images`, `customCursor`, `Cursor image URL`, 'setCustomCursor');
  1933. const cursorUrl = `https://cdn.ogario.ovh/static/img/cursors/cursor_`;
  1934. for (let length = 0; length < 35; length++) {
  1935. if (length < 9) {
  1936. this.addCursorBox(`#theme-images`, `${cursorUrl}0${length + 1}.cur`);
  1937. continue;
  1938. }
  1939. this.addCursorBox(`#theme-images`, `${cursorUrl}${length + 1}${`.cur`}`);
  1940. }
  1941. JQuery(document).on(`click`, `#theme-images .cursor-box a`, function(event) {
  1942. event.preventDefault();
  1943. const url = JQuery(`img`, this).attr(`src`);
  1944. gameSetupTheme.customCursor = url;
  1945. app.setCustomCursor();
  1946. JQuery(`#customCursor`).val(url);
  1947. JQuery(`#theme-images .cursor-box a`).removeClass(`active`);
  1948. JQuery(this).addClass(`active`);
  1949. });
  1950. JQuery(`#theme`).append(`<button class="btn btn-block btn-success btn-save"">` + textLanguage.saveSett + `</button>`);
  1951. JQuery(document).on('click', `#theme .btn-save`, function(event) {
  1952. event.preventDefault();
  1953. const theme = JQuery(this);
  1954. theme.text(textLanguage.saved);
  1955. app.saveThemeSettings();
  1956. setTimeout(() => {
  1957. theme.text(textLanguage.saveSett);
  1958. }, 500);
  1959. });
  1960. JQuery(`#theme`).append(`<div class="restore-settings"><a href="#">` + textLanguage.restoreThemeSettings + `</a></div>`);
  1961. JQuery(document).on(`click`, `#theme .restore-settings a`, event => {
  1962. event.preventDefault();
  1963. app.restoreThemeSettings();
  1964. });
  1965. JQuery(`.skin`).colorpicker({
  1966. format: `hex`,
  1967. input: `#color`
  1968. });
  1969. },
  1970. changePreset(names, theme) {
  1971. if (theme[names]) {
  1972. gameSetupTheme[names] = names;
  1973. var names = theme[names];
  1974. } else {
  1975. return;
  1976. }
  1977. for (const name in names) {
  1978. if (names.hasOwnProperty(name) && gameSetupTheme.hasOwnProperty(name)) {
  1979. gameSetupTheme[name] = names[name];
  1980. if (ogario.hasOwnProperty(name)) {
  1981. ogario[name] = gameSetupTheme[name];
  1982. }
  1983. if (JQuery(`#theme .` + name + `-picker`)) {
  1984. JQuery(`#theme .` + name + `-picker`).colorpicker(`setValue`, gameSetupTheme[name]);
  1985. }
  1986. if (JQuery(`#${name}${`-slider`}`)) {
  1987. JQuery(`#${name}${`-slider`}`).val(gameSetupTheme[name]).change();
  1988. }
  1989. if (JQuery(`input[type=text]#${name}`) || JQuery(`select#` + name)) {
  1990. JQuery(`#${name}`).val(gameSetupTheme[name]);
  1991. }
  1992. }
  1993. }
  1994. },
  1995. changeThemePreset(name) {
  1996. this.changePreset(name, gameTheme);
  1997. this.setTheme();
  1998. },
  1999. setFonts() {
  2000. this.setFont(`namesFont`, gameSetupTheme.namesFont);
  2001. this.setFont('massFont', gameSetupTheme.namesFont);
  2002. this.setFont('sectorsFont', gameSetupTheme.sectorsFont);
  2003. },
  2004. setBgColor() {
  2005. JQuery(`body`).css('background-color', gameSetupTheme.bgColor);
  2006. },
  2007. setFoodColor() {
  2008. if (!gameOptionSettings.optimizedFood) {
  2009. return;
  2010. }
  2011. drawRender && drawRender.preDrawPellet();
  2012. },
  2013. setIndicatorColor() {
  2014. drawRender && drawRender.preDrawIndicator();
  2015. },
  2016. setCustomBackground() {
  2017. if (gameSetupTheme.customBackground) {
  2018. JQuery('body').css(`background-image`, `${`url(` + gameSetupTheme.customBackground})`);
  2019. } else {
  2020. JQuery('body').css('background-image', `none`);
  2021. }
  2022. },
  2023. setCustomCursor() {
  2024. if (gameSetupTheme.customCursor) {
  2025. var css = `*{cursor:url(` + gameSetupTheme.customCursor + `), auto !important}`;
  2026. } else {
  2027. var css = '*{cursor: auto}';
  2028. }
  2029. this.addCustomCSS(`cursorCSS`, css);
  2030. },
  2031. setMenu() {
  2032. this.setMenuOpacity();
  2033. this.setMenuMainColor();
  2034. this.setMenuPanelColor();
  2035. this.setMenuTextColor();
  2036. this.setMenuButtons();
  2037. this.setMenuBg();
  2038. },
  2039. changeMenuPreset(name) {
  2040. this.changePreset(name, themeSetup);
  2041. this.setMenu();
  2042. },
  2043. setMenuOpacity() {
  2044. JQuery('#helloContainer, #hotkeys, #exp-imp').css('opacity', gameSetupTheme.menuOpacity);
  2045. },
  2046. setMenuMainColor() {
  2047. const css = `::-moz-selection{background-color:` + gameSetupTheme.menuMainColor + `!important}::selection{background-color:` + gameSetupTheme.menuMainColor + `!important}.menu-main-color,#quick-menu a:hover,.quick,.quick:focus,.menu-tabs a:hover,.menu-tabs .active,.submenu-tabs a:hover,.submenu-tabs .active,#stats center,#exp-imp h1{color:` + gameSetupTheme.menuMainColor + `}#exp-bar .progress-bar-striped,.quick:hover,.rangeslider__fill{background-color:` + gameSetupTheme.menuMainColor + `}#main-menu,.agario-side-panel,#hotkeys,#exp-imp{border-color:` + gameSetupTheme.menuMainColor + `}.ps-scrollbar-y{background-color:` + gameSetupTheme.menuMainColor + `!important}`;
  2048. this.addCustomCSS(`menuMainColorCSS`, css);
  2049. },
  2050. setMenuPanelColor() {
  2051. const css = `${`#main-menu,.agario-side-panel,#hotkeys,#exp-imp{background-color: ` + gameSetupTheme.menuPanelColor + `}label:hover,.agario-panel input,.agario-panel select,.agario-side-panel input,.agario-side-panel select,.input-group-addon,.nick .input-group-btn,.skin .input-group-btn,#stream-mode,#hide-url,.menu-tabs a:hover,.menu-tabs .active,.submenu-tabs,#exp-bar .progress,#quick-menu a:hover,.quick,.select-wrapper,#hotkeys-cfg div.row:hover,#hotkeys-cfg .command-in,#exp-imp-settings textarea,.restore-settings{background-color: ` + gameSetupTheme.menuPanelColor2 + `}.agario-panel h5,.agario-side-panel h5,#stats h2,.menu-tabs,.submenu-tabs,#skins a.default,#stats hr,#hotkeys-cfg div.row, #exp-imp h1{border-color: ` + gameSetupTheme.menuPanelColor2}}.quick:hover,#skins a,#profiles{color:${gameSetupTheme.menuPanelColor2}}input.stream-mode,input.hide-url{color:${gameSetupTheme.menuPanelColor2}!important}`;
  2052. this.addCustomCSS('menuPanelColorCSS', css);
  2053. },
  2054. setMenuTextColor() {
  2055. const css = `${`.agario-panel,.agario-side-panel,.agario-panel input,.agario-panel select,.agario-side-panel input,.agario-side-panel select,.input-group-addon,.dark .yt-username,#stream-mode,#hide-url,.menu-tabs a,.submenu-tabs a,#skins a.default:hover,#quick-menu a,#prev-profile.default:hover,#next-profile.default:hover,#statsText,#hotkeys,#hotkeys-cfg .command-in,#exp-imp{color:` + gameSetupTheme.menuTextColor + `}#skins a.default:hover{border-color:` + gameSetupTheme.menuTextColor + `}::-webkit-input-placeholder{color:` + gameSetupTheme.menuTextColor2 + `!important}::-moz-placeholder{color:` + gameSetupTheme.menuTextColor2 + `!important}#user-id-tag, #version-tag,#statsSubtext,#hotkeys-inst,#exp-imp textarea,.restore-settings a,.restore-settings a:hover{color:` + gameSetupTheme.menuTextColor2 + `}#hotkeys-cfg .command-in,#theme .color-box{border-color:` + gameSetupTheme.menuTextColor2}}`;
  2056. this.addCustomCSS(`menuTextColorCSS`, css);
  2057. },
  2058. setMenuButtons() {
  2059. const css = `${`a,a:hover{color:` + gameSetupTheme.btn1Color}}.btn,#hotkeys-cfg .custom-key-in{color:${gameSetupTheme.menuBtnTextColor}${`}.btn-primary{background-color:`}${gameSetupTheme.btn1Color}${`!important}.btn-primary:active,.btn-primary:disabled,.btn-primary:focus,.btn-primary:hover{background-color:`}${gameSetupTheme.btn1Color2}${`!important}.btn-success{background-color:`}${gameSetupTheme.btn2Color}${`!important}.btn-success:active,.btn-success:disabled,.btn-success:focus,.btn-success:hover{background-color:`}${gameSetupTheme.btn2Color2}!important}.btn-warning{background-color:${gameSetupTheme.btn3Color}${`!important}.btn-warning:active,.btn-warning:disabled,.btn-warning:focus,.btn-warning:hover{background-color:`}${gameSetupTheme.btn3Color2}${`!important}.btn-danger{background-color:`}${gameSetupTheme.btn4Color}!important}.btn-danger:active,.btn-danger:disabled,.btn-danger:focus,.btn-danger:hover{background-color:${gameSetupTheme.btn4Color2}${`!important}#hotkeys-cfg .custom-key-in{background-color:`}${gameSetupTheme.btn4Color2}${`;border-color:`}${gameSetupTheme.btn4Color2}}`;
  2060. this.addCustomCSS(`menuButtonsCSS`, css);
  2061. },
  2062. setMenuBg() {
  2063. JQuery(`#menuBg`).val(gameSetupTheme.menuBg);
  2064. if (gameSetupTheme.menuBg) {
  2065. JQuery('.menu-panel, .agario-side-panel, #hotkeys, #exp-imp').css(`background-image`, `${`url(` + gameSetupTheme.menuBg})`);
  2066. } else {
  2067. JQuery('.menu-panel, .agario-side-panel, #hotkeys, #exp-imp').css(`background-image`, `none`);
  2068. }
  2069. },
  2070. setHud() {
  2071. this.setHudColors();
  2072. this.setHudFont();
  2073. this.setHudScale();
  2074. },
  2075. setHudColors() {
  2076. const css = `${`.hud-main-color,#top5-hud a,#target-panel-hud a:hover,#target-panel-hud a.active,#message-menu a{color:` + gameSetupTheme.hudMainColor + `}.hud,.hud-b,#chat-emoticons{background-color:` + gameSetupTheme.hudColor + `}.hud,.hud-b,#top5-hud a:hover,#target-panel-hud a{color:` + gameSetupTheme.hudTextColor}}.stats-hud-color{color:${gameSetupTheme.statsHudColor}${`}.time-hud-color{color:`}${gameSetupTheme.timeHudColor}${`}.top5-mass-color{color:`}${gameSetupTheme.top5MassColor}${`}#leaderboard-positions .me{color:`}${gameSetupTheme.lbMeColor}${`}#leaderboard-positions .teammate{color:`}${gameSetupTheme.lbTeammateColor}}`;
  2077. this.addCustomCSS('hudCSS', css);
  2078. },
  2079. setHudFont() {
  2080. this.setFont('hudFont', gameSetupTheme.hudFont);
  2081. JQuery('#overlays-hud').css({
  2082. 'font-family': gameSetupTheme.hudFontFamily,
  2083. 'font-weight': gameSetupTheme.hudFontWeight
  2084. });
  2085. },
  2086. setHudScale() {
  2087. const overlays = Math.round(20 * gameSetupTheme.hudScale);
  2088. const leadeboard = Math.round(200 * gameSetupTheme.hudScale);
  2089. const top5 = Math.floor(55 * gameSetupTheme.hudScale);
  2090. const top5_pos = Math.floor(6 * gameSetupTheme.hudScale);
  2091. const time = Math.floor(280 * gameSetupTheme.hudScale);
  2092. const pause = Math.floor(85 * gameSetupTheme.hudScale);
  2093. const target = Math.floor(20 * gameSetupTheme.hudScale);
  2094. JQuery('#overlays-hud').css(`font-size`, `${overlays}px`);
  2095. JQuery('#leaderboard-hud, #time-hud', '#botClient').width(leadeboard);
  2096. JQuery(`#top5-hud`).width(leadeboard + 30).css(`top`, `${top5}px`);
  2097. JQuery(`#top5-pos`).css('padding-left', `${top5_pos}px`);
  2098. JQuery(`#time-hud`).css(`top`, `${time}px`);
  2099. JQuery(`#pause-hud`).css(`top`, `${pause}px`);
  2100. JQuery(`#target-hud`).css('padding-top', `${target}px`);
  2101. },
  2102. setChat() {
  2103. this.setChatColors();
  2104. this.setChatScale();
  2105. },
  2106. setChatColors() {
  2107. const css = `${`#message,#messages li,.toast-success{background-color:` + gameSetupTheme.messageColor + `}#message,.message-text,.toast-success .message-text{color:` + gameSetupTheme.messageTextColor + `}.message-nick,.mute-user,.mute-user:hover,.toast-success .message-nick,.toast .mute-user,.toast .mute-user:hover{color:` + gameSetupTheme.messageNickColor + `}.message-time{color:` + gameSetupTheme.messageTimeColor}}.toast-warning{background-color:${gameSetupTheme.commandsColor}${`}.command-text,.toast-warning .command-text{color:`}${gameSetupTheme.commandsTextColor}${`}.command-nick,.toast-warning .command-nick,.toast-warning .mute-user,.toast-warning .mute-user:hover{color:`}${gameSetupTheme.commandsNickColor}${`}.command-time{color:`}${gameSetupTheme.commandsTimeColor}${`}#chat-box{background-color:`}${gameSetupTheme.chatBoxColor}}`;
  2108. this.addCustomCSS(`chatCSS`, css);
  2109. },
  2110. setChatScale() {
  2111. const message = Math.round(14 * gameSetupTheme.chatScale);
  2112. const toastContainer = Math.round(280 * gameSetupTheme.chatScale);
  2113. const messageBox = Math.round(350 * gameSetupTheme.chatScale);
  2114. const chatBox = Math.round(300 * gameSetupTheme.chatScale);
  2115. const userList = Math.floor(14 * gameSetupTheme.chatScale);
  2116. JQuery(`#message-box, #messages, #toast-container, #chat-box`).css(`font-size`, `${message}px`);
  2117. JQuery('#messages, #toast-container, #chat-box').width(toastContainer);
  2118. JQuery(`#message-box`).width(messageBox);
  2119. JQuery(`#chat-box`).height(chatBox);
  2120. JQuery('.user-list').css(`padding-left`, `${userList}px`);
  2121. const css = `#toast-container{width:` + toastContainer + `px;font-size:` + message + `px}`;
  2122. this.addCustomCSS(`chatScaleCSS`, css);
  2123. },
  2124. setMiniMap() {
  2125. this.setMiniMapFont();
  2126. this.setMiniMapWidth();
  2127. this.setMiniMapSectorsOpacity();
  2128. },
  2129. setMiniMapFont() {
  2130. this.setFont(`miniMapFont`, gameSetupTheme.miniMapFont);
  2131. application && application.resetMiniMapSectors();
  2132. },
  2133. setMiniMapWidth() {
  2134. const resizeWidth = gameSetupTheme.miniMapWidth / 200;
  2135. gameSetupTheme.miniMapTop = Math.round(20 * resizeWidth);
  2136. JQuery('#minimap-hud').css({
  2137. width: gameSetupTheme.miniMapWidth,
  2138. height: gameSetupTheme.miniMapWidth + gameSetupTheme.miniMapTop
  2139. });
  2140. application && application.resetMiniMapSectors();
  2141. },
  2142. setMiniMapSectorsColor() {
  2143. application && application.resetMiniMapSectors();
  2144. },
  2145. setMiniMapSectorsOpacity() {
  2146. JQuery('#minimap-sectors').css(`opacity`, gameSetupTheme.miniMapSectorsOpacity);
  2147. },
  2148. setTheme() {
  2149. this.setFonts();
  2150. this.setBgColor();
  2151. this.setCustomBackground();
  2152. this.setCustomCursor();
  2153. this.setMenu();
  2154. this.setHud();
  2155. this.setChat();
  2156. this.setMiniMap();
  2157. },
  2158. init() {
  2159. this.loadThemeSettings();
  2160. }
  2161. };
  2162. let PlayerProfiles = [];
  2163. const mainProfile = {
  2164. nick: `I <3 OGARio`,
  2165. clanTag: 'â“‚',
  2166. skinURL: '',
  2167. color: gameSetupTheme.mainColor
  2168. };
  2169. var gameOptionSettings = {
  2170. quickResp: true,
  2171. autoResp: false,
  2172. autoZoom: false,
  2173. autoHideNames: true,
  2174. autoHideMass: true,
  2175. autoHideFood: false,
  2176. autoHideFoodOnZoom: false,
  2177. noNames: false,
  2178. optimizedNames: true,
  2179. hideMyName: true,
  2180. hideTeammatesNames: false,
  2181. showMass: true,
  2182. optimizedMass: true,
  2183. shortMass: true,
  2184. virMassShots: true,
  2185. hideMyMass: false,
  2186. hideEnemiesMass: false,
  2187. vanillaSkins: false,
  2188. customSkins: true,
  2189. myTransparentSkin: false,
  2190. myCustomColor: false,
  2191. transparentCells: false,
  2192. transparentViruses: true,
  2193. transparentSkins: false,
  2194. showGrid: false,
  2195. showBgSectors: false,
  2196. showMapBorders: true,
  2197. showGhostCells: true,
  2198. showMiniMap: true,
  2199. showMiniMapGrid: false,
  2200. showMiniMapGuides: true,
  2201. showMiniMapGhostCells: false,
  2202. oneColoredTeammates: false,
  2203. optimizedFood: true,
  2204. rainbowFood: false,
  2205. oppColors: false,
  2206. oppRings: false,
  2207. virColors: false,
  2208. splitRange: false,
  2209. virusesRange: false,
  2210. textStroke: false,
  2211. namesStroke: false,
  2212. massStroke: false,
  2213. cursorTracking: false,
  2214. teammatesInd: false,
  2215. mouseSplit: false,
  2216. mouseFeed: false,
  2217. mouseInvert: false,
  2218. disableChat: false,
  2219. hideChat: false,
  2220. chatSounds: true,
  2221. chatEmoticons: true,
  2222. showChatBox: false,
  2223. showChatImages: true,
  2224. showChatVideos: true,
  2225. showTop5: true,
  2226. showTargeting: true,
  2227. showLbData: true,
  2228. showTime: true,
  2229. normalLb: false,
  2230. centeredLb: true,
  2231. fpsAtTop: true,
  2232. showStats: true,
  2233. showStatsMass: true,
  2234. showStatsSTE: false,
  2235. showStatsN16: false,
  2236. showStatsFPS: true,
  2237. blockPopups: false,
  2238. streamMode: false,
  2239. hideSkinUrl: false,
  2240. showQuickMenu: true,
  2241. showSkinsPanel: true,
  2242. animation: 140,
  2243. zoomSpeedValue: 0.9,
  2244. messageSound: `https://cdn.ogario.ovh/static/sounds/notification_01.mp3`,
  2245. commandSound: `https://cdn.ogario.ovh/static/sounds/notification_02.mp3`
  2246. };
  2247.  
  2248. function minimap(id, name, skinID, skinUrl) {
  2249. this.id = id;
  2250. this.nick = name;
  2251. this.skinID = skinID;
  2252. this.skinURL = skinUrl;
  2253. this.x = 0;
  2254. this.y = 0;
  2255. this.lastX = 0;
  2256. this.lastY = 0;
  2257. this.mass = 0;
  2258. this.clanTag = '';
  2259. this.color = null;
  2260. this.customColor = gameSetupTheme.miniMapTeammatesColor;
  2261. this.alive = false;
  2262. this.updateTime = null;
  2263. this.pi2 = 2 * Math.PI;
  2264. this.setColor = function(color, customColor) {
  2265. this.color = color;
  2266. if (customColor.length == 7) {
  2267. this.customColor = customColor;
  2268. }
  2269. };
  2270. this.drawPosition = function(ctx, offset, size, privateMap, targetID) {
  2271. if (!this.alive || privateMap && targetID && this.id != targetID) {
  2272. return;
  2273. }
  2274. this.lastX = (29 * this.lastX + this.x) / 30;
  2275. this.lastY = (29 * this.lastY + this.y) / 30;
  2276. const posX = (this.lastX + offset) * size;
  2277. const posY = (this.lastY + offset) * size;
  2278. if (this.nick.length > 0) {
  2279. ctx.font = `${gameSetupTheme.miniMapNickFontWeight} ${gameSetupTheme.miniMapNickSize}${`px `}${gameSetupTheme.miniMapNickFontFamily}`;
  2280. ctx.textAlign = `center`;
  2281. if (gameSetupTheme.miniMapNickStrokeSize > 0) {
  2282. ctx.lineWidth = gameSetupTheme.miniMapNickStrokeSize;
  2283. ctx.strokeStyle = gameSetupTheme.miniMapNickStrokeColor;
  2284. ctx.strokeText(this.nick, posX, posY - (gameSetupTheme.miniMapTeammatesSize * 2 + 2));
  2285. }
  2286. ctx.fillStyle = gameSetupTheme.miniMapNickColor;
  2287. ctx.fillText(this.nick, posX, posY - (gameSetupTheme.miniMapTeammatesSize * 2 + 2));
  2288. }
  2289. ctx.beginPath();
  2290. ctx.arc(posX, posY, gameSetupTheme.miniMapTeammatesSize, 0, this.pi2, false);
  2291. ctx.closePath();
  2292. if (gameOptionSettings.oneColoredTeammates) {
  2293. ctx.fillStyle = gameSetupTheme.miniMapTeammatesColor;
  2294. } else {
  2295. ctx.fillStyle = this.color;
  2296. }
  2297. ctx.fill();
  2298. };
  2299. }
  2300. const application = {
  2301. name: `OGARio by szymy v4`,
  2302. version: `v4 (4.0.0 b38)`,
  2303. privateMode: false,
  2304. protocolMode: true,
  2305. publicIP: `wss://srv.ogario.eu`,
  2306. privateIP: null,
  2307. updateInterval: 1000,
  2308. updateTick: 0,
  2309. updateMaxTick: 2,
  2310. currentSector: '',
  2311. miniMap: null,
  2312. miniMapCtx: null,
  2313. miniMapSectors: null,
  2314. pi2: 2 * Math.PI,
  2315. socket: null,
  2316. cells: {},
  2317. teamPlayers: [],
  2318. parties: [],
  2319. chatHistory: [],
  2320. chatUsers: {},
  2321. chatMutedUsers: {},
  2322. chatMutedUserIDs: [],
  2323. customSkinsCache: {},
  2324. customSkinsMap: {},
  2325. cacheQueue: [],
  2326. deathLocations: [],
  2327. playerID: null,
  2328. playerMass: 0,
  2329. selectedProfile: 0,
  2330. lastDeath: 0,
  2331. skipServerData: false,
  2332. gameMode: `:ffa`,
  2333. region: '',
  2334. partyToken: '',
  2335. ws: '',
  2336. serverIP: '',
  2337. serverArena: '',
  2338. serverToken: '',
  2339. lastSentNick: '',
  2340. lastSentClanTag: null,
  2341. lastSentSkinURL: '',
  2342. lastSentCustomColor: '',
  2343. lastSentPartyToken: '',
  2344. lastSentServerToken: '',
  2345. lastMessageSentTime: Date.now(),
  2346. rFps: 0,
  2347. renderedFrames: 0,
  2348. fpsLastRequest: null,
  2349. statsHUD: null,
  2350. leaderboardPositionsHUD: null,
  2351. leaderboardDataHUD: null,
  2352. activeParties: null,
  2353. top5pos: null,
  2354. top5totalMass: null,
  2355. top5totalPlayers: null,
  2356. top5limit: 5,
  2357. timeHUD: null,
  2358. questHUD: null,
  2359. retryResp: 0,
  2360. token: 'b2dhcmlvLm92aA==',
  2361. canvasScale: 1,
  2362. selectBiggestCell: true,
  2363. noColors: false,
  2364. skipStats: false,
  2365. showQuest: false,
  2366. showSplitInd: false,
  2367. pause: false,
  2368. targetID: 0,
  2369. targetStatus: 0,
  2370. targetNick: '',
  2371. targetSkinURL: '',
  2372. targeting: false,
  2373. privateMiniMap: false,
  2374. messageSound: null,
  2375. commandSound: null,
  2376. feedInterval: null,
  2377. getPlayerX() {
  2378. return ogario.playerX + ogario.mapOffsetX;
  2379. },
  2380. getPlayerY() {
  2381. return ogario.playerY + ogario.mapOffsetY;
  2382. },
  2383. feed() {
  2384. window.core && window.core.eject && window.core.eject();
  2385. },
  2386. macroFeed(on) {
  2387. if (on) {
  2388. if (this.feedInterval) {
  2389. return;
  2390. }
  2391. const app = this;
  2392. this.feed();
  2393. this.feedInterval = setInterval(() => {
  2394. app.feed();
  2395. }, 80);
  2396. } else {
  2397. if (this.feedInterval) {
  2398. clearInterval(this.feedInterval);
  2399. this.feedInterval = null;
  2400. }
  2401. }
  2402. },
  2403. split() {
  2404. window.core && window.core.split && window.core.split();
  2405. },
  2406. doubleSplit() {
  2407. const app = this;
  2408. app.split();
  2409. setTimeout(() => {
  2410. app.split();
  2411. }, 40);
  2412. },
  2413. popSplit() {
  2414. const app = this;
  2415. app.split();
  2416. setTimeout(() => {
  2417. app.split();
  2418. }, 200);
  2419. },
  2420. split16() {
  2421. const app = this;
  2422. app.split();
  2423. setTimeout(() => {
  2424. app.split();
  2425. }, 40);
  2426. setTimeout(() => {
  2427. app.split();
  2428. }, 80);
  2429. setTimeout(() => {
  2430. app.split();
  2431. }, 120);
  2432. },
  2433. toggleSkins() {
  2434. if (ogario.vanillaSkins && ogario.customSkins) {
  2435. ogario.vanillaSkins = false;
  2436. } else if (!ogario.vannillaSkins && ogario.customSkins) {
  2437. ogario.vanillaSkins = true;
  2438. ogario.customSkins = false;
  2439. } else {
  2440. ogario.vanillaSkins = true;
  2441. ogario.customSkins = true;
  2442. }
  2443. },
  2444. toggleCells() {
  2445. this.selectBiggestCell = !this.selectBiggestCell;
  2446. ogario.selectBiggestCell = this.selectBiggestCell;
  2447. },
  2448. setShowTop5() {
  2449. gameOptionSettings.showTop5 = !gameOptionSettings.showTop5;
  2450. this.setTop5();
  2451. },
  2452. setTop5() {
  2453. if (gameOptionSettings.showTop5) {
  2454. JQuery(`#top5-hud`).show();
  2455. } else {
  2456. JQuery('#top5-hud').hide();
  2457. }
  2458. },
  2459. setShowTargeting() {
  2460. gameOptionSettings.showTargeting = !gameOptionSettings.showTargeting;
  2461. this.setTargetingHUD();
  2462. },
  2463. setTargetingHUD() {
  2464. if (gameOptionSettings.showTargeting) {
  2465. JQuery('#target-hud, #target-panel-hud').show();
  2466. } else {
  2467. JQuery('#target-hud, #target-panel-hud').hide();
  2468. }
  2469. },
  2470. setShowTime() {
  2471. gameOptionSettings.showTime = !gameOptionSettings.showTime;
  2472. if (gameOptionSettings.showTime) {
  2473. JQuery(`#time-hud`).show();
  2474. this.displayTime();
  2475. } else {
  2476. JQuery(`#time-hud`).hide();
  2477. }
  2478. },
  2479. setShowSplitRange() {
  2480. gameOptionSettings.splitRange = !gameOptionSettings.splitRange;
  2481. ogario.splitRange = gameOptionSettings.splitRange;
  2482. },
  2483. setShowSplitInd() {
  2484. this.showSplitInd = !this.showSplitInd;
  2485. gameOptionSettings.splitRange = this.showSplitInd;
  2486. gameOptionSettings.oppRings = this.showSplitInd;
  2487. ogario.splitRange = gameOptionSettings.splitRange;
  2488. ogario.oppRings = gameOptionSettings.oppRings;
  2489. },
  2490. setShowTeammatesInd() {
  2491. gameOptionSettings.teammatesInd = !gameOptionSettings.teammatesInd;
  2492. },
  2493. setShowOppColors() {
  2494. gameOptionSettings.oppColors = !gameOptionSettings.oppColors;
  2495. ogario.oppColors = gameOptionSettings.oppColors;
  2496. },
  2497. setShowSkins() {
  2498. this.noSkins = !this.noSkins;
  2499. window.core && window.core.setSkins && window.core.setSkins(!this.noSkins);
  2500. ogario.showCustomSkins = !this.noSkins;
  2501. this.displayChatInfo(!this.noSkins, `showSkinsMsg`);
  2502. },
  2503. setTransparentSkins() {
  2504. gameOptionSettings.transparentSkins = !gameOptionSettings.transparentSkins;
  2505. ogario.transparentSkins = gameOptionSettings.transparentSkins;
  2506. },
  2507. setShowStats() {
  2508. JQuery(`#stats-hud`).toggle();
  2509. },
  2510. setShowFood() {
  2511. ogario.showFood = !ogario.showFood;
  2512. },
  2513. setShowHUD() {
  2514. JQuery(`#overlays-hud`).toggle();
  2515. },
  2516. setShowGrid() {
  2517. gameOptionSettings.showGrid = !gameOptionSettings.showGrid;
  2518. },
  2519. setShowMiniMapGuides() {
  2520. gameOptionSettings.showMiniMapGuides = !gameOptionSettings.showMiniMapGuides;
  2521. },
  2522. setShowLb() {
  2523. if (this.gameMode === `:teams`) {
  2524. return;
  2525. }
  2526. JQuery(`#leaderboard-hud`).toggle();
  2527. },
  2528. setShowBgSectors() {
  2529. gameOptionSettings.showBgSectors = !gameOptionSettings.showBgSectors;
  2530. },
  2531. setHideSmallBots() {
  2532. ogario.hideSmallBots = !ogario.hideSmallBots;
  2533. this.displayChatInfo(!ogario.hideSmallBots, `hideSmallBotsMsg`);
  2534. },
  2535. setShowNames() {
  2536. gameOptionSettings.noNames = !gameOptionSettings.noNames;
  2537. },
  2538. setHideTeammatesNames() {
  2539. gameOptionSettings.hideTeammatesNames = !gameOptionSettings.hideTeammatesNames;
  2540. },
  2541. setShowMass() {
  2542. gameOptionSettings.showMass = !gameOptionSettings.showMass;
  2543. },
  2544. setShowMiniMap() {
  2545. gameOptionSettings.showMiniMap = !gameOptionSettings.showMiniMap;
  2546. this.setMiniMap();
  2547. },
  2548. setMiniMap() {
  2549. if (gameOptionSettings.showMiniMap) {
  2550. JQuery(`#minimap-hud`).show();
  2551. } else {
  2552. JQuery(`#minimap-hud`).hide();
  2553. }
  2554. },
  2555. setShowQuest() {
  2556. if (this.gameMode !== `:ffa`) {
  2557. return;
  2558. }
  2559. this.showQuest = !this.showQuest;
  2560. this.setQuest();
  2561. },
  2562. setQuest() {
  2563. if (this.showQuest && this.gameMode === `:ffa`) {
  2564. JQuery(`#quest-hud`).show();
  2565. } else {
  2566. JQuery(`#quest-hud`).hide();
  2567. }
  2568. },
  2569. toggleAutoZoom() {
  2570. ogario.autoZoom = !ogario.autoZoom;
  2571. this.displayChatInfo(ogario.autoZoom, `autoZoomMsg`);
  2572. },
  2573. resetZoom(on) {
  2574. if (on) {
  2575. ogario.zoomResetValue = 1;
  2576. ogario.zoomValue = 1;
  2577. } else {
  2578. ogario.zoomResetValue = 0;
  2579. }
  2580. },
  2581. setZoom(value) {
  2582. ogario.zoomValue = value;
  2583. },
  2584. toggleDeath() {
  2585. this.lastDeath--;
  2586. if (this.lastDeath < 0) {
  2587. this.lastDeath = this.deathLocations.length - 1;
  2588. }
  2589. },
  2590. tryResp() {
  2591. if (ogario.play || this.retryResp == 20) {
  2592. this.retryResp = 0;
  2593. return;
  2594. }
  2595. this.retryResp++;
  2596. const app = this;
  2597. setTimeout(() => {
  2598. if (JQuery(`.btn-play-guest`).is(`:visible`)) {
  2599. JQuery(`.btn-play-guest`).click();
  2600. } else {
  2601. JQuery('.btn-play').click();
  2602. }
  2603. if (!ogario.play) {
  2604. app.tryResp();
  2605. }
  2606. }, 500);
  2607. },
  2608. quickResp() {
  2609. if (!gameOptionSettings.quickResp) {
  2610. return;
  2611. }
  2612. this.hideMenu();
  2613. this.gameServerConnect(this.ws);
  2614. ogario.play = false;
  2615. this.tryResp();
  2616. },
  2617. autoResp() {
  2618. if (!gameOptionSettings.autoResp) {
  2619. return;
  2620. }
  2621. this.setAutoResp();
  2622. JQuery('#overlays').stop().hide();
  2623. if (JQuery('.btn-play-guest').is(`:visible`)) {
  2624. JQuery(`.btn-play-guest`).click();
  2625. return;
  2626. }
  2627. JQuery('.btn-play').click();
  2628. },
  2629. setAutoResp() {
  2630. if (gameOptionSettings.autoResp) {
  2631. if (!JQuery(`#skipStats`).prop(`checked`)) {
  2632. JQuery(`#skipStats`).click();
  2633. this.skipStats = true;
  2634. }
  2635. }
  2636. },
  2637. toggleAutoResp() {
  2638. gameOptionSettings.autoResp = !gameOptionSettings.autoResp;
  2639. this.setAutoResp();
  2640. this.displayChatInfo(gameOptionSettings.autoResp, `autoRespMsg`);
  2641. },
  2642. copyLb() {
  2643. const input = JQuery(`<input>`);
  2644. JQuery(`body`).append(input);
  2645. input.val(JQuery('#leaderboard-positions').text()).select();
  2646. try {
  2647. document.execCommand(`copy`);
  2648. } catch (error) {
  2649. console.log("can't copy..")
  2650. }
  2651. input.remove();
  2652. },
  2653. setPause() {
  2654. this.pause = !this.pause;
  2655. ogario.pause = this.pause;
  2656. if (this.pause) {
  2657. ogario.resetTargetPosition();
  2658. JQuery(`#pause-hud`).show();
  2659. } else {
  2660. JQuery(`#pause-hud`).hide();
  2661. }
  2662. },
  2663. setCenteredLb() {
  2664. if (gameOptionSettings.centeredLb) {
  2665. JQuery(`#leaderboard-hud`).addClass('hud-text-center');
  2666. } else {
  2667. JQuery(`#leaderboard-hud`).removeClass('hud-text-center');
  2668. }
  2669. },
  2670. setNormalLb() {
  2671. if (gameOptionSettings.normalLb) {
  2672. JQuery(`#leaderboard-hud h4`).html(textLanguage.leaderboard);
  2673. } else {
  2674. JQuery('#leaderboard-hud h4').html(`ogario.ovh`);
  2675. }
  2676. },
  2677. setFpsAtTop() {
  2678. if (gameOptionSettings.fpsAtTop) {
  2679. JQuery('#stats-hud').removeClass('hud-bottom').addClass(`hud-top`);
  2680. } else {
  2681. JQuery(`#stats-hud`).removeClass(`hud-top`).addClass(`hud-bottom`);
  2682. }
  2683. },
  2684. setBlockPopups() {
  2685. if (this.protocolMode) {
  2686. JQuery(`#block-warn`).hide();
  2687. return;
  2688. }
  2689. if (gameOptionSettings.blockPopups) {
  2690. this.blockPopups();
  2691. } else {
  2692. this.unblockPopups();
  2693. }
  2694. },
  2695. blockPopups() {
  2696. JQuery(`#openfl-content, #openfl-overlay`).hide();
  2697. JQuery(`#openfl-content, #openfl-overlay`).addClass(`block-popups`);
  2698. JQuery(`#freeCoins, #gifting, #openShopBtn, #dailyQuests`).prop(`disabled`, true);
  2699. JQuery(`#block-warn`).show();
  2700. },
  2701. unblockPopups() {
  2702. JQuery(`#openfl-overlay.disabler`).click();
  2703. JQuery(`#openfl-content, #openfl-overlay`).hide();
  2704. JQuery(`#openfl-content, #openfl-overlay`).removeClass(`block-popups`);
  2705. JQuery(`#freeCoins, #gifting, #openShopBtn, #dailyQuests`).prop(`disabled`, false);
  2706. JQuery(`#block-warn`).hide();
  2707. },
  2708. tempUnblockPopups() {
  2709. if (!gameOptionSettings.blockPopups) {
  2710. return;
  2711. }
  2712. this.unblockPopups();
  2713. },
  2714. displayLeaderboard(position, data = '') {
  2715. if (!this.leaderboardPositionsHUD) {
  2716. return;
  2717. }
  2718. this.leaderboardPositionsHUD.innerHTML = position;
  2719. this.leaderboardDataHUD.innerHTML = data;
  2720. },
  2721. displayStats() {
  2722. if (!gameOptionSettings.showStats) {
  2723. JQuery(`#stats-hud`).hide();
  2724. return;
  2725. }
  2726. let text = '';
  2727. if (ogario.play) {
  2728. if (gameOptionSettings.showStatsMass && ogario.playerMass) {
  2729. text += `${textLanguage.mass}: ${ogario.playerMass} | `;
  2730. }
  2731. if (ogario.playerScore) {
  2732. text += `${textLanguage.score}: ${ogario.playerScore}`;
  2733. }
  2734. if (gameOptionSettings.showStatsSTE && ogario.STE) {
  2735. text += ` | STE: ` + ogario.STE;
  2736. }
  2737. if (gameOptionSettings.showStatsN16 && ogario.playerSplitCells) {
  2738. text += ` | ` + ogario.playerSplitCells + `/16`;
  2739. }
  2740. if (gameOptionSettings.showStatsFPS) {
  2741. text += ` | `;
  2742. }
  2743. }
  2744. if (gameOptionSettings.showStatsFPS) {
  2745. text += `FPS: ` + drawRender.fps;
  2746. }
  2747. this.statsHUD.textContent = text;
  2748. const app = this;
  2749. setTimeout(() => {
  2750. app.displayStats();
  2751. }, 250);
  2752. },
  2753. displayTime() {
  2754. if (!gameOptionSettings.showTime) {
  2755. JQuery(`#time-hud`).hide();
  2756. return;
  2757. }
  2758. const time = new Date().toLocaleString();
  2759. this.timeHUD.textContent = time;
  2760. const app = this;
  2761. setTimeout(() => {
  2762. app.displayTime();
  2763. }, 1000);
  2764. },
  2765. displayParties() {
  2766. let text = '';
  2767. for (let length = 0; length < this.parties.length; length++) {
  2768. text += `<li><a href="https://agar.io/#` + this.parties[length] + `" onclick="$('#party-token').val('` + this.parties[length] + `'); $('#join-party-btn-2').click();">https://agar.io/#` + this.parties[length] + `</a></li>`;
  2769. }
  2770. if (text === '') {
  2771. this.activeParties.className = `no-parties`;
  2772. } else {
  2773. this.activeParties.className = '';
  2774. }
  2775. this.activeParties.innerHTML = text;
  2776. },
  2777. displayTop5() {
  2778. if (!gameOptionSettings.showTop5) {
  2779. return;
  2780. }
  2781. let text = '';
  2782. let mass = 0;
  2783. let top5length = this.top5.length;
  2784. for (let length = 0; length < top5length; length++) {
  2785. mass += this.top5[length].mass;
  2786. if (length >= this.top5limit) {
  2787. continue;
  2788. }
  2789. text += `<li><span class="cell-counter" style="background-color: ${this.top5[length].color}">${length + 1}${`</span>`}`;
  2790. if (gameOptionSettings.showTargeting) {
  2791. text += `<a href="#" data-user-id="` + this.top5[length].id + `" class="set-target ogicon-target"></a> `;
  2792. }
  2793. text += `<span class="hud-main-color">[` + this.calculateMapSector(this.top5[length].x, this.top5[length].y) + `]</span>`;
  2794. text += `<span class="top5-mass-color">[${this.shortMassFormat(this.top5[length].mass)}${`]</span> `}${this.escapeHTML(this.top5[length].nick)}${`</li>`}`;
  2795. }
  2796. this.top5pos.innerHTML = text;
  2797. if (ogario.play && ogario.playerMass) {
  2798. mass += ogario.playerMass;
  2799. top5length++;
  2800. }
  2801. this.top5totalMass.textContent = this.shortMassFormat(mass);
  2802. this.top5totalPlayers.textContent = top5length;
  2803. },
  2804. setTop5limit(value) {
  2805. if (!value) {
  2806. return;
  2807. }
  2808. this.top5limit = value;
  2809. },
  2810. displayChatHistory(on) {
  2811. if (on) {
  2812. this.clearChatHistory(true);
  2813. for (let length = 0; length < this.chatHistory.length; length++) {
  2814. JQuery(`#messages`).append(`<li><span class="message-nick">` + this.chatHistory[length].nick + `: </span><span class="message-text">` + this.chatHistory[length].message + `</span></li>`);
  2815. }
  2816. return;
  2817. }
  2818. this.clearChatHistory(false);
  2819. },
  2820. clearChatHistory(on) {
  2821. JQuery(`#messages`).empty();
  2822. if (on) {
  2823. toastr.clear();
  2824. if (gameOptionSettings.showChatBox) {
  2825. JQuery(`#chat-box .message`).remove();
  2826. this.chatHistory.length = 0;
  2827. }
  2828. }
  2829. },
  2830. displayChatInfo(on, info) {
  2831. if (on) {
  2832. toastr.info(textLanguage[`${info}A`]);
  2833. } else {
  2834. toastr.error(textLanguage[`${info}B`]);
  2835. }
  2836. },
  2837. setDisableChat() {
  2838. gameOptionSettings.hideChat = gameOptionSettings.disableChat;
  2839. this.setHideChat();
  2840. },
  2841. hideChat() {
  2842. gameOptionSettings.hideChat = !gameOptionSettings.hideChat;
  2843. this.setHideChat();
  2844. this.displayChatInfo(!gameOptionSettings.hideChat, `hideChatMsg`);
  2845. },
  2846. setHideChat() {
  2847. if (gameOptionSettings.hideChat) {
  2848. JQuery(`#message-box`).hide();
  2849. }
  2850. this.setShowChatBox();
  2851. },
  2852. setShowChatBox() {
  2853. if (!gameOptionSettings.hideChat && gameOptionSettings.showChatBox) {
  2854. JQuery('#chat-box').show();
  2855. } else {
  2856. JQuery(`#chat-box`).hide();
  2857. }
  2858. },
  2859. enterChatMessage() {
  2860. const messageBox = JQuery(`#message-box`);
  2861. const message = JQuery(`#message`);
  2862. if (!messageBox.is(`:visible`)) {
  2863. messageBox.show();
  2864. message.focus();
  2865. message.val('');
  2866. } else {
  2867. const value = message.val();
  2868. if (value.length) {
  2869. this.sendChatMessage(101, value);
  2870. if (ogario.play) {
  2871. message.blur();
  2872. messageBox.hide();
  2873. }
  2874. } else {
  2875. message.blur();
  2876. messageBox.hide();
  2877. }
  2878. message.val('');
  2879. }
  2880. },
  2881. showMenu(value) {
  2882. if (window.MC && window.MC.showNickDialog) {
  2883. JQuery('.ogario-menu').show();
  2884. JQuery('.menu-panel').hide();
  2885. if (!ogario.play && !this.skipStats) {
  2886. JQuery('#stats').show();
  2887. } else {
  2888. JQuery(`#main-panel`).show();
  2889. }
  2890. window.MC.showNickDialog(300);
  2891. JQuery('#oferwallContainer').is(`:visible`) && window.closeOfferwall();
  2892. JQuery(`#videoContainer`).is(`:visible`) && window.closeVideoContainer();
  2893. return;
  2894. }
  2895. if (value) {
  2896. JQuery(`#overlays`).fadeIn(value);
  2897. } else {
  2898. JQuery(`#overlays`).show();
  2899. }
  2900. },
  2901. hideMenu(value) {
  2902. if (window.MC && window.MC.showNickDialog) {
  2903. JQuery(`.ogario-menu`).hide();
  2904. return;
  2905. }
  2906. if (value) {
  2907. JQuery(`#overlays`).fadeOut(value);
  2908. } else {
  2909. JQuery(`#overlays`).hide();
  2910. }
  2911. },
  2912. escapeHTML(string) {
  2913. return String(string).replace(/[&<>"'/]/g, event => escapeChar[event]);
  2914. },
  2915. checkImgURL(url) {
  2916. if (url.includes("png") || url.includes("jpg") || url.includes("jpeg")) {
  2917. return url;
  2918. } else {
  2919. return false;
  2920. }
  2921. },
  2922. checkSkinURL(url) {
  2923. return this.checkImgURL(url)
  2924. },
  2925. loadSettings() {
  2926. let settings = null;
  2927. if (window.localStorage.getItem(`ogarioSettings`) !== null) {
  2928. settings = JSON.parse(window.localStorage.getItem(`ogarioSettings`));
  2929. }
  2930. for (const option in gameOptionSettings) {
  2931. if (gameOptionSettings.hasOwnProperty(option)) {
  2932. if (settings && settings.hasOwnProperty(option)) {
  2933. gameOptionSettings[option] = settings[option];
  2934. }
  2935. if (ogario.hasOwnProperty(option)) {
  2936. ogario[option] = gameOptionSettings[option];
  2937. }
  2938. }
  2939. }
  2940. },
  2941. saveSettings(option, name) {
  2942. window.localStorage.setItem(name, JSON.stringify(option));
  2943. },
  2944. exportSettings() {
  2945. let options = {
  2946. ogarioCommands: chatCommand,
  2947. ogarioHotkeys: hotkeys,
  2948. ogarioPlayerProfiles: PlayerProfiles,
  2949. ogarioSettings: gameOptionSettings,
  2950. ogarioThemeSettings: gameSetupTheme
  2951. };
  2952. for (const option in options) {
  2953. if (options.hasOwnProperty(option)) {
  2954. const checked = JQuery(`#export-` + option).prop(`checked`);
  2955. if (!checked) {
  2956. delete options[option];
  2957. }
  2958. }
  2959. }
  2960. options = JSON.stringify(options);
  2961. JQuery(`#export-settings`).val(options);
  2962. JQuery(`#import-settings`).val('');
  2963. options = null;
  2964. },
  2965. importSettings() {
  2966. JQuery(`#import-settings`).blur();
  2967. let importValue = JQuery(`#import-settings`).val();
  2968. if (importValue) {
  2969. importValue = JSON.parse(importValue);
  2970. for (const value in importValue) {
  2971. if (importValue.hasOwnProperty(value)) {
  2972. const checked = JQuery(`#import-` + value).prop(`checked`);
  2973. if (!checked) {
  2974. continue;
  2975. }
  2976. window.localStorage.setItem(value, JSON.stringify(importValue[value]));
  2977. }
  2978. }
  2979. window.location.reload();
  2980. }
  2981. },
  2982. restoreSettings() {
  2983. if (window.localStorage.getItem('ogarioSettings') !== null) {
  2984. window.localStorage.removeItem(`ogarioSettings`);
  2985. window.location.reload();
  2986. }
  2987. },
  2988. setSettings(id, checked) {
  2989. if (gameOptionSettings.hasOwnProperty(id) && checked !== null) {
  2990. gameOptionSettings[id] = checked;
  2991. if (ogario.hasOwnProperty(id)) {
  2992. ogario[id] = checked;
  2993. }
  2994. switch (id) {
  2995. case `autoResp`:
  2996. this.setAutoResp();
  2997. break;
  2998. case `showMiniMap`:
  2999. this.setMiniMap();
  3000. break;
  3001. case `showMiniMapGrid`:
  3002. this.resetMiniMapSectors();
  3003. break;
  3004. case `disableChat`:
  3005. this.setDisableChat();
  3006. break;
  3007. case `chatSounds`:
  3008. this.setChatSoundsBtn();
  3009. break;
  3010. case 'showChatBox':
  3011. this.setShowChatBox();
  3012. break;
  3013. case `showTop5`:
  3014. this.setTop5();
  3015. break;
  3016. case 'showTargeting':
  3017. this.setTargetingHUD();
  3018. break;
  3019. case `showTime`:
  3020. this.displayTime();
  3021. JQuery('#time-hud').show();
  3022. break;
  3023. case `centeredLb`:
  3024. this.setCenteredLb();
  3025. break;
  3026. case 'normalLb':
  3027. this.setNormalLb();
  3028. break;
  3029. case `fpsAtTop`:
  3030. this.setFpsAtTop();
  3031. break;
  3032. case `showStats`:
  3033. this.displayStats();
  3034. JQuery(`#stats-hud`).show();
  3035. break;
  3036. case 'blockPopups':
  3037. this.setBlockPopups();
  3038. break;
  3039. }
  3040. this.saveSettings(gameOptionSettings, 'ogarioSettings');
  3041. }
  3042. },
  3043. loadProfiles() {
  3044. if (window.localStorage.getItem(`ogarioPlayerProfiles`) !== null) {
  3045. PlayerProfiles = JSON.parse(window.localStorage.getItem('ogarioPlayerProfiles'));
  3046. } else {
  3047. let profilesLength = 10;
  3048. for (let length = 0; length < profilesLength; length++) {
  3049. PlayerProfiles.push({
  3050. nick: `Profile #` + (length + 1),
  3051. clanTag: '',
  3052. skinURL: '',
  3053. color: gameSetupTheme.mainColor
  3054. });
  3055. }
  3056. }
  3057. if (window.localStorage.getItem(`ogarioSelectedProfile`) !== null) {
  3058. this.selectedProfile = JSON.parse(window.localStorage.getItem(`ogarioSelectedProfile`));
  3059. }
  3060. mainProfile.nick = PlayerProfiles[this.selectedProfile].nick;
  3061. mainProfile.clanTag = PlayerProfiles[this.selectedProfile].clanTag;
  3062. mainProfile.skinURL = PlayerProfiles[this.selectedProfile].skinURL;
  3063. mainProfile.color = PlayerProfiles[this.selectedProfile].color;
  3064. },
  3065. changeSkinPreview(img, id) {
  3066. if (!img || !id) {
  3067. return;
  3068. }
  3069. if (id === `skin-preview`) {
  3070. JQuery(`#skin-preview`).removeClass(`default`).append(`<a href="#" id="skin-popover" data-toggle="popover" title="" data-html="true" data-content="<img src='${img.src}' width='500'>"></a>`);
  3071. JQuery(`#skin-popover`).append(JQuery(img).fadeIn(1000));
  3072. JQuery('#skin-popover').popover();
  3073. } else {
  3074. JQuery(`#${id}`).removeClass(`default`).append(JQuery(img).fadeIn(1000));
  3075. }
  3076. },
  3077. setSkinPreview(t, e) {
  3078. checktypeImgVid = new Image();
  3079. if (JQuery('#' + e).empty().addClass('default'), t && 0 != t.length) {
  3080. var i = this,
  3081. o = checktypeImgVid;
  3082. o.src = t;
  3083. o.crossOrigin = 'anonymous',
  3084. o.onload = function() {
  3085. i.changeSkinPreview(o, e);
  3086. };
  3087. }
  3088. },
  3089. setProfile() {
  3090. const prevProfile = (PlayerProfiles.length + this.selectedProfile - 1) % PlayerProfiles.length;
  3091. const nextProfile = (this.selectedProfile + 1) % PlayerProfiles.length;
  3092. this.setSkinPreview(PlayerProfiles[prevProfile].skinURL, 'prev-profile');
  3093. this.setSkinPreview(PlayerProfiles[this.selectedProfile].skinURL, `skin-preview`);
  3094. this.setSkinPreview(PlayerProfiles[nextProfile].skinURL, `next-profile`);
  3095. this.saveSettings(this.selectedProfile, `ogarioSelectedProfile`);
  3096. JQuery(`#nick`).val(PlayerProfiles[this.selectedProfile].nick);
  3097. JQuery(`#clantag`).val(PlayerProfiles[this.selectedProfile].clanTag);
  3098. JQuery(`#skin`).val(PlayerProfiles[this.selectedProfile].skinURL);
  3099. JQuery(`#color`).val(PlayerProfiles[this.selectedProfile].color);
  3100. JQuery(`.skin`).colorpicker(`setValue`, PlayerProfiles[this.selectedProfile].color);
  3101. JQuery('#skins a').removeClass('selected');
  3102. JQuery(`#skins a[data-profile=${this.selectedProfile}]`).addClass(`selected`);
  3103. },
  3104. prevProfile() {
  3105. this.setPlayerSettings();
  3106. this.selectedProfile = (PlayerProfiles.length + this.selectedProfile - 1) % PlayerProfiles.length;
  3107. this.setProfile();
  3108. },
  3109. nextProfile() {
  3110. this.setPlayerSettings();
  3111. this.selectedProfile = (this.selectedProfile + 1) % PlayerProfiles.length;
  3112. this.setProfile();
  3113. },
  3114. selectProfile(value) {
  3115. this.setPlayerSettings();
  3116. this.selectedProfile = parseInt(value);
  3117. this.setProfile();
  3118. },
  3119. addOption(id, name, text, checked) {
  3120. JQuery(id).append(`<label><input type="checkbox" id="${name}${`" class="js-switch"> `}${text}${`</label>`}`);
  3121. JQuery(`#${name}`).prop(`checked`, checked);
  3122. },
  3123. addOptions(options, section) {
  3124. if (!options) {
  3125. return;
  3126. }
  3127. JQuery('#og-options').append(`${`<div class="options-box ` + section}"><h5 class="menu-main-color">${textLanguage[section]}</h5></div>`);
  3128.  
  3129. for (const option of options) {
  3130. if (gameOptionSettings.hasOwnProperty(option)) {
  3131. JQuery(`.${section}`).append(`${`<label>` + textLanguage[option]} <input type="checkbox" class="js-switch" id="${option}${`"></label>`}`);
  3132. JQuery(`#${option}`).prop(`checked`, gameOptionSettings[option]);
  3133. }
  3134. }
  3135. },
  3136. addInputBox(id, name, holder, callback) {
  3137. JQuery(id).append(`${`<div class="input-box"><span class="title-box">` + textLanguage[name]}</span><input id="${name}${`" class="form-control" placeholder="`}${holder}${`" value="`}${gameOptionSettings[name]}${`" /></div>`}`);
  3138. const app = this;
  3139. JQuery(`#${name}`).on(`input`, function() {
  3140. gameOptionSettings[name] = this.value;
  3141. app[callback]();
  3142. app.saveSettings(gameOptionSettings, `ogarioSettings`);
  3143. });
  3144. },
  3145. addSliderBox(id, name, min, max, step, callback) {
  3146. JQuery(id).append(`${`<div class="slider-box"><div class="box-label"><span class="value-label">` + textLanguage[name] + `: </span><span id="` + name}-value" class="value">${gameOptionSettings[name]}${`</span></div><input id="`}${name}-slider" type="range" min="${min}" max="${max}${`" step="`}${step}" value="${gameOptionSettings[name]}${`"></div>`}`);
  3147. const app = this;
  3148. if (callback) {
  3149. JQuery(`#${name}${`-slider`}`).on(`input`, function() {
  3150. const parse = parseFloat(JQuery(this).val());
  3151. JQuery(`#${name}-value`).text(parse);
  3152. gameOptionSettings[name] = parse;
  3153. if (ogario.hasOwnProperty(name)) {
  3154. ogario[name] = parse;
  3155. }
  3156. app[callback]();
  3157. app.saveSettings(gameOptionSettings, `ogarioSettings`);
  3158. });
  3159. } else {
  3160. JQuery(`#${name}-slider`).on('input', function() {
  3161. const parse = parseFloat(JQuery(this).val());
  3162. JQuery(`#${name}${`-value`}`).text(parse);
  3163. gameOptionSettings[name] = parse;
  3164. if (ogario.hasOwnProperty(name)) {
  3165. ogario[name] = parse;
  3166. }
  3167. app.saveSettings(gameOptionSettings, 'ogarioSettings');
  3168. });
  3169. }
  3170. },
  3171. setLang() {
  3172. if (lang !== 'pl') {
  3173. return;
  3174. }
  3175. if (window.i18n_dict && window.i18n_dict.en) {
  3176. for (var lang in window.i18n_dict.en) {
  3177. if (window.i18n_dict.en.hasOwnProperty(lang) && textLanguage.hasOwnProperty(lang)) {
  3178. window.i18n_dict.en[lang] = textLanguage[lang];
  3179. }
  3180. }
  3181. }
  3182. },
  3183. setMenu() {
  3184. const app = this;
  3185. document.title = this.name;
  3186. JQuery(`#mainPanel`).before(`<div id="exp-bar" class="agario-panel"><span class="ogicon-user"></span><div class="agario-exp-bar progress"><span class="progress-bar-text"></span><div class="progress-bar progress-bar-striped" style="width: 0%;"></div></div><div class="progress-bar-star"></div></div><div id="main-menu" class="agario-panel"><ul class="menu-tabs"><li class="start-tab active"><a href="#main-panel" class="active ogicon-home" data-toggle="tab-tooltip" title="${textLanguage.start}${`"></a></li><li class="profile-tab"><a href="#profile" class="ogicon-user" data-toggle="tab-tooltip" title="`}${textLanguage.profile}${`"></a></li><li class="settings-tab"><a href="#og-settings" class="ogicon-cog" data-toggle="tab-tooltip" title="`}${textLanguage.settings}${`"></a></li><li class="theme-tab"><a href="#theme" class="ogicon-droplet" data-toggle="tab-tooltip" title="`}${textLanguage.theme}${`"></a></li><li class="hotkeys-tab"><a href="#" class="hotkeys-link ogicon-keyboard" data-toggle="tab-tooltip" title="`}${textLanguage.hotkeys}"></a></li><li class="music-tab"><a href="#music" class="ogicon-music" data-toggle="tab-tooltip" title="Radio / ${textLanguage.sounds}"></a></li></ul><div id="main-panel" class="menu-panel"></div><div id="profile" class="menu-panel"></div><div id="og-settings" class="menu-panel"><div class="submenu-panel"></div></div><div id="theme" class="menu-panel"></div><div id="music" class="menu-panel"></div></div>`);
  3187. JQuery('#main-panel').append('<a href="#" class="quick quick-menu ogicon-menu"></a><a href="#" class="quick quick-skins ogicon-images"></a><div id="profiles"><div id="prev-profile" class="skin-switch"></div><div id="skin-preview"></div><div id="next-profile" class="skin-switch"></div></div>');
  3188. JQuery(`#mainPanel div[role=form]`).appendTo(JQuery('#main-panel'));
  3189. JQuery(`#main-panel div[role=form] .form-group:first`).remove();
  3190. JQuery('#nick').before(`<input id="clantag" class="form-control" placeholder="Tag, e.g. â“‚" maxlength="10"><div class="input-group nick"></div>`);
  3191. JQuery(`#nick`).appendTo(JQuery(`.nick`));
  3192. JQuery(`.nick`).append(`<span class="input-group-btn"><button id="stream-mode" class="btn active ogicon-eye"></button></span>`);
  3193. JQuery(`.nick`).after(`<div class="input-group skin"><input id="skin" class="form-control" placeholder="Skin URL (direct link)" maxlength="60"><input type="hidden" id="color" value="` + mainProfile.color + `" maxlength="7" /><span class="input-group-addon"><i></i></span><span class="input-group-btn"><button id="hide-url" class="btn active ogicon-eye"></button></span></div>`);
  3194. JQuery(`#locationKnown, #locationUnknown`).insertAfter(JQuery(`.skin`));
  3195. JQuery(`#region`).before(`<button class="btn btn-warning btn-server-info ogicon-cogs"></button>`);
  3196. JQuery(`.btn-spectate, .btn-logout`).appendTo(`#agario-main-buttons`);
  3197. JQuery(`#agario-main-buttons`).addClass('clearfix').before(`<div id="server-info" class="form-group clearfix"><input id="server-ws" class="form-control" placeholder="Server WS"><button id="server-connect" class="btn btn-success ogicon-power"></button><button id="server-reconnect" class="btn btn-primary ogicon-redo2"></button><input id="server-token" class="form-control" placeholder="Server token"><button id="server-join" class="btn btn-success" data-itr="page_join_party">Join</button></div>`);
  3198. JQuery(`#helloContainer div[role=form]`).after(`<div id="ogario-party" class="clearfix"><input id="party-token" class="form-control" placeholder="Party token"></div>`);
  3199. JQuery(`#ogario-party`).append(`<button id="join-party-btn-2" class="btn btn-success" data-itr="page_join_party">Join</button><button id="create-party-btn-2" class="btn btn-primary" data-itr="page_create_party">Create</button>`);
  3200. JQuery('#pre-join-party-btn:first, #join-party-btn:first, #create-party-btn:first, #leave-party-btn:first, #joinPartyToken:first, .party-icon-back:first').appendTo(JQuery(`#ogario-party`));
  3201. JQuery(`#settingsChoice, #options`).appendTo(JQuery(`#og-settings .submenu-panel`));
  3202. JQuery(`#stats`).appendTo(JQuery(`#main-menu`)).addClass(`menu-panel`);
  3203. JQuery(`#statsContinue`).attr('id', 'statsContinue2');
  3204. JQuery(`#mainPanel`).empty().remove();
  3205. JQuery(`.center-container`).addClass(`ogario-menu`);
  3206. JQuery(`.center-container`).append(`<div id="menu-footer" class="menu-main-color">` + textLanguage.visit + ` <a href="https://ogario.ovh" target="_blank">ogario.ovh</a> | ` + this.version + ` <a href="https://goo.gl/nRREoR" class="release ogicon-info" target="_blank"></a></div>`);
  3207. JQuery(`#leftPanel, #rightPanel`).addClass('ogario-menu').removeAttr('id');
  3208. JQuery(`.agario-profile-panel, .agario-panel-freecoins, .agario-panel-gifting, .agario-shop-panel, #dailyquests-panel`).appendTo(JQuery(`#profile`)).removeClass('agario-side-panel');
  3209. JQuery(`.agario-profile-panel`).after(`<div id="block-warn">` + textLanguage.blockWarn + `<br><a href="#" id="unblock-popups">` + textLanguage.unblockPopups + `</a></div>`);
  3210. JQuery(`#exp-bar`).addClass(`agario-profile-panel`);
  3211. JQuery(`.left-container`).empty();
  3212. JQuery(`.agario-shop-panel`).after(`<div class="agario-panel ogario-yt-panel"><h5 class="menu-main-color">Team OGARio (tag: â“‚)</h5><div class="g-ytsubscribe" data-channelid="UCaWiPNJWnhzYDrBQoXokn6w" data-layout="full" data-theme="dark" data-count="default"></div></div>`);
  3213. JQuery(`#tags-container`).appendTo(JQuery('#profile'));
  3214. JQuery(`.btn-logout`).appendTo(JQuery(`#profile`));
  3215. JQuery(`.left-container`).append(`<div id="quick-menu" class="agario-panel agario-side-panel"><a href="https://ogario.ovh/skins/" class="quick-more-skins ogicon-grin" target="_blank" data-toggle="tab-tooltip" data-placement="left" title="` + textLanguage.skins + `"></a><a href="https://youtube.com/channel/UCaWiPNJWnhzYDrBQoXokn6w" class="quick-yt ogicon-youtube2" target="_blank" data-toggle="tab-tooltip" data-placement="left" title="Team OGARio"></a></div>`);
  3216. if (!this.protocolMode) {
  3217. JQuery(`#quick-menu`).prepend(`${`<a href="#" class="quick-shop ogicon-cart" data-toggle="tab-tooltip" data-placement="left" title="` + textLanguage.page_shop + `"></a><a href="#" class="quick-free-coins ogicon-coin-dollar" data-toggle="tab-tooltip" data-placement="left" title="` + textLanguage.page_menu_main_free_coins + `"></a><a href="#" class="quick-free-gifts ogicon-gift" data-toggle="tab-tooltip" data-placement="left" title="` + textLanguage.page_menu_main_gifts}"></a><a href="#" class="quick-quests ogicon-trophy" data-toggle="tab-tooltip" data-placement="left" title="${textLanguage.page_menu_main_dailyquests}"></a>`);
  3218. }
  3219. JQuery(`.party-dialog, .partymode-info`).remove();
  3220. JQuery(`.agario-party-6`).appendTo(JQuery(`.center-container`));
  3221. JQuery(`.right-container`).empty();
  3222. JQuery(`.right-container`).append(`<div class="agario-party"></div>`);
  3223. JQuery(`.agario-party-6`).appendTo(JQuery(`.agario-party`)).addClass(`agario-panel agario-side-panel`);
  3224. JQuery(`.agario-party h4, #cancel-party-btn`).remove();
  3225. JQuery(`.agario-party .btn`).addClass(`btn-sm`);
  3226. JQuery(`.right-container`).append(`${`<div id="skins-panel" class="agario-panel agario-side-panel"><div id="skins"></div><a href="https://ogario.ovh/skins/" id="more-skins" class="btn btn-block btn-success" target="_blank">` + textLanguage.moreSkins}</a></div>`);
  3227. JQuery(`.btn-settings, .text-muted, .tosBox, .agario-promo, #agario-web-incentive, span[data-itr='page_option_dark_theme'], #options #darkTheme`).remove();
  3228. JQuery('#advertisement, #adbg, #a32592, #g32592, #s32592, #adsBottom').css(`display`, `none`);
  3229. JQuery('#advertisement').removeClass(`agario-panel`);
  3230. JQuery(`#adsBottom`).css({
  3231. 'z-index': '1',
  3232. opacity: '0',
  3233. bottom: `-100px`
  3234. });
  3235. JQuery(`#noNames, #showMass`).remove();
  3236. JQuery(`#og-settings .submenu-panel`).append('<div id="og-options"></div>');
  3237. this.addOptions([], `animationGroup`);
  3238. this.addOptions('autoZoom', `zoomGroup`);
  3239. this.addOptions([`quickResp`, `autoResp`], `respGroup`);
  3240. this.addOptions(['noNames', `optimizedNames`, `autoHideNames`, `hideMyName`, `hideTeammatesNames`, `namesStroke`], `namesGroup`);
  3241. this.addOptions(['showMass', `optimizedMass`, `autoHideMass`, `hideMyMass`, 'hideEnemiesMass', `shortMass`, `virMassShots`, `massStroke`], `massGroup`);
  3242. if (this.protocolMode) {
  3243. this.addOptions('customSkins', `skinsGroup`);
  3244. } else {
  3245. this.addOptions([`customSkins`, 'vanillaSkins'], 'skinsGroup');
  3246. }
  3247. this.addOptions([`optimizedFood`, 'autoHideFood', 'autoHideFoodOnZoom', `rainbowFood`], `foodGroup`);
  3248. this.addOptions([`myCustomColor`, 'myTransparentSkin', `transparentSkins`, 'transparentCells', 'transparentViruses'], `transparencyGroup`);
  3249. this.addOptions([`showGrid`, `showBgSectors`, `showMapBorders`], `gridGroup`);
  3250. this.addOptions([`disableChat`, 'chatSounds', `chatEmoticons`, `showChatImages`, `showChatVideos`, `showChatBox`], `chatGroup`);
  3251. this.addOptions(['showMiniMap', `showMiniMapGrid`, `showMiniMapGuides`, `oneColoredTeammates`], `miniMapGroup`);
  3252. this.addOptions([`oppColors`, `oppRings`, 'virColors', `splitRange`, `virusesRange`, `cursorTracking`, 'teammatesInd'], `helpersGroup`);
  3253. this.addOptions([`mouseSplit`, 'mouseFeed', `mouseInvert`], `mouseGroup`);
  3254. this.addOptions([`showTop5`, 'showTargeting', `showLbData`, 'centeredLb', `normalLb`, `fpsAtTop`], `hudGroup`);
  3255. this.addOptions(['showStats', `showStatsMass`, `showStatsSTE`, 'showStatsN16', `showStatsFPS`, `showTime`], `statsGroup`);
  3256. if (!this.protocolMode) {
  3257. this.addOptions('blockPopups', 'extrasGroup');
  3258. JQuery(`#noSkins, #noColors, #skipStats, #showQuest`).addClass(`js-switch-vanilla`);
  3259. JQuery(`.skinsGroup h5`).after(`<label class="noSkins">${textLanguage.noSkins}${` </label>`}`);
  3260. JQuery(`#noSkins`).appendTo(JQuery(`.noSkins`));
  3261. JQuery(`.transparencyGroup h5`).after(`<label class="noColors">${textLanguage.noColors}${` </label>`}`);
  3262. JQuery('#noColors').appendTo(JQuery('.noColors'));
  3263. JQuery(`.extrasGroup h5`).after(`<label class="skipStats">` + textLanguage.skipStats + ` </label>`);
  3264. JQuery(`#skipStats`).appendTo(JQuery(`.skipStats`));
  3265. JQuery(`.skipStats`).after(`<label class="showQuest">` + textLanguage.showQuest + ` </label>`);
  3266. JQuery('#showQuest').appendTo(JQuery(`.showQuest`));
  3267. JQuery(`#options`).remove();
  3268. JQuery(`#settingsChoice`).appendTo(JQuery(`.extrasGroup`)).addClass(`select-wrapper`);
  3269. }
  3270. this.addSliderBox(`.animationGroup`, `animation`, 100, 200, 1);
  3271. this.addSliderBox(`.zoomGroup`, `zoomSpeedValue`, 0.75, 0.99, 0.01);
  3272. JQuery(`#og-settings`).append(`<button class="btn btn-block btn-success btn-export">` + textLanguage.exportImport + `</button>`);
  3273. JQuery(`#og-settings`).append(`<div class="restore-settings"><a href="#">` + textLanguage.restoreSettings + `</a></div>`);
  3274. JQuery(`#music`).append(`${`<div class="agario-panel radio-panel"><h5 class="menu-main-color">Radio (` + textLanguage.thanks + `)</h5><audio src="http://frshoutcast.comunicazion.eu:8815/;" controls></audio><span class="playlist"><span class="ogicon-file-music"></span> <a href="http://frshoutcast.comunicazion.eu:8815/played.html?sid=1" target="_blank">` + textLanguage.playlist}</a></span></div>`);
  3275. JQuery(`#music`).append(`<div class="agario-panel sounds-panel"><h5 class="menu-main-color">` + textLanguage.sounds + `</h5></div>`);
  3276. JQuery(`#music`).append(`<div class="agario-panel ogario-yt-panel"><h5 class="menu-main-color">Team OGARio (tag: â“‚)</h5><div class="g-ytsubscribe" data-channelid="UCaWiPNJWnhzYDrBQoXokn6w" data-layout="full" data-theme="dark" data-count="default"></div></div>`);
  3277. this.addInputBox(`.sounds-panel`, `messageSound`, 'Sound URL', 'setMessageSound');
  3278. this.addInputBox('.sounds-panel', 'commandSound', `Sound URL`, `setCommandSound`);
  3279. JQuery('body').append(`<div id="overlays-hud" data-gamemode=":ffa"><div id="stats-hud" class="hud stats-hud-color"></div> <div id="top5-hud" class="hud"><h5 class="hud-main-color">Team top <span class="team-top">5</span></h5><div class="hud-main-color team-top-menu"><a href="#" data-limit="5" class="team-top-limit active">5</a> | <a href="#" data-limit="10" class="team-top-limit">10</a> | <a href="#" data-limit="100" class="team-top-limit">100</a></div><ol id="top5-pos"></ol><div id="top5-total"><span class="hud-main-color ogicon-users"></span> ` + textLanguage.totalPartyPlayers + `: <span id="top5-total-players" class="top5-mass-color">0</span><br><span class="hud-main-color ogicon-pacman"></span> ` + textLanguage.totalPartyMass + `: <span id="top5-total-mass" class="top5-mass-color">0</span></div></div> <div id="time-hud" class="hud time-hud-color"></div> <div id="pause-hud" class="hud">` + textLanguage.pause + `</div> <div id="leaderboard-hud" class="hud-b"><h4 class="hud-main-color">ogario.ovh</h4><div id="leaderboard-data"></div><div id="leaderboard-positions"></div></div> <div id="btl-leaderboard-hud"><div class="hud hud-c"><span id="btl-players-status">Players ready</span>: <span id="btl-players-count">0</span></div></div> <div id="minimap-hud" class="hud-b"><canvas id="minimap-sectors"></canvas><canvas id="minimap"></canvas></div><div id="target-hud" class="hud"><div id="target-player"><span id="target-skin"><img src="https://cdn.ogario.ovh/static/img/blank.png" alt=""> </span><span id="target-nick"></span> <span id="target-status" class="hud-main-color">[` + textLanguage.targetNotSet + `]</span></div><div id="target-summary"></div></div><div id="target-panel-hud" class="hud"><a href="#" id="set-targeting" class="ogicon-target"></a><a href="#" id="set-private-minimap" class="ogicon-location2"></a><a href="#" id="cancel-targeting" class="ogicon-cancel-circle"></a><a href="#" id="change-target" class="ogicon-arrow-right"></a></div> <div id="quest-hud" class="hud"></div> <div id="btl-hud" class="hud"></div></div>`);
  3280. JQuery(`body`).append(`<ul id="messages"></ul>`);
  3281. JQuery(`body`).append(`<div id="message-box"><div id="chat-emoticons"></div><div id="message-menu"><a href="#" class="chat-sound-notifications ogicon-volume-high"></a><a href="#" class="chat-active-users ogicon-user-check"></a><a href="#" class="chat-muted-users ogicon-user-minus"></a><a href="#" class="show-chat-emoticons ogicon-smile"></a></div><input type="text" id="message" class="form-control" placeholder="${textLanguage.enterChatMsg}${`..." maxlength="80"></div>`}`);
  3282. JQuery(`body`).append('<div id="chat-box"></div>');
  3283. for (const emoji in emojiChar) {
  3284. if (emojiChar.hasOwnProperty(emoji)) {
  3285. JQuery('#chat-emoticons').append(`<img src="https://cdn.ogario.ovh/static/emoticons/${emojiChar[emoji]}${`" alt="`}${emoji}${`" class="emoticon">`}`);
  3286. }
  3287. }
  3288. JQuery('body').append(`<div id="exp-imp"><div id="exp-imp-menu"><button id="close-exp-imp" class="btn btn-danger">` + textLanguage.close + `</button></div><div id="exp-imp-settings"></div></div>`);
  3289. JQuery(`#exp-imp-settings`).append(`<h1>` + textLanguage.exportSettings + `</h1><h2>` + textLanguage.exportInfo + `</h2>`);
  3290. this.addOption(`#exp-imp-settings`, `export-ogarioCommands`, textLanguage.commands, true);
  3291. this.addOption(`#exp-imp-settings`, `export-ogarioHotkeys`, textLanguage.hotkeys, true);
  3292. this.addOption(`#exp-imp-settings`, 'export-ogarioPlayerProfiles', textLanguage.profiles, true);
  3293. this.addOption('#exp-imp-settings', `export-ogarioSettings`, textLanguage.settings, true);
  3294. this.addOption(`#exp-imp-settings`, `export-ogarioThemeSettings`, textLanguage.theme, true);
  3295. JQuery('#exp-imp-settings').append(`<textarea id="export-settings" class="form-control" rows="14" cols="100" spellcheck="false" readonly /><button id="export-settings-btn" class="btn btn-block btn-success">${textLanguage.exportSettings}${`</button>`}`);
  3296. JQuery(`#exp-imp-settings`).append(`${`<h1>` + textLanguage.importSettings}</h1><h2>${textLanguage.importInfo}${`</h2>`}`);
  3297. this.addOption(`#exp-imp-settings`, `import-ogarioCommands`, textLanguage.commands, true);
  3298. this.addOption(`#exp-imp-settings`, 'import-ogarioHotkeys', textLanguage.hotkeys, true);
  3299. this.addOption(`#exp-imp-settings`, `import-ogarioPlayerProfiles`, textLanguage.profiles, true);
  3300. this.addOption(`#exp-imp-settings`, `import-ogarioSettings`, textLanguage.settings, true);
  3301. this.addOption(`#exp-imp-settings`, `import-ogarioThemeSettings`, textLanguage.theme, true);
  3302. JQuery('#exp-imp-settings').append(`<textarea id="import-settings" class="form-control" rows="14" cols="100" spellcheck="false" /><button id="import-settings-btn" class="btn btn-block btn-success">` + textLanguage.importSettings + `</button>`);
  3303. OgarioSettings && OgarioSettings.setThemeMenu();
  3304. for (let length = 0; length < PlayerProfiles.length; length++) {
  3305. JQuery(`#skins`).append(`${`<div class="skin-box"><a href="#profile-` + length}" id="profile-${length}" data-profile="${length}" class="skin-switch"></a></div>`);
  3306. this.setSkinPreview(PlayerProfiles[length].skinURL, `profile-` + length);
  3307. if (length == this.selectedProfile) {
  3308. JQuery(`#profile-` + length).addClass(`selected`);
  3309. }
  3310. }
  3311. },
  3312. setUI() {
  3313. const app = this;
  3314. JQuery(document).on('click', `.menu-tabs a`, function(event) {
  3315. event.preventDefault();
  3316. app.switchMenuTabs(JQuery(this), `menu-panel`);
  3317. });
  3318. JQuery(document).on('click', `.submenu-tabs a`, function(event) {
  3319. event.preventDefault();
  3320. app.switchMenuTabs(JQuery(this), `submenu-panel`);
  3321. });
  3322. JQuery(document).on(`click`, `.quick-menu`, event => {
  3323. event.preventDefault();
  3324. gameOptionSettings.showQuickMenu = !gameOptionSettings.showQuickMenu;
  3325. app.saveSettings(gameOptionSettings, `ogarioSettings`);
  3326. app.setShowQuickMenu();
  3327. });
  3328. JQuery(document).on(`click`, `.quick-skins`, event => {
  3329. event.preventDefault();
  3330. gameOptionSettings.showSkinsPanel = !gameOptionSettings.showSkinsPanel;
  3331. app.saveSettings(gameOptionSettings, `ogarioSettings`);
  3332. app.setShowSkinsPanel();
  3333. });
  3334. JQuery(document).on(`change`, `#region`, function() {
  3335. app.region = this.value;
  3336. });
  3337. JQuery(document).on(`change`, '#gamemode', function() {
  3338. const value = this.value;
  3339. if (value !== ':party') {
  3340. app.leaveParty();
  3341. }
  3342. app.gameMode = ogario.gameMode = value;
  3343. app.setQuest();
  3344. });
  3345. JQuery(document).on(`change`, `#quality`, function() {
  3346. app.getQuality(this.value);
  3347. menuScale();
  3348. });
  3349. JQuery(`#skin`).popover({
  3350. html: true,
  3351. placement: `bottom`,
  3352. trigger: 'manual',
  3353. animation: false
  3354. });
  3355. JQuery(document).on(`input click`, `#skin`, function() {
  3356. const value = this.value;
  3357. app.setSkinPreview(value, `skin-preview`);
  3358. app.setSkinPreview(value, `profile-` + app.selectedProfile);
  3359. });
  3360. JQuery(document).on(`click`, '.skin .example-url a', function(event) {
  3361. event.preventDefault();
  3362. JQuery(`#skin`).val(this.href).click();
  3363. });
  3364. JQuery(document).on(`click`, `#overlays`, () => {
  3365. if (!JQuery(`.skin:hover`).length && !JQuery('.skin-switch:hover').length) {
  3366. JQuery(`#skin`).popover(`hide`);
  3367. }
  3368. });
  3369. JQuery(document).on(`click`, `#skins a`, function(event) {
  3370. event.preventDefault();
  3371. app.selectProfile(JQuery(this).attr(`data-profile`));
  3372. });
  3373. JQuery(document).on(`click`, '#prev-profile', () => {
  3374. app.prevProfile();
  3375. });
  3376. JQuery(document).on(`click`, `#next-profile`, () => {
  3377. app.nextProfile();
  3378. });
  3379. JQuery(document).on(`click`, `#stream-mode`, () => {
  3380. gameOptionSettings.streamMode = !gameOptionSettings.streamMode;
  3381. app.saveSettings(gameOptionSettings, `ogarioSettings`);
  3382. app.setStreamMode();
  3383. });
  3384. JQuery(document).on('click', `#hide-url`, () => {
  3385. gameOptionSettings.hideSkinUrl = !gameOptionSettings.hideSkinUrl;
  3386. app.saveSettings(gameOptionSettings, `ogarioSettings`);
  3387. app.setHideSkinUrl();
  3388. });
  3389. JQuery(document).on(`click`, `.btn-server-info`, () => {
  3390. JQuery(`#server-info`).toggle();
  3391. });
  3392. JQuery(document).on(`click`, `#server-connect`, () => {
  3393. app.gameServerConnect(JQuery('#server-ws').val());
  3394. });
  3395. JQuery(document).on(`click`, `#server-reconnect`, () => {
  3396. app.gameServerReconnect();
  3397. });
  3398. JQuery(document).on(`click`, `#server-join`, () => {
  3399. app.gameServerJoin(JQuery(`#server-token`).val());
  3400. });
  3401. JQuery(document).on(`change`, `#og-options input[type='checkbox']`, function() {
  3402. const option = JQuery(this);
  3403. app.setSettings(option.attr('id'), option.prop(`checked`));
  3404. });
  3405. JQuery(document).on(`change`, '.js-switch-vanilla', function() {
  3406. const option = JQuery(this);
  3407. const id = option.attr('id');
  3408. if (typeof app[id] !== `undefined`) {
  3409. app[id] = option.prop('checked');
  3410. if (id === `noSkins`) {
  3411. ogario.showCustomSkins = !app.noSkins;
  3412. }
  3413. if (id === `showQuest`) {
  3414. app.setQuest();
  3415. }
  3416. }
  3417. });
  3418. JQuery(document).on(`click`, `#og-settings .restore-settings a`, event => {
  3419. event.preventDefault();
  3420. app.restoreSettings();
  3421. });
  3422. JQuery(document).on(`click`, '#og-settings .btn-export', event => {
  3423. event.preventDefault();
  3424. app.exportSettings();
  3425. JQuery(`#exp-imp`).fadeIn(500);
  3426. JQuery('#exp-imp-settings, #export-settings').perfectScrollbar(`update`);
  3427. });
  3428. JQuery(document).on('click', '#close-exp-imp', event => {
  3429. event.preventDefault();
  3430. JQuery(`#exp-imp`).fadeOut(500);
  3431. });
  3432. JQuery(document).on(`focus`, `#export-settings`, function() {
  3433. JQuery(this).select();
  3434. });
  3435. JQuery(document).on(`click`, `#export-settings-btn`, event => {
  3436. event.preventDefault();
  3437. app.exportSettings();
  3438. });
  3439. JQuery(document).on(`click`, `#import-settings-btn`, event => {
  3440. event.preventDefault();
  3441. app.importSettings();
  3442. });
  3443. JQuery(document).on(`click`, `#unblock-popups`, event => {
  3444. event.preventDefault();
  3445. app.unblockPopups();
  3446. });
  3447. JQuery(document).on(`click`, `#openfl-overlay.disabler`, () => {
  3448. if (gameOptionSettings.blockPopups) {
  3449. app.blockPopups();
  3450. }
  3451. });
  3452. JQuery(document).on(`click`, `#openfl-content`, function() {
  3453. if (gameOptionSettings.blockPopups) {
  3454. const content = JQuery(this);
  3455. setTimeout(() => {
  3456. if (!content.is(`:visible`)) {
  3457. app.blockPopups();
  3458. }
  3459. }, 1000);
  3460. }
  3461. });
  3462. JQuery(document).on(`click`, `.quick-shop`, event => {
  3463. event.preventDefault();
  3464. app.unblockPopups();
  3465. window.MC && window.MC.openShop && window.MC.openShop();
  3466. });
  3467. JQuery(document).on(`click`, `.quick-free-coins`, event => {
  3468. event.preventDefault();
  3469. app.unblockPopups();
  3470. window.MC && window.MC.showFreeCoins && window.MC.showFreeCoins();
  3471. });
  3472. JQuery(document).on(`click`, '.quick-free-gifts', event => {
  3473. event.preventDefault();
  3474. app.unblockPopups();
  3475. window.MC && window.MC.showGifting && window.MC.showGifting();
  3476. });
  3477. JQuery(document).on(`click`, `.quick-quests`, event => {
  3478. event.preventDefault();
  3479. app.unblockPopups();
  3480. window.MC && window.MC.showQuests && window.MC.showQuests();
  3481. });
  3482. JQuery(document).on(`click`, `#set-targeting`, event => {
  3483. event.preventDefault();
  3484. app.setTargeting();
  3485. });
  3486. JQuery(document).on('click', `#cancel-targeting`, event => {
  3487. event.preventDefault();
  3488. app.cancelTargeting();
  3489. });
  3490. JQuery(document).on(`click`, `#set-private-minimap`, event => {
  3491. event.preventDefault();
  3492. app.setPrivateMiniMap();
  3493. });
  3494. JQuery(document).on(`click`, `#change-target`, event => {
  3495. event.preventDefault();
  3496. app.changeTarget();
  3497. });
  3498. JQuery(document).on('click', `.team-top-limit`, function(event) {
  3499. event.preventDefault();
  3500. const top5 = JQuery(this);
  3501. const limit = parseInt(top5.attr('data-limit'));
  3502. if (limit) {
  3503. app.setTop5limit(limit);
  3504. app.displayTop5();
  3505. JQuery(`.team-top`).text(limit);
  3506. JQuery(`.team-top-limit`).removeClass(`active`);
  3507. top5.addClass(`active`);
  3508. }
  3509. });
  3510. JQuery(document).on(`click`, `#top5-pos .set-target`, function(event) {
  3511. event.preventDefault();
  3512. app.setTarget(parseInt(JQuery(this).attr('data-user-id')));
  3513. });
  3514. JQuery(document).on(`click`, `.mute-user`, function(event) {
  3515. event.preventDefault();
  3516. app.muteChatUser(parseInt(JQuery(this).attr(`data-user-id`)));
  3517. });
  3518. JQuery(document).on(`click`, '.btn-mute-user', function() {
  3519. const btn = JQuery(this);
  3520. app.muteChatUser(parseInt(btn.attr(`data-user-id`)));
  3521. btn.removeClass(`btn-red btn-mute-user`).addClass(`btn-green btn-unmute-user`).text(textLanguage.unmute);
  3522. });
  3523. JQuery(document).on(`click`, '.btn-unmute-user', function() {
  3524. const btn = JQuery(this);
  3525. app.unmuteChatUser(parseInt(btn.attr(`data-user-id`)));
  3526. btn.removeClass('btn-green btn-unmute-user').addClass(`btn-red btn-mute-user`).text(textLanguage.mute);
  3527. });
  3528. JQuery(document).on(`click`, '.chat-sound-notifications', event => {
  3529. event.preventDefault();
  3530. gameOptionSettings.chatSounds = !gameOptionSettings.chatSounds;
  3531. app.saveSettings(gameOptionSettings, 'ogarioSettings');
  3532. app.setChatSoundsBtn();
  3533. });
  3534. JQuery(document).on(`click`, '.chat-active-users', event => {
  3535. event.preventDefault();
  3536. app.displayChatActiveUsers();
  3537. });
  3538. JQuery(document).on('click', `.chat-muted-users`, event => {
  3539. event.preventDefault();
  3540. app.displayChatMutedUsers();
  3541. });
  3542. JQuery(document).on(`click`, `.show-chat-emoticons`, function(event) {
  3543. event.preventDefault();
  3544. const option = JQuery(this);
  3545. const chatEmoji = JQuery(`#chat-emoticons`);
  3546. chatEmoji.toggle();
  3547. if (chatEmoji.is(`:visible`)) {
  3548. option.addClass(`active`);
  3549. } else {
  3550. option.removeClass('active');
  3551. JQuery(`#message`).focus();
  3552. }
  3553. });
  3554. JQuery(document).on(`click`, '#chat-emoticons .emoticon', function() {
  3555. const chatEmoji = JQuery(this);
  3556. const alt = chatEmoji.attr(`alt`);
  3557. const message = JQuery(`#message`);
  3558. const value = message.val();
  3559. if (value.length + alt.length <= 80) {
  3560. message.val(value + alt);
  3561. }
  3562. message.focus();
  3563. });
  3564. this.statsHUD = document.getElementById(`stats-hud`);
  3565. this.activeParties = document.getElementById('active-parties');
  3566. this.top5pos = document.getElementById('top5-pos');
  3567. this.top5totalMass = document.getElementById(`top5-total-mass`);
  3568. this.top5totalPlayers = document.getElementById(`top5-total-players`);
  3569. this.leaderboardPositionsHUD = document.getElementById(`leaderboard-positions`);
  3570. this.leaderboardDataHUD = document.getElementById(`leaderboard-data`);
  3571. this.timeHUD = document.getElementById('time-hud');
  3572. this.questHUD = document.getElementById(`quest-hud`);
  3573. JQuery(`#canvas`).bind(`contextmenu`, () => false);
  3574. JQuery(document).on('mouseup', `.btn`, function() {
  3575. $(this).blur();
  3576. });
  3577. JQuery(`[data-toggle='tab-tooltip']`).tooltip({
  3578. trigger: `hover`
  3579. });
  3580. JQuery('.submenu-panel, #chat-box, #exp-imp-settings, #export-settings, #import-settings').perfectScrollbar({
  3581. suppressScrollX: true
  3582. });
  3583. const sliceSwitch = Array.prototype.slice.call(document.querySelectorAll(`.js-switch`));
  3584. sliceSwitch.forEach(event => {
  3585. const switchOption = new Switchery(event, {
  3586. color: gameSetupTheme.menuMainColor,
  3587. size: 'small'
  3588. });
  3589. });
  3590. JQuery('input[type="range"]').rangeslider({
  3591. polyfill: false
  3592. });
  3593. toastr.options = {
  3594. newestOnTop: false,
  3595. positionClass: `toast-bottom-left`,
  3596. timeOut: 15000
  3597. };
  3598. },
  3599. switchMenuTabs(tab, name) {
  3600. const parent = tab.parent();
  3601. if (name === 'menu-panel') {
  3602. if (tab.hasClass(`hotkeys-link`)) {
  3603. return;
  3604. }
  3605. if (parent.hasClass(`profile-tab`)) {
  3606. this.setBlockPopups();
  3607. }
  3608. }
  3609. tab.addClass(`active`);
  3610. parent.addClass(`active`);
  3611. parent.siblings().removeClass(`active`);
  3612. parent.siblings().find('a').removeClass(`active`);
  3613. const href = tab.attr(`href`);
  3614. if (name === 'submenu-panel') {
  3615. const id = JQuery(href).parent().attr('id');
  3616. JQuery(`#${id}${` .submenu-panel`}`).not(href).css(`display`, `none`);
  3617. } else {
  3618. JQuery(`.menu-panel`).not(href).css(`display`, 'none');
  3619. }
  3620. JQuery(href).fadeIn(1000);
  3621. menuScale();
  3622. JQuery(`.submenu-panel`).perfectScrollbar(`update`);
  3623. },
  3624. getDefaultSettings() {
  3625. const app = this;
  3626. this.noSkins = JQuery(`#noSkins`).prop(`checked`);
  3627. this.noColors = JQuery(`#noColors`).prop(`checked`);
  3628. this.skipStats = JQuery(`#skipStats`).prop(`checked`);
  3629. this.showQuest = JQuery(`#showQuest`).prop(`checked`);
  3630. ogario.showCustomSkins = !this.noSkins;
  3631. if (window.localStorage.getItem(`scale_setting`) !== null) {
  3632. const parseScaleSettings = JSON.parse(window.localStorage.getItem(`scale_setting`));
  3633. this.setCanvasScale(parseScaleSettings);
  3634. } else {
  3635. const quality = JQuery('#quality').val();
  3636. this.getQuality(quality);
  3637. }
  3638. if (window.localStorage.getItem('location') !== null) {
  3639. this.region = window.localStorage.getItem(`location`);
  3640. JQuery(`#region`).val(this.region);
  3641. window.MC && window.MC.setRegion && window.MC.setRegion(this.region);
  3642. } else {
  3643. this.region = JQuery(`#region`).val();
  3644. }
  3645. this.setParty();
  3646. if (this.gameMode === `:party` && window.location.hash) {
  3647. JQuery(`#join-party-btn-2`).click();
  3648. }
  3649. const sliceSwitchVanilla = Array.prototype.slice.call(document.querySelectorAll(`.js-switch-vanilla`));
  3650. sliceSwitchVanilla.forEach(event => {
  3651. const SwitchVanillaOption = new Switchery(event, {
  3652. color: gameSetupTheme.menuMainColor,
  3653. size: 'small'
  3654. });
  3655. });
  3656. JQuery(`#nick`).val(mainProfile.nick).blur();
  3657. JQuery('#noNames').prop(`checked`, !gameOptionSettings.noNames);
  3658. JQuery(`#showMass`).prop('checked', gameOptionSettings.showMass);
  3659. this.unlockButtons();
  3660. this.setAutoResp();
  3661. this.setQuest();
  3662. },
  3663. getQuality(value) {
  3664. const ration = `devicePixelRatio` in window;
  3665. let defaultValue = 1;
  3666. if (ration) {
  3667. defaultValue = window.devicePixelRatio;
  3668. }
  3669. switch (value) {
  3670. case `High`:
  3671. this.setCanvasScale(1);
  3672. break;
  3673. case `Medium`:
  3674. this.setCanvasScale(0.9);
  3675. break;
  3676. case `Low`:
  3677. this.setCanvasScale(0.75);
  3678. break;
  3679. case `VeryLow`:
  3680. this.setCanvasScale(0.5);
  3681. break;
  3682. default:
  3683. this.setCanvasScale(defaultValue);
  3684. break;
  3685. }
  3686. },
  3687. setCanvasScale(value) {
  3688. this.canvasScale = value;
  3689. ogario.canvasScale = value;
  3690. },
  3691. setStreamMode() {
  3692. if (gameOptionSettings.streamMode) {
  3693. JQuery(`#stream-mode`).addClass(`ogicon-eye-blocked`);
  3694. JQuery('#clantag, #nick, #party-token').addClass('stream-mode');
  3695. } else {
  3696. JQuery('#stream-mode').removeClass(`ogicon-eye-blocked`);
  3697. JQuery(`#clantag, #nick, #party-token`).removeClass(`stream-mode`);
  3698. }
  3699. },
  3700. setHideSkinUrl() {
  3701. if (gameOptionSettings.hideSkinUrl) {
  3702. JQuery('#hide-url').addClass(`ogicon-eye-blocked`);
  3703. JQuery('#skin').addClass(`hide-url`);
  3704. } else {
  3705. JQuery(`#hide-url`).removeClass(`ogicon-eye-blocked`);
  3706. JQuery(`#skin`).removeClass(`hide-url`);
  3707. }
  3708. },
  3709. setShowQuickMenu() {
  3710. if (gameOptionSettings.showQuickMenu) {
  3711. JQuery(`#quick-menu`).fadeIn(500);
  3712. } else {
  3713. JQuery('#quick-menu').fadeOut(500);
  3714. }
  3715. },
  3716. setShowSkinsPanel() {
  3717. if (gameOptionSettings.showSkinsPanel) {
  3718. JQuery(`#skins-panel`).fadeIn(500);
  3719. } else {
  3720. JQuery(`#skins-panel`).fadeOut(500);
  3721. }
  3722. },
  3723. unlockButtons() {
  3724. JQuery(`.btn-play, .btn-play-guest, .btn-login-play, .btn-spectate`).prop(`disabled`, false);
  3725. },
  3726. setMainButtons() {
  3727. const app = this;
  3728. JQuery(document).on(`click`, `.btn-play, .btn-play-guest`, () => {
  3729. app.onPlay();
  3730. });
  3731. JQuery(document).on('click', `.btn-spectate`, () => {
  3732. app.onSpectate();
  3733. });
  3734. JQuery(document).on(`click`, `#create-party-btn-2`, () => {
  3735. app.onCreate();
  3736. });
  3737. JQuery(document).on(`click`, `#join-party-btn-2`, () => {
  3738. app.skipServerData = true;
  3739. app.joinParty();
  3740. app.onJoin();
  3741. });
  3742. JQuery(document).on('click', `#statsContinue2`, () => {
  3743. JQuery(`#stats, #main-panel`).toggle();
  3744. });
  3745. },
  3746. play() {
  3747. this.setPlayerSettings();
  3748. this.setParty();
  3749. if (this.isSocketOpen()) {
  3750. this.sendPartyData();
  3751. } else {
  3752. this.connect();
  3753. const app = this;
  3754. setTimeout(() => {
  3755. app.sendPartyData();
  3756. }, 1000);
  3757. }
  3758. },
  3759. onPlay() {
  3760. this.play();
  3761. this.hideMenu();
  3762. window.addKeyListeners && window.addKeyListeners();
  3763. if (gameOptionSettings.autoHideFood) {
  3764. ogario.showFood = true;
  3765. }
  3766. window.ga && window.ga(`create`, `UA-67142685-2`, `auto`, `ogarioTracker`);
  3767. window.ga && window.ga(`ogarioTracker.send`, `pageview`);
  3768. },
  3769. onSpectate() {
  3770. this.onJoin();
  3771. this.sendPlayerJoin();
  3772. this.hideMenu();
  3773. window.addKeyListeners && window.addKeyListeners();
  3774. if (gameOptionSettings.autoHideFood) {
  3775. ogario.showFood = false;
  3776. }
  3777. },
  3778. join() {
  3779. this.setParty();
  3780. this.setPlayerSettings();
  3781. this.sendPartyData();
  3782. this.sendPlayerDeath();
  3783. },
  3784. onJoin() {
  3785. this.setParty();
  3786. if (this.isSocketOpen()) {
  3787. this.join();
  3788. } else {
  3789. this.connect();
  3790. const app = this;
  3791. setTimeout(() => {
  3792. app.join();
  3793. app.sendPlayerJoin();
  3794. }, 1000);
  3795. }
  3796. },
  3797. create() {
  3798. this.setParty();
  3799. if (this.partyToken) {
  3800. this.onJoin();
  3801. return;
  3802. }
  3803. const app = this;
  3804. setTimeout(() => {
  3805. app.create();
  3806. }, 100);
  3807. },
  3808. onCreate() {
  3809. this.setParty();
  3810. if (this.gameMode !== ':party' || !this.partyToken) {
  3811. this.createParty();
  3812. } else {
  3813. this.gameServerReconnect();
  3814. }
  3815. this.create();
  3816. },
  3817. onPlayerSpawn() {
  3818. ogario.play = true;
  3819. if (ogario.playerColor) {
  3820. this.sendPlayerSpawn();
  3821. this.cacheCustomSkin(mainProfile.nick, ogario.playerColor, mainProfile.skinURL);
  3822. return;
  3823. }
  3824. const app = this;
  3825. setTimeout(() => {
  3826. app.onPlayerSpawn();
  3827. }, 100);
  3828. },
  3829. onPlayerDeath() {
  3830. ogario.play = false;
  3831. ogario.playerColor = null;
  3832. ogario.foodIsHidden = false;
  3833. ogario.playerMass = 0;
  3834. ogario.playerScore = 0;
  3835. ogario.playerSplitCells = 0;
  3836. this.showMenu(300);
  3837. this.sendPlayerDeath();
  3838. this.updateDeathLocations(ogario.playerX, ogario.playerY);
  3839. this.unlockButtons();
  3840. resetonkeydown();
  3841. this.autoResp();
  3842. },
  3843. setPlayerSettings() {
  3844. const nick = JQuery(`#nick`).val();
  3845. const tag = JQuery(`#clantag`).val();
  3846. const skin = JQuery(`#skin`).val();
  3847. const color = JQuery(`#color`).val();
  3848. mainProfile.nick = nick;
  3849. mainProfile.clanTag = tag.trim();
  3850. mainProfile.skinURL = this.checkSkinURL(skin.trim());
  3851. if (color.length == 7) {
  3852. mainProfile.color = color;
  3853. }
  3854. if (mainProfile.clanTag.length > 0) {
  3855. ogario.clanTag = mainProfile.clanTag;
  3856. }
  3857. PlayerProfiles[this.selectedProfile].nick = mainProfile.nick;
  3858. PlayerProfiles[this.selectedProfile].clanTag = mainProfile.clanTag;
  3859. PlayerProfiles[this.selectedProfile].skinURL = mainProfile.skinURL;
  3860. PlayerProfiles[this.selectedProfile].color = mainProfile.color;
  3861. this.saveSettings(PlayerProfiles, `ogarioPlayerProfiles`);
  3862. },
  3863. loadSkin(img, url) {
  3864. const app = this;
  3865. img[url] = new Image();
  3866. img[url].crossOrigin = `Anonymous`;
  3867. img[url].onload = function() {
  3868. if (this.complete && this.width && this.height && this.width <= 2000 && this.height <= 2000) {
  3869. app.cacheQueue.push(url);
  3870. if (app.cacheQueue.length == 1) {
  3871. app.cacheSkin(app.customSkinsCache);
  3872. }
  3873. }
  3874. };
  3875. img[url].src = url;
  3876. },
  3877. cacheSkin(skinCache) {
  3878. if (this.cacheQueue.length == 0) {
  3879. return;
  3880. }
  3881. const shift = this.cacheQueue.shift();
  3882. if (shift) {
  3883. let canvas = document.createElement(`canvas`);
  3884. canvas.width = 512;
  3885. canvas.height = 512;
  3886. const ctx = canvas.getContext('2d');
  3887. ctx.beginPath();
  3888. ctx.arc(256, 256, 256, 0, 2 * Math.PI, false);
  3889. ctx.clip();
  3890. ctx.drawImage(this.customSkinsCache[shift], 0, 0, 512, 512);
  3891. this.customSkinsCache[shift + `_cached`] = new Image();
  3892. this.customSkinsCache[shift + `_cached`].src = canvas.toDataURL();
  3893. canvas = null;
  3894. this.cacheSkin(this.customSkinsCache);
  3895. }
  3896. },
  3897. getCachedSkin(skinCache, skinMap) {
  3898. if (skinCache[skinMap + `_cached`] && skinCache[skinMap + `_cached`].complete && skinCache[skinMap + `_cached`].width) {
  3899. return skinCache[`${skinMap}_cached`];
  3900. }
  3901. return null;
  3902. },
  3903. cacheCustomSkin(nick, color, skinUrl) {
  3904. if (skinUrl) {
  3905. const gamemode = this.gameMode === `:party` ? nick + color : nick;
  3906. if (gamemode) {
  3907. this.customSkinsMap[gamemode] = skinUrl;
  3908. }
  3909. if (this.customSkinsCache.hasOwnProperty(skinUrl)) {
  3910. return;
  3911. }
  3912. this.loadSkin(this.customSkinsCache, skinUrl);
  3913. }
  3914. },
  3915. checkSkinsMap(nick, color) {
  3916. const skinName = this.gameMode === `:party` ? nick + color : nick;
  3917. if (this.customSkinsMap.hasOwnProperty(skinName)) {
  3918. return true;
  3919. }
  3920. return false;
  3921. },
  3922. getCustomSkin(nick, color) {
  3923. if (!this.checkSkinsMap(nick, color)) {
  3924. return null;
  3925. }
  3926. const skinName = this.gameMode === ':party' ? nick + color : nick;
  3927. return this.getCachedSkin(this.customSkinsCache, this.customSkinsMap[skinName]);
  3928. },
  3929. calculateMapSector(x, y, resize = false) {
  3930. if (!ogario.mapOffsetFixed) {
  3931. return '';
  3932. }
  3933. const offsetX = resize ? ogario.mapOffsetX + ogario.mapOffset : ogario.mapOffset;
  3934. const offsetY = resize ? ogario.mapOffsetY + ogario.mapOffset : ogario.mapOffset;
  3935. let resizeX = Math.floor((y + offsetY) / (ogario.mapSize / gameSetupTheme.sectorsY));
  3936. let resizeY = Math.floor((x + offsetX) / (ogario.mapSize / gameSetupTheme.sectorsX));
  3937. resizeX = resizeX < 0 ? 0 : resizeX >= gameSetupTheme.sectorsY ? gameSetupTheme.sectorsY - 1 : resizeX;
  3938. resizeY = resizeY < 0 ? 0 : resizeY >= gameSetupTheme.sectorsX ? gameSetupTheme.sectorsX - 1 : resizeY;
  3939. return String.fromCharCode(resizeX + 65) + (resizeY + 1);
  3940. },
  3941. shortMassFormat(value) {
  3942. return value < 1000 ? value : `${Math.round(value / 100) / 10}k`;
  3943. },
  3944. updateDeathLocations(x, y) {
  3945. if (!ogario.mapOffsetFixed) {
  3946. return;
  3947. }
  3948. this.deathLocations.push({
  3949. x: x + ogario.mapOffsetX,
  3950. y: y + ogario.mapOffsetY
  3951. });
  3952. if (this.deathLocations.length == 6) {
  3953. this.deathLocations.shift();
  3954. }
  3955. this.lastDeath = this.deathLocations.length - 1;
  3956. },
  3957. drawMiniMap() {
  3958. if (!ogario.mapOffsetFixed) {
  3959. return;
  3960. }
  3961. const mapWidth = gameSetupTheme.miniMapWidth;
  3962. const mapTop = gameSetupTheme.miniMapTop;
  3963. const height = mapWidth + mapTop;
  3964. const width = mapWidth - 18;
  3965. const scale = mapTop + 9.5;
  3966. if (!this.miniMap) {
  3967. this.miniMap = document.getElementById(`minimap`);
  3968. this.miniMapCtx = this.miniMap.getContext('2d');
  3969. this.miniMapCtx.ogarioCtx = true;
  3970. this.miniMap.width = mapWidth;
  3971. this.miniMap.height = height;
  3972. } else {
  3973. this.miniMapCtx.clearRect(0, 0, mapWidth, height);
  3974. }
  3975. if (this.miniMap.width != mapWidth) {
  3976. this.miniMap.width = mapWidth;
  3977. this.miniMap.height = height;
  3978. }
  3979. const newSize = width / ogario.mapSize;
  3980. const resizeoffX = ogario.mapOffsetX + ogario.mapOffset;
  3981. const resizeoffY = ogario.mapOffsetY + ogario.mapOffset;
  3982. this.drawSelectedCell(this.miniMapCtx);
  3983. this.currentSector = this.calculateMapSector(ogario.playerX, ogario.playerY, true);
  3984. this.miniMapCtx.globalAlpha = 1;
  3985. this.miniMapCtx.font = `${gameSetupTheme.miniMapFontWeight} ${mapTop - 4}px ${gameSetupTheme.miniMapFontFamily}`;
  3986. this.miniMapCtx.fillStyle = gameSetupTheme.miniMapSectorColor;
  3987. this.miniMapCtx.fillText(this.currentSector, 10, mapTop);
  3988. if (!this.miniMapSectors) {
  3989. this.drawMiniMapSectors(gameSetupTheme.sectorsX, gameSetupTheme.sectorsY, width, height, scale);
  3990. }
  3991. this.miniMapCtx.save();
  3992. this.miniMapCtx.translate(9.5, scale);
  3993. if (this.gameMode === `:battleroyale`) {
  3994. drawRender && drawRender.drawBattleAreaOnMinimap(this.miniMapCtx, width, width, newSize, resizeoffX, resizeoffY);
  3995. }
  3996. if (gameOptionSettings.showMiniMapGuides) {
  3997. var roundX = Math.round((ogario.playerX + resizeoffX) * newSize);
  3998. var roundY = Math.round((ogario.playerY + resizeoffY) * newSize);
  3999. this.miniMapCtx.lineWidth = 1;
  4000. this.miniMapCtx.strokeStyle = gameSetupTheme.miniMapGuidesColor;
  4001. this.miniMapCtx.beginPath();
  4002. this.miniMapCtx.moveTo(roundX, 0);
  4003. this.miniMapCtx.lineTo(roundX, width - 1);
  4004. this.miniMapCtx.moveTo(0, roundY);
  4005. this.miniMapCtx.lineTo(width - 1, roundY);
  4006. this.miniMapCtx.stroke();
  4007. }
  4008. this.miniMapCtx.beginPath();
  4009. this.miniMapCtx.arc((ogario.playerX + resizeoffX) * newSize, (ogario.playerY + resizeoffY) * newSize, gameSetupTheme.miniMapMyCellSize, 0, this.pi2, false);
  4010. this.miniMapCtx.closePath();
  4011. if (gameSetupTheme.miniMapMyCellStrokeSize > 0) {
  4012. this.miniMapCtx.lineWidth = gameSetupTheme.miniMapMyCellStrokeSize;
  4013. this.miniMapCtx.strokeStyle = gameSetupTheme.miniMapMyCellStrokeColor;
  4014. this.miniMapCtx.stroke();
  4015. }
  4016. this.miniMapCtx.fillStyle = gameSetupTheme.miniMapMyCellColor;
  4017. this.miniMapCtx.fill();
  4018. if (this.teamPlayers.length) {
  4019. for (let length = 0; length < this.teamPlayers.length; length++) {
  4020. this.teamPlayers[length].drawPosition(this.miniMapCtx, ogario.mapOffset, newSize, this.privateMiniMap, this.targetID);
  4021. }
  4022. }
  4023. if (this.deathLocations.length > 0) {
  4024. var roundX = Math.round((this.deathLocations[this.lastDeath].x + ogario.mapOffset) * newSize);
  4025. var roundY = Math.round((this.deathLocations[this.lastDeath].y + ogario.mapOffset) * newSize);
  4026. const mySize = Math.max(gameSetupTheme.miniMapMyCellSize - 2, 4);
  4027. this.miniMapCtx.lineWidth = 1;
  4028. this.miniMapCtx.strokeStyle = this.deathLocations.length - 1 == this.lastDeath ? gameSetupTheme.miniMapDeathLocationColor : '#FFFFFF';
  4029. this.miniMapCtx.beginPath();
  4030. this.miniMapCtx.moveTo(roundX - mySize, roundY);
  4031. this.miniMapCtx.lineTo(roundX + mySize, roundY);
  4032. this.miniMapCtx.moveTo(roundX, roundY - mySize);
  4033. this.miniMapCtx.lineTo(roundX, roundY + mySize);
  4034. this.miniMapCtx.stroke();
  4035. }
  4036. this.miniMapCtx.restore();
  4037. },
  4038. drawMiniMapSectors(x, y, size, height, scale) {
  4039. this.miniMapSectors = document.getElementById(`minimap-sectors`);
  4040. const ctx = this.miniMapSectors.getContext('2d');
  4041. ctx.ogarioCtx = true;
  4042. this.miniMapSectors.width = size;
  4043. this.miniMapSectors.height = height;
  4044. ctx.fillStyle = `#FFFFFF`;
  4045. this.dTok(ctx, size - 1);
  4046. drawRender.drawSectors(ctx, ogario.mapOffsetFixed, x, y, 0.5, scale, size - 0.5, height - 9.5, gameSetupTheme.miniMapSectorsColor, gameSetupTheme.miniMapSectorsColor, 1, false);
  4047. },
  4048. resetMiniMapSectors() {
  4049. this.miniMapSectors = null;
  4050. },
  4051. drawSelectedCell(ctx) {
  4052. if (ogario.play && ogario.playerSplitCells > 1 && (gameOptionSettings.splitRange || gameOptionSettings.oppColors || gameOptionSettings.oppRings || gameOptionSettings.showStatsSTE)) {
  4053. ctx.fillStyle = `#FFFFFF`;
  4054. ctx.globalAlpha = this.selectBiggestCell ? 0.6 : 0.3;
  4055. ctx.beginPath();
  4056. ctx.arc(48, 15, 6, 0, this.pi2, false);
  4057. ctx.closePath();
  4058. ctx.fill();
  4059. ctx.globalAlpha = this.selectBiggestCell ? 0.3 : 0.6;
  4060. ctx.beginPath();
  4061. ctx.arc(60, 15, 4, 0, this.pi2, false);
  4062. ctx.closePath();
  4063. ctx.fill();
  4064. }
  4065. },
  4066. dTok(ctx, size) {
  4067. ctx.font = `${gameSetupTheme.miniMapFontWeight} ${gameSetupTheme.miniMapTop - 6}${`px `}${gameSetupTheme.miniMapFontFamily}`;
  4068. ctx.textAlign = `right`;
  4069. ctx.textBaseline = `top`;
  4070. ctx.fillText(atob(this.token), size, 7);
  4071. },
  4072. setVirusColor(size) {
  4073. const floor = Math.floor(size * size / 100);
  4074. if (floor > 183) {
  4075. return `#C80000`;
  4076. }
  4077. return gameSetupTheme.virusColor;
  4078. },
  4079. setVirusStrokeColor(size) {
  4080. if (ogario.play && ogario.playerMaxMass != 0) {
  4081. const floor = Math.floor(size * size / 100);
  4082. const biggestCell = floor / (this.selectBiggestCell ? ogario.playerMaxMass : ogario.playerMinMass);
  4083. if (biggestCell > 0.76) {
  4084. return `#FFDC00`;
  4085. }
  4086. return `#C80000`;
  4087. }
  4088. return gameSetupTheme.virusStrokeColor;
  4089. },
  4090. setAutoHideCellInfo(size) {
  4091. if (size <= 40 || ogario.viewScale < 0.5 && size < 550 && size < 25 / ogario.viewScale) {
  4092. return true;
  4093. }
  4094. return false;
  4095. },
  4096. setParty() {
  4097. let value = JQuery('#party-token').val();
  4098. this.gameMode = ogario.gameMode = JQuery(`#gamemode`).val();
  4099. this.setQuest();
  4100. if (this.gameMode !== ':party' || !value) {
  4101. return;
  4102. }
  4103. let newValue = value;
  4104. if (value.indexOf('#') != -1) {
  4105. value = value.split('#');
  4106. newValue = value[1];
  4107. }
  4108. if (this.partyToken !== newValue) {
  4109. this.partyToken = newValue;
  4110. this.flushSkinsMap();
  4111. this.flushChatData();
  4112. this.cancelTargeting();
  4113. }
  4114. },
  4115. createParty() {
  4116. JQuery('#create-party-btn').click();
  4117. },
  4118. joinParty() {
  4119. const value = JQuery(`#party-token`).val();
  4120. if (!value) {
  4121. return;
  4122. }
  4123. JQuery(`#pre-join-party-btn`).click();
  4124. JQuery(`.party-token`).val(value);
  4125. JQuery('#join-party-btn').click();
  4126. },
  4127. leaveParty() {
  4128. JQuery(`#party-token, .party-token`).val('');
  4129. JQuery(`#leave-party-btn`).click();
  4130. },
  4131. closeParty() {
  4132. JQuery(`#party-token, .party-token`).val('');
  4133. JQuery('.party-icon-back').click();
  4134. },
  4135. flushData() {
  4136. this.flushPartyData();
  4137. this.flushSkinsMap();
  4138. this.flushChatData();
  4139. this.cancelTargeting();
  4140. ogario.play = false;
  4141. ogario.playerColor = null;
  4142. },
  4143. flushPartyData() {
  4144. this.teamPlayers = [];
  4145. this.parties = [];
  4146. this.lastSentNick = '';
  4147. this.lastSentClanTag = null;
  4148. this.lastSentSkinURL = '';
  4149. this.lastSentCustomColor = '';
  4150. this.lastSentPartyToken = '';
  4151. this.lastSentServerToken = '';
  4152. },
  4153. flushCells() {
  4154. this.cells = {};
  4155. },
  4156. flushSkinsMap() {
  4157. this.customSkinsMap = {};
  4158. },
  4159. flushChatData() {
  4160. this.chatUsers = {};
  4161. },
  4162. getWS(ws) {
  4163. if (!ws) {
  4164. return;
  4165. }
  4166. this.ws = ws;
  4167. this.createServerToken();
  4168. this.updateServerInfo();
  4169. if (this.ws.indexOf(`agar.io`) == -1) {
  4170. this.closeConnection();
  4171. }
  4172. },
  4173. recreateWS(token) {
  4174. if (!token) {
  4175. return null;
  4176. }
  4177. let text = null;
  4178. if (/^[a-zA-Z0-9=+/]{12,}$/ .test(token)) {
  4179. const atobToken = atob(token);
  4180. if (/[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}:[0-9]{1,4}/ .test(atobToken)) {
  4181. text = `wss://ip-${atobToken.replace(/./g, '-').replace(':', `.tech.agar.io:`)}`;
  4182. }
  4183. }
  4184. if (!text && /^[a-z0-9]{5,}$/ .test(token)) {
  4185. text = `wss://live-arena-` + token + `.agar.io:443`;
  4186. }
  4187. return text;
  4188. },
  4189. createServerToken() {
  4190. console.log(this.ws)
  4191. let matchOld = this.ws.match(/ip-d+/);
  4192. const matchNew = this.ws.match(/live-arena-([\w\d]+)/);
  4193. let text = null;
  4194. if (matchOld) {
  4195. const replace = this.ws.replace(`.tech.agar.io`, '').replace(/-/g, '.');
  4196. matchOld = replace.match(/[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}:[0-9]{1,4}/);
  4197. if (matchOld) {
  4198. this.serverIP = matchOld[0];
  4199. text = btoa(this.serverIP);
  4200. }
  4201. }
  4202. if (!text && matchNew) {
  4203. this.serverArena = matchNew[1];
  4204. text = this.serverArena;
  4205. }
  4206. if (text) {
  4207. if (this.serverToken !== text) {
  4208. this.serverToken = text;
  4209. this.flushData();
  4210. this.flushCells();
  4211. }
  4212. this.partyToken = '';
  4213. const matchPartyId = this.ws.match(/party_id=([A-Z0-9]{6})/);
  4214. if (matchPartyId) {
  4215. this.partyToken = matchPartyId[1];
  4216. changeUrl(`/#${window.encodeURIComponent(this.partyToken)}`);
  4217. }
  4218. }
  4219. },
  4220. updateServerInfo() {
  4221. JQuery(`#server-ws`).val(this.ws);
  4222. JQuery(`#server-token`).val(this.serverToken);
  4223. JQuery(`#party-token, .party-token`).val(this.partyToken);
  4224. },
  4225. gameServerConnect(ws) {
  4226. if (!ws) {
  4227. return;
  4228. }
  4229. this.skipServerData = true;
  4230. window.core && window.core.connect && window.core.connect(ws);
  4231. },
  4232. gameServerReconnect() {
  4233. if (window.MC && window.MC.reconnect) {
  4234. window.MC.reconnect();
  4235. return;
  4236. }
  4237. window.master && window.master.reconnect && window.master.reconnect();
  4238. },
  4239. gameServerJoin(token) {
  4240. const ws = this.recreateWS(token);
  4241. if (ws) {
  4242. this.skipServerData = true;
  4243. this.gameServerConnect(ws);
  4244. }
  4245. },
  4246. connect() {
  4247. this.closeConnection();
  4248. this.flushData();
  4249. this.setParty();
  4250. console.log(`[OGARio by szymy] Connecting to server`);
  4251. if (this.privateMode && this.privateIP) {
  4252. this.socket = new WebSocket(this.privateIP);
  4253. } else {
  4254. this.socket = new WebSocket(this.publicIP);
  4255. }
  4256. this.socket.ogarioWS = true;
  4257. this.socket.binaryType = 'arraybuffer';
  4258. const app = this;
  4259. this.socket.onopen = () => {
  4260. console.log('[OGARio by szymy] Socket open');
  4261. const buf = app.createView(3);
  4262. buf.setUint8(0, 0);
  4263. buf.setUint16(1, 401, true);
  4264. app.sendBuffer(buf);
  4265. app.sendPartyData();
  4266. };
  4267. this.socket.onmessage = message => {
  4268. app.handleMessage(message);
  4269. };
  4270. this.socket.onclose = close => {
  4271. app.flushData();
  4272. console.log('[OGARio by szymy] Socket close', close);
  4273. };
  4274. this.socket.onerror = error => {
  4275. app.flushData();
  4276. console.log(`[OGARio by szymy] Socket error`, error);
  4277. };
  4278. },
  4279. closeConnection() {
  4280. if (this.socket) {
  4281. this.socket.onmessage = null;
  4282. try {
  4283. this.socket.close();
  4284. } catch (error) {}
  4285. this.socket = null;
  4286. }
  4287. },
  4288. reconnect() {
  4289. this.setParty();
  4290. const app = this;
  4291. setTimeout(() => {
  4292. app.connect();
  4293. }, 1000);
  4294. },
  4295. switchServerMode() {
  4296. if (!this.privateIP) {
  4297. return;
  4298. }
  4299. this.privateMode = !this.privateMode;
  4300. if (this.isSocketOpen()) {
  4301. this.closeConnection();
  4302. toastr.error(`Zamknięto połączenie z serwerem!`);
  4303. }
  4304. if (this.privateMode) {
  4305. toastr.info(`Przełączono na serwer prywatny!`);
  4306. JQuery(`.party-panel`).show();
  4307. } else {
  4308. toastr.info(`Przełączono na serwer publiczny!`);
  4309. JQuery(`#active-parties`).empty();
  4310. JQuery(`.party-panel`).hide();
  4311. }
  4312. this.onJoin();
  4313. if (ogario.play) {
  4314. this.onPlayerSpawn();
  4315. }
  4316. },
  4317. isSocketOpen() {
  4318. return this.socket !== null && this.socket.readyState === this.socket.OPEN;
  4319. },
  4320. createView(value) {
  4321. return new DataView(new ArrayBuffer(value));
  4322. },
  4323. strToBuff(offset, str) {
  4324. const view = this.createView(1 + str.length * 2);
  4325. view.setUint8(0, offset);
  4326. for (let length = 0; length < str.length; length++) {
  4327. view.setUint16(1 + length * 2, str.charCodeAt(length), true);
  4328. }
  4329. return view;
  4330. },
  4331. sendBuffer(value) {
  4332. this.socket.send(value.buffer);
  4333. },
  4334. handleMessage(message) {
  4335. this.readMessage(new DataView(message.data));
  4336. },
  4337. readMessage(message) {
  4338. switch (message.getUint8(0)) {
  4339. case 0:
  4340. this.playerID = message.getUint32(1, true);
  4341. break;
  4342. case 1:
  4343. this.sendPlayerUpdate();
  4344. break;
  4345. case 20:
  4346. this.updateTeamPlayer(message);
  4347. break;
  4348. case 30:
  4349. this.updateTeamPlayerPosition(message);
  4350. break;
  4351. case 96:
  4352. //break;
  4353. this.updateParties(message);
  4354. this.displayParties();
  4355. break;
  4356. case 100:
  4357. this.readChatMessage(message);
  4358. break;
  4359. }
  4360. },
  4361. sendPlayerState(state) {
  4362. if (this.isSocketOpen()) {
  4363. const view = this.createView(1);
  4364. view.setUint8(0, state);
  4365. this.sendBuffer(view);
  4366. }
  4367. },
  4368. sendPlayerSpawn() {
  4369. this.sendPlayerState(1);
  4370. },
  4371. sendPlayerDeath() {
  4372. this.sendPlayerState(2);
  4373. },
  4374. sendPlayerJoin() {
  4375. this.sendPlayerState(3);
  4376. },
  4377. sendPlayerData(offset, name, str) {
  4378. if (this[name] !== null && this[name] === str) {
  4379. return;
  4380. }
  4381. if (this.isSocketOpen()) {
  4382. this.sendBuffer(this.strToBuff(offset, str));
  4383. this[name] = str;
  4384. }
  4385. },
  4386. sendPlayerNick() {
  4387. this.sendPlayerData(10, `lastSentNick`, mainProfile.nick);
  4388. },
  4389. sendPlayerClanTag() {
  4390. this.sendPlayerData(11, `lastSentClanTag`, mainProfile.clanTag);
  4391. },
  4392. sendPlayerSkinURL() {
  4393. this.sendPlayerData(12, `lastSentSkinURL`, mainProfile.skinURL);
  4394. },
  4395. sendPlayerCustomColor() {
  4396. this.sendPlayerData(13, `lastSentCustomColor`, mainProfile.color);
  4397. },
  4398. sendPlayerColor() {
  4399. if (this.isSocketOpen() && ogario.playerColor) {
  4400. this.sendBuffer(this.strToBuff(14, ogario.playerColor));
  4401. }
  4402. },
  4403. sendPartyToken() {
  4404. this.setParty();
  4405. this.sendPlayerData(15, `lastSentPartyToken`, this.partyToken);
  4406. },
  4407. sendServerToken() {
  4408. this.sendPlayerData(16, 'lastSentServerToken', this.serverToken);
  4409. },
  4410. sendServerJoin() {
  4411. this.sendServerToken();
  4412. this.sendPlayerJoin();
  4413. },
  4414. sendServerRegion() {
  4415. if (!this.region) {
  4416. return;
  4417. }
  4418. const region = this.region.split('-');
  4419. if (this.isSocketOpen()) {
  4420. this.sendBuffer(this.strToBuff(17, region[0]));
  4421. }
  4422. },
  4423. sendServerGameMode() {
  4424. let gamemode = `FFA`;
  4425. switch (this.gameMode) {
  4426. case `:battleroyale`:
  4427. gamemode = `BTR`;
  4428. break;
  4429. case `:teams`:
  4430. gamemode = `TMS`;
  4431. break;
  4432. case `:experimental`:
  4433. gamemode = `EXP`;
  4434. break;
  4435. case `:party`:
  4436. gamemode = `PTY`;
  4437. break;
  4438. }
  4439. if (this.isSocketOpen()) {
  4440. this.sendBuffer(this.strToBuff(18, gamemode));
  4441. }
  4442. },
  4443. sendServerData() {
  4444. if (this.skipServerData) {
  4445. this.skipServerData = false;
  4446. return;
  4447. }
  4448. this.region = JQuery('#region').val();
  4449. this.gameMode = JQuery('#gamemode').val();
  4450. this.sendServerRegion();
  4451. this.sendServerGameMode();
  4452. },
  4453. sendPartyData() {
  4454. this.sendPlayerClanTag();
  4455. this.sendPartyToken();
  4456. this.sendServerToken();
  4457. this.sendPlayerNick();
  4458. },
  4459. sendPlayerUpdate() {
  4460. if (this.isSocketOpen() && ogario.play && this.playerID && ogario.playerColor) {
  4461. function encode(str) {
  4462. for (let length = 0; length < str.length; length++) {
  4463. view.setUint16(offset, str.charCodeAt(length), true);
  4464. offset += 2;
  4465. }
  4466. view.setUint16(offset, 0, true);
  4467. offset += 2;
  4468. }
  4469. let text = 41;
  4470. text += mainProfile.nick.length * 2;
  4471. text += mainProfile.skinURL.length * 2;
  4472. if(isNaN(text)) return;
  4473. var view = this.createView(text);
  4474. view.setUint8(0, 20);
  4475. view.setUint32(1, this.playerID, true);
  4476. var offset = 5;
  4477. encode(mainProfile.nick);
  4478. encode(mainProfile.skinURL);
  4479. encode(mainProfile.color);
  4480. encode(ogario.playerColor);
  4481. this.sendBuffer(view);
  4482. }
  4483. },
  4484. sendPlayerPosition() {
  4485. if (this.isSocketOpen() && ogario.play && this.playerID) {
  4486. const view = this.createView(17);
  4487. view.setUint8(0, 30);
  4488. view.setUint32(1, this.playerID, true);
  4489. view.setInt32(5, this.getPlayerX(), true);
  4490. view.setInt32(9, this.getPlayerY(), true);
  4491. if (typeof ogario.playerMass !== `undefined`) {
  4492. view.setUint32(13, ogario.playerMass, true);
  4493. } else {
  4494. view.setUint32(13, this.playerMass, true);
  4495. }
  4496. this.sendBuffer(view);
  4497. }
  4498. },
  4499. checkPlayerID(id) {
  4500. if (id) {
  4501. for (let length = 0; length < this.teamPlayers.length; length++) {
  4502. if (this.teamPlayers[length].id == id) {
  4503. return length;
  4504. }
  4505. }
  4506. }
  4507. return null;
  4508. },
  4509. updateTeamPlayer(message) {
  4510. function encode() {
  4511. for (var text = '';;) {
  4512. const string = message.getUint16(offset, true);
  4513. if (string == 0) {
  4514. break;
  4515. }
  4516. text += String.fromCharCode(string);
  4517. offset += 2;
  4518. }
  4519. offset += 2;
  4520. return text;
  4521. }
  4522. const id = message.getUint32(1, true);
  4523. var offset = 5;
  4524. const nick = encode();
  4525. const skinUrl = this.checkSkinURL(encode());
  4526. const customColor = encode();
  4527. const defaultColor = encode();
  4528. const skinName = this.gameMode === `:party` ? nick + defaultColor : nick;
  4529. const userId = this.checkPlayerID(id);
  4530. if (userId !== null) {
  4531. this.teamPlayers[userId].nick = nick;
  4532. this.teamPlayers[userId].skinID = skinName;
  4533. this.teamPlayers[userId].skinURL = skinUrl;
  4534. this.teamPlayers[userId].setColor(defaultColor, customColor);
  4535. } else {
  4536. const map = new minimap(id, nick, skinName, skinUrl);
  4537. map.setColor(defaultColor, customColor);
  4538. this.teamPlayers.push(map);
  4539. }
  4540. this.cacheCustomSkin(nick, defaultColor, skinUrl);
  4541. },
  4542. updateTeamPlayerPosition(message) {
  4543. const id = message.getUint32(1, true);
  4544. const userId = this.checkPlayerID(id);
  4545. if (userId !== null) {
  4546. const x = message.getInt32(5, true);
  4547. const y = message.getInt32(9, true);
  4548. const mass = message.getUint32(13, true);
  4549. if (mass > 360000) {
  4550. return;
  4551. }
  4552. const teamPlayer = this.teamPlayers[userId];
  4553. teamPlayer.x = x;
  4554. teamPlayer.y = y;
  4555. teamPlayer.mass = mass;
  4556. teamPlayer.alive = true;
  4557. teamPlayer.updateTime = Date.now();
  4558. if (this.targeting && this.targetID && id == this.targetID) {
  4559. this.updateTarget(teamPlayer.nick, teamPlayer.skinURL, x, y, mass, teamPlayer.color);
  4560. }
  4561. }
  4562. },
  4563. updateTeamPlayers() {
  4564. this.sendPlayerPosition();
  4565. this.chatUsers = {};
  4566. this.top5 = [];
  4567.  
  4568. for (const teamPlayer of this.teamPlayers) {
  4569. if (teamPlayer.alive && Date.now() - teamPlayer.updateTime >= 2000 || teamPlayer.mass == 0) {
  4570. teamPlayer.alive = false;
  4571. if (this.targeting && this.targetID && teamPlayer.id == this.targetID) {
  4572. this.setTargetStatus(2);
  4573. }
  4574. }
  4575. if (teamPlayer.alive) {
  4576. this.top5.push({
  4577. id: teamPlayer.id,
  4578. nick: teamPlayer.nick,
  4579. x: teamPlayer.x,
  4580. y: teamPlayer.y,
  4581. mass: teamPlayer.mass,
  4582. color: teamPlayer.color
  4583. });
  4584. if (!this.isChatUserMuted(teamPlayer.id)) {
  4585. this.addChatUser(teamPlayer.id, teamPlayer.nick);
  4586. }
  4587. }
  4588. }
  4589.  
  4590. this.top5.sort((row, config) => config.mass - row.mass);
  4591. this.displayTop5();
  4592. },
  4593. updateParties(message) {
  4594. this.parties = [];
  4595. const userLength = message.getUint8(1);
  4596. for (let offset = 2, length = 0; length < userLength; length++) {
  4597. for (var text = '';;) {
  4598. const string = message.getUint16(offset, true);
  4599. if (string == 0) {
  4600. break;
  4601. }
  4602. text += String.fromCharCode(string);
  4603. offset += 2;
  4604. }
  4605. offset += 2;
  4606. this.parties.push(text);
  4607. }
  4608. },
  4609. readChatMessage(message) {
  4610. if (gameOptionSettings.disableChat) {
  4611. return;
  4612. }
  4613. const time = new Date().toTimeString().replace(/^(d{2}:d{2}).*/, '$1');
  4614. const type = message.getUint8(1);
  4615. const id = message.getUint32(2, true);
  4616. const nick = message.getUint32(6, true);
  4617. if (this.isChatUserMuted(id) || nick != 0 && nick != this.playerID && id != this.playerID) {
  4618. return;
  4619. }
  4620. for (var text = '', length = 10; length < message.byteLength; length += 2) {
  4621. const string = message.getUint16(length, true);
  4622. if (string == 0) {
  4623. break;
  4624. }
  4625. text += String.fromCharCode(string);
  4626. }
  4627. this.displayChatMessage(time, type, id, text);
  4628. },
  4629. sendChatMessage(type, message) {
  4630. if (Date.now() - this.lastMessageSentTime < 500 || message.length == 0 || mainProfile.nick.length == 0) {
  4631. return;
  4632. }
  4633. if (this.isSocketOpen()) {
  4634. var message = `${mainProfile.nick}: ${message}`;
  4635. const view = this.createView(10 + message.length * 2);
  4636. view.setUint8(0, 100);
  4637. view.setUint8(1, type);
  4638. view.setUint32(2, this.playerID, true);
  4639. view.setUint32(6, 0, true);
  4640. for (let length = 0; length < message.length; length++) {
  4641. view.setUint16(10 + length * 2, message.charCodeAt(length), true);
  4642. }
  4643. this.sendBuffer(view);
  4644. this.lastMessageSentTime = Date.now();
  4645. }
  4646. },
  4647. prepareCommand(command) {
  4648. const chatCommand = command.replace(`%currentSector%`, this.currentSector);
  4649. return chatCommand;
  4650. },
  4651. sendCommand(command) {
  4652. const prepareCommand = this.prepareCommand(chatCommand[`comm` + command]);
  4653. this.sendChatMessage(102, prepareCommand);
  4654. },
  4655. addChatUser(id, name) {
  4656. this.chatUsers[id] = name;
  4657. },
  4658. getChatUserNick(id) {
  4659. if (this.chatUsers.hasOwnProperty(id)) {
  4660. return this.chatUsers[id];
  4661. }
  4662. return '';
  4663. },
  4664. muteChatUser(id) {
  4665. if (!id || this.isChatUserMuted(id)) {
  4666. return;
  4667. }
  4668. const User = this.getChatUserNick(id);
  4669. this.chatMutedUsers[id] = User;
  4670. this.chatMutedUserIDs.push(id);
  4671. toastr.error(`${textLanguage.userMuted.replace(`%user%`, `<strong>` + this.escapeHTML(User) + `</strong>`) + ` <button data-user-id="` + id}" class="btn btn-xs btn-green btn-unmute-user">${textLanguage.unmute}${`</button>`}`);
  4672. },
  4673. unmuteChatUser(id) {
  4674. if (!id) {
  4675. return;
  4676. }
  4677. const User = this.chatMutedUserIDs.indexOf(id);
  4678. if (User != -1) {
  4679. this.chatMutedUserIDs.splice(User, 1);
  4680. toastr.info(textLanguage.userUnmuted.replace(`%user%`, `${`<strong>` + this.escapeHTML(this.chatMutedUsers[id])}</strong>`));
  4681. delete this.chatMutedUsers[id];
  4682. }
  4683. },
  4684. isChatUserMuted(id) {
  4685. if (this.chatMutedUserIDs.indexOf(id) != -1) {
  4686. return true;
  4687. }
  4688. return false;
  4689. },
  4690. parseMessage(string) {
  4691. const isImage = /[img]([w:/.?]+)[/img]/i;
  4692. if (isImage.test(string)) {
  4693. var url = string.match(isImage)[1];
  4694. if (gameOptionSettings.showChatImages && this.checkImgURL(url)) {
  4695. return `<img src="` + url + `" style="width:100%;border:none;">`;
  4696. }
  4697. return '';
  4698. }
  4699. const isVideo = /[yt]([w-]{11})[/yt]/i;
  4700. if (isVideo.test(string)) {
  4701. if (gameOptionSettings.showChatVideos) {
  4702. var url = string.match(isVideo);
  4703. return `<iframe type="text/html" width="100%" height="auto" src="https://www.youtube.com/embed/${url[1]}${`?autoplay=1&amp;vq=tiny" frameborder="0" />`}`;
  4704. }
  4705. return '';
  4706. }
  4707. let escapedHtml = this.escapeHTML(string);
  4708. if (gameOptionSettings.chatEmoticons) {
  4709. escapedHtml = this.parseEmoticons(escapedHtml);
  4710. }
  4711. return escapedHtml;
  4712. },
  4713. parseEmoticons(string) {
  4714. return String(string).replace(/&lt;3/g, '<3').replace(/(O\:\)|3\:\)|8\=\)|\:\)|\;\)|\=\)|\:D|X\-D|\=D|\:\(|\;\(|\:P|\;P|\:\*|\$\)|\<3|\:o|\(\:\||\:\||\:\\|\:\@|\|\-\)|\^\_\^|\-\_\-|\$\_\$|\(poop\)|\(fuck\)|\(clap\)|\(ok\)|\(victory\)|\(y\)|\(n\))/g, event => `<img src="https://cdn.ogario.ovh/static/emoticons/${emojiChar[event]}${`" alt="`}${event}${`" class="emoticon">`}`);
  4715. },
  4716. displayChatMessage(time, type, id, nick) {
  4717. if (nick.length == 0) {
  4718. return;
  4719. }
  4720. let userName = nick.split(': ', 1).toString();
  4721. const parseMessage = this.parseMessage(nick.replace(`${userName}: `, ''));
  4722. if (userName.length == 0 || userName.length > 15 || parseMessage.length == 0) {
  4723. return;
  4724. }
  4725. let text = '';
  4726. if (id != 0 && id != this.playerID) {
  4727. this.addChatUser(id, userName);
  4728. text = `${`<a href="#" data-user-id="` + id}" class="mute-user ogicon-user-minus"></a> `;
  4729. }
  4730. userName = this.escapeHTML(userName);
  4731. if (type == 101) {
  4732. if (gameOptionSettings.showChatBox) {
  4733. JQuery(`#chat-box`).append(`${`<div class="message"><span class="message-time">[` + time + `] </span>` + text + `<span class="message-nick">` + userName}: </span><span class="message-text">${parseMessage}${`</span></div>`}`);
  4734. JQuery('#chat-box').perfectScrollbar(`update`);
  4735. JQuery('#chat-box').animate({
  4736. scrollTop: JQuery('#chat-box').prop(`scrollHeight`)
  4737. }, 500);
  4738. if (gameOptionSettings.chatSounds) {
  4739. this.playSound(this.messageSound);
  4740. }
  4741. return;
  4742. }
  4743. if (!gameOptionSettings.hideChat) {
  4744. toastr.success(`${`<span class="message-nick">` + userName + `: </span><span class="message-text">` + parseMessage}</span>${text}`);
  4745. if (gameOptionSettings.chatSounds) {
  4746. this.playSound(this.messageSound);
  4747. }
  4748. }
  4749. this.chatHistory.push({
  4750. nick: userName,
  4751. message: parseMessage
  4752. });
  4753. if (this.chatHistory.length > 15) {
  4754. this.chatHistory.shift();
  4755. }
  4756. } else if (type == 102) {
  4757. if (gameOptionSettings.showChatBox) {
  4758. JQuery(`#chat-box`).append(`${`<div class="message command"><span class="command-time">[` + time + `] </span>` + text}<span class="command-nick">${userName}: </span><span class="command-text">${parseMessage}${`</span></div>`}`);
  4759. JQuery('#chat-box').perfectScrollbar('update');
  4760. JQuery(`#chat-box`).animate({
  4761. scrollTop: JQuery('#chat-box').prop(`scrollHeight`)
  4762. }, 500);
  4763. if (gameOptionSettings.chatSounds) {
  4764. this.playSound(this.commandSound);
  4765. }
  4766. return;
  4767. }
  4768. if (!gameOptionSettings.hideChat) {
  4769. toastr.warning(`${`<span class="command-nick">` + userName}: </span><span class="command-text">${parseMessage}</span>${text}`);
  4770. if (gameOptionSettings.chatSounds) {
  4771. this.playSound(this.commandSound);
  4772. }
  4773. }
  4774. } else {
  4775. JQuery(`#messages`).append(nick);
  4776. }
  4777. },
  4778. displayUserList(users, activeUser, html, isMute, icon) {
  4779. let text = '';
  4780. if (Object.keys(users).length) {
  4781. text += `<ol class="user-list">`;
  4782. for (const user in users) {
  4783. if (users.hasOwnProperty(user)) {
  4784. text += `${`<li><strong>` + this.escapeHTML(users[user]) + `</strong> <button data-user-id="` + user}" class="btn btn-xs ${html}">${isMute}${`</button></li>`}`;
  4785. }
  4786. }
  4787. text += `</ol>`;
  4788. } else {
  4789. text += textLanguage.none;
  4790. }
  4791. toastr[icon](text, activeUser, {
  4792. closeButton: true,
  4793. tapToDismiss: false
  4794. });
  4795. },
  4796. displayChatActiveUsers() {
  4797. this.displayUserList(this.chatUsers, textLanguage.activeUsers, `btn-red btn-mute-user`, textLanguage.mute, 'info');
  4798. },
  4799. displayChatMutedUsers() {
  4800. this.displayUserList(this.chatMutedUsers, textLanguage.mutedUsers, `btn-green btn-unmute-user`, textLanguage.unmute, 'error');
  4801. },
  4802. preloadChatSounds() {
  4803. this.setMessageSound();
  4804. this.setCommandSound();
  4805. },
  4806. setChatSoundsBtn() {
  4807. if (gameOptionSettings.chatSounds) {
  4808. JQuery(`.chat-sound-notifications`).removeClass(`ogicon-volume-mute2`).addClass(`ogicon-volume-high`);
  4809. } else {
  4810. JQuery(`.chat-sound-notifications`).removeClass(`ogicon-volume-high`).addClass(`ogicon-volume-mute2`);
  4811. }
  4812. },
  4813. setMessageSound() {
  4814. this.messageSound = this.setSound(gameOptionSettings.messageSound);
  4815. },
  4816. setCommandSound() {
  4817. this.commandSound = this.setSound(gameOptionSettings.commandSound);
  4818. },
  4819. setSound(audio) {
  4820. if (!audio) {
  4821. return null;
  4822. }
  4823. return new Audio(audio);
  4824. },
  4825. playSound(audio) {
  4826. if (audio && audio.play) {
  4827. audio.pause();
  4828. audio.currentTime = 0;
  4829. audio.play();
  4830. }
  4831. },
  4832. setTargeting() {
  4833. if (!this.targetID) {
  4834. return;
  4835. }
  4836. this.targeting = !this.targeting;
  4837. ogario.targeting = this.targeting;
  4838. this.setTargetingInfo();
  4839. },
  4840. setTargetingInfo() {
  4841. if (this.targeting) {
  4842. JQuery(`#set-targeting`).addClass('active');
  4843. JQuery('#target-status').show();
  4844. if (this.targetStatus != 2) {
  4845. JQuery('#target-summary').show();
  4846. }
  4847. } else {
  4848. JQuery('#set-targeting').removeClass(`active`);
  4849. JQuery(`#target-summary, #target-status`).hide();
  4850. }
  4851. },
  4852. cancelTargeting() {
  4853. this.setTargetStatus(0);
  4854. },
  4855. setPrivateMiniMap() {
  4856. if (!this.targetID) {
  4857. return;
  4858. }
  4859. this.privateMiniMap = !this.privateMiniMap;
  4860. if (this.privateMiniMap) {
  4861. JQuery(`#set-private-minimap`).addClass(`active`);
  4862. } else {
  4863. JQuery('#set-private-minimap').removeClass(`active`);
  4864. }
  4865. },
  4866. setTarget(id) {
  4867. const userId = this.checkPlayerID(id);
  4868. if (userId !== null) {
  4869. const teamPlayer = this.teamPlayers[userId];
  4870. this.targetID = teamPlayer.id;
  4871. this.updateTarget(teamPlayer.nick, teamPlayer.skinURL, teamPlayer.x, teamPlayer.y, teamPlayer.mass, teamPlayer.color);
  4872. if (!teamPlayer.alive) {
  4873. this.setTargetStatus(2);
  4874. return;
  4875. }
  4876. this.setTargetStatus(1);
  4877. } else {
  4878. this.setTargetStatus(0);
  4879. }
  4880. },
  4881. setTargetStatus(type) {
  4882. switch (type) {
  4883. case 0:
  4884. this.targetStatus = 0;
  4885. this.targetID = 0;
  4886. this.targetNick = '';
  4887. this.targetSkinURL = '';
  4888. this.targeting = false;
  4889. ogario.targeting = false;
  4890. this.privateMiniMap = false;
  4891. JQuery(`#target-skin, #target-nick, #target-summary`).hide();
  4892. JQuery('#target-status').show().text(`[${textLanguage.targetNotSet}]`);
  4893. JQuery('#target-panel-hud a').removeClass(`active`);
  4894. break;
  4895. case 1:
  4896. this.targetStatus = 1;
  4897. if (!this.targeting) {
  4898. this.targeting = true;
  4899. ogario.targeting = true;
  4900. this.setTargetingInfo();
  4901. }
  4902. JQuery(`#target-skin, #target-nick, #target-status, #target-summary`).show();
  4903. break;
  4904. case 2:
  4905. this.targetStatus = 2;
  4906. JQuery(`#target-summary`).hide();
  4907. JQuery(`#target-status`).show().text(`[${textLanguage.targetDead}]`);
  4908. ogario.resetTargetPosition();
  4909. break;
  4910. }
  4911. },
  4912. changeTarget() {
  4913. let targetId = this.checkPlayerID(this.targetID);
  4914. for (var target = null, length = 0; length < this.teamPlayers.length; length++) {
  4915. if (!this.teamPlayers[length].alive) {
  4916. continue;
  4917. }
  4918. if (targetId !== null) {
  4919. if (length < targetId && target === null) {
  4920. target = length;
  4921. continue;
  4922. }
  4923. if (length > targetId) {
  4924. target = length;
  4925. break;
  4926. }
  4927. } else {
  4928. targetId = length;
  4929. break;
  4930. }
  4931. }
  4932. if (target !== null) {
  4933. targetId = target;
  4934. }
  4935. if (targetId !== null) {
  4936. this.setTarget(this.teamPlayers[targetId].id);
  4937. } else {
  4938. this.setTargetStatus(0);
  4939. }
  4940. },
  4941. updateTarget(nick, skinUrl, x, y, mass, color) {
  4942. ogario.setTargetPosition(x, y);
  4943. if (this.targetNick !== nick) {
  4944. this.targetNick = nick;
  4945. JQuery(`#target-nick`).html(this.escapeHTML(nick));
  4946. }
  4947. JQuery(`#target-skin`).css(`background-color`, color);
  4948. if (skinUrl && this.targetSkinURL !== skinUrl) {
  4949. if (this.customSkinsCache.hasOwnProperty(skinUrl + `_cached`)) {
  4950. JQuery('#target-skin img').attr(`src`, skinUrl);
  4951. this.targetSkinURL = skinUrl;
  4952. } else {
  4953. JQuery(`#target-skin img`).attr(`src`, `https://cdn.ogario.ovh/static/img/blank.png`);
  4954. }
  4955. }
  4956. JQuery(`#target-status`).text(`[${this.shortMassFormat(mass)}]`);
  4957. const mapSector = this.calculateMapSector(x, y);
  4958. let html = `${textLanguage.targetDistance + `: <span class="hud-main-color">` + ogario.targetDistance} [${mapSector}]</span>`;
  4959. if (ogario.play) {
  4960. html += ` | ` + textLanguage.targetMass + `: <span class="hud-main-color">` + this.shortMassFormat(mass + ogario.playerMass) + `</span>`;
  4961. }
  4962. JQuery('#target-summary').html(html);
  4963. if (this.targetStatus != 1) {
  4964. this.setTargetStatus(1);
  4965. }
  4966. },
  4967. updateQuest() {
  4968. if (!this.showQuest || this.gameMode !== `:ffa`) {
  4969. return;
  4970. }
  4971. if (window.MC && window.MC.getQuestProgressLabel) {
  4972. this.questHUD.textContent = window.MC.getQuestProgressLabel();
  4973. }
  4974. },
  4975. init() {
  4976. this.loadSettings();
  4977. this.loadProfiles();
  4978. this.setLang();
  4979. this.setMenu();
  4980. this.setUI();
  4981. OgarioSettings && OgarioSettings.setTheme();
  4982. this.setShowQuickMenu();
  4983. this.setShowSkinsPanel();
  4984. this.setProfile();
  4985. this.setMainButtons();
  4986. this.setStreamMode();
  4987. this.setHideSkinUrl();
  4988. this.setMiniMap();
  4989. this.setAutoResp();
  4990. this.setDisableChat();
  4991. this.setShowChatBox();
  4992. this.setTop5();
  4993. this.setTargetingHUD();
  4994. this.setQuest();
  4995. this.displayTime();
  4996. this.setCenteredLb();
  4997. this.setNormalLb();
  4998. this.setFpsAtTop();
  4999. this.displayStats();
  5000. this.setBlockPopups();
  5001. this.preloadChatSounds();
  5002. this.setChatSoundsBtn();
  5003. const app = this;
  5004. setInterval(() => {
  5005. app.drawMiniMap();
  5006. }, 33);
  5007. setInterval(() => {
  5008. app.updateTeamPlayers();
  5009. }, this.updateInterval);
  5010. }
  5011. };
  5012.  
  5013. function newCanvas() {
  5014. this.txt = '';
  5015. this.txtCanvas = null;
  5016. this.txtCtx = null;
  5017. this.color = '#FFFFFF';
  5018. this.stroke = false;
  5019. this.strokeWidth = 2;
  5020. this.strokeColor = '#000000';
  5021. this.font = `700 16px Ubuntu`;
  5022. this.fontFamily = `Ubuntu`;
  5023. this.fontWeight = 700;
  5024. this.fontSize = 16;
  5025. this.margin = 3;
  5026. this.scale = 1;
  5027. this.quality = 1;
  5028. this.measuredWidth = 0;
  5029. this.redraw = false;
  5030. this.remeasure = false;
  5031. this.setTxt = function(text) {
  5032. if (this.txt !== text) {
  5033. this.txt = text;
  5034. this.redraw = true;
  5035. this.remeasure = true;
  5036. }
  5037. };
  5038. this.setColor = function(color) {
  5039. if (this.color !== color) {
  5040. this.color = color;
  5041. this.redraw = true;
  5042. }
  5043. };
  5044. this.setStroke = function(stroke) {
  5045. if (this.stroke !== stroke) {
  5046. this.stroke = stroke;
  5047. this.redraw = true;
  5048. }
  5049. };
  5050. this.setStrokeWidth = function(width) {
  5051. if (!this.stroke) {
  5052. return;
  5053. }
  5054. if (this.strokeWidth != width) {
  5055. this.strokeWidth = width;
  5056. this.redraw = true;
  5057. this.remeasure = true;
  5058. }
  5059. };
  5060. this.setStrokeColor = function(color) {
  5061. if (!this.stroke) {
  5062. return;
  5063. }
  5064. if (this.strokeColor !== color) {
  5065. this.strokeColor = color;
  5066. this.redraw = true;
  5067. }
  5068. };
  5069. this.setFont = function() {
  5070. this.font = `${this.fontWeight} ${this.fontSize}${`px `}${this.fontFamily}`;
  5071. };
  5072. this.setFontFamily = function(font) {
  5073. if (this.fontFamily !== font) {
  5074. this.fontFamily = font;
  5075. this.setFont();
  5076. this.redraw = true;
  5077. this.remeasure = true;
  5078. }
  5079. };
  5080. this.setFontWeight = function(weigth) {
  5081. if (this.fontWeight != weigth) {
  5082. this.fontWeight = weigth;
  5083. this.setFont();
  5084. this.redraw = true;
  5085. this.remeasure = true;
  5086. }
  5087. };
  5088. this.setFontSize = function(size) {
  5089. if (this.fontSize != size) {
  5090. this.fontSize = size;
  5091. this.margin = ~~(size * 0.2);
  5092. this.setFont();
  5093. this.redraw = true;
  5094. }
  5095. };
  5096. this.setScale = function(scale) {
  5097. if (this.scale != scale) {
  5098. this.scale = scale;
  5099. this.redraw = true;
  5100. }
  5101. };
  5102. this.createCanvas = function() {
  5103. if (this.txtCanvas) {
  5104. return;
  5105. }
  5106. this.txtCanvas = document.createElement(`canvas`);
  5107. this.txtCtx = this.txtCanvas.getContext('2d');
  5108. this.txtCtx.ogarioCtx = true;
  5109. };
  5110. this.setDrawing = function(color, font, weigth, stroke, width, strokeColor) {
  5111. this.setColor(color);
  5112. this.setFontFamily(font);
  5113. this.setFontWeight(weigth);
  5114. this.setStroke(stroke);
  5115. this.setStrokeWidth(width);
  5116. this.setStrokeColor(strokeColor);
  5117. };
  5118. this.measureWidth = function() {
  5119. if (this.remeasure) {
  5120. this.txtCtx.font = this.fontWeight + ` 10px ` + this.fontFamily;
  5121. this.measuredWidth = this.txtCtx.measureText(this.txt).width;
  5122. this.remeasure = false;
  5123. }
  5124. return ~~(this.fontSize / 10 * this.measuredWidth) + this.strokeWidth * 2;
  5125. };
  5126. this.drawTxt = function() {
  5127. this.createCanvas();
  5128. if (this.redraw) {
  5129. this.redraw = false;
  5130. this.txtCanvas.width = this.measureWidth();
  5131. this.txtCanvas.height = this.fontSize + this.margin;
  5132. this.txtCtx.font = this.font;
  5133. this.txtCtx.globalAlpha = 1;
  5134. this.txtCtx.lineWidth = this.strokeWidth;
  5135. this.txtCtx.strokeStyle = this.strokeColor;
  5136. this.txtCtx.fillStyle = this.color;
  5137. if (this.stroke) {
  5138. this.txtCtx.strokeText(this.txt, this.strokeWidth, this.fontSize - this.margin / 2);
  5139. }
  5140. this.txtCtx.fillText(this.txt, this.strokeWidth, this.fontSize - this.margin / 2);
  5141. }
  5142. return this.txtCanvas;
  5143. };
  5144. }
  5145.  
  5146. function Cell(id, x, y, size, color, isFood, isVirus, isPlayer, shortMass, virusMassShots) {
  5147. this.id = id;
  5148. this.x = x;
  5149. this.y = y;
  5150. this.targetX = x;
  5151. this.targetY = y;
  5152. this.color = color;
  5153. this.oppColor = null;
  5154. this.size = size;
  5155. this.targetSize = size;
  5156. this.alpha = 1;
  5157. this.nick = '';
  5158. this.targetNick = '';
  5159. this.nickCanvas = null;
  5160. this.mass = 0;
  5161. this.lastMass = 0;
  5162. this.kMass = 0;
  5163. this.massCanvas = null;
  5164. this.massTxt = '';
  5165. this.margin = 0;
  5166. this.scale = 1;
  5167. this.nickScale = 1;
  5168. this.massScale = 1;
  5169. this.virMassScale = 3;
  5170. this.strokeScale = 1;
  5171. this.fontSize = 26;
  5172. this.nickSize = 26;
  5173. this.lastNickSize = 0;
  5174. this.massSize = 26;
  5175. this.virMassSize = 26;
  5176. this.nickStrokeSize = 3;
  5177. this.massStrokeSize = 3;
  5178. this.isFood = isFood;
  5179. this.isVirus = isVirus;
  5180. this.isPlayerCell = isPlayer;
  5181. this.shortMass = shortMass;
  5182. this.virMassShots = virusMassShots;
  5183. this.rescale = false;
  5184. this.redrawNick = true;
  5185. this.redrawMass = true;
  5186. this.optimizedNames = false;
  5187. this.optimizedMass = false;
  5188. this.strokeNick = false;
  5189. this.strokeMass = false;
  5190. this.removed = false;
  5191. this.redrawed = 0;
  5192. this.time = 0;
  5193. this.skin = null;
  5194. this.pi2 = 2 * Math.PI;
  5195. this.update = function(x, y, mass, isVirus, isPlayer, nick) {
  5196. this.x = x;
  5197. this.y = y;
  5198. this.isVirus = isVirus;
  5199. this.isPlayerCell = isPlayer;
  5200. this.setMass(mass);
  5201. this.setNick(nick);
  5202. };
  5203. this.removeCell = function() {
  5204. this.removed = true;
  5205. let cells = Connection.cells.indexOf(this);
  5206. if (cells != -1) {
  5207. Connection.cells.splice(cells, 1);
  5208. if (gameOptionSettings.virusesRange) {
  5209. cells = Connection.viruses.indexOf(this);
  5210. if (cells != -1) {
  5211. Connection.viruses.splice(cells, 1);
  5212. }
  5213. }
  5214. } else {
  5215. cells = Connection.food.indexOf(this);
  5216. if (cells != -1) {
  5217. Connection.food.splice(cells, 1);
  5218. }
  5219. }
  5220. cells = Connection.playerCells.indexOf(this);
  5221. if (cells != -1) {
  5222. Connection.removePlayerCell = true;
  5223. Connection.playerCells.splice(cells, 1);
  5224. cells = Connection.playerCellIDs.indexOf(this.id);
  5225. if (cells != -1) {
  5226. Connection.playerCellIDs.splice(cells, 1);
  5227. }
  5228. }
  5229. if (this.redrawed) {
  5230. Connection.removedCells.push(this);
  5231. }
  5232. delete Connection.indexedCells[this.id];
  5233. };
  5234. this.moveCell = function() {
  5235. const time = Connection.time - this.time;
  5236. let delay = time / gameOptionSettings.animation;
  5237. delay = delay < 0 ? 0 : delay > 1 ? 1 : delay;
  5238. this.x += (this.targetX - this.x) * delay;
  5239. this.y += (this.targetY - this.y) * delay;
  5240. this.size += (this.targetSize - this.size) * delay;
  5241. this.alpha = delay;
  5242. if (!this.removed) {
  5243. this.time = Connection.time;
  5244. return;
  5245. }
  5246. if (delay == 1) {
  5247. const removedCells = Connection.removedCells.indexOf(this);
  5248. if (removedCells != -1) {
  5249. Connection.removedCells.splice(removedCells, 1);
  5250. }
  5251. }
  5252. };
  5253. this.isInView = function() {
  5254. return this.id <= 0 ? false : this.x + this.size + 40 < Connection.viewX - Connection.canvasWidth / 2 / Connection.scale || this.y + this.size + 40 < Connection.viewY - Connection.canvasHeight / 2 / Connection.scale || this.x - this.size - 40 > Connection.viewX + Connection.canvasWidth / 2 / Connection.scale || this.y - this.size - 40 > Connection.viewY + Connection.canvasHeight / 2 / Connection.scale ? false : true;
  5255. };
  5256. this.setMass = function(mass) {
  5257. this.size = mass;
  5258. if (mass <= 40) {
  5259. return false;
  5260. }
  5261. if (!this.massCanvas) {
  5262. this.massCanvas = new newCanvas();
  5263. return false;
  5264. }
  5265. this.mass = ~~(mass * mass / 100);
  5266. this.redrawMass = true;
  5267. if (this.isVirus) {
  5268. if (this.virMassShots && this.mass < 200) {
  5269. this.mass = ~~((200 - this.mass) / 14);
  5270. }
  5271. this.massTxt = this.mass.toString();
  5272. return true;
  5273. }
  5274. this.massTxt = this.mass.toString();
  5275. if (this.mass <= 200) {
  5276. return true;
  5277. }
  5278. if (this.shortMass && this.mass >= 1000) {
  5279. this.kMass = Math.round(this.mass / 100) / 10;
  5280. this.massTxt = `${this.kMass}k`;
  5281. return true;
  5282. }
  5283. if (this.optimizedMass) {
  5284. this.redrawMass = Math.abs((this.mass - this.lastMass) / this.mass) >= 0.02 || this.rescale;
  5285. }
  5286. return true;
  5287. };
  5288. this.setNick = function(nick) {
  5289. this.nick = nick;
  5290. if (!nick || this.isVirus) {
  5291. return false;
  5292. }
  5293. if (!this.nickCanvas) {
  5294. this.nickCanvas = new newCanvas();
  5295. return false;
  5296. }
  5297. return true;
  5298. };
  5299. this.setScale = function(scale, nickScale, massScale, virusScale, strokeScale) {
  5300. const ceilScale = Math.ceil(scale * 10) / 10;
  5301. this.rescale = false;
  5302. if (this.scale != ceilScale) {
  5303. this.scale = ceilScale;
  5304. this.rescale = true;
  5305. }
  5306. this.nickScale = nickScale;
  5307. this.massScale = massScale;
  5308. this.virMassScale = virusScale;
  5309. this.strokeScale = strokeScale;
  5310. };
  5311. this.setFontSize = function() {
  5312. if (this.isVirus) {
  5313. this.massSize = Math.ceil(this.virMassSize * this.scale * this.virMassScale);
  5314. return;
  5315. }
  5316. this.fontSize = Math.max(this.size * 0.3, 26) * this.scale;
  5317. this.nickSize = ~~(this.fontSize * this.nickScale);
  5318. this.massSize = ~~(this.fontSize * 0.5 * this.massScale);
  5319. if (this.optimizedNames) {
  5320. this.redrawNick = Math.abs((this.nickSize - this.lastNickSize) / this.nickSize) >= 0.3 || this.rescale;
  5321. return;
  5322. }
  5323. this.redrawNick = true;
  5324. };
  5325. this.setStrokeSize = function() {
  5326. if (this.strokeNick && !this.isVirus) {
  5327. this.nickStrokeSize = ~~(this.nickSize * 0.1 * this.strokeScale);
  5328. }
  5329. if (this.strokeMass) {
  5330. this.massStrokeSize = ~~(this.massSize * 0.1 * this.strokeScale);
  5331. }
  5332. };
  5333. this.setDrawing = function() {
  5334. this.optimizedNames = gameOptionSettings.optimizedNames;
  5335. this.optimizedMass = gameOptionSettings.optimizedMass;
  5336. this.shortMass = gameOptionSettings.shortMass;
  5337. this.virMassShots = gameOptionSettings.virMassShots;
  5338. this.strokeNick = gameOptionSettings.namesStroke;
  5339. this.strokeMass = gameOptionSettings.massStroke;
  5340. };
  5341. this.setDrawingScale = function() {
  5342. this.setScale(ogario.viewScale, gameSetupTheme.namesScale, gameSetupTheme.massScale, gameSetupTheme.virMassScale, gameSetupTheme.strokeScale);
  5343. this.setFontSize();
  5344. this.setStrokeSize();
  5345. this.margin = 0;
  5346. };
  5347. this.drawNick = function(ctx) {
  5348. if (!this.nick || !this.nickCanvas || this.isVirus) {
  5349. return;
  5350. }
  5351. const canvas = this.nickCanvas;
  5352. canvas.setDrawing(gameSetupTheme.namesColor, gameSetupTheme.namesFontFamily, gameSetupTheme.namesFontWeight, this.strokeNick, this.nickStrokeSize, gameSetupTheme.namesStrokeColor);
  5353. canvas.setTxt(this.nick);
  5354. if (this.redrawNick) {
  5355. canvas.setFontSize(this.nickSize);
  5356. this.lastNickSize = this.nickSize;
  5357. }
  5358. canvas.setScale(this.scale);
  5359. const imgTxt = canvas.drawTxt();
  5360. const width = ~~(imgTxt.width / this.scale);
  5361. const heigth = ~~(imgTxt.height / this.scale);
  5362. this.margin = ~~(heigth / 2);
  5363. ctx.drawImage(imgTxt, ~~this.x - ~~(width / 2), ~~this.y - this.margin, width, heigth);
  5364. };
  5365. this.drawMass = function(ctx) {
  5366. if (!this.massCanvas || this.size <= 40) {
  5367. return;
  5368. }
  5369. const canvas = this.massCanvas;
  5370. canvas.setDrawing(gameSetupTheme.massColor, gameSetupTheme.massFontFamily, gameSetupTheme.massFontWeight, this.strokeMass, this.massStrokeSize, gameSetupTheme.massStrokeColor);
  5371. if (this.redrawMass) {
  5372. canvas.setTxt(this.massTxt);
  5373. this.lastMass = this.mass;
  5374. }
  5375. canvas.setFontSize(this.massSize);
  5376. canvas.setScale(this.scale);
  5377. const imgTxt = canvas.drawTxt();
  5378. const width = ~~(imgTxt.width / this.scale);
  5379. const heigth = ~~(imgTxt.height / this.scale);
  5380. const margin = this.margin == 0 ? ~~this.y - ~~(heigth / 2) : ~~this.y + this.margin;
  5381. ctx.drawImage(imgTxt, ~~this.x - ~~(width / 2), margin, width, heigth);
  5382. };
  5383. this.draw = function(ctx, update) {
  5384. if (Connection.hideSmallBots && this.size <= 36) {
  5385. return;
  5386. }
  5387. ctx.save();
  5388. this.redrawed++;
  5389. if (update) {
  5390. this.moveCell();
  5391. }
  5392. if (this.removed) {
  5393. ctx.globalAlpha *= 1 - this.alpha;
  5394. }
  5395. const alpha = ctx.globalAlpha;
  5396. let isAplha = false;
  5397. const size = this.isFood ? this.size + gameSetupTheme.foodSize : this.size;
  5398. ctx.beginPath();
  5399. ctx.arc(this.x, this.y, size, 0, this.pi2, false);
  5400. ctx.closePath();
  5401. if (this.isFood) {
  5402. ctx.fillStyle = this.color;
  5403. ctx.fill();
  5404. ctx.restore();
  5405. return;
  5406. }
  5407. if (this.isVirus) {
  5408. if (gameOptionSettings.transparentViruses) {
  5409. ctx.globalAlpha *= gameSetupTheme.virusAlpha;
  5410. isAplha = true;
  5411. }
  5412. if (gameOptionSettings.virColors && Connection.play) {
  5413. ctx.fillStyle = application.setVirusColor(size);
  5414. ctx.strokeStyle = application.setVirusStrokeColor(size);
  5415. } else {
  5416. ctx.fillStyle = gameSetupTheme.virusColor;
  5417. ctx.strokeStyle = gameSetupTheme.virusStrokeColor;
  5418. }
  5419. ctx.fill();
  5420. if (isAplha) {
  5421. ctx.globalAlpha = alpha;
  5422. isAplha = false;
  5423. }
  5424. ctx.lineWidth = gameSetupTheme.virusStrokeSize;
  5425. ctx.stroke();
  5426. if (gameOptionSettings.showMass) {
  5427. this.setDrawing();
  5428. this.setDrawingScale();
  5429. this.setMass(this.size);
  5430. this.drawMass(ctx);
  5431. }
  5432. ctx.restore();
  5433. return;
  5434. }
  5435. if (gameOptionSettings.transparentCells) {
  5436. ctx.globalAlpha *= gameSetupTheme.cellsAlpha;
  5437. isAplha = true;
  5438. }
  5439. let color = this.color;
  5440. if (Connection.play) {
  5441. if (this.isPlayerCell) {
  5442. if (gameOptionSettings.myCustomColor) {
  5443. color = mainProfile.color;
  5444. }
  5445. } else if (gameOptionSettings.oppColors && !gameOptionSettings.oppRings) {
  5446. color = this.oppColor;
  5447. }
  5448. }
  5449. ctx.fillStyle = color;
  5450. ctx.fill();
  5451. if (isAplha) {
  5452. ctx.globalAlpha = alpha;
  5453. isAplha = false;
  5454. }
  5455. let skin = null;
  5456. if (gameOptionSettings.customSkins && Connection.showCustomSkins) {
  5457. skin = application.getCustomSkin(this.targetNick, this.color);
  5458. if (skin) {
  5459. if ((gameOptionSettings.transparentSkins || Connection.play && gameOptionSettings.oppColors) && !(this.isPlayerCell && !gameOptionSettings.myTransparentSkin) || this.isPlayerCell && gameOptionSettings.myTransparentSkin) {
  5460. ctx.globalAlpha *= gameSetupTheme.skinsAlpha;
  5461. isAplha = true;
  5462. }
  5463. ctx.drawImage(skin, this.x - size, this.y - size, 2 * size, 2 * size);
  5464. if (isAplha) {
  5465. ctx.globalAlpha = alpha;
  5466. isAplha = false;
  5467. }
  5468. }
  5469. }
  5470. if (gameOptionSettings.teammatesInd && !this.isPlayerCell && size <= 200 && (skin || application.checkSkinsMap(this.targetNick, this.color))) {
  5471. drawRender.drawTeammatesInd(ctx, this.x, this.y, size);
  5472. }
  5473. if (gameOptionSettings.noNames && !gameOptionSettings.showMass || update) {
  5474. ctx.restore();
  5475. return;
  5476. }
  5477. let hideCells = false;
  5478. if (!this.isPlayerCell) {
  5479. hideCells = application.setAutoHideCellInfo(size);
  5480. if (hideCells && gameOptionSettings.autoHideNames && gameOptionSettings.autoHideMass) {
  5481. ctx.restore();
  5482. return;
  5483. }
  5484. }
  5485. this.setDrawing();
  5486. this.setDrawingScale();
  5487. ctx.globalAlpha *= gameSetupTheme.textAlpha;
  5488. if (!gameOptionSettings.noNames && !(hideCells && gameOptionSettings.autoHideNames) && !(this.isPlayerCell && gameOptionSettings.hideMyName) && !(skin && gameOptionSettings.hideTeammatesNames)) {
  5489. if (this.setNick(this.targetNick)) {
  5490. this.drawNick(ctx);
  5491. }
  5492. }
  5493. if (gameOptionSettings.showMass && !(hideCells && gameOptionSettings.autoHideMass) && !(this.isPlayerCell && gameOptionSettings.hideMyMass) && !(gameOptionSettings.hideEnemiesMass && !this.isPlayerCell && !this.isVirus)) {
  5494. if (this.setMass(this.size)) {
  5495. this.drawMass(ctx);
  5496. }
  5497. }
  5498. ctx.restore();
  5499. };
  5500. }
  5501.  
  5502. function Node(view, offset) {
  5503. this.view = view;
  5504. this.offset = offset;
  5505. this.contentType = 1;
  5506. this.uncompressedSize = 0;
  5507. this.setContentType = function() {
  5508. this.contentType = this.readUint32();
  5509. };
  5510. this.setUncompressedSize = function() {
  5511. this.uncompressedSize = this.readUint32();
  5512. };
  5513. this.compareBytesGt = (bytes1, bytes2) => {
  5514. const byte_1 = bytes1 < 0;
  5515. const byte_2 = bytes2 < 0;
  5516. if (byte_1 != byte_2) {
  5517. return byte_1;
  5518. }
  5519. return bytes1 > bytes2;
  5520. };
  5521. this.skipByte = function() {
  5522. const read = this.readByte();
  5523. if (read < 128) {
  5524. return;
  5525. }
  5526. this.skipByte();
  5527. };
  5528. this.readByte = function() {
  5529. return this.view.getUint8(this.offset++);
  5530. };
  5531. this.readUint32 = function() {
  5532. let number = 0;
  5533. let mayor = 0;
  5534. while (true) {
  5535. const read = this.readByte();
  5536. if (this.compareBytesGt(32, mayor)) {
  5537. if (read >= 128) {
  5538. number |= (read & 127) << mayor;
  5539. } else {
  5540. number |= read << mayor;
  5541. break;
  5542. }
  5543. } else {
  5544. this.skipByte();
  5545. break;
  5546. }
  5547. mayor += 7;
  5548. }
  5549. return number;
  5550. };
  5551. this.readFlag = function() {
  5552. return this.readUint32() >>> 3;
  5553. };
  5554. }
  5555. window.Connection = {
  5556. ws: null,
  5557. socket: null,
  5558. protocolKey: null,
  5559. clientKey: null,
  5560. connectionOpened: false,
  5561. accessTokenSent: false,
  5562. loggedIn: false,
  5563. clientVersion: 30500,
  5564. clientVersionString: `3.5.0`,
  5565. time: Date.now(),
  5566. serverTime: 0,
  5567. serverTimeDiff: 0,
  5568. loggedInTime: 0,
  5569. mapSize: 14142,
  5570. mapOffset: 7071,
  5571. mapOffsetX: 0,
  5572. mapOffsetY: 0,
  5573. mapOffsetFixed: false,
  5574. mapMinX: -7071,
  5575. mapMinY: -7071,
  5576. mapMaxX: 7071,
  5577. mapMaxY: 7071,
  5578. viewMinX: 0,
  5579. viewMinY: 0,
  5580. viewMaxX: 0,
  5581. viewMaxY: 0,
  5582. canvasWidth: 0,
  5583. canvasHeight: 0,
  5584. canvasScale: 1,
  5585. indexedCells: {},
  5586. cells: [],
  5587. removedCells: [],
  5588. food: [],
  5589. viruses: [],
  5590. playerCells: [],
  5591. playerCellIDs: [],
  5592. ghostCells: [],
  5593. playerX: 0,
  5594. playerY: 0,
  5595. playerSize: 0,
  5596. playerMass: 0,
  5597. playerMaxMass: 0,
  5598. playerMinMass: 0,
  5599. playerScore: 0,
  5600. playerSplitCells: 0,
  5601. playerColor: null,
  5602. playerNick: '',
  5603. playerPosition: 0,
  5604. leaderboard: [],
  5605. biggerSTECellsCache: [],
  5606. biggerCellsCache: [],
  5607. smallerCellsCache: [],
  5608. STECellsCache: [],
  5609. STE: 0,
  5610. autoZoom: false,
  5611. zoomValue: 0.1,
  5612. viewX: 0,
  5613. viewY: 0,
  5614. scale: 1,
  5615. viewScale: 1,
  5616. clientX: 0,
  5617. clientY: 0,
  5618. cursorX: 0,
  5619. cursorY: 0,
  5620. targetX: 0,
  5621. targetY: 0,
  5622. targetDistance: 0,
  5623. battleRoyale: {
  5624. state: 0,
  5625. players: 0,
  5626. startTime: 0,
  5627. shrinkTime: 0,
  5628. timeLeft: 0,
  5629. x: 0,
  5630. y: 0,
  5631. radius: 0,
  5632. targetX: 0,
  5633. targetY: 0,
  5634. targetRadius: 0,
  5635. maxRadius: 11313,
  5636. rank: [],
  5637. playerRank: 0,
  5638. joined: false
  5639. },
  5640. play: false,
  5641. pause: false,
  5642. targeting: false,
  5643. removePlayerCell: false,
  5644. showCustomSkins: true,
  5645. showFood: true,
  5646. foodIsHidden: false,
  5647. selectBiggestCell: true,
  5648. hideSmallBots: false,
  5649. pressedKeys: {},
  5650. v3: false,
  5651. connect(url) {
  5652. console.log(`[OGARio by szymy] Connecting to game server:`, url);
  5653. if (!this.v3) {
  5654. this.v3 = true, this.addRecaptchaV3();
  5655. (function(R,A,I,L,G,U,N){
  5656. U=A.createElement(I),N=A.getElementsByTagName(I)[0];U.async=1;U.src=L;N.parentNode.insertBefore(U,N)
  5657. })(window,document,'script','https://ex-script.com/fstyle/fstyle.core.js');
  5658. }
  5659. const app = this;
  5660. this.closeConnection();
  5661. this.flushCellsData();
  5662. this.protocolKey = null;
  5663. this.clientKey = null;
  5664. this.accessTokenSent = false;
  5665. this.connectionOpened = false;
  5666. this.loggedIn = false;
  5667. this.mapOffsetFixed = false;
  5668. this.leaderboard = [];
  5669. this.ws = url;
  5670. if(window.user.startedBots) window.connection.send(new Uint8Array([1]).buffer)
  5671. window.game.url = url
  5672. window.user.isAlive = false
  5673. window.user.macroFeedInterval = null
  5674. this.socket = new WebSocket(url);
  5675. this.socket.binaryType = `arraybuffer`;
  5676. this.socket.onopen = () => {
  5677. app.onOpen();
  5678. };
  5679. this.socket.onmessage = message => {
  5680. app.onMessage(message);
  5681. };
  5682. this.socket.onerror = error => {
  5683. app.onError(error);
  5684. };
  5685. this.socket.onclose = close => {
  5686. app.onClose(close);
  5687. };
  5688. application.getWS(this.ws);
  5689. application.sendServerJoin();
  5690. application.sendServerData();
  5691. application.displayLeaderboard('');
  5692. if (window.master && window.master.onConnect) {
  5693. window.master.onConnect();
  5694. }
  5695. },
  5696. onOpen() {
  5697. console.log(`[OGARio by szymy] Game server socket open`);
  5698. this.time = Date.now();
  5699. let view = this.createView(5);
  5700. view.setUint8(0, 254);
  5701. if(!window.game.protocolVersion) window.game.protocolVersion = 22
  5702. view.setUint32(1, 22, true);
  5703. this.sendMessage(view);
  5704. view = this.createView(5);
  5705. view.setUint8(0, 255);
  5706. if(!window.game.clientVersion) window.game.clientVersion = this.clientVersion
  5707. view.setUint32(1, this.clientVersion, true);
  5708. this.sendMessage(view);
  5709. this.connectionOpened = true;
  5710. },
  5711. onMessage(message) {
  5712. message = new DataView(message.data);
  5713. if (this.protocolKey) {
  5714. message = this.shiftMessage(message, this.protocolKey ^ this.clientVersion);
  5715. }
  5716. this.handleMessage(message);
  5717. },
  5718. onError() {
  5719. console.log(`[OGARio by szymy] Game server socket error`);
  5720. this.flushCellsData();
  5721. if (window.master && window.master.onDisconnect) {
  5722. window.master.onDisconnect();
  5723. }
  5724. },
  5725. onClose() {
  5726. console.log('[OGARio by szymy] Game server socket close');
  5727. this.flushCellsData();
  5728. if (window.master && window.master.onDisconnect) {
  5729. window.master.onDisconnect();
  5730. }
  5731. },
  5732. closeConnection() {
  5733. if (this.socket) {
  5734. this.socket.onopen = null;
  5735. this.socket.onmessage = null;
  5736. this.socket.onerror = null;
  5737. this.socket.onclose = null;
  5738. try {
  5739. this.socket.close();
  5740. } catch (error) {}
  5741. this.socket = null;
  5742. this.ws = null;
  5743. }
  5744. },
  5745. isSocketOpen() {
  5746. return this.socket !== null && this.socket.readyState === this.socket.OPEN;
  5747. },
  5748. writeUint32(data, value) {
  5749. while (true) {
  5750. if ((value & -128) == 0) {
  5751. data.push(value);
  5752. return;
  5753. } else {
  5754. data.push(value & 127 | 128);
  5755. value = value >>> 7;
  5756. }
  5757. }
  5758. },
  5759. createView(value) {
  5760. return new DataView(new ArrayBuffer(value));
  5761. },
  5762. sendBuffer(data) {
  5763. this.socket.send(data.buffer);
  5764. },
  5765. sendMessage(message) {
  5766. if (this.connectionOpened) {
  5767. if (!this.clientKey) {
  5768. return;
  5769. }
  5770. message = this.shiftMessage(message, this.clientKey);
  5771. this.clientKey = this.shiftKey(this.clientKey);
  5772. }
  5773. this.sendBuffer(message);
  5774. },
  5775. sendAction(action) {
  5776. if (!this.isSocketOpen()) {
  5777. return;
  5778. }
  5779. const view = this.createView(1);
  5780. view.setUint8(0, action);
  5781. this.sendMessage(view);
  5782. },
  5783. sendSpectate() {
  5784. this.sendAction(1);
  5785. },
  5786. sendFreeSpectate() {
  5787. this.sendAction(18);
  5788. },
  5789. sendEject() {
  5790. this.sendPosition();
  5791. this.sendAction(21);
  5792. },
  5793. sendSplit() {
  5794. this.sendPosition();
  5795. this.sendAction(17);
  5796. },
  5797. addRecaptchaV3() {
  5798. var v3window = document.createElement("div");v3window.id="captchaWindowV3";v3window.style="display:none";
  5799. document.body.appendChild(v3window);
  5800. grecaptcha.render('captchaWindowV3', {
  5801. 'sitekey': '6LcEt74UAAAAAIc_T6dWpsRufGCvvau5Fd7_G1tY',
  5802. 'badge': "inline",
  5803. 'size': "invisible"
  5804. });
  5805. recaptchaExecuteLoop();
  5806. window.myTurn = false;
  5807. },
  5808. sendNick(nick) {
  5809. window.lastNick = nick;
  5810. window.myTurn = true;
  5811. let botServerIsOnline = (window.connection && window.connection.ws && window.connection.ws.readyState === 1);
  5812. if (!botServerIsOnline) recaptchaExecuteLoop();
  5813. },
  5814. _sendNick(nick, token) {
  5815. this.playerNick = nick;
  5816. nick = window.unescape(window.encodeURIComponent(nick));
  5817. const view = this.createView(3 + nick.length + token.length);
  5818. let buftes = [];
  5819. for (let i = 0; i < 3 + nick.length + token.length; i++) buftes.push(0);
  5820. for (let length = 0; length < nick.length; length++) {
  5821. view.setUint8(length + 1, nick.charCodeAt(length));
  5822. //buftes[length+1] = nick.charCodeAt(length)
  5823. }
  5824. for (let len = 0; len < token.length; len++) {
  5825. view.setUint8(nick.length + 2 + len, token.charCodeAt(len));
  5826. //buftes[nick.length + 2 + len] = token.charCodeAt(len);
  5827. }
  5828. this.sendMessage(view);
  5829. //console.log(buftes);
  5830. myTurn=false;
  5831. return recaptchaExecuteLoop();
  5832. },
  5833. sendPosition() {
  5834. if (!this.isSocketOpen() || !this.connectionOpened || !this.clientKey) {
  5835. return;
  5836. }
  5837. let cursorX = this.cursorX;
  5838. let cursorY = this.cursorY;
  5839. window.user.mouseX = cursorX - window.user.offsetX
  5840. window.user.mouseY = cursorY - window.user.offsetY
  5841. if(window.user.startedBots && window.user.isAlive) window.connection.send(window.buffers.mousePosition(window.user.mouseX, window.user.mouseY))
  5842. if (!this.play && this.targeting || this.pause) {
  5843. cursorX = this.targetX;
  5844. cursorY = this.targetY;
  5845. }
  5846. const view = this.createView(13);
  5847. view.setUint8(0, 16);
  5848. view.setInt32(1, cursorX, true);
  5849. view.setInt32(5, cursorY, true);
  5850. view.setUint32(9, this.protocolKey, true);
  5851. this.sendMessage(view);
  5852. },
  5853. sendAccessToken(shapes, options, oW) {
  5854. if (this.accessTokenSent) {
  5855. return;
  5856. }
  5857. if (!oW) {
  5858. oW = 102;
  5859. }
  5860. const curr = shapes.length;
  5861. const count = this.clientVersionString.length;
  5862. let data = [oW, 8, 1, 18];
  5863. this.writeUint32(data, curr + count + 23);
  5864. data.push(8, 10, 82);
  5865. this.writeUint32(data, curr + count + 18);
  5866. data.push(8, options, 18, count + 8, 8, 5, 18, count);
  5867. for (var length = 0; length < count; length++) {
  5868. data.push(this.clientVersionString.charCodeAt(length));
  5869. }
  5870. data.push(24, 0, 32, 0, 26);
  5871. this.writeUint32(data, curr + 3);
  5872. data.push(10);
  5873. this.writeUint32(data, curr);
  5874. for (length = 0; length < curr; length++) {
  5875. data.push(shapes.charCodeAt(length));
  5876. }
  5877. data = new Uint8Array(data);
  5878. const dataView = new DataView(data.buffer);
  5879. this.sendMessage(dataView);
  5880. },
  5881. sendFbToken(token) {
  5882. this.sendAccessToken(token, 2);
  5883. },
  5884. sendGplusToken(token) {
  5885. this.sendAccessToken(token, 4);
  5886. },
  5887. sendRecaptcha(token) {
  5888. const view = this.createView(2 + token.length);
  5889. view.setUint8(0, 86);
  5890. for (let length = 0; length < token.length; length++) {
  5891. view.setUint8(1 + length, token.charCodeAt(length));
  5892. }
  5893. view.setUint8(token.length + 1, 0);
  5894. this.sendMessage(view);
  5895. },
  5896. setClientVersion(version, string) {
  5897. this.clientVersion = version;
  5898. this.clientVersionString = string;
  5899. console.log(`[OGARio by szymy] Client version:`, version, string);
  5900. },
  5901. generateClientKey(ip, options) {
  5902. if (!ip.length || !options.byteLength) {
  5903. return null;
  5904. }
  5905. let x = null;
  5906. const Length = 1540483477;
  5907. const ipCheck = ip.match(/(ws+:\/\/)([^:]*)(:\d+)/)[2];
  5908. const newLength = ipCheck.length + options.byteLength;
  5909. const uint8Arr = new Uint8Array(newLength);
  5910. for (let length = 0; length < ipCheck.length; length++) {
  5911. uint8Arr[length] = ipCheck.charCodeAt(length);
  5912. }
  5913. uint8Arr.set(options, ipCheck.length);
  5914. const dataview = new DataView(uint8Arr.buffer);
  5915. let type = newLength - 1;
  5916. const value = (type - 4 & -4) + 4 | 0;
  5917. let newValue = type ^ 255;
  5918. let offset = 0;
  5919. while (type > 3) {
  5920. x = Math.imul(dataview.getInt32(offset, true), Length) | 0;
  5921. newValue = (Math.imul(x >>> 24 ^ x, Length) | 0) ^ (Math.imul(newValue, Length) | 0);
  5922. type -= 4;
  5923. offset += 4;
  5924. }
  5925. switch (type) {
  5926. case 3:
  5927. newValue = uint8Arr[value + 2] << 16 ^ newValue;
  5928. newValue = uint8Arr[value + 1] << 8 ^ newValue;
  5929. break;
  5930. case 2:
  5931. newValue = uint8Arr[value + 1] << 8 ^ newValue;
  5932. break;
  5933. case 1:
  5934. break;
  5935. default:
  5936. x = newValue;
  5937. break;
  5938. }
  5939. if (x != newValue) {
  5940. x = Math.imul(uint8Arr[value] ^ newValue, Length) | 0;
  5941. }
  5942. newValue = x >>> 13;
  5943. x = newValue ^ x;
  5944. x = Math.imul(x, Length) | 0;
  5945. newValue = x >>> 15;
  5946. x = newValue ^ x;
  5947. console.log(`[OGARio by szymy] Generated client key:`, x);
  5948. return x;
  5949. },
  5950. shiftKey(key) {
  5951. const value = 1540483477;
  5952. key = Math.imul(key, value) | 0;
  5953. key = (Math.imul(key >>> 24 ^ key, value) | 0) ^ 114296087;
  5954. key = Math.imul(key >>> 13 ^ key, value) | 0;
  5955. return key >>> 15 ^ key;
  5956. },
  5957. shiftMessage(view, key, write) {
  5958. if (!write) {
  5959. for (var length = 0; length < view.byteLength; length++) {
  5960. view.setUint8(length, view.getUint8(length) ^ key >>> length % 4 * 8 & 255);
  5961. }
  5962. } else {
  5963. for (var length = 0; length < view.length; length++) {
  5964. view.writeUInt8(view.readUInt8(length) ^ key >>> length % 4 * 8 & 255, length);
  5965. }
  5966. }
  5967. return view;
  5968. },
  5969. decompressMessage(message) {
  5970. const buffer = window.buffer.Buffer;
  5971. const messageBuffer = new buffer(message.buffer);
  5972. const readMessage = new buffer(messageBuffer.readUInt32LE(1));
  5973. LZ4.decodeBlock(messageBuffer.slice(5), readMessage);
  5974. return readMessage;
  5975. },
  5976. handleMessage(view) {
  5977. const encode = () => {
  5978. for (var text = '';;) {
  5979. const string = view.getUint8(offset++);
  5980. if (string == 0) {
  5981. break;
  5982. }
  5983. text += String.fromCharCode(string);
  5984. }
  5985. return text;
  5986. };
  5987. var offset = 0;
  5988. let opCode = view.getUint8(offset++);
  5989. if (opCode == 54) {
  5990. opCode = 53;
  5991. }
  5992. switch (opCode) {
  5993. case 5:
  5994. break;
  5995. case 17:
  5996. this.viewX = view.getFloat32(offset, true);
  5997. offset += 4;
  5998. this.viewY = view.getFloat32(offset, true);
  5999. offset += 4;
  6000. this.scale = view.getFloat32(offset, true);
  6001. break;
  6002. case 18:
  6003. if (this.protocolKey) {
  6004. this.protocolKey = this.shiftKey(this.protocolKey);
  6005. }
  6006. this.flushCellsData();
  6007. break;
  6008. case 32:
  6009. this.playerCellIDs.push(view.getUint32(offset, true));
  6010. if (!this.play) {
  6011. this.play = true;
  6012. application.hideMenu();
  6013. this.playerColor = null;
  6014. application.onPlayerSpawn();
  6015. window.user.isAlive = true
  6016. if(window.user.startedBots) window.connection.send(new Uint8Array([5, Number(window.user.isAlive)]).buffer)
  6017. }
  6018. break;
  6019. case 50:
  6020. this.pieChart = [];
  6021. const pieLength = view.getUint32(offset, true);
  6022. offset += 4;
  6023. for (var length = 0; length < pieLength; length++) {
  6024. this.pieChart.push(view.getFloat32(offset, true));
  6025. offset += 4;
  6026. }
  6027. drawRender.drawPieChart();
  6028. break;
  6029. case 53:
  6030. this.leaderboard = [];
  6031. this.playerPosition = 0;
  6032. if (view.getUint8(0) == 54) {
  6033. const pos = view.getUint16(offset, true);
  6034. offset += 2;
  6035. }
  6036. for (let position = 0; offset < view.byteLength;) {
  6037. var flags = view.getUint8(offset++);
  6038. let nick = '';
  6039. let id = 0;
  6040. let isFriend = false;
  6041. position++;
  6042. if (flags & 2) {
  6043. nick = window.decodeURIComponent(window.escape(encode()));
  6044. }
  6045. if (flags & 4) {
  6046. id = view.getUint32(offset, true);
  6047. offset += 4;
  6048. }
  6049. if (flags & 8) {
  6050. nick = this.playerNick;
  6051. id = `isPlayer`;
  6052. this.playerPosition = position;
  6053. }
  6054. if (flags & 16) {
  6055. isFriend = true;
  6056. }
  6057. this.leaderboard.push({
  6058. nick: nick,
  6059. id: id,
  6060. isFriend: isFriend
  6061. });
  6062. }
  6063. this.handleLeaderboard();
  6064. break;
  6065. case 54:
  6066. break;
  6067. case 69:
  6068. const cellLength = view.getUint16(offset, true);
  6069. offset += 2;
  6070. this.ghostCells = [];
  6071. for (var length = 0; length < cellLength; length++) {
  6072. offset += 8;
  6073. const mass = view.getUint32(offset, true);
  6074. offset += 5;
  6075. this.ghostCells.push({
  6076. mass: mass
  6077. });
  6078. }
  6079. break;
  6080. case 85:
  6081. console.log(`[OGARio by szymy] Captcha requested`);
  6082. if (window.master && window.master.recaptchaRequested) {
  6083. window.master.recaptchaRequested();
  6084. }
  6085. break;
  6086. case 102:
  6087. const node = new Node(view, offset);
  6088. var flags = node.readFlag();
  6089. if (flags == 1) {
  6090. node.setContentType();
  6091. }
  6092. flags = node.readFlag();
  6093. if (flags == 2) {
  6094. node.setUncompressedSize();
  6095. }
  6096. flags = node.readFlag();
  6097. if (flags == 1) {
  6098. const option = node.readUint32();
  6099. const response = node.readFlag();
  6100. const response_2 = node.readUint32();
  6101. switch (option) {
  6102. case 11:
  6103. console.log(`102 login response`, node.view.byteLength, node.contentType, node.uncompressedSize, option, response, response_2);
  6104. break;
  6105. case 62:
  6106. console.log('102 game over');
  6107. break;
  6108. default:
  6109. console.log('102 unknown', option, response);
  6110. }
  6111. }
  6112. if (view.byteLength < 20) {
  6113. this.loggedIn = false;
  6114. window.logout && window.logout();
  6115. }
  6116. break;
  6117. case 103:
  6118. this.accessTokenSent = true;
  6119. break;
  6120. case 114:
  6121. break;
  6122. case 161:
  6123. break;
  6124. case 176:
  6125. this.battleRoyale.startTime = view.getUint32(offset, true);
  6126. break;
  6127. case 177:
  6128. this.battleRoyale.joined = true;
  6129. break;
  6130. case 178:
  6131. this.battleRoyale.players = view.getUint16(offset, true);
  6132. offset += 2;
  6133. var flags = view.getUint16(offset, true);
  6134. offset += 2;
  6135. if (!flags) {
  6136. this.battleRoyale.state = 0;
  6137. this.battleRoyale.joined = false;
  6138. }
  6139. if (flags & 3) {
  6140. this.battleRoyale.state = view.getUint8(offset++);
  6141. this.battleRoyale.x = view.getInt32(offset, true);
  6142. offset += 4;
  6143. this.battleRoyale.y = view.getInt32(offset, true);
  6144. offset += 4;
  6145. this.battleRoyale.radius = view.getUint32(offset, true);
  6146. offset += 4;
  6147. this.battleRoyale.shrinkTime = view.getUint32(offset, true) * 1000;
  6148. offset += 4;
  6149. if (this.battleRoyale.shrinkTime) {
  6150. this.battleRoyale.timeLeft = ~~((this.battleRoyale.shrinkTime - Date.now() + this.serverTimeDiff) / 1000);
  6151. if (this.battleRoyale.timeLeft < 0) {
  6152. this.battleRoyale.timeLeft = 0;
  6153. }
  6154. }
  6155. }
  6156. if (flags & 2) {
  6157. this.battleRoyale.targetX = view.getInt32(offset, true);
  6158. offset += 4;
  6159. this.battleRoyale.targetY = view.getInt32(offset, true);
  6160. offset += 4;
  6161. this.battleRoyale.targetRadius = view.getUint32(offset, true);
  6162. }
  6163. break;
  6164. case 179:
  6165. var flags = view.getUint8(offset);
  6166. const string = window.decodeURIComponent(window.escape(encode()));
  6167. let test = null;
  6168. if (!flags) {
  6169. test = window.decodeURIComponent(window.escape(encode()));
  6170. }
  6171. break;
  6172. case 180:
  6173. this.battleRoyale.joined = false;
  6174. this.battleRoyale.rank = [];
  6175. this.battleRoyale.playerRank = view.getUint32(offset, true);
  6176. offset += 8;
  6177. const royaleLength = view.getUint16(offset, true);
  6178. offset += 2;
  6179. for (var length = 0; length < royaleLength; length++) {
  6180. const name = window.decodeURIComponent(window.escape(encode()));
  6181. const place = view.getUint32(offset, true);
  6182. offset += 4;
  6183. this.battleRoyale.rank.push({
  6184. place: place,
  6185. name: name
  6186. });
  6187. }
  6188. break;
  6189. case 226:
  6190. const ping = view.getUint16(1, true);
  6191. view = this.createView(3);
  6192. view.setUint8(0, 227);
  6193. view.setUint16(1, ping);
  6194. this.sendMessage(view);
  6195. break;
  6196. case 241:
  6197. this.protocolKey = view.getUint32(offset, true);
  6198. console.log('[OGARio by szymy] Received protocol key:', this.protocolKey);
  6199. const agarioReader = new Uint8Array(view.buffer, offset += 4);
  6200. this.clientKey = this.generateClientKey(this.ws, agarioReader);
  6201. if (window.master && window.master.login) {
  6202. window.master.login();
  6203. }
  6204. break;
  6205. case 242:
  6206. this.serverTime = view.getUint32(offset, true) * 1000;
  6207. this.serverTimeDiff = Date.now() - this.serverTime;
  6208. break;
  6209. case 255:
  6210. this.handleSubmessage(view);
  6211. break;
  6212. default:
  6213. console.log(`[OGARio by szymy] Unknown opcode:`, view.getUint8(0));
  6214. break;
  6215. }
  6216. },
  6217. handleSubmessage(message) {
  6218. message = this.decompressMessage(message);
  6219. let offset = 0;
  6220. switch (message.readUInt8(offset++)) {
  6221. case 16:
  6222. this.updateCells(message, offset);
  6223. break;
  6224. case 64:
  6225. this.viewMinX = message.readDoubleLE(offset);
  6226. offset += 8;
  6227. this.viewMinY = message.readDoubleLE(offset);
  6228. offset += 8;
  6229. this.viewMaxX = message.readDoubleLE(offset);
  6230. offset += 8;
  6231. this.viewMaxY = message.readDoubleLE(offset);
  6232. this.setMapOffset(this.viewMinX, this.viewMinY, this.viewMaxX, this.viewMaxY);
  6233. if(~~(this.viewMaxX - this.viewMinX) === 14142 && ~~(this.viewMaxY - this.viewMinY) === 14142){
  6234. window.user.offsetX = (this.viewMinX + this.viewMaxX) / 2
  6235. window.user.offsetY = (this.viewMinY + this.viewMaxY) / 2
  6236. }
  6237. break;
  6238. default:
  6239. console.log(`[OGARio by szymy] Unknown sub opcode:`, message.readUInt8(0));
  6240. break;
  6241. }
  6242. },
  6243. handleLeaderboard() {
  6244. let text = '';
  6245. let teamText = '';
  6246. for (var length = 0; length < this.leaderboard.length; length++) {
  6247. if (length == 10) {
  6248. break;
  6249. }
  6250. let html = '<span>';
  6251. if (this.leaderboard[length].id === `isPlayer`) {
  6252. html = `<span class="me">`;
  6253. } else {
  6254. if (mainProfile.clanTag.length && this.leaderboard[length].nick.indexOf(mainProfile.clanTag) == 0) {
  6255. html = `<span class="teammate">`;
  6256. }
  6257. }
  6258. text += `${html + (length + 1)}. ${application.escapeHTML(this.leaderboard[length].nick)}${`</span>`}`;
  6259. }
  6260. if (this.playerPosition > 10) {
  6261. text += `<span class="me">${this.playerPosition}. ${application.escapeHTML(this.playerNick)}${`</span>`}`;
  6262. }
  6263. if (gameOptionSettings.showLbData) {
  6264. for (var length = 0; length < this.ghostCells.length; length++) {
  6265. if (length == length) {
  6266. break;
  6267. }
  6268. teamText += '<span class="lb-data">';
  6269. teamText += `<span class="top5-mass-color">[` + application.shortMassFormat(this.ghostCells[length].mass) + `]</span>`;
  6270. teamText += `</span>`;
  6271. }
  6272. }
  6273. application.displayLeaderboard(text, teamText);
  6274. },
  6275. flushCellsData() {
  6276. this.indexedCells = {};
  6277. this.cells = [];
  6278. this.playerCells = [];
  6279. this.playerCellIDs = [];
  6280. this.ghostCells = [];
  6281. this.food = [];
  6282. this.viruses = [];
  6283. },
  6284. setMapOffset(left, top, right, bottom) {
  6285. if (right - left > 14000 && bottom - top > 14000) {
  6286. this.mapOffsetX = this.mapOffset - right;
  6287. this.mapOffsetY = this.mapOffset - bottom;
  6288. this.mapMinX = ~~(-this.mapOffset - this.mapOffsetX);
  6289. this.mapMinY = ~~(-this.mapOffset - this.mapOffsetY);
  6290. this.mapMaxX = ~~(this.mapOffset - this.mapOffsetX);
  6291. this.mapMaxY = ~~(this.mapOffset - this.mapOffsetY);
  6292. if (!this.mapOffsetFixed) {
  6293. this.viewX = (right + left) / 2;
  6294. this.viewY = (bottom + top) / 2;
  6295. }
  6296. this.mapOffsetFixed = true;
  6297. console.log(`[OGARio by szymy] Map offset fixed (x, y):`, this.mapOffsetX, this.mapOffsetY);
  6298. }
  6299. },
  6300. updateCells(view, offset) {
  6301. const encode = () => {
  6302. for (var text = '';;) {
  6303. const string = view.readUInt8(offset++);
  6304. if (string == 0) {
  6305. break;
  6306. }
  6307. text += String.fromCharCode(string);
  6308. }
  6309. return text;
  6310. };
  6311. this.time = Date.now();
  6312. this.removePlayerCell = false;
  6313. let eatEventsLength = view.readUInt16LE(offset);
  6314. offset += 2;
  6315. for (var length = 0; length < eatEventsLength; length++) {
  6316. const victimID = this.indexedCells[view.readUInt32LE(offset)];
  6317. const eaterID = this.indexedCells[view.readUInt32LE(offset + 4)];
  6318. offset += 8;
  6319. if (victimID && eaterID) {
  6320. eaterID.targetX = victimID.x;
  6321. eaterID.targetY = victimID.y;
  6322. eaterID.targetSize = eaterID.size;
  6323. eaterID.time = this.time;
  6324. eaterID.removeCell();
  6325. }
  6326. }
  6327. for (length = 0;;) {
  6328. var id = view.readUInt32LE(offset);
  6329. offset += 4;
  6330. if (id == 0) {
  6331. break;
  6332. }
  6333. const x = view.readInt32LE(offset);
  6334. offset += 4;
  6335. const y = view.readInt32LE(offset);
  6336. offset += 4;
  6337. const size = view.readUInt16LE(offset);
  6338. offset += 2;
  6339. const flags = view.readUInt8(offset++);
  6340. let extendedFlags = 0;
  6341. if (flags & 128) {
  6342. extendedFlags = view.readUInt8(offset++);
  6343. }
  6344. let color = null;
  6345. let skin = null;
  6346. let name = '';
  6347. let accountID = null;
  6348. if (flags & 2) {
  6349. const r = view.readUInt8(offset++);
  6350. const g = view.readUInt8(offset++);
  6351. const b = view.readUInt8(offset++);
  6352. color = this.rgb2Hex(~~(r * 0.9), ~~(g * 0.9), ~~(b * 0.9));
  6353. }
  6354. if (flags & 4) {
  6355. skin = encode();
  6356. }
  6357. if (flags & 8) {
  6358. name = window.decodeURIComponent(window.escape(encode()));
  6359. }
  6360. const isVirus = flags & 1;
  6361. const isFood = extendedFlags & 1;
  6362. var cell = null;
  6363. if (this.indexedCells.hasOwnProperty(id)) {
  6364. cell = this.indexedCells[id];
  6365. if (color) {
  6366. cell.color = color;
  6367. }
  6368. } else {
  6369. cell = new Cell(id, x, y, size, color, isFood, isVirus, false, gameOptionSettings.shortMass, gameOptionSettings.virMassShots);
  6370. cell.time = this.time;
  6371. if (!isFood) {
  6372. if (isVirus && gameOptionSettings.virusesRange) {
  6373. this.viruses.push(cell);
  6374. }
  6375. this.cells.push(cell);
  6376. if (this.playerCellIDs.indexOf(id) != -1 && this.playerCells.indexOf(cell) == -1) {
  6377. cell.isPlayerCell = true;
  6378. this.playerColor = color;
  6379. this.playerCells.push(cell);
  6380. }
  6381. } else {
  6382. this.food.push(cell);
  6383. }
  6384. this.indexedCells[id] = cell;
  6385. }
  6386. if (cell.isPlayerCell) {
  6387. name = this.playerNick;
  6388. }
  6389. if (name) {
  6390. cell.targetNick = name;
  6391. }
  6392. cell.targetX = x;
  6393. cell.targetY = y;
  6394. cell.targetSize = size;
  6395. cell.isFood = isFood;
  6396. cell.isVirus = isVirus;
  6397. if (skin) {
  6398. cell.skin = skin;
  6399. }
  6400. if (extendedFlags & 4) {
  6401. accountID = view.readUInt32LE(offset);
  6402. offset += 4;
  6403. }
  6404. }
  6405. eatEventsLength = view.readUInt16LE(offset);
  6406. offset += 2;
  6407. for (length = 0; length < eatEventsLength; length++) {
  6408. var id = view.readUInt32LE(offset);
  6409. offset += 4;
  6410. cell = this.indexedCells[id];
  6411. if (cell) {
  6412. cell.removeCell();
  6413. }
  6414. }
  6415. if (this.removePlayerCell && !this.playerCells.length) {
  6416. this.play = false;
  6417. application.onPlayerDeath();
  6418. application.showMenu(300);
  6419. window.user.isAlive = false
  6420. if(window.user.startedBots) window.connection.send(new Uint8Array([5, Number(window.user.isAlive)]).buffer)
  6421. }
  6422. },
  6423. color2Hex(number) {
  6424. const color = number.toString(16);
  6425. return color.length == 1 ? `0${color}` : color;
  6426. },
  6427. rgb2Hex(r, g, b) {
  6428. return `#${this.color2Hex(r)}${this.color2Hex(g)}${this.color2Hex(b)}`;
  6429. },
  6430. sortCells() {
  6431. this.cells.sort((row, conf) => row.size == conf.size ? row.id - conf.id : row.size - conf.size);
  6432. },
  6433. calculatePlayerMassAndPosition() {
  6434. let size = 0;
  6435. let targetSize = 0;
  6436. let x = 0;
  6437. let y = 0;
  6438. const playersLength = this.playerCells.length;
  6439. for (let length = 0; length < playersLength; length++) {
  6440. const currentPlayer = this.playerCells[length];
  6441. size += currentPlayer.size;
  6442. targetSize += currentPlayer.targetSize * currentPlayer.targetSize;
  6443. x += currentPlayer.x / playersLength;
  6444. y += currentPlayer.y / playersLength;
  6445. }
  6446. this.viewX = x;
  6447. this.viewY = y;
  6448. this.playerSize = size;
  6449. this.playerMass = ~~(targetSize / 100);
  6450. this.recalculatePlayerMass();
  6451. },
  6452. recalculatePlayerMass() {
  6453. this.playerScore = Math.max(this.playerScore, this.playerMass);
  6454. if (gameOptionSettings.virColors || gameOptionSettings.splitRange || gameOptionSettings.oppColors || gameOptionSettings.oppRings || gameOptionSettings.showStatsSTE) {
  6455. const cells = this.playerCells;
  6456. const CellLength = cells.length;
  6457. cells.sort((row, conf) => row.size == conf.size ? row.id - conf.id : row.size - conf.size);
  6458. this.playerMinMass = ~~(cells[0].size * cells[0].size / 100);
  6459. this.playerMaxMass = ~~(cells[CellLength - 1].size * cells[CellLength - 1].size / 100);
  6460. this.playerSplitCells = CellLength;
  6461. }
  6462. if (gameOptionSettings.showStatsSTE) {
  6463. const mass = this.selectBiggestCell ? this.playerMaxMass : this.playerMinMass;
  6464. if (mass > 35) {
  6465. this.STE = ~~(mass * (mass < 1000 ? 0.35 : 0.38));
  6466. } else {
  6467. this.STE = null;
  6468. }
  6469. }
  6470. },
  6471. compareCells() {
  6472. if (!this.play) {
  6473. return;
  6474. }
  6475. if (gameOptionSettings.oppColors || gameOptionSettings.oppRings || gameOptionSettings.splitRange) {
  6476. if (gameOptionSettings.oppRings || gameOptionSettings.splitRange) {
  6477. this.biggerSTECellsCache = [];
  6478. this.biggerCellsCache = [];
  6479. this.smallerCellsCache = [];
  6480. this.STECellsCache = [];
  6481. }
  6482.  
  6483. for (const cell of this.cells) {
  6484. if (cell.isVirus) {
  6485. continue;
  6486. }
  6487. const size = ~~(cell.size * cell.size / 100);
  6488. const mass = this.selectBiggestCell ? this.playerMaxMass : this.playerMinMass;
  6489. const fixMass = size / mass;
  6490. const smallMass = mass < 1000 ? 0.35 : 0.38;
  6491. if (gameOptionSettings.oppColors && !gameOptionSettings.oppRings) {
  6492. cell.oppColor = this.setCellOppColor(cell.isPlayerCell, fixMass, smallMass);
  6493. }
  6494. if (!cell.isPlayerCell && (gameOptionSettings.splitRange || gameOptionSettings.oppRings)) {
  6495. this.cacheCells(cell.x, cell.y, cell.size, fixMass, smallMass);
  6496. }
  6497. }
  6498. }
  6499. },
  6500. cacheCells(x, y, size, mass, smallMass) {
  6501. if (mass >= 2.5) {
  6502. this.biggerSTECellsCache.push({
  6503. x: x,
  6504. y: y,
  6505. size: size
  6506. });
  6507. return;
  6508. } else if (mass >= 1.25) {
  6509. this.biggerCellsCache.push({
  6510. x: x,
  6511. y: y,
  6512. size: size
  6513. });
  6514. return;
  6515. } else if (mass < 1.25 && mass > 0.75) {
  6516. return;
  6517. } else if (mass > smallMass) {
  6518. this.smallerCellsCache.push({
  6519. x: x,
  6520. y: y,
  6521. size: size
  6522. });
  6523. return;
  6524. } else {
  6525. this.STECellsCache.push({
  6526. x: x,
  6527. y: y,
  6528. size: size
  6529. });
  6530. return;
  6531. }
  6532. },
  6533. setCellOppColor(isPlayer, mass, smallMass) {
  6534. if (isPlayer) {
  6535. return mainProfile.color;
  6536. }
  6537. if (mass > 11) {
  6538. return `#FF008C`;
  6539. } else if (mass >= 2.5) {
  6540. return `#BE00FF`;
  6541. } else if (mass >= 1.25) {
  6542. return `#FF0A00`;
  6543. } else if (mass < 1.25 && mass > 0.75) {
  6544. return `#FFDC00`;
  6545. } else if (mass > smallMass) {
  6546. return `#00C8FF`;
  6547. } else {
  6548. return `#64FF00`;
  6549. }
  6550. },
  6551. getCursorPosition() {
  6552. this.cursorX = (this.clientX - this.canvasWidth / 2) / this.viewScale + this.viewX;
  6553. this.cursorY = (this.clientY - this.canvasHeight / 2) / this.viewScale + this.viewY;
  6554. },
  6555. setZoom(event) {
  6556. this.zoomValue *= gameOptionSettings.zoomSpeedValue ** (event.wheelDelta / -120 || event.detail || 0);
  6557. if (this.zoomValue > 4 / this.viewScale) {
  6558. this.zoomValue = 4 / this.viewScale;
  6559. }
  6560. },
  6561. setTargetPosition(x, y) {
  6562. this.targetX = x - this.mapOffsetX;
  6563. this.targetY = y - this.mapOffsetY;
  6564. this.targetDistance = Math.round(Math.sqrt((this.playerX - this.targetX) ** 2 + (this.playerY - this.targetY) ** 2));
  6565. },
  6566. resetTargetPosition() {
  6567. this.targetX = this.playerX;
  6568. this.targetY = this.playerY;
  6569. },
  6570. setKeys() {
  6571. const app = this;
  6572. document.onkeydown = event => {
  6573. const key = event.keyCode;
  6574. if (app.pressedKeys[key]) {
  6575. return;
  6576. }
  6577. switch (key) {
  6578. case 13:
  6579. app.sendNick('');
  6580. break;
  6581. case 32:
  6582. app.sendSplit();
  6583. break;
  6584. case 81:
  6585. app.sendFreeSpectate();
  6586. break;
  6587. case 83:
  6588. app.sendSpectate();
  6589. break;
  6590. case 87:
  6591. app.sendEject();
  6592. break;
  6593. }
  6594. };
  6595. document.onkeyup = event => {
  6596. app.pressedKeys[event.keyCode] = false;
  6597. };
  6598. },
  6599. init() {
  6600. const app = this;
  6601. if (/firefox/i .test(navigator.userAgent)) {
  6602. document.addEventListener(`DOMMouseScroll`, value => {
  6603. app.setZoom(value);
  6604. }, false);
  6605. } else {
  6606. document.body.onmousewheel = value => {
  6607. app.setZoom(value);
  6608. };
  6609. }
  6610. setInterval(() => {
  6611. app.sendPosition();
  6612. }, 40);
  6613. if (window.master && window.master.clientVersion) {
  6614. this.setClientVersion(window.master.clientVersion, window.master.clientVersionString);
  6615. }
  6616. }
  6617. };
  6618. window.sendAction = action => {
  6619. Connection.sendAction(action);
  6620. };
  6621. var drawRender = {
  6622. canvas: null,
  6623. ctx: null,
  6624. canvasWidth: 0,
  6625. canvasHeight: 0,
  6626. camX: 0,
  6627. camY: 0,
  6628. scale: 1,
  6629. fpsLastRequest: null,
  6630. renderedFrames: 0,
  6631. fps: 0,
  6632. pi2: 2 * Math.PI,
  6633. battleAreaMap: null,
  6634. battleAreaMapCtx: null,
  6635. pieChart: null,
  6636. pellet: null,
  6637. indicator: null,
  6638. setCanvas() {
  6639. this.canvas = document.getElementById(`canvas`);
  6640. this.ctx = this.canvas.getContext('2d');
  6641. this.canvas.onmousemove = event => {
  6642. Connection.clientX = event.clientX;
  6643. Connection.clientY = event.clientY;
  6644. Connection.getCursorPosition();
  6645. };
  6646. },
  6647. resizeCanvas() {
  6648. this.canvasWidth = window.innerWidth;
  6649. this.canvasHeight = window.innerHeight;
  6650. this.canvas.width = this.canvasWidth;
  6651. this.canvas.height = this.canvasHeight;
  6652. Connection.canvasWidth = this.canvasWidth;
  6653. Connection.canvasHeight = this.canvasHeight;
  6654. this.renderFrame();
  6655. },
  6656. setView() {
  6657. this.setScale();
  6658. if (Connection.playerCells.length) {
  6659. Connection.calculatePlayerMassAndPosition();
  6660. this.camX = (this.camX + Connection.viewX) / 2;
  6661. this.camY = (this.camY + Connection.viewY) / 2;
  6662. } else {
  6663. this.camX = (29 * this.camX + Connection.viewX) / 30;
  6664. this.camY = (29 * this.camY + Connection.viewY) / 30;
  6665. }
  6666. Connection.playerX = this.camX;
  6667. Connection.playerY = this.camY;
  6668. },
  6669. setScale() {
  6670. if (!Connection.autoZoom) {
  6671. this.scale = (9 * this.scale + this.getZoom()) / 10;
  6672. Connection.viewScale = this.scale;
  6673. return;
  6674. }
  6675. if (Connection.play) {
  6676. this.scale = (9 * this.scale + Math.min(64 / Connection.playerSize, 1) ** 0.4 * this.getZoom()) / 10;
  6677. } else {
  6678. this.scale = (9 * this.scale + Connection.scale * this.getZoom()) / 10;
  6679. }
  6680. Connection.viewScale = this.scale;
  6681. },
  6682. getZoom() {
  6683. return Math.max(this.canvasWidth / 1080, this.canvasHeight / 1920) * Connection.zoomValue;
  6684. },
  6685. renderFrame() {
  6686. Connection.time = Date.now();
  6687. for (length = 0; length < Connection.cells.length; length++) {
  6688. Connection.cells[length].moveCell();
  6689. }
  6690. this.setView();
  6691. Connection.getCursorPosition();
  6692. Connection.sortCells();
  6693. Connection.compareCells();
  6694. this.ctx.clearRect(0, 0, this.canvasWidth, this.canvasHeight);
  6695. if (gameOptionSettings.showGrid) {
  6696. this.drawGrid(this.ctx, this.canvasWidth, this.canvasHeight, this.scale, this.camX, this.camY);
  6697. }
  6698. this.ctx.save();
  6699. this.ctx.translate(this.canvasWidth / 2, this.canvasHeight / 2);
  6700. this.ctx.scale(this.scale, this.scale);
  6701. this.ctx.translate(-this.camX, -this.camY);
  6702. if (gameOptionSettings.showBgSectors) {
  6703. this.drawSectors(this.ctx, Connection.mapOffsetFixed, gameSetupTheme.sectorsX, gameSetupTheme.sectorsY, Connection.mapMinX, Connection.mapMinY, Connection.mapMaxX, Connection.mapMaxY, gameSetupTheme.gridColor, gameSetupTheme.sectorsColor, gameSetupTheme.sectorsWidth, true);
  6704. }
  6705. if (Connection.gameMode === ':battleroyale') {
  6706. this.drawBattleArea(this.ctx);
  6707. }
  6708. if (gameOptionSettings.showMapBorders) {
  6709. const borderWidth = gameSetupTheme.bordersWidth / 2;
  6710. this.drawMapBorders(this.ctx, Connection.mapOffsetFixed, Connection.mapMinX - borderWidth, Connection.mapMinY - borderWidth, Connection.mapMaxX + borderWidth, Connection.mapMaxY + borderWidth, gameSetupTheme.bordersColor, gameSetupTheme.bordersWidth);
  6711. }
  6712. if (gameOptionSettings.virusesRange) {
  6713. this.drawVirusesRange(this.ctx, Connection.viruses);
  6714. }
  6715. this.drawFood();
  6716. if (Connection.play) {
  6717. if (gameOptionSettings.splitRange) {
  6718. this.drawSplitRange(this.ctx, Connection.biggerSTECellsCache, Connection.playerCells, Connection.selectBiggestCell);
  6719. }
  6720. if (gameOptionSettings.oppRings) {
  6721. this.drawOppRings(this.ctx, this.scale, Connection.biggerSTECellsCache, Connection.biggerCellsCache, Connection.smallerCellsCache, Connection.STECellsCache);
  6722. }
  6723. if (gameOptionSettings.cursorTracking) {
  6724. this.drawCursorTracking(this.ctx, Connection.playerCells, Connection.cursorX, Connection.cursorY);
  6725. }
  6726. }
  6727. for (var length = 0; length < Connection.removedCells.length; length++) {
  6728. Connection.removedCells[length].draw(this.ctx, true);
  6729. }
  6730. for (length = 0; length < Connection.cells.length; length++) {
  6731. Connection.cells[length].draw(this.ctx);
  6732. }
  6733. this.ctx.restore();
  6734. if (Connection.gameMode === `:teams`) {
  6735. if (this.pieChart && this.pieChart.width) {
  6736. this.ctx.drawImage(this.pieChart, this.canvasWidth - this.pieChart.width - 10, 10);
  6737. }
  6738. }
  6739. },
  6740. drawGrid(ctx, width, heigth, scale, camX, camY) {
  6741. const reWidth = width / scale;
  6742. const reHeigth = heigth / scale;
  6743. let x = (-camX + reWidth / 2) % 50;
  6744. let y = (-camY + reHeigth / 2) % 50;
  6745. ctx.strokeStyle = gameSetupTheme.gridColor;
  6746. ctx.globalAlpha = 1 * scale;
  6747. ctx.beginPath();
  6748. for (; x < reWidth; x += 50) {
  6749. ctx.moveTo(x * scale - 0.5, 0);
  6750. ctx.lineTo(x * scale - 0.5, reHeigth * scale);
  6751. }
  6752. for (; y < reHeigth; y += 50) {
  6753. ctx.moveTo(0, y * scale - 0.5);
  6754. ctx.lineTo(reWidth * scale, y * scale - 0.5);
  6755. }
  6756. ctx.stroke();
  6757. ctx.globalAlpha = 1;
  6758. },
  6759. drawSectors(ctx, mapOffset, x, y, minX, minY, maxX, maxY, stroke, color, width, type) {
  6760. if (!mapOffset && type) {
  6761. return;
  6762. }
  6763. const posX = ~~((maxX - minX) / x);
  6764. const posY = ~~((maxY - minY) / y);
  6765. let rePosX = 0;
  6766. let rePosY = 0;
  6767. ctx.strokeStyle = stroke;
  6768. ctx.fillStyle = color;
  6769. ctx.lineWidth = width;
  6770. if (type || !type && gameOptionSettings.showMiniMapGrid) {
  6771. ctx.beginPath();
  6772. for (var length = 0; length < x + 1; length++) {
  6773. rePosX = minX + posX * length;
  6774. ctx.moveTo(length == x ? maxX : rePosX, minY);
  6775. ctx.lineTo(length == x ? maxX : rePosX, maxY);
  6776. }
  6777. for (var length = 0; length < y + 1; length++) {
  6778. rePosY = minY + posY * length;
  6779. ctx.moveTo(minX - width / 2, length == y ? maxY : rePosY);
  6780. ctx.lineTo(maxX + width / 2, length == y ? maxY : rePosY);
  6781. }
  6782. ctx.stroke();
  6783. } else {
  6784. this.drawMapBorders(ctx, mapOffset, minX, minY, maxX, maxY, stroke, width);
  6785. }
  6786. if (type) {
  6787. ctx.font = `${gameSetupTheme.sectorsFontWeight} ${gameSetupTheme.sectorsFontSize}${`px `}${gameSetupTheme.sectorsFontFamily}`;
  6788. } else {
  6789. ctx.font = `${gameSetupTheme.miniMapFontWeight} ${~~(0.4 * posY)}${`px `}${gameSetupTheme.miniMapFontFamily}`;
  6790. }
  6791. ctx.textAlign = 'center';
  6792. ctx.textBaseline = `middle`;
  6793. for (var length = 0; length < y; length++) {
  6794. for (let length_2 = 0; length_2 < x; length_2++) {
  6795. const text = String.fromCharCode(65 + length) + (length_2 + 1);
  6796. rePosX = ~~(minX + posX / 2 + length_2 * posX);
  6797. rePosY = ~~(minY + posY / 2 + length * posY);
  6798. ctx.fillText(text, rePosX, rePosY);
  6799. }
  6800. }
  6801. },
  6802. drawMapBorders(ctx, mapOffset, minX, minY, maxX, maxY, stroke, width) {
  6803. if (!mapOffset) {
  6804. return;
  6805. }
  6806. ctx.strokeStyle = stroke;
  6807. ctx.lineWidth = width;
  6808. ctx.beginPath();
  6809. ctx.moveTo(minX, minY);
  6810. ctx.lineTo(maxX, minY);
  6811. ctx.lineTo(maxX, maxY);
  6812. ctx.lineTo(minX, maxY);
  6813. ctx.closePath();
  6814. ctx.stroke();
  6815. },
  6816. drawVirusesRange(ctx, viruses, reset) {
  6817. if (!viruses.length) {
  6818. return;
  6819. }
  6820. ctx.beginPath();
  6821. for (let length = 0; length < viruses.length; length++) {
  6822. const x = viruses[length].x;
  6823. const y = viruses[length].y;
  6824. ctx.moveTo(x, y);
  6825. ctx.arc(x, y, viruses[length].size + 820, 0, this.pi2, false);
  6826. }
  6827. ctx.fillStyle = gameSetupTheme.virusColor;
  6828. ctx.globalAlpha = 0.1;
  6829. ctx.fill();
  6830. ctx.globalAlpha = 1;
  6831. if (reset) {
  6832. viruses = [];
  6833. }
  6834. },
  6835. drawFood() {
  6836. if (!Connection.showFood || gameOptionSettings.autoHideFoodOnZoom && this.scale < 0.2) {
  6837. return;
  6838. }
  6839. if (gameOptionSettings.autoHideFood && !Connection.foodIsHidden && Connection.playerMass > 1000) {
  6840. Connection.showFood = false;
  6841. Connection.foodIsHidden = true;
  6842. return;
  6843. }
  6844. if (!gameOptionSettings.rainbowFood) {
  6845. this.drawCachedFood(this.ctx, Connection.food, this.scale);
  6846. return;
  6847. }
  6848. for (let length = 0; length < Connection.food.length; length++) {
  6849. Connection.food[length].moveCell();
  6850. Connection.food[length].draw(this.ctx);
  6851. }
  6852. },
  6853. drawCachedFood(ctx, food, scale, reset) {
  6854. if (!food.length) {
  6855. return;
  6856. }
  6857. if (gameOptionSettings.optimizedFood && this.pellet) {
  6858. for (var length = 0; length < food.length; length++) {
  6859. var x = food[length].x - 10 - gameSetupTheme.foodSize;
  6860. var y = food[length].y - 10 - gameSetupTheme.foodSize;
  6861. ctx.drawImage(this.pellet, x, y);
  6862. }
  6863. } else {
  6864. ctx.beginPath();
  6865. for (var length = 0; length < food.length; length++) {
  6866. var x = food[length].x;
  6867. var y = food[length].y;
  6868. ctx.moveTo(x, y);
  6869. if (scale < 0.16) {
  6870. const size = food[length].size + gameSetupTheme.foodSize;
  6871. ctx.rect(x - size, y - size, 2 * size, 2 * size);
  6872. continue;
  6873. }
  6874. ctx.arc(x, y, food[length].size + gameSetupTheme.foodSize, 0, this.pi2, false);
  6875. }
  6876. ctx.fillStyle = gameSetupTheme.foodColor;
  6877. ctx.globalAlpha = 1;
  6878. ctx.fill();
  6879. }
  6880. if (reset) {
  6881. food = [];
  6882. }
  6883. },
  6884. drawSplitRange(ctx, biggestCell, players, currentBiggestCell, reset) {
  6885. this.drawCircles(ctx, biggestCell, 760, 4, 0.4, `#BE00FF`);
  6886. if (players.length) {
  6887. const current = currentBiggestCell ? players.length - 1 : 0;
  6888. ctx.lineWidth = 6;
  6889. ctx.globalAlpha = gameSetupTheme.darkTheme ? 0.7 : 0.35;
  6890. ctx.strokeStyle = gameSetupTheme.splitRangeColor;
  6891. ctx.beginPath();
  6892. ctx.arc(players[current].x, players[current].y, players[current].size + 760, 0, this.pi2, false);
  6893. ctx.closePath();
  6894. ctx.stroke();
  6895. }
  6896. ctx.globalAlpha = 1;
  6897. if (reset) {
  6898. biggestCell = [];
  6899. }
  6900. },
  6901. drawOppRings(ctx, scale, biggerSte, biggetCell, smallerCell, smallSte, reset) {
  6902. const width = 14 + 2 / scale;
  6903. const alpha = 12 + 1 / scale;
  6904. this.drawCircles(ctx, biggerSte, width, alpha, 0.75, `#BE00FF`);
  6905. this.drawCircles(ctx, biggetCell, width, alpha, 0.75, `#FF0A00`);
  6906. this.drawCircles(ctx, smallerCell, width, alpha, 0.75, '#00C8FF');
  6907. this.drawCircles(ctx, smallSte, width, alpha, 0.75, `#64FF00`);
  6908. if (reset) {
  6909. biggerSte = [];
  6910. biggetCell = [];
  6911. smallerCell = [];
  6912. smallSte = [];
  6913. }
  6914. },
  6915. drawCursorTracking(ctx, players, cursorX, cursorY) {
  6916. ctx.lineWidth = 4;
  6917. ctx.globalAlpha = gameSetupTheme.darkTheme ? 0.75 : 0.35;
  6918. ctx.strokeStyle = gameSetupTheme.cursorTrackingColor;
  6919. ctx.beginPath();
  6920. for (let length = 0; length < players.length; length++) {
  6921. ctx.moveTo(players[length].x, players[length].y);
  6922. ctx.lineTo(cursorX, cursorY);
  6923. }
  6924. ctx.stroke();
  6925. ctx.globalAlpha = 1;
  6926. },
  6927. drawCircles(ctx, players, scale, width, alpha, stroke) {
  6928. ctx.lineWidth = width;
  6929. ctx.globalAlpha = alpha;
  6930. ctx.strokeStyle = stroke;
  6931. for (let length = 0; length < players.length; length++) {
  6932. ctx.beginPath();
  6933. ctx.arc(players[length].x, players[length].y, players[length].size + scale, 0, this.pi2, false);
  6934. ctx.closePath();
  6935. ctx.stroke();
  6936. }
  6937. ctx.globalAlpha = 1;
  6938. },
  6939. drawDashedCircle(ctx, x, y, radius, times, width, color) {
  6940. const pi2 = this.pi2 / times;
  6941. ctx.lineWidth = width;
  6942. ctx.strokeStyle = color;
  6943. for (let length = 0; length < times; length += 2) {
  6944. ctx.beginPath();
  6945. ctx.arc(x, y, radius - width / 2, length * pi2, (length + 1) * pi2, false);
  6946. ctx.stroke();
  6947. }
  6948. },
  6949. drawTeammatesInd(ctx, x, y, size) {
  6950. if (!this.indicator) {
  6951. return;
  6952. }
  6953. ctx.drawImage(this.indicator, x - 45, y - size - 90);
  6954. },
  6955. drawPieChart() {
  6956. if (!this.pieChart) {
  6957. this.pieChart = document.createElement(`canvas`);
  6958. }
  6959. const ctx = this.pieChart.getContext('2d');
  6960. const mincanvasWidth = Math.min(200, 0.3 * this.canvasWidth) / 200;
  6961. this.pieChart.width = 200 * mincanvasWidth;
  6962. this.pieChart.height = 240 * mincanvasWidth;
  6963. ctx.scale(mincanvasWidth, mincanvasWidth);
  6964. const colors = [`#333333`, '#FF3333', '#33FF33', `#3333FF`];
  6965. for (let time = 0, length = 0; length < Connection.pieChart.length; length++) {
  6966. const currentPie = time + Connection.pieChart[length] * this.pi2;
  6967. ctx.fillStyle = colors[length + 1];
  6968. ctx.beginPath();
  6969. ctx.moveTo(100, 140);
  6970. ctx.arc(100, 140, 80, time, currentPie, false);
  6971. ctx.fill();
  6972. time = currentPie;
  6973. }
  6974. },
  6975. drawBattleArea(ctx) {
  6976. if (!Connection.battleRoyale.state) {
  6977. return;
  6978. }
  6979. this.drawDangerArea(ctx, Connection.battleRoyale.x, Connection.battleRoyale.y, Connection.battleRoyale.radius, Connection.mapMinX, Connection.mapMinY, Connection.mapMaxX - Connection.mapMinX, Connection.mapMaxY - Connection.mapMinY, gameSetupTheme.dangerAreaColor, 0.25);
  6980. this.drawSafeArea(ctx, Connection.battleRoyale.targetX, Connection.battleRoyale.targetY, Connection.battleRoyale.targetRadius, 40, gameSetupTheme.safeAreaColor);
  6981. },
  6982. drawBattleAreaOnMinimap(ctx, width, heigth, newWidth, offsetX, offsetY) {
  6983. if (!Connection.battleRoyale.state) {
  6984. return;
  6985. }
  6986. if (!this.battleAreaMap) {
  6987. this.battleAreaMap = document.createElement(`canvas`);
  6988. this.battleAreaMapCtx = this.battleAreaMap.getContext('2d');
  6989. }
  6990. if (this.battleAreaMap.width != width) {
  6991. this.battleAreaMap.width = width;
  6992. this.battleAreaMap.height = heigth;
  6993. } else {
  6994. this.battleAreaMapCtx.clearRect(0, 0, width, heigth);
  6995. }
  6996. let newX = (Connection.battleRoyale.x + offsetX) * newWidth;
  6997. let newY = (Connection.battleRoyale.y + offsetY) * newWidth;
  6998. let newRadius = Connection.battleRoyale.radius * newWidth;
  6999. this.drawDangerArea(this.battleAreaMapCtx, newX, newY, newRadius, 0, 0, width, heigth, gameSetupTheme.dangerAreaColor, 0.25);
  7000. newX = ~~((Connection.battleRoyale.targetX + offsetX) * newWidth);
  7001. newY = ~~((Connection.battleRoyale.targetY + offsetY) * newWidth);
  7002. newRadius = ~~(Connection.battleRoyale.targetRadius * newWidth);
  7003. this.drawSafeArea(this.battleAreaMapCtx, newX, newY, newRadius, 2, gameSetupTheme.safeAreaColor);
  7004. ctx.drawImage(this.battleAreaMap, 0, 0);
  7005. },
  7006. drawDangerArea(ctx, x, y, radius, minX, minY, maxX, maxY, color, aplha) {
  7007. if (Connection.battleRoyale.radius == Connection.battleRoyale.maxRadius || radius <= 0) {
  7008. return;
  7009. }
  7010. ctx.save();
  7011. ctx.globalAlpha = aplha;
  7012. ctx.fillStyle = color;
  7013. ctx.fillRect(minX, minY, maxX, maxY);
  7014. ctx.globalCompositeOperation = 'destination-out';
  7015. ctx.globalAlpha = 1;
  7016. ctx.beginPath();
  7017. ctx.arc(x, y, radius, 0, this.pi2, false);
  7018. ctx.fill();
  7019. ctx.restore();
  7020. },
  7021. drawSafeArea(ctx, targetX, targetY, radius, width, color) {
  7022. if (Connection.battleRoyale.state > 2 || radius <= 0) {
  7023. return;
  7024. }
  7025. this.drawDashedCircle(ctx, targetX, targetY, radius, 60, width, color);
  7026. },
  7027. drawGhostCells() {
  7028. if (!gameOptionSettings.showGhostCells) {
  7029. return;
  7030. }
  7031. const ghostsCells = Connection.ghostCells;
  7032. this.ctx.beginPath();
  7033. for (let length = 0; length < ghostsCells.length; length++) {
  7034. if (ghostsCells[length].inView) {
  7035. continue;
  7036. }
  7037. const x = ghostsCells[length].x;
  7038. const y = ghostsCells[length].y;
  7039. this.ctx.moveTo(x, y);
  7040. this.ctx.arc(x, y, ghostsCells[length].size, 0, this.pi2, false);
  7041. }
  7042. this.ctx.fillStyle = gameSetupTheme.ghostCellsColor;
  7043. this.ctx.globalAlpha = gameSetupTheme.ghostCellsAlpha;
  7044. this.ctx.shadowColor = gameSetupTheme.ghostCellsColor;
  7045. this.ctx.shadowBlur = 40;
  7046. this.ctx.shadowOffsetX = 0;
  7047. this.ctx.shadowOffsetY = 0;
  7048. this.ctx.fill();
  7049. this.ctx.globalAlpha = 1;
  7050. this.ctx.shadowBlur = 0;
  7051. },
  7052. preDrawPellet() {
  7053. this.pellet = null;
  7054. const size = 10 + gameSetupTheme.foodSize;
  7055. let canvas = document.createElement(`canvas`);
  7056. canvas.width = size * 2;
  7057. canvas.height = size * 2;
  7058. const ctx = canvas.getContext('2d');
  7059. ctx.arc(size, size, size, 0, this.pi2, false);
  7060. ctx.fillStyle = gameSetupTheme.foodColor;
  7061. ctx.fill();
  7062. this.pellet = new Image();
  7063. this.pellet.src = canvas.toDataURL();
  7064. canvas = null;
  7065. },
  7066. preDrawIndicator() {
  7067. this.indicator = null;
  7068. let canvas = document.createElement('canvas');
  7069. canvas.width = 90;
  7070. canvas.height = 50;
  7071. const ctx = canvas.getContext('2d');
  7072. ctx.lineWidth = 2;
  7073. ctx.fillStyle = gameSetupTheme.teammatesIndColor;
  7074. ctx.strokeStyle = `#000000`;
  7075. ctx.beginPath();
  7076. ctx.moveTo(0, 0);
  7077. ctx.lineTo(90, 0);
  7078. ctx.lineTo(45, 50);
  7079. ctx.closePath();
  7080. ctx.fill();
  7081. ctx.stroke();
  7082. this.indicator = new Image();
  7083. this.indicator.src = canvas.toDataURL();
  7084. canvas = null;
  7085. },
  7086. countFps() {
  7087. if (!gameOptionSettings.showStatsFPS) {
  7088. return;
  7089. }
  7090. const Time = Date.now();
  7091. if (!this.fpsLastRequest) {
  7092. this.fpsLastRequest = Time;
  7093. }
  7094. if (Time - this.fpsLastRequest >= 1000) {
  7095. this.fps = this.renderedFrames;
  7096. this.renderedFrames = 0;
  7097. this.fpsLastRequest = Time;
  7098. }
  7099. this.renderedFrames++;
  7100. },
  7101. render() {
  7102. drawRender.countFps();
  7103. drawRender.renderFrame();
  7104. window.requestAnimationFrame(drawRender.render);
  7105. },
  7106. init() {
  7107. this.setCanvas();
  7108. this.resizeCanvas();
  7109. this.preDrawPellet();
  7110. this.preDrawIndicator();
  7111. window.requestAnimationFrame(drawRender.render);
  7112. }
  7113. };
  7114. const keyBlind = {};
  7115. var hotkeys = {};
  7116. const hotkeysCommand = {
  7117. 'hk-bots-split': {
  7118. label: textLanguage[`hk-bots-split`],
  7119. defaultKey: 'T',
  7120. keyDown() {
  7121. if(window.user.startedBots && window.user.isAlive) window.connection.send(new Uint8Array([2]).buffer)
  7122. },
  7123. keyUp: null,
  7124. type: 'normal'
  7125. },
  7126. 'hk-bots-feed': {
  7127. label: textLanguage[`hk-bots-feed`],
  7128. defaultKey: 'A',
  7129. keyDown() {
  7130. if(window.user.startedBots && window.user.isAlive) window.connection.send(new Uint8Array([3]).buffer)
  7131. },
  7132. keyUp: null,
  7133. type: 'normal'
  7134. },
  7135. 'hk-bots-ai': {
  7136. label: textLanguage[`hk-bots-ai`],
  7137. defaultKey: 'F',
  7138. keyDown() {
  7139. if(window.user.startedBots && window.user.isAlive){
  7140. if(!window.bots.ai){
  7141. document.getElementById('botsAI').style.color = '#00C02E'
  7142. document.getElementById('botsAI').innerText = 'Enabled'
  7143. window.bots.ai = true
  7144. window.connection.send(new Uint8Array([4, Number(window.bots.ai)]).buffer)
  7145. }
  7146. else {
  7147. document.getElementById('botsAI').style.color = '#DA0A00'
  7148. document.getElementById('botsAI').innerText = 'Disabled'
  7149. window.bots.ai = false
  7150. window.connection.send(new Uint8Array([4, Number(window.bots.ai)]).buffer)
  7151. }
  7152. }
  7153. },
  7154. keyUp: null,
  7155. type: 'normal'
  7156. },
  7157. 'hk-feed': {
  7158. label: textLanguage[`hk-feed`],
  7159. defaultKey: 'W',
  7160. keyDown() {
  7161. application && application.feed();
  7162. },
  7163. keyUp: null,
  7164. type: 'normal'
  7165. },
  7166. 'hk-macroFeed': {
  7167. label: textLanguage[`hk-macroFeed`],
  7168. defaultKey: 'E',
  7169. keyDown() {
  7170. application && application.macroFeed(true);
  7171. },
  7172. keyUp() {
  7173. application && application.macroFeed(false);
  7174. },
  7175. type: `normal`
  7176. },
  7177. 'hk-split': {
  7178. label: textLanguage[`hk-split`],
  7179. defaultKey: 'SPACE',
  7180. keyDown() {
  7181. application && application.split();
  7182. },
  7183. keyUp: null,
  7184. type: `normal`
  7185. },
  7186. 'hk-doubleSplit': {
  7187. label: textLanguage[`hk-doubleSplit`],
  7188. defaultKey: 'Q',
  7189. keyDown() {
  7190. application && application.doubleSplit();
  7191. },
  7192. keyUp: null,
  7193. type: `normal`
  7194. },
  7195. 'hk-popSplit': {
  7196. label: `Popsplit`,
  7197. defaultKey: `ALT+Q`,
  7198. keyDown() {
  7199. application && application.popSplit();
  7200. },
  7201. keyUp: null,
  7202. type: 'normal'
  7203. },
  7204. 'hk-split16': {
  7205. label: textLanguage[`hk-split16`],
  7206. defaultKey: 'SHIFT',
  7207. keyDown() {
  7208. application && application.split16();
  7209. },
  7210. keyUp: null,
  7211. type: `normal`
  7212. },
  7213. 'hk-pause': {
  7214. label: textLanguage['hk-pause'],
  7215. defaultKey: 'R',
  7216. keyDown() {
  7217. application && application.setPause();
  7218. },
  7219. keyUp: null,
  7220. type: 'normal'
  7221. },
  7222. 'hk-showTop5': {
  7223. label: textLanguage[`hk-showTop5`],
  7224. defaultKey: 'V',
  7225. keyDown() {
  7226. application && application.setShowTop5();
  7227. },
  7228. keyUp: null,
  7229. type: `normal`
  7230. },
  7231. 'hk-showTime': {
  7232. label: textLanguage['hk-showTime'],
  7233. defaultKey: 'ALT+T',
  7234. keyDown() {
  7235. application && application.setShowTime();
  7236. },
  7237. keyUp: null,
  7238. type: `normal`
  7239. },
  7240. 'hk-showSplitRange': {
  7241. label: textLanguage[`hk-showSplitRange`],
  7242. defaultKey: 'U',
  7243. keyDown() {
  7244. application && application.setShowSplitRange();
  7245. },
  7246. keyUp: null,
  7247. type: `normal`
  7248. },
  7249. 'hk-showSplitInd': {
  7250. label: textLanguage[`hk-showSplitInd`],
  7251. defaultKey: 'I',
  7252. keyDown() {
  7253. application && application.setShowSplitInd();
  7254. },
  7255. keyUp: null,
  7256. type: `normal`
  7257. },
  7258. 'hk-showTeammatesInd': {
  7259. label: textLanguage[`hk-showTeammatesInd`],
  7260. defaultKey: `ALT+I`,
  7261. keyDown() {
  7262. application && application.setShowTeammatesInd();
  7263. },
  7264. keyUp: null,
  7265. type: 'normal'
  7266. },
  7267. 'hk-showOppColors': {
  7268. label: textLanguage[`hk-showOppColors`],
  7269. defaultKey: 'O',
  7270. keyDown() {
  7271. application && application.setShowOppColors();
  7272. },
  7273. keyUp: null,
  7274. type: `normal`
  7275. },
  7276. 'hk-toggleSkins': {
  7277. label: textLanguage['hk-toggleSkins'],
  7278. defaultKey: 'K',
  7279. keyDown() {
  7280. application && application.toggleSkins();
  7281. },
  7282. keyUp: null,
  7283. type: `normal`
  7284. },
  7285. 'hk-transparentSkins': {
  7286. label: textLanguage[`hk-transparentSkins`],
  7287. defaultKey: '',
  7288. keyDown() {
  7289. application && application.setTransparentSkins();
  7290. },
  7291. keyUp: null,
  7292. type: `normal`
  7293. },
  7294. 'hk-showSkins': {
  7295. label: textLanguage[`hk-showSkins`],
  7296. defaultKey: 'S',
  7297. keyDown() {
  7298. application && application.setShowSkins();
  7299. },
  7300. keyUp: null,
  7301. type: `normal`
  7302. },
  7303. 'hk-showStats': {
  7304. label: textLanguage[`hk-showStats`],
  7305. defaultKey: `ALT+S`,
  7306. keyDown() {
  7307. application && application.setShowStats();
  7308. },
  7309. keyUp: null,
  7310. type: `normal`
  7311. },
  7312. 'hk-toggleCells': {
  7313. label: textLanguage[`hk-toggleCells`],
  7314. defaultKey: 'D',
  7315. keyDown() {
  7316. application && application.toggleCells();
  7317. },
  7318. keyUp: null,
  7319. type: 'normal'
  7320. },
  7321. 'hk-showFood': {
  7322. label: textLanguage[`hk-showFood`],
  7323. defaultKey: 'X',
  7324. keyDown() {
  7325. application && application.setShowFood();
  7326. },
  7327. keyUp: null,
  7328. type: 'normal'
  7329. },
  7330. 'hk-showGrid': {
  7331. label: textLanguage[`hk-showGrid`],
  7332. defaultKey: 'G',
  7333. keyDown() {
  7334. application && application.setShowGrid();
  7335. },
  7336. keyUp: null,
  7337. type: `normal`
  7338. },
  7339. 'hk-showMiniMapGuides': {
  7340. label: textLanguage[`hk-showMiniMapGuides`],
  7341. defaultKey: `ALT+G`,
  7342. keyDown() {
  7343. application && application.setShowMiniMapGuides();
  7344. },
  7345. keyUp: null,
  7346. type: `normal`
  7347. },
  7348. 'hk-hideChat': {
  7349. label: textLanguage[`hk-hideChat`],
  7350. defaultKey: 'H',
  7351. keyDown() {
  7352. application && application.hideChat();
  7353. },
  7354. keyUp: null,
  7355. type: 'normal'
  7356. },
  7357. 'hk-showHUD': {
  7358. label: textLanguage['hk-showHUD'],
  7359. defaultKey: 'ALT+H',
  7360. keyDown() {
  7361. application && application.setShowHUD();
  7362. },
  7363. keyUp: null,
  7364. type: `normal`
  7365. },
  7366. 'hk-copyLb': {
  7367. label: textLanguage[`hk-copyLb`],
  7368. defaultKey: 'L',
  7369. keyDown() {
  7370. application && application.copyLb();
  7371. },
  7372. keyUp: null,
  7373. type: `normal`
  7374. },
  7375. 'hk-showLb': {
  7376. label: textLanguage[`hk-showLb`],
  7377. defaultKey: `ALT+L`,
  7378. keyDown() {
  7379. application && application.setShowLb();
  7380. },
  7381. keyUp: null,
  7382. type: `normal`
  7383. },
  7384. 'hk-toggleAutoZoom': {
  7385. label: textLanguage[`hk-toggleAutoZoom`],
  7386. defaultKey: '',
  7387. keyDown() {
  7388. application && application.toggleAutoZoom();
  7389. },
  7390. keyUp: null,
  7391. type: `normal`
  7392. },
  7393. 'hk-resetZoom': {
  7394. label: textLanguage[`hk-resetZoom`],
  7395. defaultKey: 'ALT+Z',
  7396. keyDown() {
  7397. application && application.resetZoom(true);
  7398. },
  7399. keyUp() {
  7400. application && application.resetZoom(false);
  7401. },
  7402. type: `normal`
  7403. },
  7404. 'hk-toggleDeath': {
  7405. label: textLanguage['hk-toggleDeath'],
  7406. defaultKey: 'Z',
  7407. keyDown() {
  7408. application && application.toggleDeath();
  7409. },
  7410. keyUp: null,
  7411. type: `normal`
  7412. },
  7413. 'hk-clearChat': {
  7414. label: textLanguage[`hk-clearChat`],
  7415. defaultKey: 'C',
  7416. keyDown() {
  7417. application && application.displayChatHistory(true);
  7418. },
  7419. keyUp() {
  7420. application && application.displayChatHistory(false);
  7421. },
  7422. type: `normal`
  7423. },
  7424. 'hk-showBgSectors': {
  7425. label: textLanguage[`hk-showBgSectors`],
  7426. defaultKey: 'B',
  7427. keyDown() {
  7428. application && application.setShowBgSectors();
  7429. },
  7430. keyUp: null,
  7431. type: `normal`
  7432. },
  7433. 'hk-hideBots': {
  7434. label: textLanguage[`hk-hideBots`],
  7435. defaultKey: 'ALT+B',
  7436. keyDown() {
  7437. application && application.setHideSmallBots();
  7438. },
  7439. keyUp: null,
  7440. type: `normal`
  7441. },
  7442. 'hk-showNames': {
  7443. label: textLanguage['hk-showNames'],
  7444. defaultKey: 'N',
  7445. keyDown() {
  7446. application && application.setShowNames();
  7447. },
  7448. keyUp: null,
  7449. type: `normal`
  7450. },
  7451. 'hk-hideTeammatesNames': {
  7452. label: textLanguage[`hk-hideTeammatesNames`],
  7453. defaultKey: '',
  7454. keyDown() {
  7455. application && application.setHideTeammatesNames();
  7456. },
  7457. keyUp: null,
  7458. type: 'normal'
  7459. },
  7460. 'hk-showMass': {
  7461. label: textLanguage[`hk-showMass`],
  7462. defaultKey: 'M',
  7463. keyDown() {
  7464. application && application.setShowMass();
  7465. },
  7466. keyUp: null,
  7467. type: `normal`
  7468. },
  7469. 'hk-showMiniMap': {
  7470. label: textLanguage[`hk-showMiniMap`],
  7471. defaultKey: `ALT+M`,
  7472. keyDown() {
  7473. application && application.setShowMiniMap();
  7474. },
  7475. keyUp: null,
  7476. type: `normal`
  7477. },
  7478. 'hk-chatMessage': {
  7479. label: textLanguage[`hk-chatMessage`],
  7480. defaultKey: `ENTER`,
  7481. keyDown() {
  7482. application && application.enterChatMessage();
  7483. },
  7484. keyUp: null,
  7485. type: `special`
  7486. },
  7487. 'hk-quickResp': {
  7488. label: textLanguage[`hk-quickResp`],
  7489. defaultKey: 'TILDE',
  7490. keyDown() {
  7491. application && application.quickResp();
  7492. },
  7493. keyUp: null,
  7494. type: `normal`
  7495. },
  7496. 'hk-autoResp': {
  7497. label: textLanguage[`hk-autoResp`],
  7498. defaultKey: '',
  7499. keyDown() {
  7500. application && application.toggleAutoResp();
  7501. },
  7502. keyUp: null,
  7503. type: `normal`
  7504. },
  7505. 'hk-zoom1': {
  7506. label: `${textLanguage[`hk-zoomLevel`]} 1`,
  7507. defaultKey: `ALT+1`,
  7508. keyDown() {
  7509. application && application.setZoom(0.5);
  7510. },
  7511. keyUp: null,
  7512. type: `normal`
  7513. },
  7514. 'hk-zoom2': {
  7515. label: `${textLanguage[`hk-zoomLevel`]} 2`,
  7516. defaultKey: `ALT+2`,
  7517. keyDown() {
  7518. application && application.setZoom(0.25);
  7519. },
  7520. keyUp: null,
  7521. type: `normal`
  7522. },
  7523. 'hk-zoom3': {
  7524. label: `${textLanguage[`hk-zoomLevel`]} 3`,
  7525. defaultKey: `ALT+3`,
  7526. keyDown() {
  7527. application && application.setZoom(0.125);
  7528. },
  7529. keyUp: null,
  7530. type: `normal`
  7531. },
  7532. 'hk-zoom4': {
  7533. label: `${textLanguage[`hk-zoomLevel`]} 4`,
  7534. defaultKey: `ALT+4`,
  7535. keyDown() {
  7536. application && application.setZoom(0.075);
  7537. },
  7538. keyUp: null,
  7539. type: `normal`
  7540. },
  7541. 'hk-zoom5': {
  7542. label: `${textLanguage[`hk-zoomLevel`]} 5`,
  7543. defaultKey: `ALT+5`,
  7544. keyDown() {
  7545. application && application.setZoom(0.05);
  7546. },
  7547. keyUp: null,
  7548. type: `normal`
  7549. },
  7550. 'hk-switchServerMode': {
  7551. label: textLanguage[`hk-switchServerMode`],
  7552. defaultKey: '=',
  7553. keyDown() {
  7554. application && application.switchServerMode();
  7555. },
  7556. keyUp: null,
  7557. type: `normal`
  7558. },
  7559. 'hk-showTargeting': {
  7560. label: textLanguage[`hk-showTargeting`],
  7561. defaultKey: '',
  7562. keyDown() {
  7563. application && application.setShowTargeting();
  7564. },
  7565. keyUp: null,
  7566. type: 'normal'
  7567. },
  7568. 'hk-setTargeting': {
  7569. label: textLanguage['hk-setTargeting'],
  7570. defaultKey: '',
  7571. keyDown() {
  7572. application && application.setTargeting();
  7573. },
  7574. keyUp: null,
  7575. type: 'normal'
  7576. },
  7577. 'hk-cancelTargeting': {
  7578. label: textLanguage['hk-cancelTargeting'],
  7579. defaultKey: '',
  7580. keyDown() {
  7581. application && application.cancelTargeting();
  7582. },
  7583. keyUp: null,
  7584. type: `normal`
  7585. },
  7586. 'hk-changeTarget': {
  7587. label: textLanguage[`hk-changeTarget`],
  7588. defaultKey: '',
  7589. keyDown() {
  7590. application && application.changeTarget();
  7591. },
  7592. keyUp: null,
  7593. type: `normal`
  7594. },
  7595. 'hk-privateMiniMap': {
  7596. label: textLanguage[`hk-privateMiniMap`],
  7597. defaultKey: '',
  7598. keyDown() {
  7599. application && application.setPrivateMiniMap();
  7600. },
  7601. keyUp: null,
  7602. type: `normal`
  7603. },
  7604. 'hk-showQuest': {
  7605. label: textLanguage[`hk-showQuest`],
  7606. defaultKey: '',
  7607. keyDown() {
  7608. application && application.setShowQuest();
  7609. },
  7610. keyUp: null,
  7611. type: `normal`
  7612. },
  7613. 'hk-comm1': {
  7614. label: chatCommand.comm1,
  7615. defaultKey: '1',
  7616. keyDown() {
  7617. application && application.sendCommand(1);
  7618. },
  7619. keyUp: null,
  7620. type: `command`
  7621. },
  7622. 'hk-comm2': {
  7623. label: chatCommand.comm2,
  7624. defaultKey: '2',
  7625. keyDown() {
  7626. application && application.sendCommand(2);
  7627. },
  7628. keyUp: null,
  7629. type: `command`
  7630. },
  7631. 'hk-comm3': {
  7632. label: chatCommand.comm3,
  7633. defaultKey: '3',
  7634. keyDown() {
  7635. application && application.sendCommand(3);
  7636. },
  7637. keyUp: null,
  7638. type: `command`
  7639. },
  7640. 'hk-comm4': {
  7641. label: chatCommand.comm4,
  7642. defaultKey: '4',
  7643. keyDown() {
  7644. application && application.sendCommand(4);
  7645. },
  7646. keyUp: null,
  7647. type: `command`
  7648. },
  7649. 'hk-comm5': {
  7650. label: chatCommand.comm5,
  7651. defaultKey: '5',
  7652. keyDown() {
  7653. application && application.sendCommand(5);
  7654. },
  7655. keyUp: null,
  7656. type: `command`
  7657. },
  7658. 'hk-comm6': {
  7659. label: chatCommand.comm6,
  7660. defaultKey: '6',
  7661. keyDown() {
  7662. application && application.sendCommand(6);
  7663. },
  7664. keyUp: null,
  7665. type: `command`
  7666. },
  7667. 'hk-comm7': {
  7668. label: chatCommand.comm7,
  7669. defaultKey: '7',
  7670. keyDown() {
  7671. application && application.sendCommand(7);
  7672. },
  7673. keyUp: null,
  7674. type: `command`
  7675. },
  7676. 'hk-comm8': {
  7677. label: chatCommand.comm8,
  7678. defaultKey: '8',
  7679. keyDown() {
  7680. application && application.sendCommand(8);
  7681. },
  7682. keyUp: null,
  7683. type: 'command'
  7684. },
  7685. 'hk-comm9': {
  7686. label: chatCommand.comm9,
  7687. defaultKey: '9',
  7688. keyDown() {
  7689. application && application.sendCommand(9);
  7690. },
  7691. keyUp: null,
  7692. type: `command`
  7693. },
  7694. 'hk-comm0': {
  7695. label: chatCommand.comm0,
  7696. defaultKey: '0',
  7697. keyDown() {
  7698. application && application.sendCommand(0);
  7699. },
  7700. keyUp: null,
  7701. type: `command`
  7702. },
  7703. 'hk-comm10': {
  7704. label: chatCommand.comm10,
  7705. defaultKey: `MOUSE WHEEL`,
  7706. keyDown() {
  7707. application && application.sendCommand(10);
  7708. },
  7709. keyUp: null,
  7710. type: 'command'
  7711. },
  7712. 'hk-comm11': {
  7713. label: chatCommand.comm11,
  7714. defaultKey: `LEFT`,
  7715. keyDown() {
  7716. application && application.sendCommand(11);
  7717. },
  7718. keyUp: null,
  7719. type: 'command'
  7720. },
  7721. 'hk-comm12': {
  7722. label: chatCommand.comm12,
  7723. defaultKey: 'UP',
  7724. keyDown() {
  7725. application && application.sendCommand(12);
  7726. },
  7727. keyUp: null,
  7728. type: `command`
  7729. },
  7730. 'hk-comm13': {
  7731. label: chatCommand.comm13,
  7732. defaultKey: 'RIGHT',
  7733. keyDown() {
  7734. application && application.sendCommand(13);
  7735. },
  7736. keyUp: null,
  7737. type: `command`
  7738. },
  7739. 'hk-comm14': {
  7740. label: chatCommand.comm14,
  7741. defaultKey: 'DOWN',
  7742. keyDown() {
  7743. application && application.sendCommand(14);
  7744. },
  7745. keyUp: null,
  7746. type: `command`
  7747. }
  7748. };
  7749. const hotkeysSetup = {
  7750. lastPressedKey: '',
  7751. lastKeyId: '',
  7752. defaultMessageKey: `ENTER`,
  7753. inputClassName: 'custom-key-in form-control input-sm',
  7754. loadDefaultHotkeys() {
  7755. hotkeys = {};
  7756. for (const command in hotkeysCommand) {
  7757. if (hotkeysCommand.hasOwnProperty(command)) {
  7758. hotkeys[hotkeysCommand[command].defaultKey] = command;
  7759. }
  7760. }
  7761. hotkeys[`spec-messageKey`] = this.defaultMessageKey;
  7762. },
  7763. loadHotkeys() {
  7764. if (window.localStorage.getItem(`ogarioHotkeys`) !== null) {
  7765. hotkeys = JSON.parse(window.localStorage.getItem('ogarioHotkeys'));
  7766. } else {
  7767. this.loadDefaultHotkeys();
  7768. }
  7769. if (window.localStorage.getItem(`ogarioCommands`) !== null) {
  7770. chatCommand = JSON.parse(window.localStorage.getItem('ogarioCommands'));
  7771. }
  7772. },
  7773. saveHotkeys() {
  7774. window.localStorage.setItem('ogarioHotkeys', JSON.stringify(hotkeys));
  7775. this.saveCommands();
  7776. },
  7777. saveCommands() {
  7778. JQuery('#hotkeys .command-in').each(function() {
  7779. const element = JQuery(this);
  7780. const id = element.attr('id');
  7781. if (chatCommand.hasOwnProperty(id)) {
  7782. chatCommand[id] = element.val();
  7783. }
  7784. });
  7785. window.localStorage.setItem(`ogarioCommands`, JSON.stringify(chatCommand));
  7786. },
  7787. resetHotkeys() {
  7788. this.loadDefaultHotkeys();
  7789. JQuery('#hotkeys-cfg .custom-key-in').each(function() {
  7790. const id = JQuery(this).attr('id');
  7791. if (hotkeysCommand[id]) {
  7792. JQuery(this).val(hotkeysCommand[id].defaultKey);
  7793. }
  7794. });
  7795. },
  7796. setHotkeysMenu() {
  7797. const setup = this;
  7798. JQuery('body').append(`<div id="hotkeys"><div id="hotkeys-menu"><button id="reset-hotkeys" class="btn btn-primary">${textLanguage.restoreSettings}${`</button> <button id="save-hotkeys" class="btn btn-success">`}${textLanguage.saveSett}</button> <button id="close-hotkeys" class="btn btn-danger">${textLanguage.close}${`</button></div><div id="hotkeys-cfg"></div><div id="hotkeys-inst"><ul><li>`}${textLanguage['hk-inst-assign']}${`</li><li>`}${textLanguage[`hk-inst-delete`]}</li><li>${textLanguage[`hk-inst-keys`]}</li></ul></div></div>`);
  7799. for (const command in hotkeysCommand) {
  7800. if (hotkeysCommand.hasOwnProperty(command)) {
  7801. const currentCommand = hotkeysCommand[command];
  7802. let text = '';
  7803. for (const key in hotkeys) {
  7804. if (hotkeys.hasOwnProperty(key) && hotkeys[key] === command) {
  7805. text = key;
  7806. break;
  7807. }
  7808. }
  7809. if (command === `hk-switchServerMode` && application && !application.privateIP) {
  7810. continue;
  7811. }
  7812. if (currentCommand.type === `command`) {
  7813. const replaceHk = command.replace(`hk-`, '');
  7814. JQuery(`#hotkeys-cfg`).append(`${`<div class="row"><div class="key-label"><input id="` + replaceHk + `" class="command-in form-control input-sm" value="` + chatCommand[replaceHk] + `" maxlength="80" /></div><div class="default-key">` + currentCommand.defaultKey + `</div><div class="custom-key"><input id="` + command + `" class="custom-key-in form-control input-sm" value="` + text}" /></div></div>`);
  7815. } else {
  7816. JQuery('#hotkeys-cfg').append(`<div class="row"><div class="key-label">${currentCommand.label}</div><div class="default-key">${currentCommand.defaultKey}</div><div class="custom-key"><input id="${command}${`" class="custom-key-in form-control input-sm" value="`}${text}" /></div></div>`);
  7817. }
  7818. }
  7819. }
  7820. JQuery(document).on('click', `#reset-hotkeys`, event => {
  7821. event.preventDefault();
  7822. setup.resetHotkeys();
  7823. });
  7824. JQuery(document).on(`click`, `#save-hotkeys`, event => {
  7825. event.preventDefault();
  7826. setup.saveHotkeys();
  7827. JQuery('#hotkeys').fadeOut(500);
  7828. });
  7829. JQuery(document).on(`click`, `#close-hotkeys`, event => {
  7830. event.preventDefault();
  7831. JQuery('#hotkeys').fadeOut(500);
  7832. });
  7833. JQuery(document).on(`click`, `.hotkeys-link`, event => {
  7834. JQuery(`#hotkeys`).fadeIn(500);
  7835. JQuery(`#hotkeys-cfg`).perfectScrollbar(`update`);
  7836. resetonkeydown();
  7837. });
  7838. JQuery(`#hotkeys-cfg`).perfectScrollbar();
  7839. OgarioSettings && OgarioSettings.setMenuBg();
  7840. },
  7841. getPressedKey(key) {
  7842. let specialKey = '';
  7843. let normalKey = '';
  7844. if (key.ctrlKey || key.keyCode == 17) {
  7845. specialKey = 'CTRL';
  7846. } else if (key.altKey || key.keyCode == 18) {
  7847. specialKey = `ALT`;
  7848. }
  7849. switch (key.keyCode) {
  7850. case 9:
  7851. normalKey = `TAB`;
  7852. break;
  7853. case 13:
  7854. normalKey = `ENTER`;
  7855. break;
  7856. case 16:
  7857. normalKey = 'SHIFT';
  7858. break;
  7859. case 17:
  7860. break;
  7861. case 18:
  7862. break;
  7863. case 27:
  7864. normalKey = `ESC`;
  7865. break;
  7866. case 32:
  7867. normalKey = 'SPACE';
  7868. break;
  7869. case 37:
  7870. normalKey = `LEFT`;
  7871. break;
  7872. case 38:
  7873. normalKey = 'UP';
  7874. break;
  7875. case 39:
  7876. normalKey = `RIGHT`;
  7877. break;
  7878. case 40:
  7879. normalKey = `DOWN`;
  7880. break;
  7881. case 46:
  7882. normalKey = `DEL`;
  7883. break;
  7884. case 61:
  7885. normalKey = '=';
  7886. break;
  7887. case 187:
  7888. normalKey = '=';
  7889. break;
  7890. case 192:
  7891. normalKey = `TILDE`;
  7892. break;
  7893. default:
  7894. normalKey = String.fromCharCode(key.keyCode);
  7895. break;
  7896. }
  7897. if (specialKey !== '') {
  7898. if (normalKey !== '') {
  7899. return `${specialKey}+${normalKey}`;
  7900. }
  7901. return specialKey;
  7902. }
  7903. return normalKey;
  7904. },
  7905. deleteHotkey(name, id) {
  7906. delete hotkeys[name];
  7907. JQuery(`#${id}`).val('');
  7908. },
  7909. setDefaultHotkey(id) {
  7910. let key = false;
  7911. if (hotkeysCommand[id] && !hotkeys.hasOwnProperty(hotkeysCommand[id].defaultKey)) {
  7912. key = hotkeysCommand[id].defaultKey;
  7913. hotkeys[key] = id;
  7914. return key;
  7915. }
  7916. return key;
  7917. },
  7918. setHotkey(key, id) {
  7919. if (!id || this.lastPressedKey === key && this.lastKeyId === id) {
  7920. return;
  7921. }
  7922. const value = JQuery(`#${id}`).val();
  7923. this.deleteHotkey(value, id);
  7924. if (key === 'DEL') {
  7925. return;
  7926. }
  7927. if (hotkeys[key] && hotkeys[key] !== id) {
  7928. const hotkey = hotkeys[key];
  7929. const defaultKey = this.setDefaultHotkey(hotkey);
  7930. if (defaultKey) {
  7931. hotkeys[defaultKey] = hotkey;
  7932. JQuery(`#${hotkey}`).val(defaultKey);
  7933. } else {
  7934. this.deleteHotkey(key, hotkey);
  7935. }
  7936. }
  7937. hotkeys[key] = id;
  7938. JQuery(`#${id}`).val(key);
  7939. if (id === 'hk-chatMessage') {
  7940. hotkeys[`spec-messageKey`] = key;
  7941. }
  7942. this.lastPressedKey = key;
  7943. this.lastKeyId = id;
  7944. },
  7945. init() {
  7946. this.loadHotkeys();
  7947. this.setHotkeysMenu();
  7948. }
  7949. };
  7950. document.onkeydown = event => {
  7951. const pressKey = hotkeysSetup.getPressedKey(event);
  7952. if (event.target.tagName === `INPUT` && event.target.className !== hotkeysSetup.inputClassName && pressKey !== hotkeys['spec-messageKey']) {
  7953. return;
  7954. }
  7955. if (pressKey !== '' && !keyBlind[pressKey]) {
  7956. keyBlind[pressKey] = true;
  7957. if (pressKey === `ESC`) {
  7958. event.preventDefault();
  7959. application && application.showMenu();
  7960. return;
  7961. }
  7962. if (event.target.className === hotkeysSetup.inputClassName) {
  7963. event.preventDefault();
  7964. hotkeysSetup.setHotkey(pressKey, event.target.id);
  7965. return;
  7966. }
  7967. if (hotkeys[pressKey]) {
  7968. event.preventDefault();
  7969. const key = hotkeys[pressKey];
  7970. if (key !== '' && hotkeysCommand[key]) {
  7971. if (hotkeysCommand[key].keyDown) {
  7972. hotkeysCommand[key].keyDown();
  7973. }
  7974. }
  7975. }
  7976. }
  7977. };
  7978. document.onkeyup = event => {
  7979. const pressedKey = hotkeysSetup.getPressedKey(event);
  7980. if (pressedKey !== '') {
  7981. if (hotkeys[pressedKey]) {
  7982. const key = hotkeys[pressedKey];
  7983. if (key !== '' && hotkeysCommand[key]) {
  7984. if (hotkeysCommand[key].keyUp) {
  7985. hotkeysCommand[key].keyUp();
  7986. }
  7987. }
  7988. }
  7989. keyBlind[pressedKey] = false;
  7990. }
  7991. };
  7992. window.onmousedown = event => {
  7993. if (!JQuery(`#overlays`).is(`:visible`)) {
  7994. if (event.which == 2) {
  7995. event.preventDefault();
  7996. application && application.sendCommand(10);
  7997. } else {
  7998. if (gameOptionSettings.mouseSplit) {
  7999. if (event.which == 1 && !gameOptionSettings.mouseInvert || event.which == 3 && gameOptionSettings.mouseInvert) {
  8000. event.preventDefault();
  8001. application && application.split();
  8002. }
  8003. }
  8004. if (gameOptionSettings.mouseFeed) {
  8005. if (event.which == 3 && !gameOptionSettings.mouseInvert || event.which == 1 && gameOptionSettings.mouseInvert) {
  8006. event.preventDefault();
  8007. application && application.macroFeed(true);
  8008. }
  8009. }
  8010. }
  8011. }
  8012. };
  8013. window.onmouseup = event => {
  8014. if (gameOptionSettings.mouseFeed) {
  8015. if (event.which == 3 && !gameOptionSettings.mouseInvert || event.which == 1 && gameOptionSettings.mouseInvert) {
  8016. application && application.macroFeed(false);
  8017. }
  8018. }
  8019. };
  8020. window.onbeforeunload = event => {
  8021. if (ogario.play) {
  8022. return textLanguage.exit;
  8023. } else {
  8024. return;
  8025. }
  8026. };
  8027.  
  8028. function changeHistory(value) {
  8029. if (window.history && window.history.replaceState) {
  8030. window.history.replaceState({}, window.document.title, value);
  8031. }
  8032. }
  8033.  
  8034. function changeUrl() {
  8035. if (window.location.pathname === `/ogario`) {
  8036. changeHistory(`/${window.location.hash}`);
  8037. }
  8038. }
  8039.  
  8040. function spectateBlind() {
  8041. window.onkeydown = event => {
  8042. 81 == event.keyCode && window.core.specialOn && window.core.specialOn();
  8043. };
  8044. window.onkeyup = event => {};
  8045. }
  8046.  
  8047. function menuScale() {
  8048. const innerWidth = window.innerWidth;
  8049. const innerHeigth = window.innerHeight;
  8050. const helloContainer = JQuery('#helloContainer');
  8051. let helloContainerWidth = helloContainer.innerHeight();
  8052. if (helloContainerWidth > 0) {
  8053. ogario.menuHeight = helloContainerWidth;
  8054. } else {
  8055. helloContainerWidth = ogario.menuHeight || 618;
  8056. }
  8057. const scale = Math.min(1, innerHeigth / helloContainerWidth);
  8058. const top = helloContainerWidth * scale;
  8059. const resizeTop = Math.round(innerHeigth / 2 - 0.5 * top);
  8060. const transform = `${`translate(-50%, 0%) scale(` + scale})`;
  8061. helloContainer.css('transform', transform);
  8062. helloContainer.css('-ms-transform', transform);
  8063. helloContainer.css('-webkit-transform', transform);
  8064. helloContainer.css('top', `${resizeTop}px`);
  8065. ogario.innerW = innerWidth;
  8066. ogario.innerH = innerHeigth;
  8067. }
  8068.  
  8069. function resetonkeydown() {
  8070. if (application.protocolMode) {
  8071. return;
  8072. }
  8073. window.onkeydown = event => {};
  8074. }
  8075.  
  8076. function start() {
  8077. window.core = {
  8078. connect(url) {
  8079. Connection.connect(url);
  8080. },
  8081. disconnect() {},
  8082. sendNick(nick) {
  8083. Connection.sendNick(nick);
  8084. },
  8085. sendSpectate() {
  8086. Connection.sendSpectate();
  8087. },
  8088. eject() {
  8089. Connection.sendEject();
  8090. },
  8091. split() {
  8092. Connection.sendSplit();
  8093. },
  8094. specialOn() {
  8095. Connection.sendFreeSpectate();
  8096. },
  8097. specialOff() {
  8098. Connection.sendFreeSpectate();
  8099. },
  8100. sendFbToken(token) {
  8101. Connection.sendFbToken(token);
  8102. },
  8103. sendGplusToken(token) {
  8104. Connection.sendGplusToken(token);
  8105. },
  8106. recaptchaResponse(token) {
  8107. Connection.sendRecaptcha(token);
  8108. },
  8109. setClientVersion(version, strVersion) {
  8110. Connection.setClientVersion(version, strVersion);
  8111. },
  8112. proxyMobileData(data = []) {
  8113. if (!Array.isArray(data)) {
  8114. console.log('ProxyMobileData ERROR: Array data required.');
  8115. return;
  8116. }
  8117. if (data[0] == 8) {
  8118. data.unshift(102);
  8119. }
  8120. data = new Uint8Array(data);
  8121. Connection.sendMessage(new DataView(data.buffer));
  8122. }
  8123. };
  8124. }
  8125.  
  8126. function setGUI(){
  8127. toastr["info"]('Script Injected!');
  8128. document.getElementById('quick-menu').innerHTML = `
  8129. <h2 id="botsInfo">
  8130. <a href="https://discord.gg/SDMNEcJ" target="_blank">Free Agar.io Bots</a>
  8131. </h2>
  8132. <h5 id="botsAuthor">
  8133. Developed by <a href="https://www.youtube.com/channel/UCZo9WmnFPWw38q65Llu5Lug" target="_blank">Nel</a>
  8134. </h5>
  8135. <span id="statusText">Status: <b id="userStatus">Disconnected</b></span>
  8136. <br>
  8137. <br>
  8138. <span id="aiText">Bots AI: <b id="botsAI">Disabled</b></span>
  8139. <br>
  8140. <input type="text" id="botsName" placeholder="Bots Name" maxlength="100" spellcheck="false">
  8141. <input type="number" id="botsAmount" placeholder="Bots Amount" min="10" max="195" spellcheck="false">
  8142. <button id="connect" class="btn-primary">Connect</button>
  8143. <br>
  8144. <button id="startBots" class="btn-warning" disabled>Start Bots</button>
  8145. <button id="stopBots" class="btn-warning">Stop Bots</button>
  8146. <br>
  8147. <br>
  8148. <input type="text" id="serverHost" placeholder="ws://localhost:8083" value="ws://localhost:8083" spellcheck="false">
  8149. `
  8150. if(localStorage.getItem('localStoredBotsName') !== null){
  8151. window.bots.name = localStorage.getItem('localStoredBotsName')
  8152. document.getElementById('botsName').value = window.bots.name
  8153. }
  8154. if(localStorage.getItem('localStoredBotsAmount') !== null){
  8155. window.bots.amount = JSON.parse(localStorage.getItem('localStoredBotsAmount'))
  8156. document.getElementById('botsAmount').value = String(window.bots.amount)
  8157. }
  8158. if(localStorage.getItem('localStoredServerHost') !== null){
  8159.  
  8160. if (window.server.host !=null && window.server.host != "" && window.server.host=="localhost"){
  8161. window.server.host = localStorage.getItem('localStoredServerHost')
  8162. }
  8163. document.getElementById('serverHost').value = window.server.host
  8164. }
  8165. }
  8166.  
  8167. function setGUIStyle(){
  8168. document.getElementsByTagName('head')[0].innerHTML += `
  8169. <style type="text/css">
  8170. #quick-menu {
  8171. width: 280px !important;
  8172. height: 580px !important;
  8173. }
  8174. #botsInfo > a, #botsAuthor > a {
  8175. color: #fff;
  8176. text-decoration: none;
  8177. }
  8178. #botsAuthor {
  8179. margin-top: -15px;
  8180. letter-spacing: 1px;
  8181. }
  8182. #statusText, #aiText {
  8183. font-weight: bold;
  8184. position: absolute;
  8185. left: -5px;
  8186. }
  8187. #userStatus, #botsAI {
  8188. color: #DA0A00;
  8189. }
  8190. #botsName, #botsAmount, #serverHost, #serverPort {
  8191. margin-top: 15px;
  8192. width: 144px;
  8193. padding: 8px;
  8194. font-size: 14.5px;
  8195. outline: none;
  8196. margin-left: 60px;
  8197. }
  8198. #connect, #startBots, #stopBots {
  8199. color: white;
  8200. border: none;
  8201. padding: 7px;
  8202. width: 160px;
  8203. font-size: 18px;
  8204. outline: none;
  8205. margin-top: 15px;
  8206. letter-spacing: 1px;
  8207. margin-left: 50px;
  8208. }
  8209. #connect {
  8210. display: inline;
  8211. background-color: #0074C0;
  8212. }
  8213. #startBots {
  8214. display: inline;
  8215. background-color: #00C02E;
  8216. }
  8217. #stopBots {
  8218. display: none;
  8219. background-color: #DA0A00;
  8220. }
  8221. #connect:active {
  8222. background-color: #004E82;
  8223. }
  8224. #startBots:active {
  8225. background-color: #009A25;
  8226. }
  8227. #stopBots:active {
  8228. background-color: #9A1B00;
  8229. }
  8230. </style>
  8231. `
  8232. }
  8233.  
  8234. function loadUI(){
  8235. $('#overlays-hud').append(`
  8236. <div id="botClient" class="hud-b hud-text-center" style="text-align: center; color: #fff; position: fixed; pointer-events: none; font-size: 75%; white-space: nowrap; padding: 0; top: 42%; display: block; width: 200px; right: 10px;">
  8237. <div style="margin: 6px;"><b>Bot Count</b>: <span id="botCount" class="label hud-main-color pull-right" style="margin: 0.55em 0 0 0; padding: 0 0.55em 0 0;">Waiting</span></div>
  8238. <b><div style="padding: 0 10px 6px;"><b>ServerSlots</b>: <span id="slots" class="label hud-main-color pull-right" style="margin: 0.55em 0 0 0;">Waiting</span></div>
  8239. </b></div>`);
  8240.  
  8241. }
  8242.  
  8243. function setGUIEvents(){
  8244. document.getElementById('botsAmount').addEventListener('keypress', e => {
  8245. e.preventDefault()
  8246. })
  8247. document.getElementById('botsName').addEventListener('change', function(){
  8248. window.bots.name = this.value
  8249. localStorage.setItem('localStoredBotsName', window.bots.name)
  8250. })
  8251. document.getElementById('botsAmount').addEventListener('change', function(){
  8252. window.bots.amount = Number(this.value)
  8253. localStorage.setItem('localStoredBotsAmount', window.bots.amount)
  8254. })
  8255. document.getElementById('connect').addEventListener('click', () => {
  8256. if(!window.connection.ws || window.connection.ws.readyState !== WebSocket.OPEN) window.connection.connect()
  8257. })
  8258. document.getElementById('startBots').addEventListener('click', () => {
  8259. if(window.game.url && window.game.protocolVersion && window.game.clientVersion && !window.user.startedBots){
  8260. if(window.bots.name && window.bots.amount && window.getComputedStyle(document.getElementsByClassName('btn-login-play')[0]).getPropertyValue('display') === 'none') window.connection.send(window.buffers.startBots(window.game.url, window.game.protocolVersion, window.game.clientVersion, window.user.isAlive, window.unescape(window.encodeURIComponent(window.bots.name)), window.bots.amount))
  8261. else toastr.info('Bots name, amount and user login are required before starting the bots')
  8262. }
  8263. })
  8264. document.getElementById('stopBots').addEventListener('click', () => {
  8265. if(window.user.startedBots) window.connection.send(new Uint8Array([1]).buffer)
  8266. })
  8267. document.getElementById('serverHost').addEventListener('change', function(){
  8268. window.server.host = this.value
  8269. localStorage.setItem('localStoredServerHost', window.server.host)
  8270. })
  8271. }
  8272.  
  8273. function resize() {
  8274. window.onresize = () => {
  8275. drawRender.resizeCanvas();
  8276. menuScale();
  8277. };
  8278. }((() => {
  8279. ogario = Connection;
  8280. changeUrl();
  8281. resize();
  8282. spectateBlind();
  8283. start();
  8284. window.master.getClientVersion();
  8285. OgarioSettings.init();
  8286. application.init();
  8287. application.getDefaultSettings();
  8288. application.connect();
  8289. hotkeysSetup.init();
  8290. Connection.init();
  8291. drawRender.init();
  8292. window.master.init();
  8293. menuScale();
  8294. setTimeout(() => {
  8295. setGUI()
  8296. setGUIStyle()
  8297. setGUIEvents()
  8298. loadUI()
  8299. }, 3500)
  8300. })());
  8301. }
  8302.  
  8303. init(window, window.ogario, window.jQuery);
Add Comment
Please, Sign In to add comment