Guest User

Untitled

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