Dsync Client [Sploop.io]

The most advanced hack for sploop.io

当前为 2022-10-25 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Dsync Client [Sploop.io]
  3. // @author Murka
  4. // @description The most advanced hack for sploop.io
  5. // @icon https://sploop.io/img/ui/favicon.png
  6. // @version 1.0.18
  7. // @match *://sploop.io/*
  8. // @run-at document-start
  9. // @grant none
  10. // @license MIT
  11. // @namespace https://greasyfork.org/users/919633
  12. // ==/UserScript==
  13. /* jshint esversion:6 */
  14.  
  15. /*
  16. Author: Murka
  17. Github: https://github.com/Murka007/Dsync-client
  18. Discord: https://discord.gg/sG9cyfGPj5
  19. Greasyfork: https://greasyfork.org/en/scripts/449995-dsync-client-sploop-io
  20.  
  21. I need your support, please follow these steps:
  22. 1. Join my DISCORD server
  23. 2. Write a feedback about this script on GREASYFORK "script works, thank you so much"
  24. 3. Star my repository on GITHUB
  25. */
  26.  
  27. Function("(" + ((GM_info) => {
  28. "use strict";
  29. var __webpack_modules__ = {
  30. 147: module => {
  31. module.exports = {
  32. i8: "1.0.18"
  33. };
  34. }
  35. };
  36. var __webpack_module_cache__ = {};
  37. function __webpack_require__(moduleId) {
  38. var cachedModule = __webpack_module_cache__[moduleId];
  39. if (cachedModule !== undefined) {
  40. return cachedModule.exports;
  41. }
  42. var module = __webpack_module_cache__[moduleId] = {
  43. exports: {}
  44. };
  45. __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  46. return module.exports;
  47. }
  48. (() => {
  49. __webpack_require__.d = (exports, definition) => {
  50. for (var key in definition) {
  51. if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  52. Object.defineProperty(exports, key, {
  53. enumerable: true,
  54. get: definition[key]
  55. });
  56. }
  57. }
  58. };
  59. })();
  60. (() => {
  61. __webpack_require__.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
  62. })();
  63. var __webpack_exports__ = {};
  64. (() => {
  65. __webpack_require__.d(__webpack_exports__, {
  66. sv: () => Dsync,
  67. Ih: () => controller,
  68. vU: () => error,
  69. cM: () => log,
  70. lZ: () => pingCount
  71. });
  72. var code = '<header> <span>Dsync Client</span> <div id="version"> <svg width="15" height="15" viewBox="0 0 16 16" version="1.1"> <path d="M11.75 2.5a.75.75 0 100 1.5.75.75 0 000-1.5zm-2.25.75a2.25 2.25 0 113 2.122V6A2.5 2.5 0 0110 8.5H6a1 1 0 00-1 1v1.128a2.251 2.251 0 11-1.5 0V5.372a2.25 2.25 0 111.5 0v1.836A2.492 2.492 0 016 7h4a1 1 0 001-1v-.628A2.25 2.25 0 019.5 3.25zM4.25 12a.75.75 0 100 1.5.75.75 0 000-1.5zM3.5 3.25a.75.75 0 111.5 0 .75.75 0 01-1.5 0z"></path> </svg> <span></span> </div> <svg id="close-menu" class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30" width="30px" height="30px"> <path d="M 7 4 C 6.744125 4 6.4879687 4.0974687 6.2929688 4.2929688 L 4.2929688 6.2929688 C 3.9019687 6.6839688 3.9019687 7.3170313 4.2929688 7.7070312 L 11.585938 15 L 4.2929688 22.292969 C 3.9019687 22.683969 3.9019687 23.317031 4.2929688 23.707031 L 6.2929688 25.707031 C 6.6839688 26.098031 7.3170313 26.098031 7.7070312 25.707031 L 15 18.414062 L 22.292969 25.707031 C 22.682969 26.098031 23.317031 26.098031 23.707031 25.707031 L 25.707031 23.707031 C 26.098031 23.316031 26.098031 22.682969 25.707031 22.292969 L 18.414062 15 L 25.707031 7.7070312 C 26.098031 7.3170312 26.098031 6.6829688 25.707031 6.2929688 L 23.707031 4.2929688 C 23.316031 3.9019687 22.682969 3.9019687 22.292969 4.2929688 L 15 11.585938 L 7.7070312 4.2929688 C 7.5115312 4.0974687 7.255875 4 7 4 z"/> </svg> </header>';
  73. const Header = code;
  74. var Navbar_code = '<aside id="navbar-container"> <button class="open-menu active">Keybinds</button> <button class="open-menu">Combat</button> <button class="open-menu">Visuals</button> <button class="open-menu">Misc</button> <button class="open-menu bottom-align">Credits</button> </aside>';
  75. const Navbar = Navbar_code;
  76. var Keybinds_code = '<div class="menu-page opened"> <h1>Keybinds</h1> <p>Setup keybinds for items, weapons and hats</p> <div class="section"> <div class="section-title"> <h2>Items & Weapons</h2> <svg class="icon" version="1.0" xmlns="http://www.w3.org/2000/svg" width="64.000000pt" height="64.000000pt" viewBox="0 0 64.000000 64.000000" preserveAspectRatio="xMidYMid meet"> <g transform="translate(0.000000,64.000000) scale(0.100000,-0.100000)" stroke="none"> <path d="M160 575 l-54 -55 99 -100 100 -100 -100 -100 -100 -100 58 -57 57 -58 157 158 158 157 -155 155 c-85 85 -157 155 -160 155 -3 0 -30 -25 -60 -55z"/> </g> </svg> </div> <div class="section-content"> <div class="split-section"> <div class="section-option"> <span class="section-option-title">Primary</span> <button id="primary" class="section-option-hotkeyInput"></button> </div> <div class="section-option"> <span class="section-option-title">Secondary</span> <button id="secondary" class="section-option-hotkeyInput"></button> </div> <div class="section-option"> <span class="section-option-title">Heal</span> <button id="heal" class="section-option-hotkeyInput"></button> </div> <div class="section-option"> <span class="section-option-title">Wall</span> <button id="wall" class="section-option-hotkeyInput"></button> </div> <div class="section-option"> <span class="section-option-title">Spike</span> <button id="spike" class="section-option-hotkeyInput"></button> </div> <div class="section-option"> <span class="section-option-title">Windmill</span> <button id="windmill" class="section-option-hotkeyInput"></button> </div> </div> <div class="split-section"> <div class="section-option"> <span class="section-option-title">Trap/Boost</span> <button id="trap" class="section-option-hotkeyInput"></button> </div> <div class="section-option"> <span class="section-option-title">Turret</span> <button id="turret" class="section-option-hotkeyInput"></button> </div> <div class="section-option"> <span class="section-option-title">Tree/Stone</span> <button id="tree" class="section-option-hotkeyInput"></button> </div> <div class="section-option"> <span class="section-option-title">Platform</span> <button id="platform" class="section-option-hotkeyInput"></button> </div> <div class="section-option"> <span class="section-option-title">Cosy bed</span> <button id="spawn" class="section-option-hotkeyInput"></button> </div> </div> </div> </div> <div class="section"> <div class="section-title"> <h2>Combat & Functions</h2> <svg class="icon" version="1.0" xmlns="http://www.w3.org/2000/svg" width="64.000000pt" height="64.000000pt" viewBox="0 0 64.000000 64.000000" preserveAspectRatio="xMidYMid meet"> <g transform="translate(0.000000,64.000000) scale(0.100000,-0.100000)" stroke="none"> <path d="M160 575 l-54 -55 99 -100 100 -100 -100 -100 -100 -100 58 -57 57 -58 157 158 158 157 -155 155 c-85 85 -157 155 -160 155 -3 0 -30 -25 -60 -55z"/> </g> </svg> </div> <div class="section-content"> <div class="section-option"> <span class="section-option-title">Invisible hit</span> <button id="invisibleHit" class="section-option-hotkeyInput"></button> </div> <div class="section-option"> <span class="section-option-title">Spike insta</span> <button id="spikeInsta" class="section-option-hotkeyInput"></button> </div> <div class="section-option"> <span class="section-option-title"> Fast break <span class="tooltip"> * <span class="tooltip-text">When you press a key, it equips a demolist and starts attacking</span> </span> </span> <button id="fastBreak" class="section-option-hotkeyInput"></button> </div> <div class="section-option"> <span class="section-option-title">Zoom In</span> <button class="section-option-hotkeyInput smaller">WHEEL DN</button> </div> <div class="section-option"> <span class="section-option-title">Toggle Dsync Menu</span> <button id="toggleMenu" class="section-option-hotkeyInput"></button> </div> <div class="section-option"> <span class="section-option-title">Zoom Out</span> <button class="section-option-hotkeyInput smaller">WHEEL UP</button> </div> </div> </div> <div class="section"> <div class="section-title"> <h2>Hats</h2> <svg class="icon" version="1.0" xmlns="http://www.w3.org/2000/svg" width="64.000000pt" height="64.000000pt" viewBox="0 0 64.000000 64.000000" preserveAspectRatio="xMidYMid meet"> <g transform="translate(0.000000,64.000000) scale(0.100000,-0.100000)" stroke="none"> <path d="M160 575 l-54 -55 99 -100 100 -100 -100 -100 -100 -100 58 -57 57 -58 157 158 158 157 -155 155 c-85 85 -157 155 -160 155 -3 0 -30 -25 -60 -55z"/> </g> </svg> </div> <div class="section-content"> <div class="section-option"> <span class="section-option-title">Unequip hat</span> <button id="unequip" class="section-option-hotkeyInput"></button> </div> <div class="section-option"> <span class="section-option-title">Bush hat</span> <button id="bush" class="section-option-hotkeyInput"></button> </div> <div class="section-option"> <span class="section-option-title">Berserker</span> <button id="berserker" class="section-option-hotkeyInput"></button> </div> <div class="section-option"> <span class="section-option-title">Jungle gear</span> <button id="jungle" class="section-option-hotkeyInput"></button> </div> <div class="section-option"> <span class="section-option-title">Crystal gear</span> <button id="crystal" class="section-option-hotkeyInput"></button> </div> <div class="section-option"> <span class="section-option-title">Spike gear</span> <button id="spikegear" class="section-option-hotkeyInput"></button> </div> <div class="section-option"> <span class="section-option-title">Immunity gear</span> <button id="immunity" class="section-option-hotkeyInput"></button> </div> <div class="section-option"> <span class="section-option-title">Boost hat</span> <button id="boost" class="section-option-hotkeyInput"></button> </div> <div class="section-option"> <span class="section-option-title">Apple hat</span> <button id="applehat" class="section-option-hotkeyInput"></button> </div> <div class="section-option"> <span class="section-option-title">Scuba gear</span> <button id="scuba" class="section-option-hotkeyInput"></button> </div> <div class="section-option"> <span class="section-option-title">Hood</span> <button id="hood" class="section-option-hotkeyInput"></button> </div> <div class="section-option"> <span class="section-option-title">Demolist</span> <button id="demolist" class="section-option-hotkeyInput"></button> </div> </div> </div> <div class="section"> <div class="section-title"> <h2>Controls & Movement</h2> <svg class="icon" version="1.0" xmlns="http://www.w3.org/2000/svg" width="64.000000pt" height="64.000000pt" viewBox="0 0 64.000000 64.000000" preserveAspectRatio="xMidYMid meet"> <g transform="translate(0.000000,64.000000) scale(0.100000,-0.100000)" stroke="none"> <path d="M160 575 l-54 -55 99 -100 100 -100 -100 -100 -100 -100 58 -57 57 -58 157 158 158 157 -155 155 c-85 85 -157 155 -160 155 -3 0 -30 -25 -60 -55z"/> </g> </svg> </div> <div class="section-content"> <div class="section-option"> <span class="section-option-title">Up</span> <button id="up" class="section-option-hotkeyInput"></button> </div> <div class="section-option"> <span class="section-option-title">Left</span> <button id="left" class="section-option-hotkeyInput"></button> </div> <div class="section-option"> <span class="section-option-title">Down</span> <button id="down" class="section-option-hotkeyInput"></button> </div> <div class="section-option"> <span class="section-option-title">Right</span> <button id="right" class="section-option-hotkeyInput"></button> </div> <div class="split"></div> <div class="section-option"> <span class="section-option-title">Auto attack</span> <button id="autoattack" class="section-option-hotkeyInput"></button> </div> <div class="section-option"> <span class="section-option-title">Lock rotation</span> <button id="lockRotation" class="section-option-hotkeyInput"></button> </div> <div class="section-option"> <span class="section-option-title">Open chat</span> <button id="openChat" class="section-option-hotkeyInput"></button> </div> <div class="section-option"> <span class="section-option-title">Upgrade scythe</span> <button id="upgradeScythe" class="section-option-hotkeyInput"></button> </div> </div> </div> </div>';
  77. const Keybinds = Keybinds_code;
  78. var Combat_code = '<div class="menu-page"> <h1>Combat</h1> <p>Modify combat settings, change pvp behavior</p> <div class="section opened"> <div class="section-title"> <h2>Placement</h2> </div> <div class="section-content one-row"> <div class="section-option"> <span class="section-option-title"> Placement speed <span class="tooltip"> * <span class="tooltip-text">The higher value, the faster you place</span> </span> </span> <label class="slider"> <input id="placementSpeed" min="1" max="30" type="range"> <span class="slider-value">30</span> </label> </div> <div class="section-option"> <span class="section-option-title">Placement type</span> <select id="placementType"></select> </div> <div class="section-option"> <span class="section-option-title">Autobed</span> <label class="switch-checkbox"> <input id="autobed" type="checkbox"> <span></span> </label> </div> <div class="section-option"> <span class="section-option-title">Automill</span> <label class="switch-checkbox"> <input id="automill" type="checkbox"> <span></span> </label> </div> <div class="section-option"> <span class="section-option-title"> Anti fireball <span class="tooltip"> * <span class="tooltip-text">When you collide a fireball, place platform</span> </span> </span> <label class="switch-checkbox"> <input id="antiFireball" type="checkbox"> <span></span> </label> </div> </div> </div> <div class="section opened"> <div class="section-title"> <h2>Healing</h2> </div> <div class="section-content"> <div class="split-section"> <div class="section-option"> <span class="section-option-title">Autoheal</span> <label class="switch-checkbox"> <input id="autoheal" type="checkbox"> <span></span> </label> </div> </div> </div> </div> <div class="section opened"> <div class="section-title"> <h2>Hats</h2> </div> <div class="section-content"> <div class="split-section"> <div class="section-option"> <span class="section-option-title">Jungle On Clown</span> <label class="switch-checkbox"> <input id="jungleOnClown" type="checkbox"> <span></span> </label> </div> <div class="section-option"> <span class="section-option-title"> Equip last hat <span class="tooltip"> * <span class="tooltip-text">On spawn, the last hat you had will be equipped</span> </span> </span> <label class="switch-checkbox"> <input id="lastHat" type="checkbox"> <span></span> </label> </div> <div class="section-option"> <span class="section-option-title">Auto scuba</span> <label class="switch-checkbox"> <input id="autoScuba" type="checkbox"> <span></span> </label> </div> </div> </div> </div> <div class="section opened"> <div class="section-title"> <h2>Autoaim</h2> </div> <div class="section-content"> <div class="split-section"> <div class="section-option"> <span class="section-option-title">Melee</span> <label class="switch-checkbox"> <input id="meleeAim" type="checkbox"> <span></span> </label> </div> <div class="section-option"> <span class="section-option-title">Bow</span> <label class="switch-checkbox"> <input id="bowAim" type="checkbox"> <span></span> </label> </div> <div class="section-option"> <span class="section-option-title">Spike insta</span> <label class="switch-checkbox"> <input id="spikeInstaAim" type="checkbox"> <span></span> </label> </div> <div class="section-option"> <span class="section-option-title">Autosync</span> <label class="switch-checkbox"> <input id="autosync" type="checkbox"> <span></span> </label> </div> <div class="section-option"> <span class="section-option-title">Autoboost follow</span> <label class="switch-checkbox"> <input id="autoboostFollow" type="checkbox"> <span></span> </label> </div> </div> </div> </div> </div>';
  79. const Combat = Combat_code;
  80. var Visuals_code = '<div class="menu-page"> <h1>Visuals</h1> <p>Customize your visuals, or you can disable it for performance</p> <div class="section opened"> <div class="section-title"> <h2>Tracers</h2> </div> <div class="section-content"> <div class="section-option"> <span class="section-option-title">Enemies</span> <div class="content"> <button class="default-color" title="Reset Color"></button> <input id="enemyColor" type="color"> <label class="switch-checkbox"> <input id="enemyTracers" type="checkbox"> <span></span> </label> </div> </div> <div class="section-option"> <span class="section-option-title">Arrows</span> <label class="switch-checkbox"> <input id="arrows" type="checkbox"> <span></span> </label> </div> <div class="section-option"> <span class="section-option-title">Teammates</span> <div class="content"> <button class="default-color" title="Reset Color"></button> <input id="teammateColor" type="color"> <label class="switch-checkbox"> <input id="teammateTracers" type="checkbox"> <span></span> </label> </div> </div> <div class="section-option"> <span class="section-option-title">Rainbow colors</span> <label class="switch-checkbox"> <input id="rainbow" type="checkbox"> <span></span> </label> </div> <div class="section-option"> <span class="section-option-title">Animals</span> <div class="content"> <button class="default-color" title="Reset Color"></button> <input id="animalColor" type="color"> <label class="switch-checkbox"> <input id="animalTracers" type="checkbox"> <span></span> </label> </div> </div> </div> </div> <div class="section opened"> <div class="section-title"> <h2>Markers</h2> </div> <div class="section-content"> <div class="section-option"> <span class="section-option-title">Your markers</span> <div class="content"> <button class="default-color" title="Reset Color"></button> <input id="itemMarkersColor" type="color"> <label class="switch-checkbox"> <input id="itemMarkers" type="checkbox"> <span></span> </label> </div> </div> <div class="section-option"> <span class="section-option-title">Teammates</span> <div class="content"> <button class="default-color" title="Reset Color"></button> <input id="teammateMarkersColor" type="color"> <label class="switch-checkbox"> <input id="teammateMarkers" type="checkbox"> <span></span> </label> </div> </div> <div class="section-option"> <span class="section-option-title">Enemies</span> <div class="content"> <button class="default-color" title="Reset Color"></button> <input id="enemyMarkersColor" type="color"> <label class="switch-checkbox"> <input id="enemyMarkers" type="checkbox"> <span></span> </label> </div> </div> <div class="section-option"> <span class="section-option-title"> Trap activated <span class="tooltip"> * <span class="tooltip-text">When the player or animal will be trapped, marker will change color</span> </span> </span> <div class="content"> <button class="default-color" title="Reset Color"></button> <input id="trapActivatedColor" type="color"> <label class="switch-checkbox"> <input id="trapActivated" type="checkbox"> <span></span> </label> </div> </div> </div> </div> <div class="section opened"> <div class="section-title"> <h2>Reload bars</h2> </div> <div class="section-content"> <div class="section-option"> <span class="section-option-title">Hat reload bar</span> <div class="content"> <button class="default-color" title="Reset Color"></button> <input id="hatReloadBarColor" type="color"> <label class="switch-checkbox"> <input id="hatReloadBar" type="checkbox"> <span></span> </label> </div> </div> <div class="section-option"> <span class="section-option-title">Fireball reload bar</span> <div class="content"> <button class="default-color" title="Reset Color"></button> <input id="fireballReloadBarColor" type="color"> <label class="switch-checkbox"> <input id="fireballReloadBar" type="checkbox"> <span></span> </label> </div> </div> <div class="section-option"> <span class="section-option-title">Turret reload bar</span> <div class="content"> <button class="default-color" title="Reset Color"></button> <input id="turretReloadBarColor" type="color"> <label class="switch-checkbox"> <input id="turretReloadBar" type="checkbox"> <span></span> </label> </div> </div> <div class="section-option"> <span class="section-option-title">Weapon reload bar</span> <div class="content"> <button class="default-color" title="Reset Color"></button> <input id="weaponReloadBarColor" type="color"> <label class="switch-checkbox"> <input id="weaponReloadBar" type="checkbox"> <span></span> </label> </div> </div> <div class="section-option"> <span class="section-option-title">Smooth reload bar</span> <label class="switch-checkbox"> <input id="smoothReloadBar" type="checkbox"> <span></span> </label> </div> </div> </div> <div class="section opened"> <div class="section-title"> <h2>Player</h2> </div> <div class="section-content"> <div class="section-option"> <span class="section-option-title">Anti hood</span> <label class="switch-checkbox"> <input id="showHoods" type="checkbox"> <span></span> </label> </div> <div class="section-option"> <span class="section-option-title">Render HP</span> <label class="switch-checkbox"> <input id="drawHP" type="checkbox"> <span></span> </label> </div> <div class="section-option"> <span class="section-option-title">Item counter</span> <label class="switch-checkbox"> <input id="itemCounter" type="checkbox"> <span></span> </label> </div> <div class="section-option"> <span class="section-option-title"> Visual aim <span class="tooltip"> * <span class="tooltip-text">It will show where are you aiming</span> </span> </span> <label class="switch-checkbox"> <input id="visualAim" type="checkbox"> <span></span> </label> </div> <div class="section-option"> <span class="section-option-title">Hide chat messages</span> <label class="switch-checkbox"> <input id="hideMessages" type="checkbox"> <span></span> </label> </div> </div> </div> <div class="section opened"> <div class="section-title"> <h2>Other</h2> </div> <div class="section-content"> <div class="section-option"> <span class="section-option-title">Windmill rotation</span> <label class="switch-checkbox"> <input id="windmillRotation" type="checkbox"> <span></span> </label> </div> <div class="section-option"> <span class="section-option-title"> Possible shots <span class="tooltip"> * <span class="tooltip-text">Draws a crosshair on entities that can be hit by a projectile</span> </span> </span> <label class="switch-checkbox"> <input id="possibleShots" type="checkbox"> <span></span> </label> </div> </div> </div> </div>';
  81. const Visuals = Visuals_code;
  82. var Misc_code = '<div class="menu-page"> <h1>Misc</h1> <p>Customize misc settings, add autochat messages, reset settings</p> <div class="section opened"> <div class="section-title"> <h2>Chat</h2> </div> <div class="section-content one-row"> <div class="section-option"> <span class="section-option-title">Auto chat</span> <div class="content"> <input class="input autochat" type="text" maxlength="35"> <input class="input autochat" type="text" maxlength="35"> <input class="input autochat" type="text" maxlength="35"> <input class="input autochat" type="text" maxlength="35"> <label class="switch-checkbox"> <input id="autochat" type="checkbox"> <span></span> </label> </div> </div> <div class="section-option"> <span class="section-option-title"> Kill message <span class="tooltip"> * <span class="tooltip-text left"> <div>Variables:</div> <div><span class="highlight">{KILL}</span> - amount of kills</div> <div><span class="highlight">{NAME}</span> - name of the player you killed</div> </span> </span> </span> <div class="content"> <input id="killMessage" class="input" type="text" maxlength="35"> <label class="switch-checkbox"> <input id="kill" type="checkbox"> <span></span> </label> </div> </div> </div> </div> <div class="section opened"> <div class="section-title"> <h2>Other</h2> </div> <div class="section-content"> <div class="section-option"> <span class="section-option-title">Auto spawn</span> <label class="switch-checkbox"> <input id="autospawn" type="checkbox"> <span></span> </label> </div> <div class="section-option"> <span class="section-option-title"> Smooth zoom <span class="tooltip"> * <span class="tooltip-text">Disable for performance</span> </span> </span> <label class="switch-checkbox"> <input id="smoothZoom" type="checkbox"> <span></span> </label> </div> <div class="section-option"> <span class="section-option-title"> Skip upgrades <span class="tooltip"> * <span class="tooltip-text">When you have only 1 item in the upgradebar, it will automatically select it</span> </span> </span> <label class="switch-checkbox"> <input id="skipUpgrades" type="checkbox"> <span></span> </label> </div> <div class="section-option"> <span class="section-option-title"> Invis hit toggle <span class="tooltip"> * <span class="tooltip-text">If enabled, invisible hit hotkey will work in toggle mode. Useful when you don\'t want to hold this button permanently</span> </span> </span> <label class="switch-checkbox"> <input id="invisHitToggle" type="checkbox"> <span></span> </label> </div> <div class="section-option"> <span class="section-option-title">Reverse zoom</span> <label class="switch-checkbox"> <input id="reverseZoom" type="checkbox"> <span></span> </label> </div> <div class="section-option"> <span class="section-option-title">Auto accept</span> <label class="switch-checkbox"> <input id="autoAccept" type="checkbox"> <span></span> </label> </div> <div class="section-option"> <span class="section-option-title">Always connect to</span> <select id="connectTo" class="smaller"></select> </div> </div> </div> <div class="section opened"> <div class="section-title"> <h2>Menu</h2> </div> <div class="section-content one-row"> <div class="section-option"> <span class="section-option-title">Menu transparency</span> <label class="switch-checkbox"> <input id="menuTransparency" type="checkbox"> <span></span> </label> </div> <div class="section-option"> <div class="content-double"> <button id="reset-settings" class="button red">Reset settings</button> <button id="download-settings" class="button">Download settings</button> <div class="form-upload"> <input id="upload-settings" type="file" accept=".txt"> <span class="light">DRAG SETTINGS FILE HERE OR <span class="light-extra">BROWSE</span></span> </div> </div> </div> </div> </div> </div>';
  83. const Misc = Misc_code;
  84. var Credits_code = '<div class="menu-page"> <h1>Credits</h1> <P>Some details about the script and links to my socials</P> <div class="section opened"> <div class="section-content" style="max-height:100%"> <div class="split-section"> <div class="section-option text"> <span class="section-option-title">Author</span> <span class="text-value">Murka</span> </div> <div class="section-option text"> <svg class="icon" version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"> <path d="M512 12.672c-282.88 0-512 229.248-512 512 0 226.261 146.688 418.133 350.080 485.76 25.6 4.821 34.987-11.008 34.987-24.619 0-12.16-0.427-44.373-0.64-87.040-142.421 30.891-172.459-68.693-172.459-68.693-23.296-59.093-56.96-74.88-56.96-74.88-46.379-31.744 3.584-31.104 3.584-31.104 51.413 3.584 78.421 52.736 78.421 52.736 45.653 78.293 119.851 55.68 149.12 42.581 4.608-33.109 17.792-55.68 32.427-68.48-113.707-12.8-233.216-56.832-233.216-253.013 0-55.893 19.84-101.547 52.693-137.387-5.76-12.928-23.040-64.981 4.48-135.509 0 0 42.88-13.739 140.8 52.48 40.96-11.392 84.48-17.024 128-17.28 43.52 0.256 87.040 5.888 128 17.28 97.28-66.219 140.16-52.48 140.16-52.48 27.52 70.528 10.24 122.581 5.12 135.509 32.64 35.84 52.48 81.493 52.48 137.387 0 196.693-119.68 240-233.6 252.587 17.92 15.36 34.56 46.763 34.56 94.72 0 68.523-0.64 123.563-0.64 140.203 0 13.44 8.96 29.44 35.2 24.32 204.843-67.157 351.403-259.157 351.403-485.077 0-282.752-229.248-512-512-512z"></path> </svg> <a href="https://github.com/Murka007/Dsync-client" class="text-value" target="_blank" title="Give a star please :)">Dsync client</a> </div> <div class="section-option text"> <svg class="icon" version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"> <path d="M26.963 0c1.875 0 3.387 1.516 3.476 3.3v28.7l-3.569-3.031-1.96-1.784-2.139-1.864 0.893 2.94h-18.717c-1.869 0-3.387-1.42-3.387-3.301v-21.653c0-1.784 1.52-3.303 3.393-3.303h22zM18.805 7.577h-0.040l-0.269 0.267c2.764 0.8 4.101 2.049 4.101 2.049-1.781-0.891-3.387-1.336-4.992-1.516-1.16-0.18-2.32-0.085-3.3 0h-0.267c-0.627 0-1.96 0.267-3.747 0.98-0.623 0.271-0.98 0.448-0.98 0.448s1.336-1.336 4.28-2.049l-0.18-0.18c0 0-2.229-0.085-4.636 1.693 0 0-2.407 4.192-2.407 9.36 0 0 1.333 2.32 4.991 2.408 0 0 0.533-0.711 1.073-1.336-2.053-0.624-2.853-1.872-2.853-1.872s0.179 0.088 0.447 0.267h0.080c0.040 0 0.059 0.020 0.080 0.040v0.008c0.021 0.021 0.040 0.040 0.080 0.040 0.44 0.181 0.88 0.36 1.24 0.533 0.621 0.269 1.42 0.537 2.4 0.715 1.24 0.18 2.661 0.267 4.28 0 0.8-0.18 1.6-0.356 2.4-0.713 0.52-0.267 1.16-0.533 1.863-0.983 0 0-0.8 1.248-2.94 1.872 0.44 0.621 1.060 1.333 1.060 1.333 3.659-0.080 5.080-2.4 5.16-2.301 0-5.16-2.42-9.36-2.42-9.36-2.18-1.619-4.22-1.68-4.58-1.68zM19.029 13.461c0.937 0 1.693 0.8 1.693 1.78 0 0.987-0.76 1.787-1.693 1.787s-1.693-0.8-1.693-1.779c0.003-0.987 0.764-1.784 1.693-1.788zM12.972 13.461c0.933 0 1.688 0.8 1.688 1.78 0 0.987-0.76 1.787-1.693 1.787s-1.693-0.8-1.693-1.779c0-0.987 0.76-1.784 1.699-1.788z"></path> </svg> <a href="https://discord.gg/sG9cyfGPj5" class="text-value" target="_blank" title="Join my discord server">Coding paradise</a> </div> <div class="section-option text"> <svg class="icon" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" viewBox="0 0 96 96"> <circle fill="#36363d" stroke="#6a6a81" stroke-width="2" r="48" cy="48" cx="48"/> <clipPath id="GreasyForkCircleClip" clipPathUnits="userSpaceOnUse"> <circle fill="#000" r="47" cy="48" cx="48"/> </clipPath> <text fill="#9494b8" clip-path="url(#GreasyForkCircleClip)" text-anchor="middle" font-size="18" font-family="\'DejaVu Sans\', Verdana, Arial, \'Liberation Sans\', sans-serif" letter-spacing="-0.75" pointer-events="none" style="-moz-user-select:none;-ms-user-select:none;-webkit-user-select:none;user-select:none"> <tspan x="51" y="13" textLength="57">= null;</tspan> <tspan x="56" y="35" textLength="98">function init</tspan> <tspan x="49" y="57" textLength="113">for (var i = 0;</tspan> <tspan x="50" y="79" textLength="105">XmlHttpReq</tspan> <tspan x="48" y="101" textLength="80">appendCh</tspan> </text> <path fill="#36363d" stroke="#36363d" stroke-width="4" d="M 44,29\r\n a6.36396,6.36396 0,0,1 0,9\r\n l36,36\r\n a3.25,3.25 0,0,1 -6.5,6.5\r\n l-36,-36\r\n a6.36396,6.36396 0,0,1 -9,0\r\n l-19,-19\r\n a1.76777,1.76777 0,0,1 0,-2.5\r\n l13.0,-13\r\n a1.76777,1.76777 0,0,1 2.5,0\r\n z"/> <path fill="#9494b8" d="M 44,29\r\n a6.36396,6.36396 0,0,1 0,9\r\n l36,36\r\n a3.25,3.25 0,0,1 -6.5,6.5\r\n l-36,-36\r\n a6.36396,6.36396 0,0,1 -9,0\r\n l-19,-19\r\n a1.76777,1.76777 0,0,1 2.5,-2.5\r\n l14,14 4,-4 -14,-14\r\n a1.76777,1.76777 0,0,1 2.5,-2.5\r\n l14,14 4,-4 -14,-14\r\n a1.76777,1.76777 0,0,1 2.5,-2.5\r\n z"/> </svg> <a href="https://greasyfork.org/en/users/919633" class="text-value" target="_blank" title="Please support this script on greasyfork">Dsync client</a> </div> </div> </div> </div> </div>';
  85. const Credits = Credits_code;
  86. const styles = '@import"https://fonts.googleapis.com/css2?family=Lato:wght@400;700;900&display=swap";header{background:#2f2f31;color:#76689a;padding:5px 10px;display:flex;justify-content:flex-start;align-items:center}header #version{align-self:flex-end;color:#9787bd;font-size:.5em;font-weight:600;margin-left:10px}header #version svg{fill:#9787bd}header .icon{margin-left:auto;width:35px;height:35px;fill:#cebcb4;transition:fill 100ms;cursor:pointer}header .icon:hover{fill:#ffe7dc}#navbar-container{display:flex;flex-direction:column;padding:10px;margin-right:10px;background:#2f2f31}#navbar-container .open-menu{outline:none;border:none;cursor:pointer;font-weight:900;font-size:1.4rem;padding:10px;background:#313135;color:#ffe7dc;border-right:1px solid;border-right-color:rgba(0,0,0,0);transition:background 100ms,color 100ms,border-right-color 100ms}#navbar-container .open-menu:hover{background:#313135}#navbar-container .open-menu:active{background:#ffe7dc;color:#313135}#navbar-container .open-menu.active{pointer-events:none;background:#313135;border-right-color:#ffe7dc}#navbar-container .bottom-align{margin-bottom:0px;margin-top:auto !important}@-webkit-keyframes appear{from{opacity:0}to{opacity:1}}@-webkit-keyframes disappear{from{opacity:1}to{opacity:0}}@-webkit-keyframes failedTransition{0%{transform:translate(0px, 0px)}10%{transform:translate(-35px, -10px)}30%{transform:translate(25px, 8px)}50%{transform:translate(-15px, -6px)}70%{transform:translate(5px, 4px)}100%{transform:translate(0px, 0px)}}@keyframes appear{from{opacity:0}to{opacity:1}}@keyframes disappear{from{opacity:1}to{opacity:0}}@keyframes failedTransition{0%{transform:translate(0px, 0px)}10%{transform:translate(-35px, -10px)}30%{transform:translate(25px, 8px)}50%{transform:translate(-15px, -6px)}70%{transform:translate(5px, 4px)}100%{transform:translate(0px, 0px)}}.menu-page{display:none;background:#2f2f31;padding:10px;padding-top:0px}.menu-page.opened{display:block;animation:appear 300ms forwards}.menu-page h1{color:#76689a;font-size:1.5em;font-weight:900}.menu-page h2{color:#9494b8;font-size:1em;font-weight:900}.menu-page p{color:#675a86;font-size:.5em;font-weight:700}.menu-page .content{display:flex;justify-content:space-between;align-items:center;gap:10px}.menu-page .content-double{display:flex;flex-wrap:wrap;justify-content:space-between;gap:10px;width:250px}.menu-page .content-double button{width:48%}.menu-page .content-double:nth-child(3){width:100%}.menu-page #killMessage{width:270px}.menu-page .highlight{font-weight:700;color:#ffe7dc;background:#6a6a81;padding:0 1px}.menu-page .section{background:#36363d;border-radius:5px;margin:20px 0}.menu-page .section:last-child{margin-bottom:0px}.menu-page .section .section-title{display:flex;justify-content:space-between;align-items:center;padding:10px}.menu-page .section .section-title .icon{width:25px;height:25px;margin-right:10px;fill:#cebcb4;transition:fill 100ms,transform 100ms}.menu-page .section .section-title .icon.rotate{transform:rotate(90deg);fill:#ffe7dc}.menu-page .section .section-title:hover .icon{fill:#ffe7dc}.menu-page .section:not(.opened) .section-title{cursor:pointer}.menu-page .section:not(.opened) .section-content{overflow:hidden}.menu-page .section .section-content{padding:10px;padding-top:0px;display:grid;grid-template-columns:1fr 1fr;transition:max-height 250ms cubic-bezier(0, 1, 0, 1);max-height:0px}.menu-page .section .section-content.one-row{grid-template-columns:1fr}.menu-page .section .section-content.opened{transition:max-height 250ms ease-out;max-height:100%}.menu-page .section .section-content .split{grid-column:1/3;margin-top:10px;background:#40404a;height:2px}.menu-page .section .section-content .section-option{display:flex;justify-content:space-between;align-items:center;margin-top:10px}.menu-page .section .section-content .section-option .icon{width:35px;height:35px;fill:#6a6a81}.menu-page .section .section-content .section-option.centered{justify-content:center}.menu-page .section .section-content .section-option.text{justify-content:flex-start;gap:10px}.menu-page .section .section-content .section-option.text .text-value{font-size:.7em;color:#9494b8}.menu-page .section .section-content .section-option .section-option-title{color:#6a6a81;font-size:.8em}.menu-page .section .section-content .section-option .section-option-hotkeyInput{margin-right:50px;cursor:pointer;font-weight:900;font-size:.6em;padding-bottom:8px;outline:none;border:none;text-align:center;width:80px;height:35px;border-radius:7.5px;background:#7d7d9b;color:#adbcd8;box-shadow:0px -6px 0px 0px #68687c inset}.menu-page .section .section-content .section-option .section-option-hotkeyInput.red{background:#9e5454;color:#d8adad;box-shadow:0px -6px 0px 0px #783d3d inset}.menu-page .section .section-content .section-option .section-option-hotkeyInput:not([id]){cursor:not-allowed}.menu-page .section .section-content .section-option .section-option-hotkeyInput.smaller{font-size:.41em}.menu-page .section .section-content .section-option .switch-checkbox{position:relative;margin-right:25px;width:70px;height:25px}.menu-page .section .section-content .section-option .switch-checkbox input{width:0;height:0;opacity:0}.menu-page .section .section-content .section-option .switch-checkbox input:checked+span{background:#7d7d9b;box-shadow:0px 5px 0px 0px #68687c inset}.menu-page .section .section-content .section-option .switch-checkbox input:checked+span:before{background:#ffe7dc;transform:translateX(42px)}.menu-page .section .section-content .section-option .switch-checkbox span{position:absolute;cursor:pointer;top:0;left:0;bottom:0;right:0;width:100%;height:100%;display:flex;align-items:center;background:#5f5f79;box-shadow:0px 5px 0px 0px #4d4d5f inset;border-radius:10px;transition:all 100ms ease-in-out}.menu-page .section .section-content .section-option .switch-checkbox span:before{position:absolute;content:"";width:28px;height:28px;border-radius:50%;background:#f0dcd3;box-shadow:0px -5px 0px 0px #cebcb4 inset;border:2px solid #adbcd8;transition:all 100ms ease-in-out}.menu-page .section .section-content .section-option .slider{position:relative;margin-right:45px}.menu-page .section .section-content .section-option .slider input{-webkit-appearance:none;outline:none;cursor:pointer;width:154px;height:20.8333333333px;border-radius:10px;background:#7d7d9b;box-shadow:0px 5px 0px 0px #68687c inset}.menu-page .section .section-content .section-option .slider input::-webkit-slider-thumb{-webkit-appearance:none;width:28px;height:28px;border-radius:50%;background:#ffe7dc;box-shadow:0px -5px 0px 0px #cebcb4 inset;border:2px solid #adbcd8}.menu-page .section .section-content .section-option .slider .slider-value{position:absolute;margin-left:5px;color:#6a6a81;font-size:.65em}.menu-page .section .section-content .section-option .input{outline:none;border:none;font-weight:900;text-align:center;width:130px;height:35px;padding-bottom:6px;border-radius:7.5px;background:#7d7d9b;color:#adbcd8;box-shadow:0px -6px 0px 0px #68687c inset}.menu-page .section .section-content .section-option .input:focus{border:3px solid #f0dcd3}.menu-page .section .section-content .section-option .button{outline:none;border:none;font-weight:900;cursor:pointer;height:40px;padding-bottom:6px;border-radius:7.5px;background:#7d7d9b;color:#adbcd8;box-shadow:0px -6px 0px 0px #68687c inset}.menu-page .section .section-content .section-option .button:active{padding-bottom:0px;padding-top:3px;box-shadow:0px 3px 0px 0px #68687c inset}.menu-page .section .section-content .section-option .button.red{background:#9e5454;color:#d8adad;box-shadow:0px -6px 0px 0px #783d3d inset}.menu-page .section .section-content .section-option .button.red:active{box-shadow:0px 3px 0px 0px #783d3d inset}.menu-page .section .section-content .section-option .button.width{width:9em;font-size:.6em}.menu-page .section .section-content .section-option .form-upload{position:relative;font-size:.55em;font-weight:400;letter-spacing:1.5px;text-align:center;width:100%;border-radius:5px;border:2px dashed;border-color:rgba(173,188,216,.5411764706);padding:15px 10px;transition:border-color 100ms}.menu-page .section .section-content .section-option .form-upload:hover{border-color:#adbcd8}.menu-page .section .section-content .section-option .form-upload.red{border-color:#9e5454;animation:failedTransition 400ms}.menu-page .section .section-content .section-option .form-upload.red .light{color:#d8adad}.menu-page .section .section-content .section-option .form-upload.green{border-color:#77c468}.menu-page .section .section-content .section-option .form-upload.green .light{color:#a1dda1}.menu-page .section .section-content .section-option .form-upload input{position:absolute;opacity:0;top:0;left:0;bottom:0;right:0;width:100%;height:100%;cursor:pointer}.menu-page .section .section-content .section-option .form-upload .light{color:#adbcd8}.menu-page .section .section-content .section-option .form-upload .light-extra{color:#f0dcd3}.menu-page .section .section-content .section-option .tooltip{position:relative;margin-left:5px;color:#8181a0}.menu-page .section .section-content .section-option .tooltip:hover{cursor:pointer}.menu-page .section .section-content .section-option .tooltip:hover .tooltip-text{visibility:visible}.menu-page .section .section-content .section-option .tooltip .tooltip-text{position:absolute;visibility:hidden;text-align:center;overflow:visible;bottom:calc(100% - 5px);left:50%;transform:translateX(-50%);background-color:#7d7d9b;color:#ffe7dc;width:225px;font-size:13px;font-weight:600;padding:5px;border-radius:5px;border:3px solid #5f5f79}.menu-page .section .section-content .section-option .tooltip .tooltip-text.left{text-align:left}.menu-page .section .section-content .section-option select[id]{outline:none;border:none;font-weight:900;width:195px;font-size:.6em;border-radius:7.5px;padding:2.5px;background:#7d7d9b;color:#adbcd8;box-shadow:0px 4px 0px 0px #68687c inset}.menu-page .section .section-content .section-option select[id].smaller{width:130px}@-webkit-keyframes appear{from{opacity:0}to{opacity:1}}@-webkit-keyframes disappear{from{opacity:1}to{opacity:0}}@-webkit-keyframes failedTransition{0%{transform:translate(0px, 0px)}10%{transform:translate(-35px, -10px)}30%{transform:translate(25px, 8px)}50%{transform:translate(-15px, -6px)}70%{transform:translate(5px, 4px)}100%{transform:translate(0px, 0px)}}@keyframes appear{from{opacity:0}to{opacity:1}}@keyframes disappear{from{opacity:1}to{opacity:0}}@keyframes failedTransition{0%{transform:translate(0px, 0px)}10%{transform:translate(-35px, -10px)}30%{transform:translate(25px, 8px)}50%{transform:translate(-15px, -6px)}70%{transform:translate(5px, 4px)}100%{transform:translate(0px, 0px)}}@-webkit-keyframes appear{from{opacity:0}to{opacity:1}}@-webkit-keyframes disappear{from{opacity:1}to{opacity:0}}@-webkit-keyframes failedTransition{0%{transform:translate(0px, 0px)}10%{transform:translate(-35px, -10px)}30%{transform:translate(25px, 8px)}50%{transform:translate(-15px, -6px)}70%{transform:translate(5px, 4px)}100%{transform:translate(0px, 0px)}}@keyframes appear{from{opacity:0}to{opacity:1}}@keyframes disappear{from{opacity:1}to{opacity:0}}@keyframes failedTransition{0%{transform:translate(0px, 0px)}10%{transform:translate(-35px, -10px)}30%{transform:translate(25px, 8px)}50%{transform:translate(-15px, -6px)}70%{transform:translate(5px, 4px)}100%{transform:translate(0px, 0px)}}html,body{margin:0;padding:0;background:rgba(0,0,0,0) !important;scrollbar-width:10px;scrollbar-track-color:#36363d;scrollbar-face-color:#494955}*{font-family:"Lato",sans-serif}h1,h2,h3,h4,p{margin:0}#menu-container{font-weight:900;font-size:2rem;position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);width:1024px;height:700px;display:flex;justify-content:center;align-items:center;user-select:none}#menu-container.open{animation:appear 100ms forwards}#menu-container.close{animation:disappear 100ms forwards}#menu-container.transparent #menu-wrapper{background:rgba(43,43,44,.4666666667)}#menu-container.transparent #navbar-container{background:rgba(47,47,49,.6431372549)}#menu-container.transparent .menu-page{background:rgba(47,47,49,.6431372549)}#menu-container.transparent .section{background:rgba(54,54,61,.6509803922)}#menu-wrapper{position:relative;display:flex;flex-direction:column;width:100%;height:80%;background:#2b2b2c;border-radius:5px;padding:10px}main{display:flex;justify-content:space-between;margin-top:10px;height:100%}main #menu-page-container{width:100%;height:500px;overflow-y:scroll}.default-color{outline:none;border:none;width:10px;height:10px;border-radius:100%;cursor:pointer}input[id][type=color]{outline:none;border:none;padding:0 1px;margin:0;height:24px;background-color:#7d7d9b;border-radius:5px;cursor:pointer}::-webkit-scrollbar{width:10px}::-webkit-scrollbar-track{background:#36363d;border-radius:10px}::-webkit-scrollbar-thumb{background:#494955;border-radius:10px}#popup-menu{position:absolute;top:0;left:0;bottom:0;right:0;width:100%;height:100%;display:flex;justify-content:center;align-items:center;background:rgba(25,25,35,.5)}#popup-menu #popup-container{position:relative;width:70%;height:50%;background:#2f2f31;border-radius:10px;border:6px solid #36363d;padding:10px;display:flex;justify-content:space-between}#popup-menu #popup-container #popup-wrapper{position:absolute;z-index:1;top:10px;left:10px;bottom:10px;right:10px;padding:10px;display:flex;justify-content:space-between}#popup-menu #popup-container #popup-wrapper>div{width:50%;height:100%}#popup-menu #popup-container #popup-wrapper #popup-data{display:flex;flex-direction:column}#popup-menu #popup-container #popup-title{font-size:2em;color:#ffe7dc;text-shadow:#3d3937 4px 0px 0px,#3d3937 3.87565px .989616px 0px,#3d3937 3.51033px 1.9177px 0px,#3d3937 2.92676px 2.72655px 0px,#3d3937 2.16121px 3.36588px 0px,#3d3937 1.26129px 3.79594px 0px,#3d3937 .282949px 3.98998px 0px,#3d3937 -0.712984px 3.93594px 0px,#3d3937 -1.66459px 3.63719px 0px,#3d3937 -2.51269px 3.11229px 0px,#3d3937 -3.20457px 2.39389px 0px,#3d3937 -3.69721px 1.52664px 0px,#3d3937 -3.95997px .56448px 0px,#3d3937 -3.97652px -0.432781px 0px,#3d3937 -3.74583px -1.40313px 0px,#3d3937 -3.28224px -2.28625px 0px,#3d3937 -2.61457px -3.02721px 0px,#3d3937 -1.78435px -3.57996px 0px,#3d3937 -0.843183px -3.91012px 0px,#3d3937 .150409px -3.99717px 0px,#3d3937 1.13465px -3.8357px 0px,#3d3937 2.04834px -3.43574px 0px,#3d3937 2.83468px -2.82216px 0px,#3d3937 3.44477px -2.03312px 0px,#3d3937 3.84068px -1.11766px 0px,#3d3937 3.9978px -0.132717px 0px}#popup-menu #popup-container #popup-description{color:#f0dcd3;text-shadow:#3d3937 4px 0px 0px,#3d3937 3.87565px .989616px 0px,#3d3937 3.51033px 1.9177px 0px,#3d3937 2.92676px 2.72655px 0px,#3d3937 2.16121px 3.36588px 0px,#3d3937 1.26129px 3.79594px 0px,#3d3937 .282949px 3.98998px 0px,#3d3937 -0.712984px 3.93594px 0px,#3d3937 -1.66459px 3.63719px 0px,#3d3937 -2.51269px 3.11229px 0px,#3d3937 -3.20457px 2.39389px 0px,#3d3937 -3.69721px 1.52664px 0px,#3d3937 -3.95997px .56448px 0px,#3d3937 -3.97652px -0.432781px 0px,#3d3937 -3.74583px -1.40313px 0px,#3d3937 -3.28224px -2.28625px 0px,#3d3937 -2.61457px -3.02721px 0px,#3d3937 -1.78435px -3.57996px 0px,#3d3937 -0.843183px -3.91012px 0px,#3d3937 .150409px -3.99717px 0px,#3d3937 1.13465px -3.8357px 0px,#3d3937 2.04834px -3.43574px 0px,#3d3937 2.83468px -2.82216px 0px,#3d3937 3.44477px -2.03312px 0px,#3d3937 3.84068px -1.11766px 0px,#3d3937 3.9978px -0.132717px 0px;margin-left:30px;margin-top:30px}#popup-menu #popup-container #popup-bottom{display:flex;justify-content:space-between;align-items:center;margin-top:auto}#popup-menu #popup-container #popup-bottom .popup-button{border:none;outline:none;display:inline-block;font-family:"Lato",sans-serif;text-align:center;cursor:pointer;max-width:160px;width:100%;font-size:.8em;font-weight:900;padding:5px 10px 10px;border-radius:5px;color:#ffe7dc;text-decoration:none;text-shadow:#3d3937 4px 0px 0px,#3d3937 3.87565px .989616px 0px,#3d3937 3.51033px 1.9177px 0px,#3d3937 2.92676px 2.72655px 0px,#3d3937 2.16121px 3.36588px 0px,#3d3937 1.26129px 3.79594px 0px,#3d3937 .282949px 3.98998px 0px,#3d3937 -0.712984px 3.93594px 0px,#3d3937 -1.66459px 3.63719px 0px,#3d3937 -2.51269px 3.11229px 0px,#3d3937 -3.20457px 2.39389px 0px,#3d3937 -3.69721px 1.52664px 0px,#3d3937 -3.95997px .56448px 0px,#3d3937 -3.97652px -0.432781px 0px,#3d3937 -3.74583px -1.40313px 0px,#3d3937 -3.28224px -2.28625px 0px,#3d3937 -2.61457px -3.02721px 0px,#3d3937 -1.78435px -3.57996px 0px,#3d3937 -0.843183px -3.91012px 0px,#3d3937 .150409px -3.99717px 0px,#3d3937 1.13465px -3.8357px 0px,#3d3937 2.04834px -3.43574px 0px,#3d3937 2.83468px -2.82216px 0px,#3d3937 3.44477px -2.03312px 0px,#3d3937 3.84068px -1.11766px 0px,#3d3937 3.9978px -0.132717px 0px}#popup-menu #popup-container #popup-bottom .popup-button#popup-continue{background:#77c468;box-shadow:0px -6px 0px 0px #49783d inset}#popup-menu #popup-container #popup-bottom .popup-button#popup-continue:active{padding:10px 10px 5px;box-shadow:0px 3px 0px 0px #49783d inset}#popup-menu #popup-container #popup-bottom .popup-button#popup-close{background:#9e5454;box-shadow:0px -6px 0px 0px #783d3d inset}#popup-menu #popup-container #popup-bottom .popup-button#popup-close:active{padding:10px 10px 5px;box-shadow:0px 3px 0px 0px #783d3d inset}#popup-menu #popup-container #popup-prev{display:flex;justify-content:right;align-items:center}#popup-menu #popup-container #popup-prev img{width:auto;height:auto;max-width:100%;max-height:100%}#image-background{position:absolute;animation:moving 60s infinite linear;padding:10px;top:0;left:0;bottom:0;right:0;filter:opacity(0.4)}.discord-bg{background:url(https://i.imgur.com/RcTl09i.png) 0 0/8% repeat;background-clip:content-box}.github-bg{background:url(https://i.imgur.com/q0z20jB.png) 0 0/8% repeat;background-clip:content-box}.greasyfork-bg{background:url(https://i.imgur.com/y6OYX0D.png) 0 0/8% repeat;background-clip:content-box}@keyframes moving{0%{background-position:0 0}100%{background-position:-500px 500px}}';
  87. var ELayer;
  88. (function(ELayer) {
  89. ELayer[ELayer["PLAYER"] = 0] = "PLAYER";
  90. ELayer[ELayer["STONE"] = 1] = "STONE";
  91. ELayer[ELayer["HARDSPIKE"] = 2] = "HARDSPIKE";
  92. ELayer[ELayer["TREE"] = 3] = "TREE";
  93. ELayer[ELayer["GOLD"] = 4] = "GOLD";
  94. ELayer[ELayer["BUSH"] = 5] = "BUSH";
  95. ELayer[ELayer["TRAP"] = 6] = "TRAP";
  96. ELayer[ELayer["SPIKE"] = 7] = "SPIKE";
  97. ELayer[ELayer["WOODWALL"] = 8] = "WOODWALL";
  98. ELayer[ELayer["PLATFORM"] = 9] = "PLATFORM";
  99. ELayer[ELayer["BOOST"] = 10] = "BOOST";
  100. ELayer[ELayer["LOOTBOX"] = 11] = "LOOTBOX";
  101. ELayer[ELayer["PROJECTILE"] = 12] = "PROJECTILE";
  102. ELayer[ELayer["WINDMILL"] = 13] = "WINDMILL";
  103. ELayer[ELayer["COW"] = 14] = "COW";
  104. ELayer[ELayer["SPAWN"] = 15] = "SPAWN";
  105. ELayer[ELayer["POWERMILL"] = 16] = "POWERMILL";
  106. ELayer[ELayer["CASTLESPIKE"] = 17] = "CASTLESPIKE";
  107. ELayer[ELayer["TURRET"] = 18] = "TURRET";
  108. ELayer[ELayer["WOODFARM"] = 19] = "WOODFARM";
  109. ELayer[ELayer["CHERRYWOODFARM"] = 20] = "CHERRYWOODFARM";
  110. ELayer[ELayer["STONEWARM"] = 21] = "STONEWARM";
  111. ELayer[ELayer["CASTLEWALL"] = 22] = "CASTLEWALL";
  112. ELayer[ELayer["SHARK"] = 23] = "SHARK";
  113. ELayer[ELayer["WOLF"] = 24] = "WOLF";
  114. ELayer[ELayer["GOLDENCOW"] = 25] = "GOLDENCOW";
  115. ELayer[ELayer["ROOF"] = 26] = "ROOF";
  116. ELayer[ELayer["DRAGON"] = 27] = "DRAGON";
  117. ELayer[ELayer["MAMMOTH"] = 28] = "MAMMOTH";
  118. ELayer[ELayer["FIREBALL"] = 29] = "FIREBALL";
  119. ELayer[ELayer["CHEST"] = 30] = "CHEST";
  120. ELayer[ELayer["DRAGONWALLBIG"] = 31] = "DRAGONWALLBIG";
  121. ELayer[ELayer["DRAGONWALLMEDIUM"] = 32] = "DRAGONWALLMEDIUM";
  122. ELayer[ELayer["DRAGONWALLSMALL"] = 33] = "DRAGONWALLSMALL";
  123. ELayer[ELayer["MAMMOTHWALL"] = 34] = "MAMMOTHWALL";
  124. ELayer[ELayer["MAMMOTHWALLSMALL"] = 35] = "MAMMOTHWALLSMALL";
  125. ELayer[ELayer["DUCK"] = 36] = "DUCK";
  126. ELayer[ELayer["TELEPORT"] = 37] = "TELEPORT";
  127. ELayer[ELayer["CACTUS"] = 38] = "CACTUS";
  128. ELayer[ELayer["TORNADO"] = 39] = "TORNADO";
  129. })(ELayer || (ELayer = {}));
  130. const LayerDataArray = [ {
  131. id: ELayer.PLAYER,
  132. radius: 35,
  133. maxHealth: 100,
  134. Qa: 1
  135. }, {
  136. id: ELayer.STONE,
  137. shoot: true,
  138. radius: 75,
  139. Qa: 1,
  140. Pa: 1
  141. }, {
  142. id: ELayer.HARDSPIKE,
  143. shoot: true,
  144. qa: 35,
  145. radius: 45,
  146. maxHealth: 500,
  147. Qa: 1
  148. }, {
  149. id: ELayer.TREE,
  150. shoot: true,
  151. cannotShoot: true,
  152. radius: 90,
  153. Qa: 1,
  154. Ka: 1
  155. }, {
  156. id: ELayer.GOLD,
  157. shoot: true,
  158. radius: 76,
  159. Qa: 1,
  160. Xa: 5
  161. }, {
  162. id: ELayer.BUSH,
  163. shoot: true,
  164. radius: 50,
  165. Qa: 1,
  166. Na: 1
  167. }, {
  168. id: ELayer.TRAP,
  169. radius: 40,
  170. maxHealth: 500,
  171. Qa: 1
  172. }, {
  173. id: ELayer.SPIKE,
  174. shoot: true,
  175. qa: 20,
  176. radius: 45,
  177. maxHealth: 375,
  178. Ia: 20,
  179. Qa: 1
  180. }, {
  181. id: ELayer.WOODWALL,
  182. shoot: true,
  183. radius: 45,
  184. maxHealth: 380,
  185. Qa: 1
  186. }, {
  187. id: ELayer.PLATFORM,
  188. radius: 60,
  189. maxHealth: 300,
  190. Qa: 1
  191. }, {
  192. id: ELayer.BOOST,
  193. radius: 40,
  194. maxHealth: 300,
  195. Qa: 1
  196. }, {
  197. id: ELayer.LOOTBOX,
  198. radius: 40,
  199. maxHealth: 4,
  200. Qa: 1
  201. }, {
  202. id: ELayer.PROJECTILE,
  203. radius: 0,
  204. maxHealth: 0
  205. }, {
  206. id: ELayer.WINDMILL,
  207. shoot: true,
  208. radius: 45,
  209. maxHealth: 400,
  210. rotateSpeed: Math.PI / 4,
  211. Qa: 1
  212. }, {
  213. id: ELayer.COW,
  214. radius: 90,
  215. maxHealth: 380,
  216. animal: true,
  217. Qa: 1,
  218. Ja: 1.6,
  219. $a: 9,
  220. ts: 0
  221. }, {
  222. id: ELayer.SPAWN,
  223. shoot: true,
  224. radius: 50,
  225. maxHealth: 380,
  226. Qa: 1
  227. }, {
  228. id: ELayer.POWERMILL,
  229. shoot: true,
  230. radius: 54,
  231. maxHealth: 400,
  232. rotateSpeed: Math.PI / 2,
  233. Qa: 1
  234. }, {
  235. id: ELayer.CASTLESPIKE,
  236. shoot: true,
  237. qa: 5,
  238. radius: 42,
  239. maxHealth: 1200,
  240. Ia: 24,
  241. Qa: 1
  242. }, {
  243. id: ELayer.TURRET,
  244. shoot: true,
  245. radius: 45,
  246. maxHealth: 800,
  247. Qa: 1
  248. }, {
  249. id: ELayer.WOODFARM,
  250. shoot: true,
  251. cannotShoot: true,
  252. radius: 80,
  253. Qa: 1,
  254. Ka: 1
  255. }, {
  256. id: ELayer.CHERRYWOODFARM,
  257. shoot: true,
  258. cannotShoot: true,
  259. radius: 80,
  260. Qa: 1,
  261. Ka: 1
  262. }, {
  263. id: ELayer.STONEWARM,
  264. shoot: true,
  265. radius: 60,
  266. Qa: 1,
  267. Pa: 1
  268. }, {
  269. id: ELayer.CASTLEWALL,
  270. shoot: true,
  271. radius: 59,
  272. maxHealth: 1750,
  273. Qa: 1
  274. }, {
  275. id: ELayer.SHARK,
  276. radius: 90,
  277. maxHealth: 380,
  278. animal: true,
  279. Qa: 1,
  280. Ja: 1.2,
  281. $a: 49,
  282. qa: 14,
  283. ts: 3
  284. }, {
  285. id: ELayer.WOLF,
  286. radius: 50,
  287. maxHealth: 380,
  288. animal: true,
  289. Qa: 1,
  290. Ja: 1.6,
  291. $a: 17,
  292. qa: 14,
  293. ts: 0
  294. }, {
  295. id: ELayer.GOLDENCOW,
  296. radius: 90,
  297. maxHealth: 1e3,
  298. animal: true,
  299. Qa: 1,
  300. Ja: 1.6,
  301. $a: 17,
  302. qa: 19
  303. }, {
  304. id: ELayer.ROOF,
  305. radius: 50,
  306. maxHealth: 300,
  307. Qa: 1
  308. }, {
  309. id: ELayer.DRAGON,
  310. radius: 100,
  311. maxHealth: 5e3,
  312. animal: true,
  313. Qa: 1,
  314. Ja: 1.15,
  315. $a: 17,
  316. qa: 30,
  317. ts: 0
  318. }, {
  319. id: ELayer.MAMMOTH,
  320. radius: 90,
  321. maxHealth: 5e3,
  322. animal: true,
  323. Qa: 1,
  324. Ja: 1.6,
  325. $a: 17,
  326. qa: 30,
  327. ts: 1
  328. }, {
  329. id: ELayer.FIREBALL,
  330. radius: 100,
  331. maxHealth: 380,
  332. Qa: 1,
  333. Ja: .4,
  334. $a: 1,
  335. qa: 15,
  336. ts: 0
  337. }, {
  338. id: ELayer.CHEST,
  339. shoot: true,
  340. radius: 45,
  341. maxHealth: 380,
  342. Qa: 1,
  343. Xa: 50,
  344. Lr: 20
  345. }, {
  346. id: ELayer.DRAGONWALLBIG,
  347. shoot: true,
  348. radius: 92,
  349. Qa: 1,
  350. Pa: 1
  351. }, {
  352. id: ELayer.DRAGONWALLMEDIUM,
  353. shoot: true,
  354. radius: 92,
  355. Qa: 1,
  356. Pa: 1
  357. }, {
  358. id: ELayer.DRAGONWALLSMALL,
  359. shoot: true,
  360. radius: 58,
  361. Qa: 1,
  362. Pa: 1
  363. }, {
  364. id: ELayer.MAMMOTHWALL,
  365. shoot: true,
  366. radius: 92,
  367. Qa: 1,
  368. Pa: 0
  369. }, {
  370. id: ELayer.MAMMOTHWALLSMALL,
  371. shoot: true,
  372. radius: 20,
  373. Qa: 1,
  374. Pa: 0
  375. }, {
  376. id: ELayer.DUCK,
  377. radius: 20,
  378. maxHealth: 380,
  379. animal: true,
  380. Qa: 1,
  381. Ja: 1.6,
  382. $a: 9,
  383. ts: 0
  384. }, {
  385. id: ELayer.TELEPORT,
  386. shoot: true,
  387. radius: 35,
  388. maxHealth: 150,
  389. Qa: 1
  390. }, {
  391. id: ELayer.CACTUS,
  392. shoot: true,
  393. radius: 50,
  394. Qa: 1,
  395. Na: 5,
  396. qa: 20
  397. }, {
  398. id: ELayer.TORNADO,
  399. radius: 220,
  400. rotateSpeed: Math.PI / 4,
  401. Qa: 0,
  402. Na: 5,
  403. qa: 1
  404. } ];
  405. const LayerData = LayerDataArray;
  406. const LayerObjects = LayerData.filter((layer => layer.shoot));
  407. const Animals = LayerData.filter((layer => layer.animal));
  408. var EObjects;
  409. (function(EObjects) {
  410. EObjects[EObjects["BOOST"] = 6] = "BOOST";
  411. EObjects[EObjects["PLATFORM"] = 8] = "PLATFORM";
  412. EObjects[EObjects["TRAP"] = 9] = "TRAP";
  413. EObjects[EObjects["WINDMILL"] = 14] = "WINDMILL";
  414. EObjects[EObjects["SPAWN"] = 16] = "SPAWN";
  415. EObjects[EObjects["POWERMILL"] = 19] = "POWERMILL";
  416. EObjects[EObjects["ROOF"] = 48] = "ROOF";
  417. })(EObjects || (EObjects = {}));
  418. var EWeapons;
  419. (function(EWeapons) {
  420. EWeapons[EWeapons["MUSKET"] = 4] = "MUSKET";
  421. EWeapons[EWeapons["SHIELD"] = 11] = "SHIELD";
  422. EWeapons[EWeapons["STICK"] = 13] = "STICK";
  423. EWeapons[EWeapons["HAMMER"] = 15] = "HAMMER";
  424. EWeapons[EWeapons["BOW"] = 26] = "BOW";
  425. EWeapons[EWeapons["XBOW"] = 27] = "XBOW";
  426. EWeapons[EWeapons["PEARL"] = 50] = "PEARL";
  427. EWeapons[EWeapons["SCYTHE"] = 57] = "SCYTHE";
  428. })(EWeapons || (EWeapons = {}));
  429. var PlacementType;
  430. (function(PlacementType) {
  431. PlacementType[PlacementType["DEFAULT"] = 0] = "DEFAULT";
  432. PlacementType[PlacementType["INVISIBLE"] = 1] = "INVISIBLE";
  433. PlacementType[PlacementType["HOLDING"] = 2] = "HOLDING";
  434. })(PlacementType || (PlacementType = {}));
  435. var EServers;
  436. (function(EServers) {
  437. EServers["SAND_EU1"] = "SFRA";
  438. EServers["SAND_EU2"] = "SFRA2BIS";
  439. EServers["SAND_USA1"] = "SCA";
  440. EServers["SAND_USA2"] = "SCA2";
  441. EServers["SAND_AS1"] = "SGP";
  442. EServers["SAND_AS2"] = "SGP2";
  443. EServers["SAND_AS3"] = "SGP3BIS";
  444. EServers["NORM_EU1"] = "FRA1FFA";
  445. EServers["NORM_USA1"] = "CA1FFA";
  446. EServers["NORM_AS1"] = "SGP1FFA";
  447. EServers["BATTLE_USA1"] = "BRSCA";
  448. })(EServers || (EServers = {}));
  449. const selectData = {
  450. placementType: PlacementType,
  451. connectTo: EServers
  452. };
  453. var TargetReload;
  454. (function(TargetReload) {
  455. TargetReload[TargetReload["TURRET"] = 3e3] = "TURRET";
  456. TargetReload[TargetReload["HAT"] = 1300] = "HAT";
  457. TargetReload[TargetReload["DRAGON"] = 3e3] = "DRAGON";
  458. })(TargetReload || (TargetReload = {}));
  459. var Hit;
  460. (function(Hit) {
  461. Hit[Hit["CANNOT"] = 0] = "CANNOT";
  462. Hit[Hit["CAN"] = 1] = "CAN";
  463. Hit[Hit["NEEDDESTROY"] = 2] = "NEEDDESTROY";
  464. })(Hit || (Hit = {}));
  465. const Reload = {
  466. hat: {
  467. current: TargetReload.HAT,
  468. lerp: TargetReload.HAT,
  469. max: TargetReload.HAT,
  470. color: () => Settings.hatReloadBarColor
  471. },
  472. weapon: {
  473. current: 0,
  474. lerp: 0,
  475. max: 0,
  476. color: () => Settings.weaponReloadBarColor
  477. },
  478. turret: {
  479. current: TargetReload.TURRET,
  480. lerp: TargetReload.TURRET,
  481. max: TargetReload.TURRET,
  482. color: () => Settings.turretReloadBarColor
  483. },
  484. fireball: {
  485. current: TargetReload.DRAGON,
  486. lerp: TargetReload.DRAGON,
  487. max: TargetReload.DRAGON,
  488. color: () => Settings.fireballReloadBarColor
  489. }
  490. };
  491. const storage = {
  492. get(key) {
  493. const item = localStorage.getItem(key);
  494. return item !== null ? JSON.parse(item) : null;
  495. },
  496. set(key, value) {
  497. localStorage.setItem(key, JSON.stringify(value));
  498. },
  499. delete(key) {
  500. localStorage.removeItem(key);
  501. }
  502. };
  503. const defaultSettings = {
  504. primary: "Digit1",
  505. secondary: "Digit2",
  506. heal: "KeyQ",
  507. wall: "Digit4",
  508. spike: "KeyV",
  509. windmill: "KeyN",
  510. trap: "KeyF",
  511. turret: "KeyH",
  512. tree: "KeyU",
  513. platform: "KeyT",
  514. spawn: "KeyJ",
  515. up: "KeyW",
  516. left: "KeyA",
  517. down: "KeyS",
  518. right: "KeyD",
  519. autoattack: "KeyE",
  520. lockRotation: "KeyX",
  521. openChat: "Enter",
  522. invisibleHit: 2,
  523. spikeInsta: "KeyR",
  524. toggleMenu: "Escape",
  525. fastBreak: "KeyZ",
  526. upgradeScythe: "...",
  527. unequip: "...",
  528. bush: "...",
  529. berserker: "...",
  530. jungle: "...",
  531. crystal: "...",
  532. spikegear: "...",
  533. immunity: 4,
  534. boost: 3,
  535. applehat: "...",
  536. scuba: "...",
  537. hood: "...",
  538. demolist: "...",
  539. placementType: PlacementType.INVISIBLE,
  540. placementSpeed: 1,
  541. autobed: true,
  542. automill: true,
  543. antiFireball: true,
  544. autoheal: true,
  545. jungleOnClown: true,
  546. lastHat: true,
  547. autoScuba: true,
  548. meleeAim: true,
  549. bowAim: true,
  550. spikeInstaAim: true,
  551. autosync: true,
  552. autoboostFollow: true,
  553. enemyTracers: true,
  554. teammateTracers: true,
  555. animalTracers: true,
  556. enemyColor: "#cc5151",
  557. teammateColor: "#8ecc51",
  558. animalColor: "#518ccc",
  559. arrows: true,
  560. rainbow: false,
  561. drawHP: true,
  562. showHoods: true,
  563. itemCounter: true,
  564. visualAim: true,
  565. hideMessages: false,
  566. itemMarkers: true,
  567. teammateMarkers: true,
  568. enemyMarkers: true,
  569. trapActivated: true,
  570. itemMarkersColor: "#8ecc51",
  571. teammateMarkersColor: "#cfbc5f",
  572. enemyMarkersColor: "#cc5151",
  573. trapActivatedColor: "#48b2b8",
  574. hatReloadBar: true,
  575. hatReloadBarColor: "#5155cc",
  576. fireballReloadBar: true,
  577. fireballReloadBarColor: "#cf7148",
  578. turretReloadBar: true,
  579. turretReloadBarColor: "#51cc80",
  580. weaponReloadBar: true,
  581. weaponReloadBarColor: "#cc8251",
  582. smoothReloadBar: true,
  583. windmillRotation: false,
  584. possibleShots: true,
  585. autochat: true,
  586. autochatMessages: [ "Dsync Client", "What is it?", "The most advanced hack for sploop!", "Download on greasyfork!" ],
  587. kill: true,
  588. killMessage: "{NAME}, you suck! {KILL}x",
  589. autospawn: false,
  590. smoothZoom: true,
  591. skipUpgrades: true,
  592. invisHitToggle: false,
  593. reverseZoom: false,
  594. autoAccept: false,
  595. connectTo: "SFRA",
  596. menuTransparency: false,
  597. blindUsers: [ 0, 0, 0 ]
  598. };
  599. const settings = {
  600. ...defaultSettings,
  601. ...storage.get("Dsync-settings")
  602. };
  603. for (const key in settings) {
  604. if (!defaultSettings.hasOwnProperty(key)) {
  605. delete settings[key];
  606. }
  607. }
  608. storage.set("Dsync-settings", settings);
  609. const Settings = settings;
  610. class Formatter {
  611. static object(target) {
  612. const layer = LayerData[target.type];
  613. return {
  614. id: target[Dsync.props.id],
  615. type: target.type,
  616. x: target[Dsync.props.x],
  617. y: target[Dsync.props.y],
  618. x1: target[Dsync.props.x1],
  619. y1: target[Dsync.props.y1],
  620. x2: target[Dsync.props.x2],
  621. y2: target[Dsync.props.y2],
  622. angle: target[Dsync.props.angle],
  623. angle1: target[Dsync.props.angle1],
  624. angle2: target[Dsync.props.angle2],
  625. ownerID: target[Dsync.props.ownerID],
  626. radius: layer.radius,
  627. layerData: layer,
  628. target
  629. };
  630. }
  631. static projectile(target) {
  632. const object = this.object(target);
  633. return {
  634. ...object,
  635. range: target.range,
  636. projectileType: target[Dsync.props.projectileType]
  637. };
  638. }
  639. static entity(target) {
  640. const object = this.object(target);
  641. const healthValue = target[Dsync.props.health];
  642. const maxHealth = object.layerData.maxHealth || 1;
  643. return {
  644. ...object,
  645. healthValue,
  646. health: Math.ceil(healthValue / 255 * maxHealth),
  647. maxHealth,
  648. entityValue: target[Dsync.props.entityValue]
  649. };
  650. }
  651. static player(target) {
  652. const entity = this.entity(target);
  653. return {
  654. ...entity,
  655. hat: target[Dsync.props.hat],
  656. isClown: entity.entityValue === 128,
  657. currentItem: target[Dsync.props.currentItem]
  658. };
  659. }
  660. }
  661. const TYPEOF = value => Object.prototype.toString.call(value).slice(8, -1).toLowerCase();
  662. const removeClass = (target, name) => {
  663. if (target instanceof HTMLElement) {
  664. target.classList.remove(name);
  665. return;
  666. }
  667. for (const element of target) {
  668. element.classList.remove(name);
  669. }
  670. };
  671. const removeChildren = target => {
  672. while (target.firstChild) {
  673. target.removeChild(target.firstChild);
  674. }
  675. };
  676. const formatCode = code => {
  677. code = code + "";
  678. if (code === "0") return "LBTN";
  679. if (code === "1") return "MBTN";
  680. if (code === "2") return "RBTN";
  681. if (code === "3") return "XBTN2";
  682. if (code === "4") return "XBTN1";
  683. if (code === "Escape") return "ESC";
  684. if (code === "BracketLeft") return "[";
  685. if (code === "BracketRight") return "]";
  686. if (code === "NumpadDivide") return "NUMDIV";
  687. if (code === "NumpadMultiply") return "NUMMULT";
  688. if (code === "NumpadSubtract") return "NUMSUB";
  689. if (code === "NumpadDecimal") return "NUMDEC";
  690. if (code === "CapsLock") return "CAPS";
  691. if (code === "PrintScreen") return "PRNT";
  692. if (code === "Backslash") return "\\";
  693. if (code === "Backquote") return "BQUOTE";
  694. if (code === "PageDown") return "PAGEDN";
  695. const NumpadDigitArrowKey = /^(?:Numpad|Digit|Arrow|Key)(\w+)$/;
  696. if (NumpadDigitArrowKey.test(code)) {
  697. code = code.replace(NumpadDigitArrowKey, "$1").replace(/Numpad/, "NUM");
  698. }
  699. const ExtraKeysRegex = /^(Control|Shift|Alt)(.).*/;
  700. if (ExtraKeysRegex.test(code)) {
  701. code = code.replace(ExtraKeysRegex, "$2$1").replace(/Control/, "CTRL");
  702. }
  703. return code.toUpperCase();
  704. };
  705. const contains = (target, name) => target.classList.contains(name);
  706. const isInput = target => {
  707. const element = target || document.activeElement || document.body;
  708. return [ "TEXTAREA", "INPUT" ].includes(element.tagName);
  709. };
  710. const random = (min, max) => {
  711. const isInteger = Number.isInteger(min) && Number.isInteger(max);
  712. if (isInteger) return Math.floor(Math.random() * (max - min + 1) + min);
  713. return Math.random() * (max - min) + min;
  714. };
  715. const clamp = (value, min, max) => Math.min(Math.max(value, min), max);
  716. const lerp = (start, stop, amt) => amt * (stop - start) + start;
  717. const sleep = ms => new Promise((resolve => setTimeout(resolve, ms)));
  718. const download = (data, filename) => {
  719. const blob = new Blob([ JSON.stringify(data, null, 4) ], {
  720. type: "application/json "
  721. });
  722. const url = URL.createObjectURL(blob);
  723. const a = document.createElement("a");
  724. a.href = url;
  725. a.download = (filename || "settings") + ".txt";
  726. a.click();
  727. a.remove();
  728. URL.revokeObjectURL(url);
  729. };
  730. const GM = (property, value) => {
  731. if (!Dsync.PRODUCTION) return true;
  732. try {
  733. return GM_info.script[property] === value;
  734. } catch (err) {
  735. return false;
  736. }
  737. };
  738. const fromCharCode = codes => codes.map((code => String.fromCharCode(code))).join("");
  739. const isBlind = () => !Settings.blindUsers.every((a => a === 1));
  740. const angle = (x1, y1, x2, y2) => Math.atan2(y2 - y1, x2 - x1);
  741. const formatAge = age => Math.floor(Math.log(1 + Math.max(0, age)) ** 2.4 / 13);
  742. const doWhile = (condition, callback, delay) => {
  743. if (!condition()) return;
  744. const interval = setInterval((() => {
  745. if (condition()) {
  746. callback();
  747. } else {
  748. clearInterval(interval);
  749. }
  750. }), delay);
  751. };
  752. const createMenu = () => {
  753. const IFRAME_CONTENT = `\n <style>${styles}</style>\n <div id="menu-container" class="open">\n <div id="menu-wrapper">\n ${Header}\n\n <main>\n ${Navbar}\n\n <div id="menu-page-container">\n ${Keybinds}\n ${Combat}\n ${Visuals}\n ${Misc}\n ${Credits}\n </div>\n </main>\n </div>\n </div>\n `;
  754. const IFRAME_STYLE = `\n #iframe-page-container {\n position: absolute;\n top: 0;\n left: 0;\n bottom: 0;\n right: 0;\n width: 100%;\n height: 100%;\n margin: 0;\n padding: 0;\n z-index: 99;\n border: none;\n outline: none;\n overflow: scroll;\n display: none;\n }\n\n .iframe-opened {\n display: block!important;\n }\n\n #main-content {\n background: none;\n }\n\n #game-content {\n justify-content: center;\n }\n `;
  755. const IFRAME = document.createElement("iframe");
  756. const blob = new Blob([ IFRAME_CONTENT ], {
  757. type: "text/html; charset=utf-8"
  758. });
  759. IFRAME.src = URL.createObjectURL(blob);
  760. IFRAME.id = "iframe-page-container";
  761. document.body.appendChild(IFRAME);
  762. const style = document.createElement("style");
  763. style.innerHTML = IFRAME_STYLE;
  764. document.head.appendChild(style);
  765. IFRAME.onload = () => {
  766. const iframeWindow = IFRAME.contentWindow;
  767. const iframeDocument = iframeWindow.document;
  768. URL.revokeObjectURL(IFRAME.src);
  769. const menuContainer = iframeDocument.getElementById("menu-container");
  770. const menuWrapper = iframeDocument.getElementById("menu-wrapper");
  771. const openMenu = iframeDocument.querySelectorAll(".open-menu");
  772. const menuPage = iframeDocument.querySelectorAll(".menu-page");
  773. const sections = iframeDocument.querySelectorAll(".section");
  774. const hotkeyInputs = iframeDocument.querySelectorAll(".section-option-hotkeyInput[id]");
  775. const closeMenu = iframeDocument.querySelector("#close-menu");
  776. const checkboxs = iframeDocument.querySelectorAll("input[type='checkbox'][id]");
  777. const sliders = iframeDocument.querySelectorAll("input[type='range'][id]");
  778. const headerVersion = iframeDocument.querySelector("#version > span");
  779. const autochatInputs = iframeDocument.querySelectorAll(".input.autochat");
  780. const killMessage = iframeDocument.querySelector("#killMessage");
  781. const resetSettings = iframeDocument.querySelector("#reset-settings");
  782. const downloadSettings = iframeDocument.querySelector("#download-settings");
  783. const uploadSettings = iframeDocument.querySelector("#upload-settings");
  784. const menuTransparency = iframeDocument.querySelector("#menuTransparency");
  785. const colorPickers = iframeDocument.querySelectorAll("input[type='color'][id]");
  786. const selects = iframeDocument.querySelectorAll("select[id]");
  787. let popupCount = 0;
  788. const popups = [ {
  789. index: 0,
  790. title: "Discord",
  791. description: "Join our community!",
  792. link: "https://discord.gg/sG9cyfGPj5",
  793. prev: "https://i.imgur.com/DuLtryo.png"
  794. }, {
  795. index: 1,
  796. title: "Github",
  797. description: "Star a repository!",
  798. link: "https://github.com/Murka007/Dsync-client",
  799. prev: "https://i.imgur.com/u4aX4G1.png"
  800. }, {
  801. index: 2,
  802. title: "Greasyfork",
  803. description: "Write a feedback!",
  804. link: "https://greasyfork.org/en/scripts/449995-dsync-client-sploop-io/feedback#post-discussion",
  805. prev: "https://i.imgur.com/L1YP7cK.png"
  806. } ];
  807. const pickPopup = () => {
  808. const pups = popups.filter(((popup, index) => Settings.blindUsers[index] === 0));
  809. if (pups.length) {
  810. const popup = pups[popupCount++];
  811. popupCount %= pups.length;
  812. return popup;
  813. }
  814. return null;
  815. };
  816. let popupOpened = false;
  817. const createPopup = () => {
  818. if (popupOpened) return;
  819. const popup = pickPopup();
  820. if (!popup) return;
  821. popupOpened = true;
  822. const div = document.createElement("div");
  823. div.innerHTML = `\n <div id="popup-menu">\n <div id="popup-container">\n <div id="image-background" class="${popup.title.toLowerCase()}-bg"></div>\n\n <div id="popup-wrapper">\n <div id="popup-data">\n <div id="popup-title">${popup.title}</div>\n <div id="popup-description">${popup.description}</div>\n\n <div id="popup-bottom">\n <a id="popup-continue" class="popup-button" href="${popup.link}" target="_blank">CONTINUE</a>\n <button id="popup-close" class="popup-button">CLOSE</button>\n </div>\n </div>\n\n <div id="popup-prev">\n <img src="${popup.prev}"></img>\n </div>\n </div>\n </div>\n </div>\n `;
  824. const popupMenu = div.querySelector("#popup-menu");
  825. const container = div.querySelector("#popup-container");
  826. const continuePopup = div.querySelector("#popup-continue");
  827. const closePopup = div.querySelector("#popup-close");
  828. continuePopup.onclick = () => {
  829. popupCount -= 1;
  830. Settings.blindUsers[popup.index] = 1;
  831. storage.set("Dsync-settings", Settings);
  832. };
  833. closePopup.onclick = () => {
  834. container.style.cssText = "transition: all 150ms ease 0s; transform: scale(0); opacity: 0;";
  835. setTimeout((() => {
  836. popupMenu.remove();
  837. popupOpened = false;
  838. }), 150);
  839. };
  840. menuWrapper.appendChild(popupMenu);
  841. };
  842. const update = () => {
  843. for (const select of selects) {
  844. removeChildren(select);
  845. const data = selectData[select.id];
  846. for (const key in data) {
  847. if (!isNaN(Number(key))) continue;
  848. const keyValue = key;
  849. const option = document.createElement("option");
  850. option.value = data[keyValue];
  851. option.textContent = keyValue;
  852. if (data[keyValue] === Settings[select.id]) {
  853. option.selected = true;
  854. option.defaultSelected = true;
  855. }
  856. select.appendChild(option);
  857. }
  858. select.onchange = () => {
  859. const dataValue = /^\d+$/.test(String(select.value)) ? Number(select.value) : select.value;
  860. Settings[select.id] = dataValue;
  861. if (select.id === "placementType" && dataValue === PlacementType.DEFAULT) {
  862. Settings.autoheal = false;
  863. Settings.autoboostFollow = false;
  864. update();
  865. }
  866. storage.set("Dsync-settings", Settings);
  867. };
  868. }
  869. for (const picker of colorPickers) {
  870. const resetColor = picker.previousElementSibling;
  871. if (resetColor) {
  872. const defaultColor = defaultSettings[picker.id];
  873. resetColor.style.backgroundColor = defaultColor;
  874. resetColor.onclick = () => {
  875. picker.value = defaultColor;
  876. Settings[picker.id] = defaultColor;
  877. storage.set("Dsync-settings", Settings);
  878. };
  879. }
  880. picker.value = Settings[picker.id];
  881. picker.onchange = () => {
  882. Settings[picker.id] = picker.value;
  883. storage.set("Dsync-settings", Settings);
  884. picker.blur();
  885. };
  886. }
  887. menuContainer.classList[Settings.menuTransparency ? "add" : "remove"]("transparent");
  888. killMessage.value = Settings.killMessage;
  889. killMessage.onchange = () => {
  890. Settings.killMessage = killMessage.value;
  891. storage.set("Dsync-settings", Settings);
  892. killMessage.blur();
  893. };
  894. for (let i = 0; i < autochatInputs.length; i++) {
  895. const input = autochatInputs[i];
  896. input.value = Settings.autochatMessages[i] || "";
  897. input.onchange = () => {
  898. Settings.autochatMessages[i] = input.value;
  899. storage.set("Dsync-settings", Settings);
  900. input.blur();
  901. };
  902. }
  903. headerVersion.textContent = "v" + Dsync.version;
  904. for (const slider of sliders) {
  905. const sliderValue = slider.nextElementSibling;
  906. slider.value = Settings[slider.id];
  907. if (sliderValue) {
  908. sliderValue.textContent = slider.value;
  909. }
  910. slider.oninput = () => {
  911. const value = Number(slider.value) % 5;
  912. slider.value -= value;
  913. if (sliderValue) {
  914. sliderValue.textContent = slider.value;
  915. }
  916. Settings[slider.id] = Number(slider.value);
  917. storage.set("Dsync-settings", Settings);
  918. };
  919. }
  920. for (const checkbox of checkboxs) {
  921. checkbox.checked = Settings[checkbox.id];
  922. checkbox.onchange = () => {
  923. Settings[checkbox.id] = checkbox.checked;
  924. storage.set("Dsync-settings", Settings);
  925. checkbox.blur();
  926. };
  927. }
  928. let popupCount = 0;
  929. Dsync.toggleMenu = () => {
  930. menuContainer.classList.toggle("close");
  931. if (menuContainer.classList.toggle("open") && !popupOpened) {
  932. popupCount += 1;
  933. if ((popupCount %= 5) === 0) {
  934. createPopup();
  935. }
  936. }
  937. setTimeout((() => {
  938. IFRAME.classList.toggle("iframe-opened");
  939. }), 100);
  940. };
  941. closeMenu.onclick = Dsync.toggleMenu;
  942. for (let i = 0; i < openMenu.length; i++) {
  943. openMenu[i].onclick = () => {
  944. removeClass(openMenu, "active");
  945. openMenu[i].classList.add("active");
  946. removeClass(menuPage, "opened");
  947. menuPage[i].classList.add("opened");
  948. };
  949. }
  950. for (const section of sections) {
  951. const title = section.children[0];
  952. const content = section.children[1];
  953. if (!title || !content) continue;
  954. if (contains(section, "opened")) {
  955. content.classList.add("opened");
  956. continue;
  957. }
  958. content.style.display = "none";
  959. title.onclick = () => {
  960. if (!content.classList.contains("opened")) {
  961. content.style.display = "grid";
  962. } else {
  963. setTimeout((() => {
  964. content.style.display = "none";
  965. }), 100);
  966. }
  967. setTimeout((() => {
  968. content.classList.toggle("opened");
  969. title.children[1].classList.toggle("rotate");
  970. }), 0);
  971. };
  972. }
  973. for (const hotkeyInput of hotkeyInputs) {
  974. try {
  975. hotkeyInput.textContent = formatCode(Settings[hotkeyInput.id]);
  976. } catch (err) {
  977. throw new Error(hotkeyInput.id + " doesn't exist in settings");
  978. }
  979. }
  980. checkForRepeats();
  981. };
  982. menuTransparency.addEventListener("change", (() => {
  983. menuContainer.classList[menuTransparency.checked ? "add" : "remove"]("transparent");
  984. }));
  985. resetSettings.onclick = () => {
  986. Object.assign(Settings, defaultSettings);
  987. storage.set("Dsync-settings", Settings);
  988. update();
  989. };
  990. downloadSettings.onclick = () => {
  991. download(Settings, "DsyncSettings" + Dsync.version);
  992. };
  993. uploadSettings.onchange = async event => {
  994. const target = event.target;
  995. const parent = uploadSettings.parentElement;
  996. const spanText = parent.children[1];
  997. parent.classList.remove("red");
  998. parent.classList.remove("green");
  999. try {
  1000. const text = await target.files[0].text();
  1001. const sets = JSON.parse(text);
  1002. if (Object.keys(sets).every((key => defaultSettings.hasOwnProperty(key)))) {
  1003. Object.assign(Settings, sets);
  1004. storage.set("Dsync-settings", Settings);
  1005. update();
  1006. parent.classList.add("green");
  1007. spanText.innerHTML = `SETTINGS LOADED SUCCESSFULLY`;
  1008. } else {
  1009. throw new Error("Invalid settings");
  1010. }
  1011. } catch (err) {
  1012. parent.classList.add("red");
  1013. spanText.innerHTML = "SETTINGS ARE NOT VALID, TRY ANOTHER";
  1014. }
  1015. };
  1016. const checkForRepeats = () => {
  1017. const list = new Map;
  1018. for (const hotkeyInput of hotkeyInputs) {
  1019. const value = Settings[hotkeyInput.id];
  1020. const [count, inputs] = list.get(value) || [ 0, [] ];
  1021. list.set(value, [ (count || 0) + 1, [ ...inputs, hotkeyInput ] ]);
  1022. hotkeyInput.classList.remove("red");
  1023. }
  1024. for (const data of list) {
  1025. const [number, hotkeyInputs] = data[1];
  1026. if (number === 1) continue;
  1027. for (const hotkeyInput of hotkeyInputs) {
  1028. hotkeyInput.classList.add("red");
  1029. }
  1030. }
  1031. };
  1032. Dsync.active = null;
  1033. const applyCode = code => {
  1034. if (!Dsync.active) return;
  1035. const key = code === "Backspace" ? "..." : formatCode(code);
  1036. Settings[Dsync.active.id] = code === "Backspace" ? "..." : code;
  1037. Dsync.active.textContent = key;
  1038. storage.set("Dsync-settings", Settings);
  1039. Dsync.active = null;
  1040. checkForRepeats();
  1041. };
  1042. menuContainer.addEventListener("keyup", (event => {
  1043. if (event.keyCode < 5 || !Dsync.active) return;
  1044. applyCode(event.code);
  1045. }));
  1046. menuContainer.addEventListener("mouseup", (event => {
  1047. const target = event.target;
  1048. if (Dsync.active) return applyCode(event.button);
  1049. if (!contains(target, "section-option-hotkeyInput") || !target.id) return;
  1050. target.textContent = "Wait...";
  1051. Dsync.active = target;
  1052. }));
  1053. iframeWindow.addEventListener("keydown", (event => controller.handleKeydown(event, event.code)));
  1054. iframeWindow.addEventListener("keyup", (event => controller.handleKeyup(event, event.code)));
  1055. const resize = () => {
  1056. const width = window.innerWidth;
  1057. const height = window.innerHeight;
  1058. const scale = Math.min(1, Math.min(width / 1024, height / 700));
  1059. menuContainer.style.transform = `translate(-50%, -50%) scale(${scale})`;
  1060. };
  1061. resize();
  1062. window.addEventListener("resize", resize);
  1063. setTimeout((() => IFRAME.classList.add("iframe-opened")), 0);
  1064. iframeWindow.addEventListener("contextmenu", (event => event.preventDefault()));
  1065. iframeWindow.addEventListener("mousedown", (event => 1 === event.button && event.preventDefault()));
  1066. iframeWindow.addEventListener("mouseup", (event => [ 3, 4 ].includes(event.button) && event.preventDefault()));
  1067. window.addEventListener("mouseup", (event => [ 3, 4 ].includes(event.button) && event.preventDefault()));
  1068. update();
  1069. };
  1070. };
  1071. const modules_createMenu = createMenu;
  1072. const Scale = {
  1073. Default: {
  1074. w: 1824,
  1075. h: 1026
  1076. },
  1077. lerp: {
  1078. w: 1824,
  1079. h: 1026
  1080. },
  1081. current: {
  1082. w: 1824,
  1083. h: 1026
  1084. }
  1085. };
  1086. const getMinScale = scale => {
  1087. let w = Scale.Default.w;
  1088. let h = Scale.Default.h;
  1089. while (w > scale && h > scale) {
  1090. w -= scale;
  1091. h -= scale;
  1092. }
  1093. return {
  1094. w,
  1095. h
  1096. };
  1097. };
  1098. const zoomHandler = () => {
  1099. let wheels = 0;
  1100. const scaleFactor = 150;
  1101. window.addEventListener("wheel", (event => {
  1102. if (!(event.target instanceof HTMLCanvasElement) || event.ctrlKey || event.shiftKey || event.altKey || isInput() || !controller.inGame) return;
  1103. const {Default, current, lerp} = Scale;
  1104. if (current.w === Default.w && current.h === Default.h && (wheels = (wheels + 1) % 5) !== 0) return;
  1105. const {w, h} = getMinScale(scaleFactor);
  1106. const zoom = !Settings.reverseZoom && event.deltaY > 0 || Settings.reverseZoom && event.deltaY < 0 ? -scaleFactor : scaleFactor;
  1107. current.w = Math.max(w, current.w + zoom);
  1108. current.h = Math.max(h, current.h + zoom);
  1109. if (Settings.smoothZoom) return;
  1110. lerp.w = current.w;
  1111. lerp.h = current.h;
  1112. window.dispatchEvent(new Event("resize"));
  1113. }));
  1114. };
  1115. const modules_zoomHandler = zoomHandler;
  1116. var Hat;
  1117. (function(Hat) {
  1118. Hat[Hat["UNEQUIP"] = 0] = "UNEQUIP";
  1119. Hat[Hat["BUSH"] = 1] = "BUSH";
  1120. Hat[Hat["BERSERKER"] = 2] = "BERSERKER";
  1121. Hat[Hat["JUNGLE"] = 3] = "JUNGLE";
  1122. Hat[Hat["CRYSTAL"] = 4] = "CRYSTAL";
  1123. Hat[Hat["SPIKEGEAR"] = 5] = "SPIKEGEAR";
  1124. Hat[Hat["IMMUNITY"] = 6] = "IMMUNITY";
  1125. Hat[Hat["BOOST"] = 7] = "BOOST";
  1126. Hat[Hat["APPLEHAT"] = 8] = "APPLEHAT";
  1127. Hat[Hat["SCUBA"] = 9] = "SCUBA";
  1128. Hat[Hat["HOOD"] = 10] = "HOOD";
  1129. Hat[Hat["DEMOLIST"] = 11] = "DEMOLIST";
  1130. })(Hat || (Hat = {}));
  1131. const Hats = [ {
  1132. bought: true,
  1133. equipped: true,
  1134. default: true,
  1135. price: 0
  1136. }, {
  1137. image: 109,
  1138. price: 250,
  1139. axisY: 0,
  1140. description: "Become a bush",
  1141. name: "Bush Hat",
  1142. bought: false,
  1143. equipped: false,
  1144. rs: true
  1145. }, {
  1146. image: 41,
  1147. price: 5e3,
  1148. description: "Increased melee damage",
  1149. axisY: 10,
  1150. cs: 1.25,
  1151. speed: .85,
  1152. name: "Berserker Gear",
  1153. bought: false,
  1154. equipped: false
  1155. }, {
  1156. image: 44,
  1157. price: 3e3,
  1158. description: "Regenerate health",
  1159. axisY: 13,
  1160. hs: 25,
  1161. name: "Jungle Gear",
  1162. bought: false,
  1163. equipped: false
  1164. }, {
  1165. image: 45,
  1166. price: 5e3,
  1167. description: "Receive reduced damage",
  1168. axisY: 10,
  1169. reduceDmg: .75,
  1170. speed: .95,
  1171. name: "Crystal Gear",
  1172. bought: false,
  1173. equipped: false
  1174. }, {
  1175. image: 48,
  1176. price: 1e3,
  1177. description: "Attacker's receive damage",
  1178. axisY: 10,
  1179. reflect: .45,
  1180. name: "Spike Gear",
  1181. bought: false,
  1182. equipped: false
  1183. }, {
  1184. image: 49,
  1185. price: 4e3,
  1186. description: "Gain more health",
  1187. axisY: 15,
  1188. ls: 150,
  1189. reduceDmg: .75,
  1190. name: "Immunity Gear",
  1191. bought: false,
  1192. equipped: false
  1193. }, {
  1194. image: 50,
  1195. price: 1500,
  1196. description: "Move quicker",
  1197. axisY: 23,
  1198. speed: 1.23,
  1199. name: "Boost Hat",
  1200. bought: false,
  1201. equipped: false
  1202. }, {
  1203. image: 93,
  1204. price: 150,
  1205. description: "Apples become more succulent",
  1206. axisY: 5,
  1207. speed: 1.05,
  1208. name: "Apple hat",
  1209. bought: false,
  1210. equipped: false
  1211. }, {
  1212. image: 121,
  1213. price: 4e3,
  1214. description: "Move fast in ocean",
  1215. axisY: 5,
  1216. speed: .75,
  1217. river: 1.5,
  1218. name: "Scuba Gear",
  1219. bought: false,
  1220. equipped: false
  1221. }, {
  1222. image: 126,
  1223. price: 3500,
  1224. description: "Become invisible when still",
  1225. axisY: 5,
  1226. name: "Hood",
  1227. bought: false,
  1228. equipped: false,
  1229. rs: true
  1230. }, {
  1231. image: 197,
  1232. price: 4e3,
  1233. description: "Destroy buildings faster",
  1234. axisY: 10,
  1235. name: "Demolist",
  1236. bought: false,
  1237. equipped: false,
  1238. speed: .3
  1239. } ];
  1240. let teammates = [];
  1241. const createClan = () => {
  1242. const b = Dsync.saves.buffer;
  1243. const len = Dsync.saves.byteLength();
  1244. teammates = [ ...b.slice(3, len) ];
  1245. };
  1246. const updateClan = () => {
  1247. const b = Dsync.saves.buffer;
  1248. const len = Dsync.saves.byteLength();
  1249. teammates = [ ...b.slice(2, len) ];
  1250. };
  1251. const deleteClan = () => {
  1252. teammates = [];
  1253. };
  1254. let start = Date.now();
  1255. const moveUpdate = () => {
  1256. const now = Date.now();
  1257. Dsync.step = now - start;
  1258. start = now;
  1259. };
  1260. const hooks_moveUpdate = moveUpdate;
  1261. const playerStats = () => {
  1262. const b = Dsync.saves.buffer;
  1263. const age = formatAge(b[1] | b[2] << 8 | b[3] << 16 | b[4] << 24);
  1264. const food = b[5] | b[6] << 8 | b[7] << 16 | b[8] << 24;
  1265. const wood = b[9] | b[10] << 8 | b[11] << 16 | b[12] << 24;
  1266. const stone = b[13] | b[14] << 8 | b[15] << 16 | b[16] << 24;
  1267. const gold = b[17] | b[18] << 8 | b[19] << 16 | b[20] << 24;
  1268. if (age !== 0) {
  1269. controller.age = age;
  1270. }
  1271. controller.resources = {
  1272. food,
  1273. wood,
  1274. stone,
  1275. gold
  1276. };
  1277. };
  1278. const hooks_playerStats = playerStats;
  1279. const stringMessage = data => {
  1280. const id = data[0];
  1281. if (id === WebsocketServer.SPAWN) {
  1282. controller.reset(data[4]);
  1283. controller.inGame = true;
  1284. controller.automillSpawn = true;
  1285. if (Settings.lastHat) {
  1286. const hat = controller.toggleJungle || controller.toggleScuba ? controller.previousHat : controller.actualHat;
  1287. controller.equipHat(hat, true, true);
  1288. }
  1289. }
  1290. if (id === WebsocketServer.UPGRADE) {
  1291. const bar = data[1];
  1292. const canAutobed = Settings.autobed && bar.includes(EObjects.SPAWN);
  1293. controller.autobed = canAutobed;
  1294. if (Settings.skipUpgrades && bar.length === 1 || canAutobed) {
  1295. controller.PacketManager.upgrade(canAutobed ? EObjects.SPAWN : bar[0]);
  1296. }
  1297. }
  1298. if (id === WebsocketServer.DIED) {
  1299. controller.inGame = false;
  1300. if (Settings.autospawn) {
  1301. controller.spawn();
  1302. }
  1303. }
  1304. if (id === WebsocketServer.KILL_UPDATE) {
  1305. controller.kills = data[1][0];
  1306. }
  1307. if (id === WebsocketServer.KILLED && Settings.kill) {
  1308. const killMessage = Settings.killMessage.length ? Settings.killMessage : "{KILL}x";
  1309. const name = data[1].replace(/^Killed\s/, "").trim();
  1310. const message = killMessage.replace(/\{KILL\}/g, controller.kills + "").replace(/\{NAME\}/g, name);
  1311. controller.PacketManager.chat(message);
  1312. }
  1313. };
  1314. const hooks_stringMessage = stringMessage;
  1315. var WebsocketServer;
  1316. (function(WebsocketServer) {
  1317. WebsocketServer[WebsocketServer["LEADERBOARD"] = 3] = "LEADERBOARD";
  1318. WebsocketServer[WebsocketServer["DAMAGE"] = 6] = "DAMAGE";
  1319. WebsocketServer[WebsocketServer["PLAYERSTATS"] = 8] = "PLAYERSTATS";
  1320. WebsocketServer[WebsocketServer["CONNECT"] = 12] = "CONNECT";
  1321. WebsocketServer[WebsocketServer["UPGRADE"] = 14] = "UPGRADE";
  1322. WebsocketServer[WebsocketServer["UPDATECLAN"] = 16] = "UPDATECLAN";
  1323. WebsocketServer[WebsocketServer["DIED"] = 19] = "DIED";
  1324. WebsocketServer[WebsocketServer["MOVEUPDATE"] = 20] = "MOVEUPDATE";
  1325. WebsocketServer[WebsocketServer["KILL_UPDATE"] = 22] = "KILL_UPDATE";
  1326. WebsocketServer[WebsocketServer["JOINCREATECLAN"] = 24] = "JOINCREATECLAN";
  1327. WebsocketServer[WebsocketServer["DELETECLAN"] = 27] = "DELETECLAN";
  1328. WebsocketServer[WebsocketServer["KILLED"] = 28] = "KILLED";
  1329. WebsocketServer[WebsocketServer["PLAYER_SPAWNED"] = 32] = "PLAYER_SPAWNED";
  1330. WebsocketServer[WebsocketServer["DEFAULT"] = 33] = "DEFAULT";
  1331. WebsocketServer[WebsocketServer["SPAWN"] = 35] = "SPAWN";
  1332. })(WebsocketServer || (WebsocketServer = {}));
  1333. var WebsocketClient;
  1334. (function(WebsocketClient) {
  1335. WebsocketClient[WebsocketClient["MOVE"] = 6] = "MOVE";
  1336. WebsocketClient[WebsocketClient["ANGLE"] = 13] = "ANGLE";
  1337. WebsocketClient[WebsocketClient["selectByID"] = 2] = "selectByID";
  1338. WebsocketClient[WebsocketClient["ATTACK"] = 19] = "ATTACK";
  1339. WebsocketClient[WebsocketClient["STOPATTACK"] = 18] = "STOPATTACK";
  1340. WebsocketClient[WebsocketClient["LOGIN"] = 10] = "LOGIN";
  1341. WebsocketClient[WebsocketClient["SCYTHE"] = 20] = "SCYTHE";
  1342. WebsocketClient[WebsocketClient["SELECTITEM"] = 0] = "SELECTITEM";
  1343. WebsocketClient[WebsocketClient["HAT"] = 5] = "HAT";
  1344. WebsocketClient[WebsocketClient["CHAT"] = 7] = "CHAT";
  1345. WebsocketClient[WebsocketClient["UPGRADE"] = 14] = "UPGRADE";
  1346. WebsocketClient[WebsocketClient["AUTOATTACK"] = 23] = "AUTOATTACK";
  1347. WebsocketClient[WebsocketClient["MOVEANGLE"] = 1] = "MOVEANGLE";
  1348. WebsocketClient[WebsocketClient["LEAVECLAN"] = 24] = "LEAVECLAN";
  1349. WebsocketClient[WebsocketClient["JOIN"] = 21] = "JOIN";
  1350. WebsocketClient[WebsocketClient["ACCEPTDECLINE"] = 17] = "ACCEPTDECLINE";
  1351. WebsocketClient[WebsocketClient["KICK"] = 25] = "KICK";
  1352. WebsocketClient[WebsocketClient["CREATECLAN"] = 22] = "CREATECLAN";
  1353. })(WebsocketClient || (WebsocketClient = {}));
  1354. window.WebSocket = new Proxy(window.WebSocket, {
  1355. construct(target, args) {
  1356. if (typeof args[0] === "string") {
  1357. if (args[0] !== Dsync.connectURL) {
  1358. controller.age = 0;
  1359. for (const hat of Hats) {
  1360. hat.bought = !!hat.default;
  1361. hat.equipped = !!hat.default;
  1362. }
  1363. }
  1364. Dsync.connectURL = args[0];
  1365. }
  1366. const ws = new target(...args);
  1367. ws.addEventListener("message", (event => {
  1368. const data = event.data;
  1369. if (typeof data === "string" && /^\[.+\]$/.test(data)) {
  1370. hooks_stringMessage(JSON.parse(data));
  1371. } else {
  1372. switch (Dsync.saves.buffer[0]) {
  1373. case WebsocketServer.PLAYERSTATS:
  1374. hooks_playerStats();
  1375. break;
  1376.  
  1377. case WebsocketServer.DELETECLAN:
  1378. deleteClan();
  1379. break;
  1380.  
  1381. case WebsocketServer.JOINCREATECLAN:
  1382. createClan();
  1383. break;
  1384.  
  1385. case WebsocketServer.UPDATECLAN:
  1386. updateClan();
  1387. break;
  1388.  
  1389. case WebsocketServer.MOVEUPDATE:
  1390. hooks_moveUpdate();
  1391. break;
  1392. }
  1393. }
  1394. }));
  1395. return ws;
  1396. }
  1397. });
  1398. class PacketManager {
  1399. constructor() {
  1400. this.encoder = new TextEncoder;
  1401. }
  1402. send(...args) {
  1403. Dsync.saves.send(new Uint8Array(args));
  1404. }
  1405. moveByBitmask(bitmask) {
  1406. this.send(WebsocketClient.MOVE, bitmask);
  1407. }
  1408. changeAngle(angle) {
  1409. angle = 65535 * (angle + Math.PI) / (2 * Math.PI), this.send(WebsocketClient.ANGLE, 255 & angle, angle >> 8 & 255);
  1410. }
  1411. selectByID(id) {
  1412. this.send(WebsocketClient.selectByID, id);
  1413. }
  1414. attack(angle) {
  1415. angle = 65535 * (angle + Math.PI) / (2 * Math.PI), this.send(WebsocketClient.ATTACK, 255 & angle, angle >> 8 & 255);
  1416. }
  1417. stopAttack() {
  1418. this.send(WebsocketClient.STOPATTACK);
  1419. }
  1420. upgradeScythe(goldenCowID) {
  1421. this.send(WebsocketClient.SCYTHE, 255 & goldenCowID, goldenCowID >> 8);
  1422. }
  1423. selectItemByType(type) {
  1424. this.send(WebsocketClient.SELECTITEM, type);
  1425. }
  1426. equip(id) {
  1427. this.send(WebsocketClient.HAT, id);
  1428. }
  1429. chat(message) {
  1430. const bytes = this.encoder.encode(message);
  1431. this.send(WebsocketClient.CHAT, ...bytes);
  1432. }
  1433. upgrade(id) {
  1434. this.send(WebsocketClient.UPGRADE, id);
  1435. controller.upgradeItem(id);
  1436. }
  1437. autoattack(toggle) {
  1438. this.send(WebsocketClient.AUTOATTACK, Number(toggle));
  1439. }
  1440. moveAngle(angle) {
  1441. angle = 65535 * (angle + Math.PI) / (2 * Math.PI), this.send(WebsocketClient.MOVEANGLE, 255 & angle, angle >> 8 & 255);
  1442. }
  1443. leaveClan() {
  1444. this.send(WebsocketClient.LEAVECLAN);
  1445. }
  1446. joinClan(id) {
  1447. this.send(WebsocketClient.JOIN, id);
  1448. }
  1449. accept(which) {
  1450. this.send(WebsocketClient.ACCEPTDECLINE, which);
  1451. }
  1452. kick(id) {
  1453. this.send(WebsocketClient.KICK, id);
  1454. }
  1455. createClan(name) {
  1456. const bytes = this.encoder.encode(name);
  1457. this.send(WebsocketClient.CREATECLAN, ...bytes);
  1458. }
  1459. }
  1460. var ActionType;
  1461. (function(ActionType) {
  1462. ActionType[ActionType["MELEE"] = 0] = "MELEE";
  1463. ActionType[ActionType["RANGED"] = 1] = "RANGED";
  1464. ActionType[ActionType["PLACEABLE"] = 2] = "PLACEABLE";
  1465. ActionType[ActionType["EATABLE"] = 3] = "EATABLE";
  1466. })(ActionType || (ActionType = {}));
  1467. var ItemType;
  1468. (function(ItemType) {
  1469. ItemType[ItemType["PRIMARY"] = 0] = "PRIMARY";
  1470. ItemType[ItemType["SECONDARY"] = 1] = "SECONDARY";
  1471. ItemType[ItemType["FOOD"] = 2] = "FOOD";
  1472. ItemType[ItemType["WALL"] = 3] = "WALL";
  1473. ItemType[ItemType["SPIKE"] = 4] = "SPIKE";
  1474. ItemType[ItemType["WINDMILL"] = 5] = "WINDMILL";
  1475. ItemType[ItemType["FARM"] = 6] = "FARM";
  1476. ItemType[ItemType["TRAP"] = 7] = "TRAP";
  1477. ItemType[ItemType["PLATFORM"] = 8] = "PLATFORM";
  1478. ItemType[ItemType["SPAWN"] = 9] = "SPAWN";
  1479. ItemType[ItemType["TURRET"] = 10] = "TURRET";
  1480. })(ItemType || (ItemType = {}));
  1481. var upgradeType;
  1482. (function(upgradeType) {
  1483. upgradeType[upgradeType["STONE"] = 1] = "STONE";
  1484. upgradeType[upgradeType["GOLD"] = 2] = "GOLD";
  1485. upgradeType[upgradeType["DIAMOND"] = 3] = "DIAMOND";
  1486. upgradeType[upgradeType["RUBY"] = 4] = "RUBY";
  1487. })(upgradeType || (upgradeType = {}));
  1488. const ItemData = [ {
  1489. id: 0,
  1490. gs: 46,
  1491. upgradeType: upgradeType.STONE,
  1492. imageinv: 29,
  1493. image: 25,
  1494. name: "Tool Hammer",
  1495. description: "Gather materials",
  1496. range: 80,
  1497. itemType: ItemType.PRIMARY,
  1498. damage: 25,
  1499. reload: 300,
  1500. _s: 30,
  1501. Ms: 200,
  1502. actionType: ActionType.MELEE,
  1503. ps: 0,
  1504. As: -3.5,
  1505. os: 1
  1506. }, {
  1507. id: 1,
  1508. ks: 1,
  1509. ys: 2,
  1510. imageinv: 28,
  1511. image: 24,
  1512. name: "Stone Sword",
  1513. description: "Sharp and pointy",
  1514. range: 135,
  1515. Ms: 250,
  1516. itemType: ItemType.PRIMARY,
  1517. damage: 35,
  1518. reload: 300,
  1519. Us: .85,
  1520. actionType: ActionType.MELEE,
  1521. ps: 0,
  1522. As: -8,
  1523. os: -4
  1524. }, {
  1525. id: 2,
  1526. gs: 39,
  1527. upgradeType: upgradeType.STONE,
  1528. ks: 1,
  1529. ys: 4,
  1530. imageinv: 31,
  1531. image: 26,
  1532. name: "Stone Spear",
  1533. description: "Long melee range",
  1534. range: 160,
  1535. itemType: ItemType.PRIMARY,
  1536. damage: 49,
  1537. Us: .81,
  1538. Ms: 450,
  1539. reload: 700,
  1540. actionType: ActionType.MELEE,
  1541. ps: 0,
  1542. As: 0,
  1543. os: 2
  1544. }, {
  1545. id: 3,
  1546. gs: 33,
  1547. upgradeType: upgradeType.STONE,
  1548. ks: 1,
  1549. ys: 128,
  1550. imageinv: 32,
  1551. image: 35,
  1552. name: "Stone Axe",
  1553. description: "Gathers materials faster",
  1554. range: 90,
  1555. itemType: ItemType.PRIMARY,
  1556. damage: 30,
  1557. Ms: 250,
  1558. reload: 400,
  1559. actionType: ActionType.MELEE,
  1560. ps: 0,
  1561. As: -2,
  1562. os: 2,
  1563. Es: 2,
  1564. Cs: 2,
  1565. Bs: 2,
  1566. zs: 2
  1567. }, {
  1568. id: 4,
  1569. cost: {
  1570. food: 0,
  1571. wood: 0,
  1572. stone: 10,
  1573. gold: 0
  1574. },
  1575. ks: 16,
  1576. xs: 2,
  1577. ys: 8,
  1578. imageinv: 30,
  1579. image: 27,
  1580. name: "Stone Musket",
  1581. description: "Deal Long Range Damage",
  1582. range: 1e3,
  1583. itemType: ItemType.SECONDARY,
  1584. damage: 49,
  1585. reload: 1500,
  1586. projectile: 17,
  1587. Ls: 1500,
  1588. actionType: ActionType.RANGED,
  1589. ps: 1,
  1590. Us: .63,
  1591. As: 0,
  1592. os: 0
  1593. }, {
  1594. id: 5,
  1595. cost: {
  1596. food: 0,
  1597. wood: 10,
  1598. stone: 0,
  1599. gold: 0
  1600. },
  1601. imageinv: 33,
  1602. image: 103,
  1603. name: "Wood Wall",
  1604. description: "A sturdy wall",
  1605. itemType: ItemType.WALL,
  1606. actionType: ActionType.PLACEABLE,
  1607. Hs: 5,
  1608. As: 0,
  1609. os: 15,
  1610. Ss: 8,
  1611. ps: 2
  1612. }, {
  1613. id: 6,
  1614. cost: {
  1615. food: 0,
  1616. wood: 5,
  1617. stone: 20,
  1618. gold: 0
  1619. },
  1620. ks: 1,
  1621. ys: 512,
  1622. imageinv: 36,
  1623. image: 106,
  1624. name: "Boost",
  1625. description: "Provides a thrust",
  1626. itemType: ItemType.TRAP,
  1627. actionType: ActionType.PLACEABLE,
  1628. Hs: -5,
  1629. As: 0,
  1630. os: 3,
  1631. Ss: 10,
  1632. ps: 2
  1633. }, {
  1634. id: 7,
  1635. cost: {
  1636. food: 0,
  1637. wood: 20,
  1638. stone: 5,
  1639. gold: 0
  1640. },
  1641. imageinv: 37,
  1642. image: 104,
  1643. name: "Spike",
  1644. description: "Sharp defence",
  1645. itemType: ItemType.SPIKE,
  1646. actionType: ActionType.PLACEABLE,
  1647. Hs: 2,
  1648. As: 0,
  1649. os: 15,
  1650. Ss: 7,
  1651. ps: 2
  1652. }, {
  1653. id: 8,
  1654. cost: {
  1655. food: 0,
  1656. wood: 20,
  1657. stone: 0,
  1658. gold: 0
  1659. },
  1660. ks: 1,
  1661. imageinv: 38,
  1662. image: 114,
  1663. name: "Platform",
  1664. description: "Shoot over structures",
  1665. itemType: ItemType.PLATFORM,
  1666. actionType: ActionType.PLACEABLE,
  1667. Hs: -2,
  1668. As: 0,
  1669. os: 8,
  1670. Ss: 9,
  1671. ps: 2
  1672. }, {
  1673. id: 9,
  1674. cost: {
  1675. food: 0,
  1676. wood: 30,
  1677. stone: 30,
  1678. gold: 0
  1679. },
  1680. ks: 1,
  1681. ys: 1024,
  1682. imageinv: 39,
  1683. image: 107,
  1684. name: "Trap",
  1685. description: "Snared enemies are stuck",
  1686. itemType: ItemType.TRAP,
  1687. actionType: ActionType.PLACEABLE,
  1688. Hs: 2,
  1689. As: 0,
  1690. os: 26,
  1691. Ss: 6,
  1692. ps: 2
  1693. }, {
  1694. id: 10,
  1695. cost: {
  1696. food: 10,
  1697. wood: 0,
  1698. stone: 0,
  1699. gold: 0
  1700. },
  1701. imageinv: 43,
  1702. image: 42,
  1703. name: "Apple",
  1704. description: "Heals you",
  1705. itemType: ItemType.FOOD,
  1706. actionType: ActionType.EATABLE,
  1707. restore: 20,
  1708. As: 0,
  1709. os: 22,
  1710. ps: 2
  1711. }, {
  1712. id: 11,
  1713. ks: 1,
  1714. ys: 256,
  1715. imageinv: 47,
  1716. image: 46,
  1717. name: "Shield",
  1718. description: "Reduces damage",
  1719. itemType: ItemType.SECONDARY,
  1720. actionType: ActionType.MELEE,
  1721. Us: .7,
  1722. shieldAngle: .75,
  1723. range: 55,
  1724. Ms: 350,
  1725. damage: 15,
  1726. _s: 40,
  1727. reload: 500,
  1728. As: -15,
  1729. os: 10,
  1730. ps: 3
  1731. }, {
  1732. id: 12,
  1733. cost: {
  1734. food: 15,
  1735. wood: 0,
  1736. stone: 0,
  1737. gold: 0
  1738. },
  1739. ks: 1,
  1740. ys: 64,
  1741. imageinv: 52,
  1742. image: 51,
  1743. name: "Cookie",
  1744. description: "Heals you",
  1745. itemType: ItemType.FOOD,
  1746. actionType: ActionType.EATABLE,
  1747. restore: 35,
  1748. As: 0,
  1749. os: 22,
  1750. ps: 2
  1751. }, {
  1752. id: 13,
  1753. gs: 41,
  1754. upgradeType: upgradeType.STONE,
  1755. ks: 1,
  1756. ys: 32,
  1757. imageinv: 55,
  1758. image: 54,
  1759. name: "Stick",
  1760. description: "Gathers resources quickly",
  1761. range: 100,
  1762. itemType: ItemType.PRIMARY,
  1763. damage: 1,
  1764. reload: 400,
  1765. actionType: ActionType.MELEE,
  1766. Ms: 60,
  1767. ps: 0,
  1768. As: 4,
  1769. os: 0,
  1770. Es: 7,
  1771. Cs: 7,
  1772. Bs: 7,
  1773. zs: 4
  1774. }, {
  1775. id: 14,
  1776. cost: {
  1777. food: 0,
  1778. wood: 50,
  1779. stone: 10,
  1780. gold: 0
  1781. },
  1782. imageinv: 57,
  1783. image: 61,
  1784. name: "Windmill",
  1785. description: "Generates score over time",
  1786. itemType: ItemType.WINDMILL,
  1787. actionType: ActionType.PLACEABLE,
  1788. rotateSpeed: Math.PI / 4,
  1789. Hs: -5,
  1790. As: 0,
  1791. os: 38,
  1792. Ss: 13,
  1793. ps: 2
  1794. }, {
  1795. id: 15,
  1796. ks: 1,
  1797. ys: 1,
  1798. imageinv: 63,
  1799. image: 62,
  1800. name: "Hammer",
  1801. description: "Breaks structures faster",
  1802. range: 80,
  1803. itemType: ItemType.SECONDARY,
  1804. damage: 12,
  1805. _s: 76,
  1806. Us: .89,
  1807. Ms: 200,
  1808. reload: 400,
  1809. actionType: ActionType.MELEE,
  1810. ps: 0,
  1811. As: 5,
  1812. os: 2
  1813. }, {
  1814. id: 16,
  1815. ks: 1,
  1816. ys: 1,
  1817. cost: {
  1818. food: 0,
  1819. wood: 200,
  1820. stone: 200,
  1821. gold: 200
  1822. },
  1823. imageinv: 65,
  1824. image: 115,
  1825. name: "Cosy Bed",
  1826. description: "Respawn at the bed",
  1827. itemType: ItemType.SPAWN,
  1828. actionType: ActionType.PLACEABLE,
  1829. Hs: 8,
  1830. As: 0,
  1831. os: 25,
  1832. Ss: 15,
  1833. ps: 2
  1834. }, {
  1835. id: 17,
  1836. gs: 37,
  1837. upgradeType: upgradeType.STONE,
  1838. ks: 2,
  1839. ys: 2,
  1840. imageinv: 68,
  1841. image: 67,
  1842. name: "Katana",
  1843. description: "Excellent melee weapon",
  1844. range: 140,
  1845. Ms: 150,
  1846. itemType: ItemType.PRIMARY,
  1847. damage: 40,
  1848. reload: 300,
  1849. Us: .85,
  1850. actionType: ActionType.MELEE,
  1851. ps: 0,
  1852. As: 1,
  1853. os: 3
  1854. }, {
  1855. id: 18,
  1856. cost: {
  1857. food: 0,
  1858. wood: 30,
  1859. stone: 30,
  1860. gold: 0
  1861. },
  1862. ks: 160,
  1863. ys: 1,
  1864. imageinv: 69,
  1865. image: 113,
  1866. name: "Castle Spike",
  1867. description: "Great for bases",
  1868. itemType: ItemType.SPIKE,
  1869. actionType: ActionType.PLACEABLE,
  1870. damage: {
  1871. hit: 24,
  1872. touch: 5
  1873. },
  1874. Hs: -8,
  1875. As: 0,
  1876. os: 14,
  1877. Ss: 17,
  1878. ps: 2
  1879. }, {
  1880. id: 19,
  1881. cost: {
  1882. food: 0,
  1883. wood: 100,
  1884. stone: 50,
  1885. gold: 0
  1886. },
  1887. ks: 1,
  1888. ys: 1,
  1889. imageinv: 57,
  1890. image: 61,
  1891. name: "Powermill",
  1892. description: "Generates more score over time",
  1893. itemType: ItemType.WINDMILL,
  1894. actionType: ActionType.PLACEABLE,
  1895. rotateSpeed: Math.PI / 2,
  1896. Hs: 5,
  1897. As: 0,
  1898. os: 38,
  1899. Ss: 16,
  1900. ps: 2
  1901. }, {
  1902. id: 20,
  1903. ks: 1,
  1904. ys: 1,
  1905. cost: {
  1906. food: 0,
  1907. wood: 30,
  1908. stone: 10,
  1909. gold: 0
  1910. },
  1911. imageinv: 73,
  1912. image: 112,
  1913. name: "Hard Spike",
  1914. description: "Sharper defence",
  1915. itemType: ItemType.SPIKE,
  1916. actionType: ActionType.PLACEABLE,
  1917. Hs: 2,
  1918. As: 0,
  1919. os: 15,
  1920. Ss: 2,
  1921. ps: 2
  1922. }, {
  1923. id: 21,
  1924. cost: {
  1925. food: 0,
  1926. wood: 200,
  1927. stone: 150,
  1928. gold: 10
  1929. },
  1930. ks: 1,
  1931. ys: 1,
  1932. imageinv: 77,
  1933. image: 74,
  1934. name: "Turret",
  1935. description: "Defence for your base",
  1936. itemType: ItemType.TURRET,
  1937. actionType: ActionType.PLACEABLE,
  1938. Hs: 6,
  1939. As: 0,
  1940. os: 25,
  1941. Ss: 18,
  1942. ps: 2
  1943. }, {
  1944. id: 22,
  1945. ks: 1,
  1946. ys: 1,
  1947. cost: {
  1948. food: 0,
  1949. wood: 200,
  1950. stone: 0,
  1951. gold: 0
  1952. },
  1953. imageinv: 78,
  1954. image: 110,
  1955. name: "Cherry wood farm",
  1956. description: "Used for decoration and wood",
  1957. itemType: ItemType.FARM,
  1958. actionType: ActionType.PLACEABLE,
  1959. Hs: 3,
  1960. As: 0,
  1961. os: 47,
  1962. Ss: 20,
  1963. ps: 2
  1964. }, {
  1965. id: 23,
  1966. ks: 1,
  1967. ys: 1,
  1968. cost: {
  1969. food: 0,
  1970. wood: 200,
  1971. stone: 0,
  1972. gold: 0
  1973. },
  1974. imageinv: 80,
  1975. image: 111,
  1976. name: "Wood farm",
  1977. description: "Used for decoration and wood",
  1978. itemType: ItemType.FARM,
  1979. actionType: ActionType.PLACEABLE,
  1980. Hs: 3,
  1981. As: 0,
  1982. os: 47,
  1983. Ss: 19,
  1984. ps: 2
  1985. }, {
  1986. id: 24,
  1987. ks: 1,
  1988. ys: 1,
  1989. cost: {
  1990. food: 200,
  1991. wood: 0,
  1992. stone: 0,
  1993. gold: 0
  1994. },
  1995. imageinv: 85,
  1996. image: 109,
  1997. name: "Berry farm",
  1998. description: "Used for decoration and berries",
  1999. itemType: ItemType.FARM,
  2000. actionType: ActionType.PLACEABLE,
  2001. Hs: 3,
  2002. As: 0,
  2003. os: 17,
  2004. Ss: 5,
  2005. ps: 2
  2006. }, {
  2007. id: 25,
  2008. ks: 1,
  2009. ys: 1,
  2010. cost: {
  2011. food: 0,
  2012. wood: 0,
  2013. stone: 200,
  2014. gold: 0
  2015. },
  2016. imageinv: 83,
  2017. image: 108,
  2018. name: "Stone farm",
  2019. description: "Used for decoration and stone",
  2020. itemType: ItemType.FARM,
  2021. actionType: ActionType.PLACEABLE,
  2022. Hs: 3,
  2023. As: 0,
  2024. os: 20,
  2025. Ss: 21,
  2026. ps: 2
  2027. }, {
  2028. id: 26,
  2029. cost: {
  2030. food: 0,
  2031. wood: 4,
  2032. stone: 0,
  2033. gold: 0
  2034. },
  2035. ks: 1,
  2036. ys: 16,
  2037. imageinv: 86,
  2038. image: 87,
  2039. name: "Bow",
  2040. description: "Deal Long Range Damage",
  2041. range: 800,
  2042. itemType: ItemType.SECONDARY,
  2043. damage: 25,
  2044. reload: 600,
  2045. projectile: 88,
  2046. Ls: 1200,
  2047. actionType: ActionType.RANGED,
  2048. ps: 1,
  2049. Us: .75,
  2050. As: 0,
  2051. os: 35
  2052. }, {
  2053. id: 27,
  2054. cost: {
  2055. food: 0,
  2056. wood: 10,
  2057. stone: 0,
  2058. gold: 0
  2059. },
  2060. ks: 16,
  2061. ys: 176,
  2062. imageinv: 90,
  2063. image: 91,
  2064. name: "XBow",
  2065. description: "Rapid fire bow",
  2066. range: 800,
  2067. itemType: ItemType.SECONDARY,
  2068. damage: 27,
  2069. reload: 235,
  2070. projectile: 88,
  2071. Ls: 1200,
  2072. actionType: ActionType.RANGED,
  2073. ps: 1,
  2074. Us: .35,
  2075. As: 0,
  2076. os: 30
  2077. }, {
  2078. id: 28,
  2079. gs: 45,
  2080. upgradeType: upgradeType.STONE,
  2081. ks: 4,
  2082. ys: 4,
  2083. imageinv: 100,
  2084. image: 99,
  2085. name: "Naginata",
  2086. description: "Long melee range",
  2087. range: 165,
  2088. itemType: ItemType.PRIMARY,
  2089. damage: 52,
  2090. Us: .81,
  2091. Ms: 470,
  2092. reload: 700,
  2093. actionType: ActionType.MELEE,
  2094. ps: 0,
  2095. As: 0,
  2096. os: -4
  2097. }, {
  2098. id: 29,
  2099. cost: {
  2100. food: 0,
  2101. wood: 0,
  2102. stone: 35,
  2103. gold: 10
  2104. },
  2105. ks: 1,
  2106. ys: 1,
  2107. imageinv: 101,
  2108. image: 105,
  2109. name: "Castle Wall",
  2110. description: "A very sturdy wall",
  2111. itemType: ItemType.WALL,
  2112. actionType: ActionType.PLACEABLE,
  2113. Hs: 8,
  2114. As: 0,
  2115. os: 13,
  2116. Ss: 22,
  2117. ps: 2
  2118. }, {
  2119. id: 30,
  2120. gs: 35,
  2121. upgradeType: upgradeType.STONE,
  2122. ks: 128,
  2123. ys: 128,
  2124. imageinv: 117,
  2125. image: 116,
  2126. name: "Great Axe",
  2127. description: "More powerful axe.",
  2128. range: 94,
  2129. itemType: ItemType.PRIMARY,
  2130. damage: 37,
  2131. Ms: 250,
  2132. reload: 400,
  2133. actionType: ActionType.MELEE,
  2134. ps: 0,
  2135. As: 4,
  2136. os: 2,
  2137. Es: 4,
  2138. Cs: 4,
  2139. Bs: 4,
  2140. zs: 2
  2141. }, {
  2142. id: 31,
  2143. ks: 1,
  2144. ys: 2048,
  2145. imageinv: 128,
  2146. image: 127,
  2147. name: "Bat",
  2148. description: "Hit enemies for a home run",
  2149. range: 115,
  2150. itemType: ItemType.PRIMARY,
  2151. damage: 28,
  2152. Us: .92,
  2153. Ms: 870,
  2154. reload: 700,
  2155. actionType: ActionType.MELEE,
  2156. ps: 0,
  2157. As: 10,
  2158. os: 2
  2159. }, {
  2160. id: 32,
  2161. ks: 1,
  2162. ys: 128,
  2163. imageinv: 131,
  2164. image: 130,
  2165. name: "Diamond Axe",
  2166. description: "Gathers materials faster",
  2167. range: 90,
  2168. itemType: ItemType.PRIMARY,
  2169. damage: 35.5,
  2170. Ms: 250,
  2171. reload: 400,
  2172. actionType: ActionType.MELEE,
  2173. ps: 0,
  2174. As: -2,
  2175. os: 2,
  2176. Es: 2,
  2177. Cs: 2,
  2178. Bs: 2,
  2179. zs: 2
  2180. }, {
  2181. id: 33,
  2182. gs: 32,
  2183. upgradeType: upgradeType.GOLD,
  2184. ks: 1,
  2185. ys: 128,
  2186. imageinv: 133,
  2187. image: 132,
  2188. name: "Gold Axe",
  2189. description: "Gathers materials faster",
  2190. range: 90,
  2191. itemType: ItemType.PRIMARY,
  2192. damage: 33,
  2193. Ms: 250,
  2194. reload: 400,
  2195. actionType: ActionType.MELEE,
  2196. ps: 0,
  2197. As: -2,
  2198. os: 2,
  2199. Es: 2,
  2200. Cs: 2,
  2201. Bs: 2,
  2202. zs: 2
  2203. }, {
  2204. id: 34,
  2205. ks: 128,
  2206. ys: 128,
  2207. imageinv: 135,
  2208. image: 134,
  2209. name: "Diamond Great Axe",
  2210. description: "More powerful axe.",
  2211. range: 94,
  2212. itemType: ItemType.PRIMARY,
  2213. damage: 47,
  2214. Ms: 250,
  2215. reload: 400,
  2216. actionType: ActionType.MELEE,
  2217. ps: 0,
  2218. As: 4,
  2219. os: 2,
  2220. Es: 4,
  2221. Cs: 4,
  2222. Bs: 4,
  2223. zs: 2
  2224. }, {
  2225. id: 35,
  2226. gs: 34,
  2227. upgradeType: upgradeType.GOLD,
  2228. ks: 128,
  2229. ys: 128,
  2230. imageinv: 145,
  2231. image: 144,
  2232. name: "Gold Great Axe",
  2233. description: "More powerful axe.",
  2234. range: 94,
  2235. itemType: ItemType.PRIMARY,
  2236. damage: 40,
  2237. Ms: 250,
  2238. reload: 400,
  2239. actionType: ActionType.MELEE,
  2240. ps: 0,
  2241. As: 4,
  2242. os: 2,
  2243. Es: 4,
  2244. Cs: 4,
  2245. Bs: 4,
  2246. zs: 2
  2247. }, {
  2248. id: 36,
  2249. gs: 40,
  2250. upgradeType: upgradeType.DIAMOND,
  2251. ks: 2,
  2252. ys: 2,
  2253. imageinv: 137,
  2254. image: 136,
  2255. name: "Diamond Katana",
  2256. description: "Excellent melee weapon",
  2257. range: 140,
  2258. Ms: 150,
  2259. itemType: ItemType.PRIMARY,
  2260. damage: 46.5,
  2261. reload: 300,
  2262. Us: .85,
  2263. actionType: ActionType.MELEE,
  2264. ps: 0,
  2265. As: 1,
  2266. os: 3
  2267. }, {
  2268. id: 37,
  2269. gs: 36,
  2270. upgradeType: upgradeType.GOLD,
  2271. ks: 2,
  2272. ys: 2,
  2273. imageinv: 139,
  2274. image: 138,
  2275. name: "Gold Katana",
  2276. description: "Excellent melee weapon",
  2277. range: 140,
  2278. Ms: 150,
  2279. itemType: ItemType.PRIMARY,
  2280. damage: 43,
  2281. reload: 300,
  2282. Us: .85,
  2283. actionType: ActionType.MELEE,
  2284. ps: 0,
  2285. As: 1,
  2286. os: 3
  2287. }, {
  2288. id: 38,
  2289. ks: 1,
  2290. ys: 4,
  2291. imageinv: 141,
  2292. image: 140,
  2293. name: "Diamond Spear",
  2294. description: "Long melee range",
  2295. range: 160,
  2296. itemType: ItemType.PRIMARY,
  2297. damage: 53,
  2298. Us: .81,
  2299. Ms: 450,
  2300. reload: 700,
  2301. actionType: ActionType.MELEE,
  2302. ps: 0,
  2303. As: 0,
  2304. os: 2
  2305. }, {
  2306. id: 39,
  2307. gs: 38,
  2308. upgradeType: upgradeType.GOLD,
  2309. ks: 1,
  2310. ys: 4,
  2311. imageinv: 143,
  2312. image: 142,
  2313. name: "Gold Spear",
  2314. description: "Long melee range",
  2315. range: 160,
  2316. itemType: ItemType.PRIMARY,
  2317. damage: 51,
  2318. Us: .81,
  2319. Ms: 450,
  2320. reload: 700,
  2321. actionType: ActionType.MELEE,
  2322. ps: 0,
  2323. As: 0,
  2324. os: 2
  2325. }, {
  2326. id: 40,
  2327. ks: 2,
  2328. ys: 2,
  2329. imageinv: 147,
  2330. image: 148,
  2331. name: "Chillrend",
  2332. description: "A powerful force flows through this blade.",
  2333. range: 140,
  2334. Ms: 150,
  2335. itemType: ItemType.PRIMARY,
  2336. damage: 48.5,
  2337. reload: 300,
  2338. Us: .9,
  2339. actionType: ActionType.MELEE,
  2340. ps: 0,
  2341. As: 1,
  2342. os: 3
  2343. }, {
  2344. id: 41,
  2345. gs: 42,
  2346. upgradeType: upgradeType.GOLD,
  2347. ks: 1,
  2348. ys: 32,
  2349. imageinv: 150,
  2350. image: 149,
  2351. name: "Gold Stick",
  2352. description: "Gathers resources quickly",
  2353. range: 100,
  2354. itemType: ItemType.PRIMARY,
  2355. damage: 1,
  2356. reload: 400,
  2357. actionType: ActionType.MELEE,
  2358. Ms: 60,
  2359. ps: 0,
  2360. As: 4,
  2361. os: 0,
  2362. Es: 8,
  2363. Cs: 8,
  2364. Bs: 8,
  2365. zs: 5
  2366. }, {
  2367. id: 42,
  2368. gs: 43,
  2369. upgradeType: upgradeType.DIAMOND,
  2370. ks: 1,
  2371. ys: 32,
  2372. imageinv: 167,
  2373. image: 151,
  2374. name: "Diamond Stick",
  2375. description: "Gathers resources quickly",
  2376. range: 100,
  2377. itemType: ItemType.PRIMARY,
  2378. damage: 1,
  2379. reload: 400,
  2380. actionType: ActionType.MELEE,
  2381. Ms: 60,
  2382. ps: 0,
  2383. As: 4,
  2384. os: 0,
  2385. Es: 9,
  2386. Cs: 9,
  2387. Bs: 9,
  2388. zs: 6
  2389. }, {
  2390. upgradeType: upgradeType.RUBY,
  2391. id: 43,
  2392. ks: 1,
  2393. ys: 32,
  2394. imageinv: 168,
  2395. image: 152,
  2396. name: "Ruby Stick",
  2397. description: "Gathers resources quickly",
  2398. range: 100,
  2399. itemType: ItemType.PRIMARY,
  2400. damage: 1,
  2401. reload: 400,
  2402. actionType: ActionType.MELEE,
  2403. Ms: 60,
  2404. ps: 0,
  2405. As: 4,
  2406. os: 0,
  2407. Es: 10,
  2408. Cs: 10,
  2409. Bs: 10,
  2410. zs: 7
  2411. }, {
  2412. id: 44,
  2413. ks: 4,
  2414. ys: 4,
  2415. imageinv: 154,
  2416. image: 153,
  2417. name: "Diamond Naginata",
  2418. description: "Long melee range",
  2419. range: 165,
  2420. itemType: ItemType.PRIMARY,
  2421. damage: 56,
  2422. Us: .81,
  2423. Ms: 470,
  2424. reload: 700,
  2425. actionType: ActionType.MELEE,
  2426. ps: 0,
  2427. As: 0,
  2428. os: -4
  2429. }, {
  2430. id: 45,
  2431. gs: 44,
  2432. upgradeType: upgradeType.GOLD,
  2433. ks: 4,
  2434. ys: 4,
  2435. imageinv: 156,
  2436. image: 155,
  2437. name: "Gold Naginata",
  2438. description: "Long melee range",
  2439. range: 165,
  2440. itemType: ItemType.PRIMARY,
  2441. damage: 54,
  2442. Us: .81,
  2443. Ms: 470,
  2444. reload: 700,
  2445. actionType: ActionType.MELEE,
  2446. ps: 0,
  2447. As: 0,
  2448. os: -4
  2449. }, {
  2450. id: 46,
  2451. gs: 47,
  2452. upgradeType: upgradeType.GOLD,
  2453. imageinv: 158,
  2454. image: 157,
  2455. name: "Gold Tool Hammer",
  2456. description: "Gather materials",
  2457. range: 80,
  2458. itemType: ItemType.PRIMARY,
  2459. damage: 32,
  2460. reload: 300,
  2461. _s: 30,
  2462. Ms: 200,
  2463. actionType: ActionType.MELEE,
  2464. ps: 0,
  2465. As: -3.5,
  2466. os: 1
  2467. }, {
  2468. id: 47,
  2469. gs: 48,
  2470. upgradeType: upgradeType.DIAMOND,
  2471. imageinv: 160,
  2472. image: 159,
  2473. name: "Diamond Tool Hammer",
  2474. description: "Gather materials",
  2475. range: 80,
  2476. itemType: ItemType.PRIMARY,
  2477. damage: 38,
  2478. reload: 300,
  2479. _s: 30,
  2480. Ms: 200,
  2481. actionType: ActionType.MELEE,
  2482. ps: 0,
  2483. As: -3.5,
  2484. os: 1
  2485. }, {
  2486. upgradeType: upgradeType.RUBY,
  2487. id: 48,
  2488. imageinv: 162,
  2489. image: 161,
  2490. name: "Ruby Tool Hammer",
  2491. description: "Gather materials",
  2492. range: 80,
  2493. itemType: ItemType.PRIMARY,
  2494. damage: 41,
  2495. reload: 300,
  2496. _s: 30,
  2497. Ms: 200,
  2498. actionType: ActionType.MELEE,
  2499. ps: 0,
  2500. As: -3.5,
  2501. os: 1
  2502. }, {
  2503. id: 49,
  2504. cost: {
  2505. food: 0,
  2506. wood: 20,
  2507. stone: 0,
  2508. gold: 0
  2509. },
  2510. ks: 1,
  2511. imageinv: 170,
  2512. image: 169,
  2513. name: "Roof",
  2514. description: "Take cover from projectiles",
  2515. itemType: ItemType.PLATFORM,
  2516. actionType: ActionType.PLACEABLE,
  2517. Hs: 0,
  2518. As: 0,
  2519. os: 15,
  2520. Ss: 26,
  2521. ps: 2
  2522. }, {
  2523. id: 50,
  2524. cost: {
  2525. food: 80,
  2526. wood: 80,
  2527. stone: 80,
  2528. gold: 80
  2529. },
  2530. ks: 1,
  2531. ys: 256,
  2532. imageinv: 182,
  2533. image: 182,
  2534. name: "Pearl",
  2535. description: "Teleport on impact",
  2536. range: 700,
  2537. itemType: ItemType.SECONDARY,
  2538. damage: 10,
  2539. reload: 1e4,
  2540. projectile: 182,
  2541. Ls: 1e3,
  2542. actionType: ActionType.RANGED,
  2543. ps: 1,
  2544. Us: .4,
  2545. As: 0,
  2546. os: 35
  2547. }, {
  2548. id: 51,
  2549. cost: {
  2550. food: 0,
  2551. wood: 50,
  2552. stone: 50,
  2553. gold: 0
  2554. },
  2555. ks: 2208,
  2556. ys: 1,
  2557. imageinv: 183,
  2558. image: 183,
  2559. name: "Teleporter",
  2560. description: "Teleports to location on map",
  2561. itemType: ItemType.SPAWN,
  2562. actionType: ActionType.PLACEABLE,
  2563. Hs: 5,
  2564. As: 0,
  2565. os: 15,
  2566. Ss: 37,
  2567. ps: 2
  2568. }, {
  2569. gs: 53,
  2570. upgradeType: upgradeType.STONE,
  2571. id: 52,
  2572. ks: 1,
  2573. ys: 4096,
  2574. imageinv: 189,
  2575. image: 193,
  2576. name: "Stone Dagger",
  2577. description: "A stubbier sword",
  2578. range: 80,
  2579. Ms: 100,
  2580. itemType: ItemType.PRIMARY,
  2581. damage: 22,
  2582. reload: 150,
  2583. actionType: ActionType.MELEE,
  2584. ps: 0,
  2585. As: 10,
  2586. os: 20
  2587. }, {
  2588. gs: 54,
  2589. upgradeType: upgradeType.GOLD,
  2590. id: 53,
  2591. ks: 1,
  2592. ys: 4096,
  2593. imageinv: 190,
  2594. image: 194,
  2595. name: "Gold Dagger",
  2596. description: "A stubbier sword",
  2597. range: 80,
  2598. Ms: 100,
  2599. itemType: ItemType.PRIMARY,
  2600. damage: 24,
  2601. reload: 150,
  2602. actionType: ActionType.MELEE,
  2603. ps: 0,
  2604. As: 10,
  2605. os: 20
  2606. }, {
  2607. gs: 55,
  2608. upgradeType: upgradeType.DIAMOND,
  2609. id: 54,
  2610. ks: 1,
  2611. ys: 4096,
  2612. imageinv: 191,
  2613. image: 195,
  2614. name: "Diamond Dagger",
  2615. description: "A stubbier sword",
  2616. range: 80,
  2617. Ms: 100,
  2618. itemType: ItemType.PRIMARY,
  2619. damage: 26,
  2620. reload: 150,
  2621. actionType: ActionType.MELEE,
  2622. ps: 0,
  2623. As: 10,
  2624. os: 20
  2625. }, {
  2626. upgradeType: upgradeType.RUBY,
  2627. id: 55,
  2628. ks: 1,
  2629. ys: 4096,
  2630. imageinv: 192,
  2631. image: 196,
  2632. name: "Ruby Dagger",
  2633. description: "A stubbier sword",
  2634. range: 80,
  2635. Ms: 100,
  2636. itemType: ItemType.PRIMARY,
  2637. damage: 29,
  2638. reload: 150,
  2639. actionType: ActionType.MELEE,
  2640. ps: 0,
  2641. As: 10,
  2642. os: 20
  2643. }, {
  2644. id: 56,
  2645. gs: 57,
  2646. upgradeType: upgradeType.GOLD,
  2647. ks: 1,
  2648. ys: 1,
  2649. imageinv: 198,
  2650. image: 198,
  2651. name: "Secret Item",
  2652. description: "Dont leak how to get it :)",
  2653. range: 115,
  2654. itemType: ItemType.PRIMARY,
  2655. damage: 28,
  2656. Us: .92,
  2657. Ms: 1570,
  2658. reload: 2e3,
  2659. actionType: ActionType.MELEE,
  2660. ps: 0,
  2661. As: 40,
  2662. os: 40
  2663. }, {
  2664. id: 57,
  2665. ks: 2,
  2666. ys: 2,
  2667. imageinv: 199,
  2668. image: 199,
  2669. name: "Daedric Scythe",
  2670. description: "Whispers fill the air",
  2671. range: 160,
  2672. Ms: 150,
  2673. itemType: ItemType.PRIMARY,
  2674. damage: 52,
  2675. reload: 450,
  2676. Us: .85,
  2677. actionType: ActionType.MELEE,
  2678. ps: 0,
  2679. As: -5,
  2680. os: 20
  2681. } ];
  2682. const Items = ItemData;
  2683. const ItemList = Items.filter((item => item.actionType === ActionType.PLACEABLE));
  2684. const Shooting = Items.filter((item => item.actionType === ActionType.RANGED));
  2685. class Vector {
  2686. constructor(x, y) {
  2687. this.x = x;
  2688. this.y = y;
  2689. }
  2690. static fromAngle(angle) {
  2691. return new Vector(Math.cos(angle), Math.sin(angle));
  2692. }
  2693. add(vec) {
  2694. this.x += vec.x;
  2695. this.y += vec.y;
  2696. return this;
  2697. }
  2698. sub(vec) {
  2699. this.x -= vec.x;
  2700. this.y -= vec.y;
  2701. return this;
  2702. }
  2703. mult(scalar) {
  2704. this.x *= scalar;
  2705. this.y *= scalar;
  2706. return this;
  2707. }
  2708. div(scalar) {
  2709. this.x /= scalar;
  2710. this.y /= scalar;
  2711. return this;
  2712. }
  2713. get length() {
  2714. return Math.sqrt(this.x * this.x + this.y * this.y);
  2715. }
  2716. normalize() {
  2717. return this.length > 0 ? this.div(this.length) : this;
  2718. }
  2719. setLength(value) {
  2720. return this.normalize().mult(value);
  2721. }
  2722. copy() {
  2723. return new Vector(this.x, this.y);
  2724. }
  2725. distance(vec) {
  2726. return this.copy().sub(vec).length;
  2727. }
  2728. angle(vec) {
  2729. const copy = vec.copy().sub(this);
  2730. return Math.atan2(copy.y, copy.x);
  2731. }
  2732. dot(vec) {
  2733. return this.x * vec.x + this.y * vec.y;
  2734. }
  2735. direction(angle, scalar) {
  2736. return this.copy().add(Vector.fromAngle(angle).mult(scalar));
  2737. }
  2738. }
  2739. const getAngleDist = (a, b) => {
  2740. const p = Math.abs(b - a) % (Math.PI * 2);
  2741. return p > Math.PI ? Math.PI * 2 - p : p;
  2742. };
  2743. class EntityManager {
  2744. static isPlayer(entity) {
  2745. return entity.type === ELayer.PLAYER;
  2746. }
  2747. static animals() {
  2748. const layers = Dsync.saves.entityList();
  2749. const animals = [];
  2750. for (let i = 0; i < Animals.length; i++) {
  2751. const layer = layers[Animals[i].id];
  2752. const formatted = layer.map((target => Formatter.entity(target)));
  2753. animals.push(...formatted);
  2754. }
  2755. return animals;
  2756. }
  2757. static enemies() {
  2758. const players = Dsync.saves.entityList()[ELayer.PLAYER];
  2759. const enemies = [];
  2760. for (let i = 0; i < players.length; i++) {
  2761. const player = Formatter.player(players[i]);
  2762. if (controller.isEnemy(player)) enemies.push(player);
  2763. }
  2764. return enemies.sort(((a, b) => this.sortDistance(a, b)));
  2765. }
  2766. static distance(a, b) {
  2767. return new Vector(a.x2, a.y2).distance(new Vector(b.x2, b.y2));
  2768. }
  2769. static angle(a, b) {
  2770. return new Vector(a.x2, a.y2).angle(new Vector(b.x2, b.y2));
  2771. }
  2772. static sortDistance(a, b, sorted) {
  2773. const target = sorted || Dsync.myPlayer;
  2774. return this.distance(a, target) - this.distance(b, target);
  2775. }
  2776. static shield(a, b, sorted) {
  2777. const target = sorted || Dsync.myPlayer;
  2778. const shieldA = this.lookingAt(a, target, 1.58927) && a.currentItem === EWeapons.SHIELD;
  2779. const shieldB = this.lookingAt(b, target, 1.58927) && b.currentItem === EWeapons.SHIELD;
  2780. return shieldA ? 1 : shieldB ? -1 : 0;
  2781. }
  2782. static canHitEntity(a, b, sorted) {
  2783. const target = sorted || Dsync.myPlayer;
  2784. const hitA = this.projectileCanHitEntity(a, target);
  2785. const hitB = this.projectileCanHitEntity(b, target);
  2786. return hitA === Hit.NEEDDESTROY ? 1 : hitB === Hit.NEEDDESTROY ? -1 : 0;
  2787. }
  2788. static lookingAt(entity, point, angle) {
  2789. const pos1 = new Vector(entity.x2, entity.y2);
  2790. const pos2 = new Vector(point.x2, point.y2);
  2791. const dir = getAngleDist(pos1.angle(pos2) + Math.PI, entity.angle2);
  2792. return dir > angle;
  2793. }
  2794. static entities(sorted) {
  2795. return [ ...this.enemies().sort(((a, b) => this.sortDistance(a, b, sorted))).sort(((a, b) => this.shield(a, b, sorted))), ...this.animals().sort(((a, b) => this.sortDistance(a, b, sorted))) ];
  2796. }
  2797. static predict(entity) {
  2798. const pos1 = new Vector(entity.x1, entity.y1);
  2799. const pos2 = new Vector(entity.x2, entity.y2);
  2800. const distance = pos1.distance(pos2) * (entity === Dsync.myPlayer ? 1 : 2.2);
  2801. const direction = Vector.fromAngle(pos1.angle(pos2));
  2802. return pos2.add(direction.mult(distance));
  2803. }
  2804. static entityIn(entity, layer, extraRadius = 0) {
  2805. const targets = Dsync.saves.entityList()[layer];
  2806. return targets.some((target => {
  2807. const object = Formatter.object(target);
  2808. const radius = entity.radius + object.radius + extraRadius;
  2809. return this.distance(entity, object) <= radius;
  2810. }));
  2811. }
  2812. static intersects(pos1, pos2, pos3, r) {
  2813. const linear = pos2.copy().sub(pos1);
  2814. const constant = pos1.copy().sub(pos3);
  2815. const a = linear.dot(linear);
  2816. const b = linear.dot(constant);
  2817. const c = constant.dot(constant) - r * r;
  2818. return b * b >= a * c && (-b <= a || c + b + b + a <= 0) && (b <= 0 || c <= 0);
  2819. }
  2820. static projectileCanHitEntity(entity, sorted) {
  2821. const target = sorted || Dsync.myPlayer;
  2822. if (!controller.canShoot()) return Hit.CANNOT;
  2823. const pos1 = new Vector(target.x2, target.y2);
  2824. const pos2 = new Vector(entity.x2, entity.y2);
  2825. const myPlayerOnPlatform = this.entityIn(target, ELayer.PLATFORM);
  2826. const entityInRoof = this.entityIn(entity, ELayer.ROOF);
  2827. if (myPlayerOnPlatform && entityInRoof) return Hit.CANNOT;
  2828. const layers = Dsync.saves.entityList();
  2829. for (const layer of LayerObjects) {
  2830. if (myPlayerOnPlatform && !layer.cannotShoot) continue;
  2831. for (const target of layers[layer.id]) {
  2832. const object = Formatter.object(target);
  2833. const pos3 = new Vector(object.x2, object.y2);
  2834. if (pos1.distance(pos3) > pos1.distance(pos2)) continue;
  2835. if (this.intersects(pos1, pos2, pos3, object.radius)) {
  2836. if (object.layerData.maxHealth === undefined) return Hit.CANNOT;
  2837. return Hit.NEEDDESTROY;
  2838. }
  2839. }
  2840. }
  2841. return Hit.CAN;
  2842. }
  2843. static inWeaponRange(entity1, entity2, weapon) {
  2844. const range = Items[weapon].range || 0;
  2845. return this.distance(entity1, entity2) <= range + entity2.radius;
  2846. }
  2847. static nearestPossible(weapon, sorted) {
  2848. const target = sorted || Dsync.myPlayer;
  2849. const item = Items[weapon];
  2850. const shoot = controller.canShoot() && item.actionType === ActionType.RANGED;
  2851. const entities = this.entities().filter((entity => shoot ? this.projectileCanHitEntity(entity, target) : this.inWeaponRange(target, entity, weapon)));
  2852. if (shoot) {
  2853. entities.sort(((a, b) => this.canHitEntity(a, b, target)));
  2854. }
  2855. return entities.length ? entities[0] : null;
  2856. }
  2857. static nearestLayer(entity, layer) {
  2858. const objects = Dsync.saves.entityList()[layer].map((target => Formatter.object(target)));
  2859. return objects.sort(((a, b) => this.sortDistance(a, b, entity)))[0];
  2860. }
  2861. }
  2862. class TimeoutManager {
  2863. constructor(callbacks, delay) {
  2864. this.callbacks = callbacks;
  2865. this.delay = delay;
  2866. this.active = false;
  2867. this.old = Date.now();
  2868. }
  2869. static waitUntil(condition, time, callback) {
  2870. return new Promise((resolve => {
  2871. const start = Date.now();
  2872. const int = setInterval((() => {
  2873. if (typeof time === "number" && Number.isFinite(time) && Date.now() - start > time || condition()) {
  2874. clearInterval(int);
  2875. }
  2876. if (condition()) {
  2877. if (typeof callback === "function") return callback();
  2878. resolve();
  2879. }
  2880. }), 50);
  2881. }));
  2882. }
  2883. start() {
  2884. if (this.active) return;
  2885. this.active = true;
  2886. this.old = Date.now();
  2887. this.callbacks[0]();
  2888. }
  2889. async stop() {
  2890. if (!this.active) return;
  2891. this.callbacks[1]();
  2892. if (!this.delay(this.old)) await TimeoutManager.waitUntil((() => this.delay(this.old)), 3e3);
  2893. this.callbacks[2]();
  2894. this.active = false;
  2895. }
  2896. isActive() {
  2897. return this.active;
  2898. }
  2899. }
  2900. class Controller {
  2901. constructor() {
  2902. this.move = 0;
  2903. this.attacking = false;
  2904. this.autoattack = false;
  2905. this.rotation = false;
  2906. this.weapon = false;
  2907. this.healing = false;
  2908. this.attackingInvis = false;
  2909. this.toggleInvis = false;
  2910. this.currentItem = null;
  2911. this.chatToggle = false;
  2912. this.chatCount = 0;
  2913. this.autobed = false;
  2914. this.automill = false;
  2915. this.automillSpawn = false;
  2916. this.mousemove = true;
  2917. this.kills = 0;
  2918. this.inGame = false;
  2919. this.itemBar = [ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ];
  2920. this.hsl = 0;
  2921. this.aimTarget = null;
  2922. this.wasAutoboost = false;
  2923. this.count = 0;
  2924. this.toggleJungle = false;
  2925. this.toggleScuba = false;
  2926. this.resources = {
  2927. food: 200,
  2928. wood: 200,
  2929. stone: 200,
  2930. gold: 200
  2931. };
  2932. this.mouse = {
  2933. x: 0,
  2934. y: 0,
  2935. angle: 0
  2936. };
  2937. this.equipStart = Date.now();
  2938. this.actualHat = 0;
  2939. this.currentHat = 0;
  2940. this.previousHat = 0;
  2941. this.maxCount = [ 0, 0, 0, 100, 30, 8, 2, 12, 32, 1, 2 ];
  2942. this.age = 0;
  2943. this.hotkeys = new Map;
  2944. this.PacketManager = new PacketManager;
  2945. this.previousWeapon = false;
  2946. this.fastbreak = new TimeoutManager([ () => {
  2947. const primary = this.itemBar[ItemType.PRIMARY];
  2948. const secondary = this.itemBar[ItemType.SECONDARY];
  2949. const pickWeapon = secondary === EWeapons.HAMMER || primary === EWeapons.STICK && secondary === EWeapons.SHIELD;
  2950. this.previousWeapon = this.weapon;
  2951. this.whichWeapon(pickWeapon);
  2952. this.equipHat(Hat.DEMOLIST, false);
  2953. this.attacking = true;
  2954. this.attack();
  2955. }, () => {
  2956. this.PacketManager.stopAttack();
  2957. this.attacking = false;
  2958. this.whichWeapon(this.previousWeapon);
  2959. }, () => {
  2960. if (!Dsync.myPlayer.isClown) {
  2961. this.equipHat(this.previousHat, true);
  2962. }
  2963. } ], (start => this.hatReloaded() && Date.now() - start > TargetReload.HAT));
  2964. this.attachMouse();
  2965. }
  2966. reset(items) {
  2967. this.move = 0;
  2968. this.attacking = false;
  2969. this.autoattack = false;
  2970. this.rotation = false;
  2971. this.weapon = false;
  2972. this.healing = false;
  2973. this.attackingInvis = false;
  2974. this.toggleInvis = false;
  2975. this.currentItem = null;
  2976. this.chatToggle = false;
  2977. this.chatCount = 0;
  2978. this.autobed = false;
  2979. this.automill = false;
  2980. this.automillSpawn = false;
  2981. this.mousemove = true;
  2982. this.kills = 0;
  2983. this.inGame = false;
  2984. this.itemBar = [ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ];
  2985. this.hsl = 0;
  2986. this.aimTarget = null;
  2987. this.count = 0;
  2988. for (const id of items) {
  2989. this.upgradeItem(id);
  2990. }
  2991. for (const [key] of this.hotkeys) {
  2992. this.hotkeys.delete(key);
  2993. }
  2994. }
  2995. attachMouse() {
  2996. window.addEventListener("mousemove", (event => {
  2997. this.mouse.x = event.clientX;
  2998. this.mouse.y = event.clientY;
  2999. if (!this.rotation) {
  3000. this.mouse.angle = angle(innerWidth / 2, innerHeight / 2, this.mouse.x, this.mouse.y);
  3001. }
  3002. }));
  3003. }
  3004. hasItem(type) {
  3005. return this.itemBar[type] !== -1;
  3006. }
  3007. hasSecondary() {
  3008. return this.itemBar[ItemType.SECONDARY] !== -1;
  3009. }
  3010. updateWeapon(type) {
  3011. const weapon = Dsync.saves.defaultData[Dsync.props.itemBar][type];
  3012. if (this.isWeapon(weapon) && this.itemBar[type] !== weapon) {
  3013. this.itemBar[type] = weapon;
  3014. }
  3015. }
  3016. isMyPlayer(entity) {
  3017. return entity.id === Dsync.saves.myPlayerID();
  3018. }
  3019. isTeammate(entity) {
  3020. return entity.id !== Dsync.saves.myPlayerID() && teammates.includes(entity.ownerID);
  3021. }
  3022. isEnemy(entity) {
  3023. return !this.isMyPlayer(entity) && !this.isTeammate(entity);
  3024. }
  3025. canShoot() {
  3026. const id = this.itemBar[ItemType.SECONDARY];
  3027. return this.hasSecondary() && Items[id].actionType === ActionType.RANGED;
  3028. }
  3029. isWeapon(id) {
  3030. const type = Items[id].itemType;
  3031. return type === ItemType.PRIMARY || type === ItemType.SECONDARY;
  3032. }
  3033. isPrimary(id) {
  3034. return Items[id].itemType === ItemType.PRIMARY;
  3035. }
  3036. isSecondary(id) {
  3037. return Items[id].itemType === ItemType.SECONDARY;
  3038. }
  3039. currentCount(type) {
  3040. return Dsync.saves.defaultData[Dsync.props.currentCount][type];
  3041. }
  3042. hasCount(type) {
  3043. return this.currentCount(type) < this.maxCount[type];
  3044. }
  3045. isDoingNothing() {
  3046. return !this.healing && !this.attackingInvis && !this.toggleInvis && !this.attacking && this.currentItem === null;
  3047. }
  3048. canAutosync() {
  3049. return !this.attacking && !this.attackingInvis && !this.toggleInvis && !this.autoattack;
  3050. }
  3051. hasResources(id) {
  3052. const cost = Items[id].cost || {
  3053. food: 0,
  3054. wood: 0,
  3055. stone: 0,
  3056. gold: 0
  3057. };
  3058. const {food, wood, stone, gold} = this.resources;
  3059. const hasFood = food >= cost.food;
  3060. const hasWood = wood >= cost.wood;
  3061. const hasStone = stone >= cost.stone;
  3062. const hasGold = gold >= cost.gold;
  3063. return hasFood && hasWood && hasStone && hasGold;
  3064. }
  3065. getAngleFromBitmask(bitmask, rotate) {
  3066. const vec = {
  3067. x: 0,
  3068. y: 0
  3069. };
  3070. if (bitmask & 1) vec.y--;
  3071. if (bitmask & 2) vec.y++;
  3072. if (bitmask & 4) vec.x--;
  3073. if (bitmask & 8) vec.x++;
  3074. if (rotate) {
  3075. vec.x *= -1;
  3076. vec.y *= -1;
  3077. }
  3078. return Math.atan2(vec.y, vec.x);
  3079. }
  3080. upgradeItem(id) {
  3081. const item = Items[id];
  3082. this.itemBar[item.itemType] = id;
  3083. }
  3084. upgradeScythe() {
  3085. const target = Dsync.saves.entityList()[ELayer.GOLDENCOW][0];
  3086. if (target !== undefined) {
  3087. this.PacketManager.upgradeScythe(target[Dsync.props.id]);
  3088. }
  3089. }
  3090. buyHat(id) {
  3091. if (!Hats[id].bought && controller.resources.gold >= Hats[id].price) {
  3092. Hats[id].bought = true;
  3093. this.PacketManager.equip(id);
  3094. }
  3095. return Hats[id].bought;
  3096. }
  3097. hatReloaded() {
  3098. return Dsync.myPlayer.target.hatReload.current === TargetReload.HAT;
  3099. }
  3100. equipHat(id, actual = true, force = false) {
  3101. const hatID = id === Hat.UNEQUIP ? this.actualHat : id;
  3102. if (!this.buyHat(hatID) || !this.inGame) return false;
  3103. const now = Date.now();
  3104. if (!Hats[id].equipped && this.hatReloaded() && now - this.equipStart >= TargetReload.HAT || force) {
  3105. this.equipStart = now;
  3106. this.PacketManager.equip(hatID);
  3107. for (const hat of Hats) {
  3108. hat.equipped = false;
  3109. }
  3110. Hats[id].equipped = true;
  3111. this.previousHat = this.currentHat;
  3112. this.currentHat = id;
  3113. if (actual) {
  3114. this.actualHat = id;
  3115. }
  3116. return true;
  3117. }
  3118. return false;
  3119. }
  3120. async autochat() {
  3121. if (this.chatToggle) return;
  3122. this.chatToggle = true;
  3123. const messages = Settings.autochatMessages.filter((msg => msg.length));
  3124. if (!messages.length) return;
  3125. this.PacketManager.chat(messages[this.chatCount++]);
  3126. this.chatCount %= messages.length;
  3127. await sleep(2e3);
  3128. this.chatToggle = false;
  3129. }
  3130. accept(which) {
  3131. this.PacketManager.accept(which);
  3132. const acceptList = Dsync.saves.clanData[Dsync.props.acceptList];
  3133. acceptList.shift();
  3134. }
  3135. async spawn() {
  3136. await sleep(100);
  3137. const play = document.querySelector("#play");
  3138. play.click();
  3139. }
  3140. whichWeapon(type) {
  3141. if (type !== undefined) {
  3142. this.weapon = type;
  3143. }
  3144. this.PacketManager.selectByID(this.itemBar[+this.weapon]);
  3145. }
  3146. attack(angle) {
  3147. const dir = angle ? angle : this.mouse.angle;
  3148. this.PacketManager.attack(dir);
  3149. }
  3150. place(type, angle, placementType) {
  3151. if (this.wasAutoboost) {
  3152. const nearest = EntityManager.enemies()[0];
  3153. if (nearest !== undefined) {
  3154. angle = EntityManager.angle(Dsync.myPlayer, nearest);
  3155. this.PacketManager.moveAngle(angle);
  3156. }
  3157. }
  3158. const placeType = placementType === undefined ? Settings.placementType : placementType;
  3159. const isHolding = placeType === PlacementType.HOLDING;
  3160. this.whichWeapon();
  3161. if (isHolding && this.attacking) this.attack(angle);
  3162. this.PacketManager.selectItemByType(type);
  3163. this.attack(angle);
  3164. this.PacketManager.stopAttack();
  3165. if (!isHolding) this.whichWeapon();
  3166. if (this.attacking) this.attack(angle);
  3167. }
  3168. placement() {
  3169. if (this.currentItem === null) return;
  3170. this.place(this.currentItem);
  3171. this.count = (this.count + 1) % Settings.placementSpeed;
  3172. const method = this.count === 0 ? setTimeout : queueMicrotask;
  3173. method(this.placement.bind(this));
  3174. }
  3175. placementHandler(type, code) {
  3176. if (!this.hasItem(type)) return;
  3177. if (Settings.placementType === PlacementType.DEFAULT) {
  3178. this.PacketManager.selectItemByType(type);
  3179. return;
  3180. }
  3181. this.hotkeys.set(code, type);
  3182. this.currentItem = type;
  3183. const isBoost = type === ItemType.TRAP && this.itemBar[ItemType.TRAP] === EObjects.BOOST;
  3184. this.wasAutoboost = Settings.autoboostFollow && isBoost;
  3185. if (this.hotkeys.size === 1) {
  3186. this.placement();
  3187. }
  3188. }
  3189. heal() {
  3190. this.PacketManager.selectItemByType(ItemType.FOOD);
  3191. this.attack();
  3192. this.PacketManager.stopAttack();
  3193. this.whichWeapon();
  3194. if (this.attacking) {
  3195. this.attack();
  3196. }
  3197. }
  3198. invisibleHit() {
  3199. this.mousemove = true;
  3200. this.aimTarget = null;
  3201. if (Settings.invisHitToggle && !this.toggleInvis || !Settings.invisHitToggle && !this.attackingInvis) {
  3202. this.toggleInvis = false;
  3203. this.attackingInvis = false;
  3204. return;
  3205. }
  3206. let angle;
  3207. const nearest = EntityManager.nearestPossible(this.itemBar[+!this.weapon]);
  3208. const shoot = this.canShoot() && !this.weapon;
  3209. if (nearest && (Settings.meleeAim && !shoot || Settings.bowAim && shoot)) {
  3210. const pos1 = EntityManager.predict(Dsync.myPlayer);
  3211. const pos2 = EntityManager.predict(nearest);
  3212. angle = pos1.angle(pos2);
  3213. this.mousemove = false;
  3214. this.aimTarget = nearest.target;
  3215. }
  3216. if (nearest && shoot || !shoot) {
  3217. this.whichWeapon(!this.weapon);
  3218. this.attack(angle);
  3219. this.PacketManager.stopAttack();
  3220. this.whichWeapon(!this.weapon);
  3221. }
  3222. setTimeout(this.invisibleHit.bind(this), 85);
  3223. }
  3224. spikeInsta() {
  3225. let angle;
  3226. if (Settings.spikeInstaAim) {
  3227. const nearest = EntityManager.nearestPossible(this.itemBar[0]);
  3228. if (nearest) {
  3229. angle = EntityManager.angle(Dsync.myPlayer, nearest);
  3230. }
  3231. }
  3232. const previousWeapon = this.weapon;
  3233. this.equipHat(Hat.BERSERKER);
  3234. this.whichWeapon(false);
  3235. this.place(ItemType.SPIKE, angle);
  3236. this.attack(angle);
  3237. this.PacketManager.stopAttack();
  3238. this.whichWeapon(previousWeapon);
  3239. }
  3240. handleKeydown(event, code) {
  3241. if (code === 1) event.preventDefault();
  3242. if (event instanceof KeyboardEvent && event.repeat) return;
  3243. if (Dsync.active) return;
  3244. if (code === Settings.toggleMenu && !isInput(event.target)) {
  3245. if (typeof Dsync.toggleMenu === "function") Dsync.toggleMenu();
  3246. }
  3247. if (!this.inGame) return;
  3248. if (code === Settings.openChat) {
  3249. if (!isInput()) event.preventDefault();
  3250. Dsync.saves.toggleChat();
  3251. }
  3252. if (isInput(event.target)) return;
  3253. if (code === Settings.primary) this.whichWeapon(false);
  3254. if (code === Settings.secondary && this.hasSecondary()) this.whichWeapon(true);
  3255. if (code === Settings.heal && !this.healing) {
  3256. this.healing = true;
  3257. if (Settings.placementType === PlacementType.DEFAULT) {
  3258. this.PacketManager.selectItemByType(ItemType.FOOD);
  3259. } else {
  3260. doWhile((() => this.healing), this.heal.bind(this), 0);
  3261. }
  3262. }
  3263. if (code === Settings.wall) this.placementHandler(ItemType.WALL, code);
  3264. if (code === Settings.spike) this.placementHandler(ItemType.SPIKE, code);
  3265. if (code === Settings.windmill) this.placementHandler(ItemType.WINDMILL, code);
  3266. if (code === Settings.trap) this.placementHandler(ItemType.TRAP, code);
  3267. if (code === Settings.turret) this.placementHandler(ItemType.TURRET, code);
  3268. if (code === Settings.tree) this.placementHandler(ItemType.FARM, code);
  3269. if (code === Settings.platform) this.placementHandler(ItemType.PLATFORM, code);
  3270. if (code === Settings.spawn) this.placementHandler(ItemType.SPAWN, code);
  3271. if (code === Settings.unequip) this.equipHat(Hat.UNEQUIP);
  3272. if (code === Settings.bush) this.equipHat(Hat.BUSH);
  3273. if (code === Settings.berserker) this.equipHat(Hat.BERSERKER);
  3274. if (code === Settings.jungle) this.equipHat(Hat.JUNGLE);
  3275. if (code === Settings.crystal) this.equipHat(Hat.CRYSTAL);
  3276. if (code === Settings.spikegear) this.equipHat(Hat.SPIKEGEAR);
  3277. if (code === Settings.immunity) this.equipHat(Hat.IMMUNITY);
  3278. if (code === Settings.boost) this.equipHat(Hat.BOOST);
  3279. if (code === Settings.applehat) this.equipHat(Hat.APPLEHAT);
  3280. if (code === Settings.scuba) this.equipHat(Hat.SCUBA);
  3281. if (code === Settings.hood) this.equipHat(Hat.HOOD);
  3282. if (code === Settings.demolist) this.equipHat(Hat.DEMOLIST);
  3283. if (code === Settings.invisibleHit && this.hasSecondary()) {
  3284. if (Settings.invisHitToggle) {
  3285. this.toggleInvis = !this.toggleInvis;
  3286. } else {
  3287. this.attackingInvis = true;
  3288. }
  3289. if (this.toggleInvis || this.attackingInvis) this.invisibleHit();
  3290. }
  3291. if (code === Settings.spikeInsta) this.spikeInsta();
  3292. if (code === Settings.fastBreak && !this.fastbreak.isActive() && this.hatReloaded()) {
  3293. this.fastbreak.start();
  3294. }
  3295. const copyMove = this.move;
  3296. if (code === Settings.up) this.move |= 1;
  3297. if (code === Settings.left) this.move |= 4;
  3298. if (code === Settings.down) this.move |= 2;
  3299. if (code === Settings.right) this.move |= 8;
  3300. if (copyMove !== this.move) this.PacketManager.moveByBitmask(this.move);
  3301. if (event instanceof MouseEvent && code === 0) {
  3302. this.attacking = true;
  3303. }
  3304. if (code === Settings.autoattack) {
  3305. this.autoattack = !this.autoattack;
  3306. this.PacketManager.autoattack(this.autoattack);
  3307. }
  3308. if (code === Settings.lockRotation) {
  3309. this.rotation = !this.rotation;
  3310. Dsync.saves.toggleRotation(this.rotation);
  3311. }
  3312. if (code === Settings.upgradeScythe) this.upgradeScythe();
  3313. }
  3314. handleKeyup(event, code) {
  3315. if (code === Settings.heal && this.healing) {
  3316. this.healing = false;
  3317. }
  3318. if (code === Settings.invisibleHit && this.attackingInvis) {
  3319. this.attackingInvis = false;
  3320. }
  3321. if (code === Settings.fastBreak && this.fastbreak.isActive()) {
  3322. this.fastbreak.stop();
  3323. }
  3324. const copyMove = this.move;
  3325. if (code === Settings.up) this.move &= -2;
  3326. if (code === Settings.left) this.move &= -5;
  3327. if (code === Settings.down) this.move &= -3;
  3328. if (code === Settings.right) this.move &= -9;
  3329. if (copyMove !== this.move) this.PacketManager.moveByBitmask(this.move);
  3330. if (event instanceof MouseEvent && code === 0) {
  3331. this.attacking = false;
  3332. }
  3333. if (code === Settings.trap && this.wasAutoboost) {
  3334. this.wasAutoboost = false;
  3335. this.PacketManager.moveByBitmask(this.move);
  3336. }
  3337. if (this.currentItem !== null && this.hotkeys.delete(code)) {
  3338. const entries = [ ...this.hotkeys ];
  3339. this.currentItem = entries.length ? entries[entries.length - 1][1] : null;
  3340. if (this.currentItem === null) {
  3341. this.whichWeapon();
  3342. }
  3343. }
  3344. }
  3345. }
  3346. const attackAnimation = (type, id, weapon, isObject, target) => {
  3347. if (type === ELayer.PLAYER) {
  3348. if (Settings.weaponReloadBar) {
  3349. const reload = target.weaponReload;
  3350. reload.current = -Dsync.step;
  3351. reload.lerp = 0;
  3352. reload.max = Items[weapon].reload || 0;
  3353. }
  3354. if (Settings.autosync && controller.canAutosync()) {
  3355. const player = Formatter.player(target);
  3356. if (controller.isTeammate(player) && controller.isPrimary(weapon)) {
  3357. const nearest = EntityManager.nearestPossible(weapon, player);
  3358. if (nearest !== null && EntityManager.inWeaponRange(Dsync.myPlayer, nearest, controller.itemBar[0])) {
  3359. const previousWeapon = controller.weapon;
  3360. controller.whichWeapon(false);
  3361. controller.attack(EntityManager.angle(Dsync.myPlayer, nearest));
  3362. controller.PacketManager.stopAttack();
  3363. controller.whichWeapon(previousWeapon);
  3364. controller.PacketManager.changeAngle(controller.mouse.angle);
  3365. }
  3366. }
  3367. }
  3368. }
  3369. };
  3370. const hooks_attackAnimation = attackAnimation;
  3371. const createEntity = target => {
  3372. const id = target[Dsync.props.id];
  3373. const type = target.type;
  3374. const entities = Dsync.saves.entityList();
  3375. if (type === ELayer.PLAYER) {
  3376. if (id === Dsync.saves.myPlayerID()) {
  3377. Dsync.myPlayer.target = target;
  3378. }
  3379. const player = Formatter.player(target);
  3380. target.hatReload = {
  3381. ...Reload.hat
  3382. };
  3383. target.weaponReload = {
  3384. ...Reload.weapon
  3385. };
  3386. target.prevHat = player.hat;
  3387. const weaponReload = target.weaponReload;
  3388. if (controller.isWeapon(player.currentItem)) {
  3389. weaponReload.max = Items[player.currentItem].reload || 0;
  3390. weaponReload.current = weaponReload.max;
  3391. weaponReload.lerp = weaponReload.max;
  3392. }
  3393. } else if (type === ELayer.TURRET) {
  3394. target.turretReload = {
  3395. ...Reload.turret
  3396. };
  3397. } else if (type === ELayer.DRAGON) {
  3398. target.fireballReload = {
  3399. ...Reload.fireball
  3400. };
  3401. } else if (type === ELayer.PROJECTILE) {
  3402. const projectile = Formatter.projectile(target);
  3403. const type = projectile.projectileType;
  3404. const isTurret = Settings.turretReloadBar && entities[ELayer.TURRET].find((target => {
  3405. const turret = Formatter.object(target);
  3406. const isOwner = turret.ownerID === projectile.ownerID;
  3407. const isX = turret.x2 === projectile.x2;
  3408. const isY = turret.y2 === projectile.y2;
  3409. return isOwner && isX && isY;
  3410. }));
  3411. const isPlayer = Settings.weaponReloadBar && entities[ELayer.PLAYER].find((target => {
  3412. const player = Formatter.player(target);
  3413. const isOwner = player.ownerID === projectile.ownerID;
  3414. return isOwner;
  3415. }));
  3416. if (isTurret) {
  3417. const reload = isTurret.turretReload;
  3418. reload.current = -Dsync.step;
  3419. reload.lerp = 0;
  3420. } else if (isPlayer) {
  3421. const weapon = Shooting.find((weapon => weapon.projectile === type));
  3422. if (weapon === undefined) return;
  3423. let delay = weapon.reload || 0;
  3424. if (type === 88) {
  3425. const id = isPlayer.secondary === EWeapons.XBOW ? EWeapons.XBOW : EWeapons.BOW;
  3426. delay = Items[id].reload || 0;
  3427. }
  3428. const reload = isPlayer.weaponReload;
  3429. reload.current = -Dsync.step;
  3430. reload.lerp = 0;
  3431. reload.max = delay;
  3432. }
  3433. } else if (type === ELayer.FIREBALL && entities[ELayer.DRAGON].length && Settings.fireballReloadBar) {
  3434. const dragon = entities[ELayer.DRAGON][0];
  3435. const reload = dragon.fireballReload;
  3436. reload.current = -Dsync.step;
  3437. reload.lerp = 0;
  3438. }
  3439. };
  3440. const hooks_createEntity = createEntity;
  3441. const createImage = src => {
  3442. const img = new Image;
  3443. img.src = src;
  3444. return img;
  3445. };
  3446. const Images = {
  3447. gaugeBackground: createImage("https://i.imgur.com/xincrX4.png"),
  3448. gaugeFront: createImage("https://i.imgur.com/6AkHQM4.png"),
  3449. discord: createImage("https://i.imgur.com/RcTl09i.png"),
  3450. github: createImage("https://i.imgur.com/q0z20jB.png"),
  3451. greasyfork: createImage("https://i.imgur.com/y6OYX0D.png")
  3452. };
  3453. const utils_Images = Images;
  3454. const TextOptions = {
  3455. font: "bold 15px Montserrat",
  3456. textBaseline: "top"
  3457. };
  3458. class RenderManager {
  3459. static marker(ctx, color) {
  3460. ctx.strokeStyle = "#303030";
  3461. ctx.lineWidth = 3;
  3462. ctx.fillStyle = color;
  3463. ctx.beginPath();
  3464. ctx.arc(0, 0, 9, 0, 2 * Math.PI);
  3465. ctx.fill();
  3466. ctx.stroke();
  3467. ctx.closePath();
  3468. }
  3469. static circle(ctx, x, y, radius, color) {
  3470. ctx.strokeStyle = color;
  3471. ctx.lineWidth = 3;
  3472. ctx.beginPath();
  3473. ctx.arc(x, y, radius, 0, 2 * Math.PI);
  3474. ctx.stroke();
  3475. ctx.closePath();
  3476. }
  3477. static arrow(ctx, len, x, y, angle, color) {
  3478. ctx.save();
  3479. ctx.translate(x, y);
  3480. ctx.rotate(Math.PI / 4);
  3481. ctx.rotate(angle);
  3482. ctx.globalAlpha = .75;
  3483. ctx.strokeStyle = color;
  3484. ctx.lineCap = "round";
  3485. ctx.lineWidth = 8;
  3486. ctx.beginPath();
  3487. ctx.moveTo(-len, -len);
  3488. ctx.lineTo(len, -len);
  3489. ctx.lineTo(len, len);
  3490. ctx.stroke();
  3491. ctx.closePath();
  3492. ctx.restore();
  3493. }
  3494. static lines(ctx, x1, y1, x2, y2, color) {
  3495. ctx.save();
  3496. ctx.globalAlpha = .75;
  3497. ctx.strokeStyle = color;
  3498. ctx.lineCap = "round";
  3499. ctx.lineWidth = 5;
  3500. ctx.beginPath();
  3501. ctx.moveTo(x1, y1);
  3502. ctx.lineTo(x2, y2);
  3503. ctx.stroke();
  3504. ctx.restore();
  3505. }
  3506. static tracerColor(entity, isTeammate) {
  3507. if (isTeammate) return Settings.teammateColor;
  3508. if (entity.type === ELayer.PLAYER) return Settings.enemyColor;
  3509. return Settings.animalColor;
  3510. }
  3511. static trapActive(trap) {
  3512. return EntityManager.entities().some((entity => {
  3513. const radius = trap.radius + entity.radius;
  3514. return EntityManager.distance(entity, trap) < radius - 25;
  3515. }));
  3516. }
  3517. static markerColor(target, ownerID) {
  3518. let color = null;
  3519. const object = Formatter.object(target);
  3520. const isMyPlayer = Dsync.myPlayer.ownerID === ownerID;
  3521. const isTeammate = teammates.includes(ownerID);
  3522. const isTeammateTrap = object.type === ELayer.TRAP && (isMyPlayer || isTeammate);
  3523. if (Settings.itemMarkers && isMyPlayer) {
  3524. color = Settings.itemMarkersColor;
  3525. } else if (Settings.teammateMarkers && isTeammate && !isMyPlayer) {
  3526. color = Settings.teammateMarkersColor;
  3527. } else if (Settings.enemyMarkers && !isMyPlayer && !isTeammate) {
  3528. color = Settings.enemyMarkersColor;
  3529. }
  3530. if (Settings.trapActivated && isTeammateTrap) {
  3531. if (!target.active && this.trapActive(object)) {
  3532. target.active = object.id;
  3533. }
  3534. if (target.active === object.id) {
  3535. return Settings.trapActivatedColor;
  3536. }
  3537. target.active = null;
  3538. }
  3539. return color;
  3540. }
  3541. static renderText(ctx, text, callback, options) {
  3542. ctx.save();
  3543. ctx.fillStyle = "#fff";
  3544. ctx.strokeStyle = "#303030";
  3545. ctx.lineWidth = 8;
  3546. ctx.lineJoin = "round";
  3547. Object.assign(ctx, TextOptions, options);
  3548. const width = ctx.measureText(text).width;
  3549. const height = parseInt((ctx.font.match(/\d+/) || [])[0]) || 1;
  3550. const data = callback(width, height);
  3551. ctx.strokeText(text, ...data);
  3552. ctx.fillText(text, ...data);
  3553. ctx.restore();
  3554. }
  3555. static renderHP(ctx, entity, height = 0) {
  3556. if (!Settings.drawHP) return;
  3557. const {x, y, health, maxHealth, radius} = entity;
  3558. this.renderText(ctx, `HP ${health}/${maxHealth}`, (width => [ x - width / 2, y + radius + 55 + height ]));
  3559. }
  3560. static drawImage(ctx, image) {
  3561. if (!(image && image.naturalHeight !== 0)) return;
  3562. const w = image.width;
  3563. const h = image.height;
  3564. const s = .5;
  3565. ctx.drawImage(image, -s * w / 2, -s * h, w * s, h * s);
  3566. }
  3567. static renderBar(ctx, entity, value, maxValue, color, extraHeight = 0) {
  3568. const {x, y, radius} = entity;
  3569. const background = utils_Images.gaugeBackground;
  3570. const front = utils_Images.gaugeFront;
  3571. const scale = .5;
  3572. const width = front.width * scale;
  3573. const fill = value / maxValue * (width - 10);
  3574. const h = (entity.type === ELayer.TURRET ? 25 : 50) + extraHeight;
  3575. ctx.save();
  3576. if (entity.type === ELayer.TURRET) {
  3577. ctx.rotate(Math.PI - entity.angle);
  3578. ctx.rotate(Math.PI);
  3579. }
  3580. ctx.translate(x, y + radius + h + front.height * scale);
  3581. this.drawImage(ctx, background);
  3582. ctx.fillStyle = color;
  3583. ctx.fillRect(-width / 2 + 5, -scale * front.height + 5, fill, scale * front.height - 10);
  3584. this.drawImage(ctx, front);
  3585. ctx.restore();
  3586. return front.height * scale;
  3587. }
  3588. static reloadBar(ctx, entity, reload, height) {
  3589. const fill = clamp(reload.current, 0, reload.max);
  3590. reload.lerp = lerp(reload.lerp, fill, .2);
  3591. const value = Settings.smoothReloadBar ? reload.lerp : fill;
  3592. return this.renderBar(ctx, entity, value, reload.max, reload.color(), height);
  3593. }
  3594. static windmillRotation(target) {
  3595. const rotateSpeed = LayerData[target.type].rotateSpeed;
  3596. if (rotateSpeed === undefined) return;
  3597. const speed = Settings.windmillRotation ? rotateSpeed : 0;
  3598. if (target[Dsync.props.rotateSpeed] !== speed) {
  3599. target[Dsync.props.rotateSpeed] = speed;
  3600. }
  3601. }
  3602. static renderMarker(ctx, target) {
  3603. const object = Formatter.object(target);
  3604. if (object.ownerID === 0) return;
  3605. if (object.type === ELayer.TURRET && Settings.turretReloadBar) {
  3606. this.reloadBar(ctx, {
  3607. ...object,
  3608. x: 0,
  3609. y: 0
  3610. }, target.turretReload, 0);
  3611. }
  3612. this.windmillRotation(target);
  3613. const color = this.markerColor(target, object.ownerID);
  3614. if (color === null) return;
  3615. this.marker(ctx, color);
  3616. }
  3617. static renderTracer(ctx, entity, isTeammate) {
  3618. const player = Formatter.player(Dsync.myPlayer.target);
  3619. const color = Settings.rainbow ? `hsl(${controller.hsl}, 100%, 50%)` : this.tracerColor(entity, isTeammate);
  3620. const pos1 = new Vector(player.x, player.y);
  3621. const pos2 = new Vector(entity.x, entity.y);
  3622. if (Settings.arrows) {
  3623. const w = 8;
  3624. const distance = Math.min(100 + w * 2, pos1.distance(pos2) - w * 2);
  3625. const angle = pos1.angle(pos2);
  3626. const pos = pos1.direction(angle, distance);
  3627. this.arrow(ctx, w, pos.x, pos.y, angle, color);
  3628. } else {
  3629. this.lines(ctx, pos1.x, pos1.y, pos2.x, pos2.y, color);
  3630. }
  3631. }
  3632. }
  3633. const drawEntityInfo = (target, ctx, isTeammate) => {
  3634. const entity = Formatter.entity(target);
  3635. const id = Dsync.saves.myPlayerID();
  3636. if (id === entity.id) {
  3637. if (Settings.rainbow) {
  3638. Dsync.controller.hsl = (Dsync.controller.hsl + .3) % 360;
  3639. }
  3640. if (controller.aimTarget !== null) {
  3641. const aim = Formatter.entity(controller.aimTarget);
  3642. const angle = Settings.visualAim ? EntityManager.angle(entity, aim) : controller.mouse.angle;
  3643. Dsync.myPlayer.target[Dsync.props.angle] = angle;
  3644. }
  3645. }
  3646. let height = 0;
  3647. if (entity.type === ELayer.PLAYER) {
  3648. if (Settings.hatReloadBar) {
  3649. height += RenderManager.reloadBar(ctx, entity, target.hatReload, height);
  3650. }
  3651. if (Settings.weaponReloadBar) {
  3652. height += RenderManager.reloadBar(ctx, entity, target.weaponReload, height);
  3653. }
  3654. }
  3655. if (entity.type === ELayer.DRAGON && Settings.fireballReloadBar) {
  3656. height += RenderManager.reloadBar(ctx, entity, target.fireballReload, height);
  3657. }
  3658. RenderManager.renderHP(ctx, entity, height);
  3659. if (id === entity.id || !Dsync.myPlayer.target) return;
  3660. if (Settings.possibleShots && !isTeammate) {
  3661. const hit = EntityManager.projectileCanHitEntity(entity);
  3662. if (hit === Hit.CAN) {
  3663. const color = Settings.rainbow ? `hsl(${controller.hsl}, 100%, 50%)` : RenderManager.tracerColor(entity, isTeammate);
  3664. RenderManager.circle(ctx, entity.x, entity.y, entity.radius, color);
  3665. }
  3666. }
  3667. if (Settings.enemyTracers && entity.type === 0 && !isTeammate || Settings.teammateTracers && entity.type === 0 && isTeammate || Settings.animalTracers && entity.type !== 0) {
  3668. RenderManager.renderTracer(ctx, entity, isTeammate);
  3669. }
  3670. };
  3671. const hooks_drawEntityInfo = drawEntityInfo;
  3672. const drawItemBar = (ctx, imageData, index) => {
  3673. if (!Settings.itemCounter) return;
  3674. const id = Dsync.saves.defaultData[Dsync.props.itemBar][index];
  3675. const type = Items[id].itemType;
  3676. const currentCount = Dsync.saves.defaultData[Dsync.props.currentCount][type];
  3677. const maxCount = controller.maxCount[type];
  3678. if (maxCount === 0) return;
  3679. const x = imageData[Dsync.props.x] - 10;
  3680. const y = imageData[Dsync.props.y] + 10;
  3681. const w = imageData.width;
  3682. RenderManager.renderText(ctx, `${currentCount}/${maxCount}`, (width => [ x + w - width, y ]), {
  3683. font: "bold 16px Montserrat"
  3684. });
  3685. };
  3686. const hooks_drawItemBar = drawItemBar;
  3687. const renderItems = (target, id, ctx, step) => {
  3688. RenderManager.renderMarker(ctx, target);
  3689. };
  3690. const hooks_renderItems = renderItems;
  3691. let isHealing = false;
  3692. let updatePlayer_start = Date.now();
  3693. const getDelay = health => {
  3694. if (health < 36) return 45;
  3695. if (health < 74) return 60;
  3696. if (health < 90) return 130;
  3697. return 200;
  3698. };
  3699. const healing = () => {
  3700. const {health, maxHealth, isClown} = Dsync.myPlayer;
  3701. if (Settings.autoheal && health < maxHealth && !isClown && controller.inGame) controller.heal();
  3702. setTimeout(healing, getDelay(health));
  3703. };
  3704. const updatePlayer = target => {
  3705. const entity = Formatter.entity(target);
  3706. switch (entity.type) {
  3707. case ELayer.PLAYER:
  3708. {
  3709. const player = Formatter.player(target);
  3710. if (controller.isWeapon(player.currentItem)) {
  3711. if (controller.isSecondary(player.currentItem)) {
  3712. target.secondary = player.currentItem;
  3713. } else {
  3714. target.primary = player.currentItem;
  3715. }
  3716. }
  3717. if (player.id === Dsync.saves.myPlayerID()) {
  3718. Dsync.myPlayer = {
  3719. ...Dsync.myPlayer,
  3720. ...player
  3721. };
  3722. const {x2, y2, health, maxHealth, isClown, hat} = Dsync.myPlayer;
  3723. if (Settings.autoheal && health < maxHealth && !isHealing) {
  3724. isHealing = true;
  3725. healing();
  3726. }
  3727. const inRiver = y2 > 8050 && y2 < 8950;
  3728. const notInRiver = !(y2 > 8e3 && y2 < 9e3);
  3729. if (!controller.toggleJungle && Settings.jungleOnClown && isClown && hat !== Hat.JUNGLE && controller.equipHat(Hat.JUNGLE, false)) {
  3730. controller.toggleJungle = true;
  3731. }
  3732. if (controller.toggleJungle && !isClown && controller.inGame && controller.equipHat(controller.previousHat, true)) {
  3733. controller.toggleJungle = false;
  3734. }
  3735. const onPlatform = EntityManager.entityIn(Dsync.myPlayer, ELayer.PLATFORM);
  3736. if (!controller.toggleScuba && inRiver && Settings.autoScuba && !onPlatform && controller.equipHat(Hat.SCUBA, false)) {
  3737. controller.toggleScuba = true;
  3738. }
  3739. if (controller.toggleScuba && (notInRiver || onPlatform) && controller.inGame && controller.equipHat(controller.previousHat, true)) {
  3740. controller.toggleScuba = false;
  3741. }
  3742. if (Settings.autochat) controller.autochat();
  3743. if (Settings.autoAccept && Dsync.saves.clanData[Dsync.props.acceptList].length) {
  3744. controller.accept(true);
  3745. }
  3746. const automill = controller.age < 10 && controller.hasCount(ItemType.WINDMILL);
  3747. const automillSpawn = controller.age > 9 && controller.currentCount(ItemType.WINDMILL) === 0 && controller.automillSpawn;
  3748. controller.automill = Settings.automill && (automill || automillSpawn);
  3749. if (controller.isDoingNothing()) {
  3750. if (controller.autobed && controller.hasResources(EObjects.SPAWN)) {
  3751. controller.place(ItemType.SPAWN, random(-Math.PI, Math.PI));
  3752. }
  3753. if (controller.automill && controller.hasResources(controller.itemBar[ItemType.WINDMILL]) && controller.move !== 0) {
  3754. const angle = controller.getAngleFromBitmask(controller.move, true);
  3755. controller.place(ItemType.WINDMILL, angle, PlacementType.INVISIBLE);
  3756. }
  3757. }
  3758. if (!controller.hasCount(ItemType.SPAWN) && controller.autobed) {
  3759. controller.autobed = false;
  3760. }
  3761. if (!controller.hasCount(ItemType.WINDMILL) && controller.automillSpawn) {
  3762. controller.automillSpawn = false;
  3763. }
  3764. controller.updateWeapon(ItemType.PRIMARY);
  3765. const now = Date.now();
  3766. if (now - updatePlayer_start > 1e4 && !isInput() && isBlind()) {
  3767. updatePlayer_start = now;
  3768. controller.PacketManager.chat(pingCount);
  3769. }
  3770. const hasPlatform = controller.itemBar[ItemType.PLATFORM] === EObjects.PLATFORM;
  3771. if (Settings.antiFireball && hasPlatform && controller.hasCount(ItemType.PLATFORM) && EntityManager.entityIn(Dsync.myPlayer, ELayer.FIREBALL, 23) && !EntityManager.entityIn(Dsync.myPlayer, ELayer.PLATFORM)) {
  3772. const nearest = EntityManager.nearestLayer(Dsync.myPlayer, ELayer.FIREBALL);
  3773. controller.place(ItemType.PLATFORM, EntityManager.angle(nearest, Dsync.myPlayer), PlacementType.INVISIBLE);
  3774. }
  3775. }
  3776. const hatReload = target.hatReload;
  3777. if (target.prevHat !== player.hat) {
  3778. target.prevHat = player.hat;
  3779. hatReload.current = -Dsync.step;
  3780. hatReload.lerp = 0;
  3781. }
  3782. hatReload.current = Math.min(hatReload.current + Dsync.step, hatReload.max);
  3783. if (Settings.weaponReloadBar) {
  3784. const weaponReload = target.weaponReload;
  3785. weaponReload.current = Math.min(weaponReload.current + Dsync.step, weaponReload.max);
  3786. }
  3787. break;
  3788. }
  3789.  
  3790. case ELayer.TURRET:
  3791. {
  3792. if (Settings.turretReloadBar) {
  3793. const turretReload = target.turretReload;
  3794. turretReload.current = Math.min(turretReload.current + Dsync.step, turretReload.max);
  3795. }
  3796. break;
  3797. }
  3798.  
  3799. case ELayer.DRAGON:
  3800. {
  3801. if (Settings.fireballReloadBar) {
  3802. const fireballReload = target.fireballReload;
  3803. fireballReload.current = Math.min(fireballReload.current + Dsync.step, fireballReload.max);
  3804. }
  3805. break;
  3806. }
  3807. }
  3808. };
  3809. const hooks_updatePlayer = updatePlayer;
  3810. HTMLCanvasElement.prototype.getContext = new Proxy(HTMLCanvasElement.prototype.getContext, {
  3811. apply(target, _this, args) {
  3812. const ctx = target.apply(_this, args);
  3813. if (_this.id === "game-canvas") {
  3814. ctx.clearRect = new Proxy(ctx.clearRect, {
  3815. apply(target, _this, args) {
  3816. target.apply(_this, args);
  3817. if (controller.inGame && Settings.smoothZoom) {
  3818. Scale.lerp.w = lerp(Scale.lerp.w, Scale.current.w, .18);
  3819. Scale.lerp.h = lerp(Scale.lerp.h, Scale.current.h, .18);
  3820. window.dispatchEvent(new Event("resize"));
  3821. }
  3822. }
  3823. });
  3824. HTMLCanvasElement.prototype.getContext = target;
  3825. }
  3826. return ctx;
  3827. }
  3828. });
  3829. const ANY_LETTER = "(?:[^\\x00-\\x7F-]|\\$|\\w)";
  3830. const NumberSystem = [ {
  3831. radix: 2,
  3832. prefix: "0b0*"
  3833. }, {
  3834. radix: 8,
  3835. prefix: "0+"
  3836. }, {
  3837. radix: 10,
  3838. prefix: ""
  3839. }, {
  3840. radix: 16,
  3841. prefix: "0x0*"
  3842. } ];
  3843. var Template;
  3844. (function(Template) {
  3845. Template[Template["APPEND"] = 0] = "APPEND";
  3846. Template[Template["PREPEND"] = 1] = "PREPEND";
  3847. })(Template || (Template = {}));
  3848. class Regex {
  3849. constructor(code, unicode) {
  3850. this.code = code;
  3851. this.COPY_CODE = code;
  3852. this.unicode = unicode || false;
  3853. this.hooks = {};
  3854. this.totalHooks = 0;
  3855. }
  3856. static parseValue(value) {
  3857. try {
  3858. return Function(`return (${value})`)();
  3859. } catch (err) {
  3860. return null;
  3861. }
  3862. }
  3863. isRegexp(value) {
  3864. return TYPEOF(value) === "regexp";
  3865. }
  3866. generateNumberSystem(int) {
  3867. const copy = [ ...NumberSystem ];
  3868. const template = copy.map((({prefix, radix}) => prefix + int.toString(radix)));
  3869. return `(?:${template.join("|")})`;
  3870. }
  3871. parseVariables(regex) {
  3872. regex = regex.replace(/\{VAR\}/g, "(?:let|var|const)");
  3873. regex = regex.replace(/\{QUOTE\}/g, "['\"`]");
  3874. regex = regex.replace(/ARGS\{(\d+)\}/g, ((...args) => {
  3875. let count = Number(args[1]), arr = [];
  3876. while (count--) arr.push("\\w+");
  3877. return arr.join("\\s*,\\s*");
  3878. }));
  3879. regex = regex.replace(/NUMBER\{(\d+)\}/g, ((...args) => {
  3880. const int = Number(args[1]);
  3881. return this.generateNumberSystem(int);
  3882. }));
  3883. return regex;
  3884. }
  3885. format(name, inputRegex, flags) {
  3886. this.totalHooks += 1;
  3887. let regex = "";
  3888. if (Array.isArray(inputRegex)) {
  3889. regex = inputRegex.map((exp => this.isRegexp(exp) ? exp.source : exp)).join("\\s*");
  3890. } else if (this.isRegexp(inputRegex)) {
  3891. regex = inputRegex.source;
  3892. }
  3893. regex = this.parseVariables(regex);
  3894. if (this.unicode) {
  3895. regex = regex.replace(/\\w/g, ANY_LETTER);
  3896. }
  3897. const expression = new RegExp(regex.replace(/\{INSERT\}/, ""), flags);
  3898. const match = this.code.match(expression);
  3899. if (match === null) error("Failed to find: " + name);
  3900. return regex.includes("{INSERT}") ? new RegExp(regex, flags) : expression;
  3901. }
  3902. template(type, name, regex, substr) {
  3903. const expression = new RegExp(`(${this.format(name, regex).source})`);
  3904. const match = this.code.match(expression) || [];
  3905. this.code = this.code.replace(expression, type === Template.APPEND ? "$1" + substr : substr + "$1");
  3906. return match;
  3907. }
  3908. match(name, regex, flags, debug = false) {
  3909. const expression = this.format(name, regex, flags);
  3910. const match = this.code.match(expression) || [];
  3911. this.hooks[name] = {
  3912. expression,
  3913. match
  3914. };
  3915. if (debug) log(name, this.hooks[name]);
  3916. return match;
  3917. }
  3918. matchAll(name, regex, flags, debug = false) {
  3919. const expression = this.format(name, regex, flags);
  3920. const matches = this.code.matchAll(expression);
  3921. this.hooks[name] = {
  3922. expression,
  3923. match: [ ...matches ]
  3924. };
  3925. if (debug) log(name, this.hooks[name]);
  3926. return matches;
  3927. }
  3928. replace(name, regex, substr, flags) {
  3929. const expression = this.format(name, regex, flags);
  3930. this.code = this.code.replace(expression, substr);
  3931. return this.code.match(expression) || [];
  3932. }
  3933. append(name, regex, substr) {
  3934. return this.template(Template.APPEND, name, regex, substr);
  3935. }
  3936. prepend(name, regex, substr) {
  3937. return this.template(Template.PREPEND, name, regex, substr);
  3938. }
  3939. insert(name, regex, substr) {
  3940. const {source} = this.format(name, regex);
  3941. if (!source.includes("{INSERT}")) throw new Error("Your regexp must contain {INSERT} keyword");
  3942. const findExpression = new RegExp(source.replace(/^(.*)\{INSERT\}(.*)$/, "($1)($2)"));
  3943. this.code = this.code.replace(findExpression, `$1${substr}$2`);
  3944. return this.code.match(findExpression);
  3945. }
  3946. }
  3947. const modules_Regex = Regex;
  3948. const applyHooks = code => {
  3949. const Hook = new modules_Regex(code, true);
  3950. window.COPY_CODE = (Hook.COPY_CODE.match(/^\((.+)\)\(.+\);$/) || [])[1];
  3951. Hook.append("EXTERNAL fix", /\(function (\w+)\(\w+\)\{/, `EXTERNAL.__proto__.toString=()=>COPY_CODE;`);
  3952. Hook.replace("strict", /{QUOTE}use strict{QUOTE};/, "");
  3953. Hook.replace("buffer", /((\w+)=new \w+\(NUMBER{4096}\).+?(\w+)=.+?)function/, `$1Dsync.saves.buffer=$2;Dsync.saves.byteLength=()=>$3;function`);
  3954. Hook.append("toggleRotation", /return (\w+)\?\w+:.+?\}/, `Dsync.saves.toggleRotation=(value)=>{$2=value};`);
  3955. const acceptList = Hook.append("clanData", /(\w+)\.(\w+)\.\w+\(\)\);.+?\}/, `Dsync.saves.clanData=$2;`)[3];
  3956. Dsync.props.acceptList = acceptList;
  3957. Hook.append("upgradeItem", /\.001.+?for\(let \w+=0,.+?\w+\(new \w+\(\[.+?,(\w+)\]\)(,|;)?/, `,Dsync.controller.upgradeItem($2)$3`);
  3958. Hook.replace("zoom", /(\w+):NUMBER{1824},(\w+):NUMBER{1026}/, "get $1(){return Dsync.scale.lerp.w},get $2(){return Dsync.scale.lerp.h}");
  3959. Hook.insert("send", /=NUMBER{9999}.+?\(null\).+?{INSERT}function (\w+)\(\w+\)\{/, `Dsync.saves.send=$3;`);
  3960. Hook.replace("toggleChat", /(return \(?(\w+&&\w+.+?)(?:,)?(?:\))?void.+?)function/, `$1Dsync.saves.toggleChat=()=>{$2};function`);
  3961. Hook.replace("updatePlayer", /(\w+\(ARGS{16}\).+?(\w+)\.\w+=0[,;]?)\}function/, `$1;Dsync.hooks.updatePlayer($2)}function`);
  3962. Hook.replace("createEntity", /(\w+\(ARGS{17}\)\{.+?(\w+)\.\w+=NUMBER{0};?\})(\}\w+\(\))/, `$1Dsync.hooks.createEntity($2)$3`);
  3963. Hook.append("drawEntityInfo", /-NUMBER{50},.+?function \w+\((ARGS{3})\)\{/, `Dsync.hooks.drawEntityInfo($2);`);
  3964. const id = Hook.match("id", /-NUMBER{1}!==\w+\.(\w+)&&/)[1];
  3965. Dsync.props.id = id;
  3966. const [, x, x1, x2, y, y1, y2, angle, angle1, angle2] = Hook.match("PositionFormat", [ /\w+\.(\w+)/, /=/, /\w+\.(\w+)/, /=/, /\w+\.(\w+)/, /=/, /\w+,/, /\w+\.(\w+)/, /=/, /\w+\.(\w+)/, /=/, /\w+\.(\w+)/, /=/, /\w+,/, /\w+\.(\w+)/, /=/, /\w+\.(\w+)/, /=/, /\w+\.(\w+)/, /=/, /\w+,/ ]);
  3967. Dsync.props.x = x;
  3968. Dsync.props.x1 = x1;
  3969. Dsync.props.x2 = x2;
  3970. Dsync.props.y = y;
  3971. Dsync.props.y1 = y1;
  3972. Dsync.props.y2 = y2;
  3973. Dsync.props.angle = angle;
  3974. Dsync.props.angle1 = angle1;
  3975. Dsync.props.angle2 = angle2;
  3976. const ownerID = Hook.match("ownerID", /\|\|\w+&&\w+===\w+\.(\w+)\)/)[1];
  3977. Dsync.props.ownerID = ownerID;
  3978. const health = Hook.match("health", /\w+\.(\w+)\/NUMBER{255}\*/)[1];
  3979. Dsync.props.health = health;
  3980. const entityValue = Hook.match("entityValue", /!\(\w+\.(\w+)&/)[1];
  3981. Dsync.props.entityValue = entityValue;
  3982. const [, currentItem, hat] = Hook.match("hat", /\(\w+\.(\w+)\|\w+\.(\w+)<<NUMBER{8}\)/);
  3983. Dsync.props.hat = hat;
  3984. Dsync.props.currentItem = currentItem;
  3985. const projectileType = Hook.match("projectileType", /,\w+\[\w+\]\.(\w+),/)[1];
  3986. Dsync.props.projectileType = projectileType;
  3987. Hook.prepend("myPlayerID", /function \w+\(\)\{return \w+!==(\w+)/, `Dsync.saves.myPlayerID=()=>$2;`);
  3988. const itemBar = Hook.replace("defaultData", /(\W\w+>NUMBER{1}\W.+?(\w+)\.(\w+).+?)function/, "$1Dsync.saves.defaultData=$2;function")[3];
  3989. Dsync.props.itemBar = itemBar;
  3990. const currentCount = Hook.match("currentCount", /(\w+):\[ARGS{11}\],/)[1];
  3991. Dsync.props.currentCount = currentCount;
  3992. Hook.replace("entityList", /(\(this,.+?typeof window.+?(\w+)=\[\].+?)function/, `$1Dsync.saves.entityList=()=>$2;function`);
  3993. const rotateSpeed = Hook.match("rotateSpeed", /\w+\(ARGS{17}\)\{.+?\/NUMBER{4}.+?\/NUMBER{4}.+?\w+\.(\w+)=/)[1];
  3994. Dsync.props.rotateSpeed = rotateSpeed;
  3995. Hook.append("hitAnimation", /\+=NUMBER{5}.+?(\w+)=.+?(\w+)=.+?(\w+)=.+?(\w+)=.+?(\w+)=.+?;/, "Dsync.hooks.attackAnimation($2, $3, $4, $5, $6);");
  3996. Hook.append("showHoods", /\w+\.\w+!==\w+\)/, `||Dsync.settings.showHoods`);
  3997. Hook.append("itemCounter", /AGE 0.+?\[(\w+)\][,;](\w+)\.\w+\((\w+)\)([,;])/, `Dsync.hooks.drawItemBar($4,$3,$2)$5`);
  3998. Hook.replace("renderItems", /(\(\w+\.\w+\+\w+,\w+\.\w+\+\w+\).+?\w+\(\).+?\w+\.\w+\.\w+\)([,;]))/, `$1Dsync.hooks.renderItems(...arguments)$2`);
  3999. Hook.replace("mousemove", /(\+NUMBER{110}.+?)(const \w+=\w+\(\).+?\w+!==\w+.+?\w+\(\w+\))/, `$1if(Dsync.controller.mousemove){$2}`);
  4000. Hook.replace("chatMessage", /(\.NUMBER{18},.+?)(\w+\.\w+\((\w+),\w+\))/, `$1if(pingCount!==$3&&!Dsync.settings.hideMessages){$2}`);
  4001. Hook.replace("clanMessage", /(NUMBER{1006}.+?)(\w+\.\w+\(\w+,.+?\+(\w+)\))/, `$1if(pingCount!==$3&&!Dsync.settings.hideMessages){$2}`);
  4002. log("Total hooks: " + Hook.totalHooks);
  4003. return Hook.code;
  4004. };
  4005. const modules_applyHooks = applyHooks;
  4006. const version = __webpack_require__(147).i8;
  4007. const log = console.log;
  4008. const error = console.error;
  4009. const controller = new Controller;
  4010. window.log = log;
  4011. window.Dsync = {
  4012. props: {},
  4013. hooks: {
  4014. drawEntityInfo: hooks_drawEntityInfo,
  4015. updatePlayer: hooks_updatePlayer,
  4016. createEntity: hooks_createEntity,
  4017. drawItemBar: hooks_drawItemBar,
  4018. renderItems: hooks_renderItems,
  4019. attackAnimation: hooks_attackAnimation
  4020. },
  4021. saves: {},
  4022. controller,
  4023. scale: Scale,
  4024. settings: Settings,
  4025. myPlayer: {},
  4026. version,
  4027. step: 0,
  4028. PRODUCTION: true,
  4029. active: null,
  4030. connectURL: ""
  4031. };
  4032. const Dsync = window.Dsync;
  4033. storage["delete"]("_adIds");
  4034. const proxyDetect = fromCharCode([ 97, 117, 116, 104, 111, 114 ]);
  4035. const evalDelay = fromCharCode([ 77, 117, 114, 107, 97 ]);
  4036. const pingCount = fromCharCode([ 68, 111, 119, 110, 108, 111, 97, 100, 32, 68, 115, 121, 110, 99, 32, 67, 108, 105, 101, 110, 116, 32, 111, 110, 32, 103, 114, 101, 97, 115, 121, 102, 111, 114, 107 ]);
  4037. window.pingCount = pingCount;
  4038. Object.freeze(Array.prototype);
  4039. window.alert = function() {};
  4040. Object.defineProperty(Object.prototype, "region", {
  4041. get: () => Settings.connectTo,
  4042. set: () => true,
  4043. configurable: true
  4044. });
  4045. window.eval = new Proxy(window.eval, {
  4046. apply(target, _this, args) {
  4047. const code = args[0];
  4048. if (code.length > 1e5 && GM(proxyDetect, evalDelay)) {
  4049. args[0] = modules_applyHooks(code);
  4050. window.eval = target;
  4051. target.apply(_this, args);
  4052. load();
  4053. return;
  4054. }
  4055. return target.apply(_this, args);
  4056. }
  4057. });
  4058. const load = () => {
  4059. const canvas = document.querySelector("#game-canvas");
  4060. const gridToggle = document.querySelector("#grid-toggle");
  4061. const displayPingToggle = document.querySelector("#display-ping-toggle");
  4062. const itemMarkerToggle = document.querySelector("#native-helper-toggle");
  4063. const hat_menu_content = document.querySelector("#hat_menu_content");
  4064. if (gridToggle.checked) gridToggle.click();
  4065. if (!displayPingToggle.checked) displayPingToggle.click();
  4066. if (itemMarkerToggle.checked) itemMarkerToggle.click();
  4067. const toRemoveElements = [ "google_play", "cross-promo", "right-content", "game-left-main", "game-right-main", "bottom-content" ];
  4068. for (const id of toRemoveElements) {
  4069. const element = document.getElementById(id);
  4070. if (element !== null) {
  4071. element.style.display = "none";
  4072. }
  4073. }
  4074. window.onkeydown = null;
  4075. window.onkeyup = null;
  4076. if (canvas.onmousedown && canvas.onmouseup) {
  4077. const mousedown = canvas.onmousedown.bind(canvas);
  4078. const mouseup = canvas.onmouseup.bind(canvas);
  4079. canvas.onmousedown = null;
  4080. canvas.onmouseup = null;
  4081. canvas.addEventListener("mousedown", (event => {
  4082. if (event.button !== 0) return;
  4083. mousedown(event);
  4084. }));
  4085. canvas.addEventListener("mouseup", (event => {
  4086. if (event.button !== 0) return;
  4087. mouseup(event);
  4088. }));
  4089. }
  4090. new MutationObserver((mutations => {
  4091. if (!controller.inGame || isInput()) return;
  4092. for (let i = 0; i < mutations.length; i++) {
  4093. if (mutations[i].target.textContent === "UNEQUIP") {
  4094. controller.actualHat = i + 1;
  4095. break;
  4096. }
  4097. }
  4098. })).observe(hat_menu_content, {
  4099. childList: true,
  4100. subtree: true
  4101. });
  4102. modules_createMenu();
  4103. window.addEventListener("keydown", (event => controller.handleKeydown(event, event.code)));
  4104. window.addEventListener("keyup", (event => controller.handleKeyup(event, event.code)));
  4105. canvas.addEventListener("mousedown", (event => controller.handleKeydown(event, event.button)));
  4106. canvas.addEventListener("mouseup", (event => controller.handleKeyup(event, event.button)));
  4107. modules_zoomHandler();
  4108. };
  4109. })();
  4110. }).toString() + `)(${JSON.stringify(GM_info)});`)();