CowJS

Special creation library for "moomoo.io ". With it, you can create scripts faster, as well as draw in it without using the game code.

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.cn-greasyfork.org/scripts/480301/1322984/CowJS.js

  1. /******/
  2. (function() { // webpackBootstrap
  3. /******/
  4. "use strict";
  5. /******/
  6. var __webpack_modules__ = ({
  7. /***/
  8. "./src/Cow.js":
  9. /*!********************!*\
  10. !*** ./src/Cow.js ***!
  11. \********************/
  12. /***/
  13. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  14. __webpack_require__.r(__webpack_exports__);
  15. /* harmony import */
  16. var _config_json__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ./config.json */ "./src/config.json");
  17. /* harmony import */
  18. var _constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__( /*! ./constants.js */ "./src/constants.js");
  19. /* harmony import */
  20. var _modules_entities_Player_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__( /*! ./modules/entities/Player.js */ "./src/modules/entities/Player.js");
  21. /* harmony import */
  22. var _modules_plugins_index_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__( /*! ./modules/plugins/index.js */ "./src/modules/plugins/index.js");
  23. /* harmony import */
  24. var _game_configs_index_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__( /*! ./game_configs/index.js */ "./src/game_configs/index.js");
  25. class Cow {
  26. constructor() {
  27. this.config = _config_json__WEBPACK_IMPORTED_MODULE_0__
  28. this.items = _game_configs_index_js__WEBPACK_IMPORTED_MODULE_4__
  29. this.codec = _constants_js__WEBPACK_IMPORTED_MODULE_1__.codec
  30. this.socket = _constants_js__WEBPACK_IMPORTED_MODULE_1__.socket
  31. this.playersManager = _constants_js__WEBPACK_IMPORTED_MODULE_1__.playersManager
  32. this.objectsManager = _constants_js__WEBPACK_IMPORTED_MODULE_1__.objectsManager
  33. this.animalsManager = _constants_js__WEBPACK_IMPORTED_MODULE_1__.animalsManager
  34. this.ticker = _constants_js__WEBPACK_IMPORTED_MODULE_1__.ticker
  35. this.camera = _constants_js__WEBPACK_IMPORTED_MODULE_1__.camera
  36. this.renderer = _constants_js__WEBPACK_IMPORTED_MODULE_1__.renderer
  37. this.input = _constants_js__WEBPACK_IMPORTED_MODULE_1__.input
  38. this.placement = _constants_js__WEBPACK_IMPORTED_MODULE_1__.placement
  39. this.player = void 0
  40. this.inGame = false
  41. this._plugins = new Map([
  42. ["auto-reconect", new _modules_plugins_index_js__WEBPACK_IMPORTED_MODULE_3__.AutoReconect()]
  43. ])
  44. }
  45. setCodec(msgpack) {
  46. _constants_js__WEBPACK_IMPORTED_MODULE_1__.codec.encoder = { encode: msgpack.encode }
  47. _constants_js__WEBPACK_IMPORTED_MODULE_1__.codec.decoder = { decode: msgpack.decode }
  48. _constants_js__WEBPACK_IMPORTED_MODULE_1__.codec.isReady = true
  49.  
  50. this.codec = _constants_js__WEBPACK_IMPORTED_MODULE_1__.codec
  51. }
  52. onPacket(packetName, listener) {
  53. this.socket.handler.onPacket(packetName, listener)
  54. }
  55. onKeyboard(keyName, listener, options) {
  56. return this.input.keyboard.on(keyName, listener, options)
  57. }
  58. sendPacket(packetName, ...content) {
  59. this.socket.send(packetName, content)
  60. }
  61. placeItem(groupIndex, {
  62. angle
  63. } = {}, callback) {
  64. this.placement.placeItem(groupIndex, {
  65. angle
  66. }, callback)
  67. }
  68. addRender(renderKey, renderFunc) {
  69. this.renderer.addRender(renderKey, renderFunc)
  70. }
  71. setInGame(_inGame) {
  72. if (typeof _inGame !== 'boolean') return
  73. this._inGame = _inGame
  74. }
  75. getNearPlayer(checkEnemy) {
  76. if (!this.player) return
  77. const {
  78. CowUtils
  79. } = window
  80. let players = this.playersManager.list
  81. if (!checkEnemy) players = players.filter((player) => player.visible)
  82. if (checkEnemy) {
  83. players = players.filter((player) => !player.isAlly && player.visible)
  84. }
  85. return players.sort((a, b) => {
  86. a = CowUtils.getDistance(a, this.player)
  87. b = CowUtils.getDistance(b, this.player)
  88. return a - b
  89. })[0]
  90. }
  91. getNearEnemy() {
  92. return this.getNearPlayer(true)
  93. }
  94. setPlayer(player) {
  95. this.camera.setTo(player.x, player.y)
  96. if (!(player instanceof _modules_entities_Player_js__WEBPACK_IMPORTED_MODULE_2__["default"]) || typeof this.player !== 'undefined') return
  97. this.player = player
  98. }
  99. setPluginState(pluginName, state) {
  100. if (!this._plugins.has(pluginName)) return
  101. const plugin = this._plugins.get(pluginName)
  102. plugin.setActiveState(state)
  103. }
  104. executePlugin(pluginName) {
  105. if (!this._plugins.has(pluginName)) return
  106. const plugin = this._plugins.get(pluginName)
  107. if (!plugin.isActiveState) return
  108. plugin.execute()
  109. }
  110. }
  111. /* harmony default export */
  112. __webpack_exports__["default"] = (Cow);
  113. /***/
  114. }),
  115. /***/
  116. "./src/constants.js":
  117. /*!**************************!*\
  118. !*** ./src/constants.js ***!
  119. \**************************/
  120. /***/
  121. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  122. __webpack_require__.r(__webpack_exports__);
  123. /* harmony export */
  124. __webpack_require__.d(__webpack_exports__, {
  125. /* harmony export */
  126. animalsManager: function() {
  127. return /* binding */ animalsManager;
  128. },
  129. /* harmony export */
  130. camera: function() {
  131. return /* binding */ camera;
  132. },
  133. /* harmony export */
  134. codec: function() {
  135. return /* binding */ codec;
  136. },
  137. /* harmony export */
  138. cow: function() {
  139. return /* binding */ cow;
  140. },
  141. /* harmony export */
  142. input: function() {
  143. return /* binding */ input;
  144. },
  145. /* harmony export */
  146. objectsManager: function() {
  147. return /* binding */ objectsManager;
  148. },
  149. /* harmony export */
  150. placement: function() {
  151. return /* binding */ placement;
  152. },
  153. /* harmony export */
  154. playersManager: function() {
  155. return /* binding */ playersManager;
  156. },
  157. /* harmony export */
  158. renderer: function() {
  159. return /* binding */ renderer;
  160. },
  161. /* harmony export */
  162. socket: function() {
  163. return /* binding */ socket;
  164. },
  165. /* harmony export */
  166. ticker: function() {
  167. return /* binding */ ticker;
  168. }
  169. /* harmony export */
  170. });
  171. /* harmony import */
  172. var _Cow_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ./Cow.js */ "./src/Cow.js");
  173. /* harmony import */
  174. var _modules_Placement_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__( /*! ./modules/Placement.js */ "./src/modules/Placement.js");
  175. /* harmony import */
  176. var _modules_Ticker_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__( /*! ./modules/Ticker.js */ "./src/modules/Ticker.js");
  177. /* harmony import */
  178. var _modules_input_Input_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__( /*! ./modules/input/Input.js */ "./src/modules/input/Input.js");
  179. /* harmony import */
  180. var _modules_managers_AnimalsManager_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__( /*! ./modules/managers/AnimalsManager.js */ "./src/modules/managers/AnimalsManager.js");
  181. /* harmony import */
  182. var _modules_managers_ObjectsManager_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__( /*! ./modules/managers/ObjectsManager.js */ "./src/modules/managers/ObjectsManager.js");
  183. /* harmony import */
  184. var _modules_managers_PlayersManager_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__( /*! ./modules/managers/PlayersManager.js */ "./src/modules/managers/PlayersManager.js");
  185. /* harmony import */
  186. var _modules_render_Camera_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__( /*! ./modules/render/Camera.js */ "./src/modules/render/Camera.js");
  187. /* harmony import */
  188. var _modules_render_Renderer_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__( /*! ./modules/render/Renderer.js */ "./src/modules/render/Renderer.js");
  189. /* harmony import */
  190. var _modules_socket_Socket_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__( /*! ./modules/socket/Socket.js */ "./src/modules/socket/Socket.js");
  191. const codec = {
  192. decoder: void 0,
  193. encoder: void 0,
  194. isReady: false
  195. }
  196. const socket = new _modules_socket_Socket_js__WEBPACK_IMPORTED_MODULE_9__["default"]()
  197. const playersManager = new _modules_managers_PlayersManager_js__WEBPACK_IMPORTED_MODULE_6__["default"]()
  198. const objectsManager = new _modules_managers_ObjectsManager_js__WEBPACK_IMPORTED_MODULE_5__["default"]()
  199. const animalsManager = new _modules_managers_AnimalsManager_js__WEBPACK_IMPORTED_MODULE_4__["default"]()
  200. const ticker = new _modules_Ticker_js__WEBPACK_IMPORTED_MODULE_2__["default"]()
  201. const camera = new _modules_render_Camera_js__WEBPACK_IMPORTED_MODULE_7__["default"]()
  202. const renderer = new _modules_render_Renderer_js__WEBPACK_IMPORTED_MODULE_8__["default"]()
  203. const input = new _modules_input_Input_js__WEBPACK_IMPORTED_MODULE_3__["default"]()
  204. const placement = new _modules_Placement_js__WEBPACK_IMPORTED_MODULE_1__["default"]()
  205. const cow = new _Cow_js__WEBPACK_IMPORTED_MODULE_0__["default"]()
  206. /***/
  207. }),
  208. /***/
  209. "./src/game_configs/accessories.js":
  210. /*!*****************************************!*\
  211. !*** ./src/game_configs/accessories.js ***!
  212. \*****************************************/
  213. /***/
  214. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  215. __webpack_require__.r(__webpack_exports__);
  216. const accessories = [{
  217. id: 12,
  218. name: "Snowball",
  219. price: 1e3,
  220. scale: 105,
  221. xOff: 18,
  222. desc: "no effect"
  223. }, {
  224. id: 9,
  225. name: "Tree Cape",
  226. price: 1e3,
  227. scale: 90,
  228. desc: "no effect"
  229. }, {
  230. id: 10,
  231. name: "Stone Cape",
  232. price: 1e3,
  233. scale: 90,
  234. desc: "no effect"
  235. }, {
  236. id: 3,
  237. name: "Cookie Cape",
  238. price: 1500,
  239. scale: 90,
  240. desc: "no effect"
  241. }, {
  242. id: 8,
  243. name: "Cow Cape",
  244. price: 2e3,
  245. scale: 90,
  246. desc: "no effect"
  247. }, {
  248. id: 11,
  249. name: "Monkey Tail",
  250. price: 2e3,
  251. scale: 97,
  252. xOff: 25,
  253. desc: "Super speed but reduced damage",
  254. spdMult: 1.35,
  255. dmgMultO: .2
  256. }, {
  257. id: 17,
  258. name: "Apple Basket",
  259. price: 3e3,
  260. scale: 80,
  261. xOff: 12,
  262. desc: "slowly regenerates health over time",
  263. healthRegen: 1
  264. }, {
  265. id: 6,
  266. name: "Winter Cape",
  267. price: 3e3,
  268. scale: 90,
  269. desc: "no effect"
  270. }, {
  271. id: 4,
  272. name: "Skull Cape",
  273. price: 4e3,
  274. scale: 90,
  275. desc: "no effect"
  276. }, {
  277. id: 5,
  278. name: "Dash Cape",
  279. price: 5e3,
  280. scale: 90,
  281. desc: "no effect"
  282. }, {
  283. id: 2,
  284. name: "Dragon Cape",
  285. price: 6e3,
  286. scale: 90,
  287. desc: "no effect"
  288. }, {
  289. id: 1,
  290. name: "Super Cape",
  291. price: 8e3,
  292. scale: 90,
  293. desc: "no effect"
  294. }, {
  295. id: 7,
  296. name: "Troll Cape",
  297. price: 8e3,
  298. scale: 90,
  299. desc: "no effect"
  300. }, {
  301. id: 14,
  302. name: "Thorns",
  303. price: 1e4,
  304. scale: 115,
  305. xOff: 20,
  306. desc: "no effect"
  307. }, {
  308. id: 15,
  309. name: "Blockades",
  310. price: 1e4,
  311. scale: 95,
  312. xOff: 15,
  313. desc: "no effect"
  314. }, {
  315. id: 20,
  316. name: "Devils Tail",
  317. price: 1e4,
  318. scale: 95,
  319. xOff: 20,
  320. desc: "no effect"
  321. }, {
  322. id: 16,
  323. name: "Sawblade",
  324. price: 12e3,
  325. scale: 90,
  326. spin: !0,
  327. xOff: 0,
  328. desc: "deal damage to players that damage you",
  329. dmg: .15
  330. }, {
  331. id: 13,
  332. name: "Angel Wings",
  333. price: 15e3,
  334. scale: 138,
  335. xOff: 22,
  336. desc: "slowly regenerates health over time",
  337. healthRegen: 3
  338. }, {
  339. id: 19,
  340. name: "Shadow Wings",
  341. price: 15e3,
  342. scale: 138,
  343. xOff: 22,
  344. desc: "increased movement speed",
  345. spdMult: 1.1
  346. }, {
  347. id: 18,
  348. name: "Blood Wings",
  349. price: 2e4,
  350. scale: 178,
  351. xOff: 26,
  352. desc: "restores health when you deal damage",
  353. healD: .2
  354. }, {
  355. id: 21,
  356. name: "Corrupt X Wings",
  357. price: 2e4,
  358. scale: 178,
  359. xOff: 26,
  360. desc: "deal damage to players that damage you",
  361. dmg: .25
  362. }]
  363. accessories.searchById = function(id) {
  364. return this.find((accessory) => accessory.id === id)
  365. }
  366. /* harmony default export */
  367. __webpack_exports__["default"] = (accessories);
  368. /***/
  369. }),
  370. /***/
  371. "./src/game_configs/aiTypes.js":
  372. /*!*************************************!*\
  373. !*** ./src/game_configs/aiTypes.js ***!
  374. \*************************************/
  375. /***/
  376. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  377. __webpack_require__.r(__webpack_exports__);
  378. /* harmony default export */
  379. __webpack_exports__["default"] = ([{
  380. id: 0,
  381. src: "cow_1",
  382. killScore: 150,
  383. health: 500,
  384. weightM: 0.8,
  385. speed: 0.00095,
  386. turnSpeed: 0.001,
  387. scale: 72,
  388. drop: ["food", 50]
  389. }, {
  390. id: 1,
  391. src: "pig_1",
  392. killScore: 200,
  393. health: 800,
  394. weightM: 0.6,
  395. speed: 0.00085,
  396. turnSpeed: 0.001,
  397. scale: 72,
  398. drop: ["food", 80]
  399. }, {
  400. id: 2,
  401. name: "Bull",
  402. src: "bull_2",
  403. hostile: true,
  404. dmg: 20,
  405. killScore: 1000,
  406. health: 1800,
  407. weightM: 0.5,
  408. speed: 0.00094,
  409. turnSpeed: 0.00074,
  410. scale: 78,
  411. viewRange: 800,
  412. chargePlayer: true,
  413. drop: ["food", 100]
  414. }, {
  415. id: 3,
  416. name: "Bully",
  417. src: "bull_1",
  418. hostile: true,
  419. dmg: 20,
  420. killScore: 2000,
  421. health: 2800,
  422. weightM: 0.45,
  423. speed: 0.001,
  424. turnSpeed: 0.0008,
  425. scale: 90,
  426. viewRange: 900,
  427. chargePlayer: true,
  428. drop: ["food", 400]
  429. }, {
  430. id: 4,
  431. name: "Wolf",
  432. src: "wolf_1",
  433. hostile: true,
  434. dmg: 8,
  435. killScore: 500,
  436. health: 300,
  437. weightM: 0.45,
  438. speed: 0.001,
  439. turnSpeed: 0.002,
  440. scale: 84,
  441. viewRange: 800,
  442. chargePlayer: true,
  443. drop: ["food", 200]
  444. }, {
  445. id: 5,
  446. name: "Quack",
  447. src: "chicken_1",
  448. dmg: 8,
  449. killScore: 2000,
  450. noTrap: true,
  451. health: 300,
  452. weightM: 0.2,
  453. speed: 0.0018,
  454. turnSpeed: 0.006,
  455. scale: 70,
  456. drop: ["food", 100]
  457. }, {
  458. id: 6,
  459. name: "MOOSTAFA",
  460. nameScale: 50,
  461. src: "enemy",
  462. hostile: true,
  463. dontRun: true,
  464. fixedSpawn: true,
  465. spawnDelay: 60000,
  466. noTrap: true,
  467. colDmg: 100,
  468. dmg: 40,
  469. killScore: 8000,
  470. health: 18000,
  471. weightM: 0.4,
  472. speed: 0.0007,
  473. turnSpeed: 0.01,
  474. scale: 80,
  475. spriteMlt: 1.8,
  476. leapForce: 0.9,
  477. viewRange: 1000,
  478. hitRange: 210,
  479. hitDelay: 1000,
  480. chargePlayer: true,
  481. drop: ["food", 100]
  482. }, {
  483. id: 7,
  484. name: "Treasure",
  485. hostile: true,
  486. nameScale: 35,
  487. src: "crate_1",
  488. fixedSpawn: true,
  489. spawnDelay: 120000,
  490. colDmg: 200,
  491. killScore: 5000,
  492. health: 20000,
  493. weightM: 0.1,
  494. speed: 0.0,
  495. turnSpeed: 0.0,
  496. scale: 70,
  497. spriteMlt: 1.0
  498. }, {
  499. id: 8,
  500. name: "MOOFIE",
  501. src: "wolf_2",
  502. hostile: true,
  503. fixedSpawn: true,
  504. dontRun: true,
  505. hitScare: 4,
  506. spawnDelay: 30000,
  507. noTrap: true,
  508. nameScale: 35,
  509. dmg: 10,
  510. colDmg: 100,
  511. killScore: 3000,
  512. health: 7000,
  513. weightM: 0.45,
  514. speed: 0.0015,
  515. turnSpeed: 0.002,
  516. scale: 90,
  517. viewRange: 800,
  518. chargePlayer: true,
  519. drop: ["food", 1000]
  520. }]);
  521. /***/
  522. }),
  523. /***/
  524. "./src/game_configs/groups.js":
  525. /*!************************************!*\
  526. !*** ./src/game_configs/groups.js ***!
  527. \************************************/
  528. /***/
  529. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  530. __webpack_require__.r(__webpack_exports__);
  531. /* harmony default export */
  532. __webpack_exports__["default"] = ([{
  533. id: 0,
  534. name: "food",
  535. layer: 0
  536. }, {
  537. id: 1,
  538. name: "walls",
  539. place: !0,
  540. limit: 30,
  541. layer: 0
  542. }, {
  543. id: 2,
  544. name: "spikes",
  545. place: !0,
  546. limit: 15,
  547. layer: 0
  548. }, {
  549. id: 3,
  550. name: "mill",
  551. place: !0,
  552. limit: 7,
  553. sandboxLimit: 299,
  554. layer: 1
  555. }, {
  556. id: 4,
  557. name: "mine",
  558. place: !0,
  559. limit: 1,
  560. layer: 0
  561. }, {
  562. id: 5,
  563. name: "trap",
  564. place: !0,
  565. limit: 6,
  566. layer: -1
  567. }, {
  568. id: 6,
  569. name: "booster",
  570. place: !0,
  571. limit: 12,
  572. sandboxLimit: 299,
  573. layer: -1
  574. }, {
  575. id: 7,
  576. name: "turret",
  577. place: !0,
  578. limit: 2,
  579. layer: 1
  580. }, {
  581. id: 8,
  582. name: "watchtower",
  583. place: !0,
  584. limit: 12,
  585. layer: 1
  586. }, {
  587. id: 9,
  588. name: "buff",
  589. place: !0,
  590. limit: 4,
  591. layer: -1
  592. }, {
  593. id: 10,
  594. name: "spawn",
  595. place: !0,
  596. limit: 1,
  597. layer: -1
  598. }, {
  599. id: 11,
  600. name: "sapling",
  601. place: !0,
  602. limit: 2,
  603. layer: 0
  604. }, {
  605. id: 12,
  606. name: "blocker",
  607. place: !0,
  608. limit: 3,
  609. layer: -1
  610. }, {
  611. id: 13,
  612. name: "teleporter",
  613. place: !0,
  614. limit: 2,
  615. sandboxLimit: 299,
  616. layer: -1
  617. }]);
  618. /***/
  619. }),
  620. /***/
  621. "./src/game_configs/hats.js":
  622. /*!**********************************!*\
  623. !*** ./src/game_configs/hats.js ***!
  624. \**********************************/
  625. /***/
  626. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  627. __webpack_require__.r(__webpack_exports__);
  628. const hats = [{
  629. id: 45,
  630. name: "Shame!",
  631. dontSell: !0,
  632. price: 0,
  633. scale: 120,
  634. desc: "hacks are for losers"
  635. }, {
  636. id: 51,
  637. name: "Moo Cap",
  638. price: 0,
  639. scale: 120,
  640. desc: "coolest mooer around"
  641. }, {
  642. id: 50,
  643. name: "Apple Cap",
  644. price: 0,
  645. scale: 120,
  646. desc: "apple farms remembers"
  647. }, {
  648. id: 28,
  649. name: "Moo Head",
  650. price: 0,
  651. scale: 120,
  652. desc: "no effect"
  653. }, {
  654. id: 29,
  655. name: "Pig Head",
  656. price: 0,
  657. scale: 120,
  658. desc: "no effect"
  659. }, {
  660. id: 30,
  661. name: "Fluff Head",
  662. price: 0,
  663. scale: 120,
  664. desc: "no effect"
  665. }, {
  666. id: 36,
  667. name: "Pandou Head",
  668. price: 0,
  669. scale: 120,
  670. desc: "no effect"
  671. }, {
  672. id: 37,
  673. name: "Bear Head",
  674. price: 0,
  675. scale: 120,
  676. desc: "no effect"
  677. }, {
  678. id: 38,
  679. name: "Monkey Head",
  680. price: 0,
  681. scale: 120,
  682. desc: "no effect"
  683. }, {
  684. id: 44,
  685. name: "Polar Head",
  686. price: 0,
  687. scale: 120,
  688. desc: "no effect"
  689. }, {
  690. id: 35,
  691. name: "Fez Hat",
  692. price: 0,
  693. scale: 120,
  694. desc: "no effect"
  695. }, {
  696. id: 42,
  697. name: "Enigma Hat",
  698. price: 0,
  699. scale: 120,
  700. desc: "join the enigma army"
  701. }, {
  702. id: 43,
  703. name: "Blitz Hat",
  704. price: 0,
  705. scale: 120,
  706. desc: "hey everybody i'm blitz"
  707. }, {
  708. id: 49,
  709. name: "Bob XIII Hat",
  710. price: 0,
  711. scale: 120,
  712. desc: "like and subscribe"
  713. }, {
  714. id: 57,
  715. name: "Pumpkin",
  716. price: 50,
  717. scale: 120,
  718. desc: "Spooooky"
  719. }, {
  720. id: 8,
  721. name: "Bummle Hat",
  722. price: 100,
  723. scale: 120,
  724. desc: "no effect"
  725. }, {
  726. id: 2,
  727. name: "Straw Hat",
  728. price: 500,
  729. scale: 120,
  730. desc: "no effect"
  731. }, {
  732. id: 15,
  733. name: "Winter Cap",
  734. price: 600,
  735. scale: 120,
  736. desc: "allows you to move at normal speed in snow",
  737. coldM: 1
  738. }, {
  739. id: 5,
  740. name: "Cowboy Hat",
  741. price: 1e3,
  742. scale: 120,
  743. desc: "no effect"
  744. }, {
  745. id: 4,
  746. name: "Ranger Hat",
  747. price: 2e3,
  748. scale: 120,
  749. desc: "no effect"
  750. }, {
  751. id: 18,
  752. name: "Explorer Hat",
  753. price: 2e3,
  754. scale: 120,
  755. desc: "no effect"
  756. }, {
  757. id: 31,
  758. name: "Flipper Hat",
  759. price: 2500,
  760. scale: 120,
  761. desc: "have more control while in water",
  762. watrImm: !0
  763. }, {
  764. id: 1,
  765. name: "Marksman Cap",
  766. price: 3e3,
  767. scale: 120,
  768. desc: "increases arrow speed and range",
  769. aMlt: 1.3
  770. }, {
  771. id: 10,
  772. name: "Bush Gear",
  773. price: 3e3,
  774. scale: 160,
  775. desc: "allows you to disguise yourself as a bush"
  776. }, {
  777. id: 48,
  778. name: "Halo",
  779. price: 3e3,
  780. scale: 120,
  781. desc: "no effect"
  782. }, {
  783. id: 6,
  784. name: "Soldier Helmet",
  785. price: 4e3,
  786. scale: 120,
  787. desc: "reduces damage taken but slows movement",
  788. spdMult: .94,
  789. dmgMult: .75
  790. }, {
  791. id: 23,
  792. name: "Anti Venom Gear",
  793. price: 4e3,
  794. scale: 120,
  795. desc: "makes you immune to poison",
  796. poisonRes: 1
  797. }, {
  798. id: 13,
  799. name: "Medic Gear",
  800. price: 5e3,
  801. scale: 110,
  802. desc: "slowly regenerates health over time",
  803. healthRegen: 3
  804. }, {
  805. id: 9,
  806. name: "Miners Helmet",
  807. price: 5e3,
  808. scale: 120,
  809. desc: "earn 1 extra gold per resource",
  810. extraGold: 1
  811. }, {
  812. id: 32,
  813. name: "Musketeer Hat",
  814. price: 5e3,
  815. scale: 120,
  816. desc: "reduces cost of projectiles",
  817. projCost: .5
  818. }, {
  819. id: 7,
  820. name: "Bull Helmet",
  821. price: 6e3,
  822. scale: 120,
  823. desc: "increases damage done but drains health",
  824. healthRegen: -5,
  825. dmgMultO: 1.5,
  826. spdMult: .96
  827. }, {
  828. id: 22,
  829. name: "Emp Helmet",
  830. price: 6e3,
  831. scale: 120,
  832. desc: "turrets won't attack but you move slower",
  833. antiTurret: 1,
  834. spdMult: .7
  835. }, {
  836. id: 12,
  837. name: "Booster Hat",
  838. price: 6e3,
  839. scale: 120,
  840. desc: "increases your movement speed",
  841. spdMult: 1.16
  842. }, {
  843. id: 26,
  844. name: "Barbarian Armor",
  845. price: 8e3,
  846. scale: 120,
  847. desc: "knocks back enemies that attack you",
  848. dmgK: .6
  849. }, {
  850. id: 21,
  851. name: "Plague Mask",
  852. price: 1e4,
  853. scale: 120,
  854. desc: "melee attacks deal poison damage",
  855. poisonDmg: 5,
  856. poisonTime: 6
  857. }, {
  858. id: 46,
  859. name: "Bull Mask",
  860. price: 1e4,
  861. scale: 120,
  862. desc: "bulls won't target you unless you attack them",
  863. bullRepel: 1
  864. }, {
  865. id: 14,
  866. name: "Windmill Hat",
  867. topSprite: !0,
  868. price: 1e4,
  869. scale: 120,
  870. desc: "generates points while worn",
  871. pps: 1.5
  872. }, {
  873. id: 11,
  874. name: "Spike Gear",
  875. topSprite: !0,
  876. price: 1e4,
  877. scale: 120,
  878. desc: "deal damage to players that damage you",
  879. dmg: .45
  880. }, {
  881. id: 53,
  882. name: "Turret Gear",
  883. topSprite: !0,
  884. price: 1e4,
  885. scale: 120,
  886. desc: "you become a walking turret",
  887. turret: {
  888. proj: 1,
  889. range: 700,
  890. rate: 2500
  891. },
  892. spdMult: .7
  893. }, {
  894. id: 20,
  895. name: "Samurai Armor",
  896. price: 12e3,
  897. scale: 120,
  898. desc: "increased attack speed and fire rate",
  899. atkSpd: .78
  900. }, {
  901. id: 58,
  902. name: "Dark Knight",
  903. price: 12e3,
  904. scale: 120,
  905. desc: "restores health when you deal damage",
  906. healD: .4
  907. }, {
  908. id: 27,
  909. name: "Scavenger Gear",
  910. price: 15e3,
  911. scale: 120,
  912. desc: "earn double points for each kill",
  913. kScrM: 2
  914. }, {
  915. id: 40,
  916. name: "Tank Gear",
  917. price: 15e3,
  918. scale: 120,
  919. desc: "increased damage to buildings but slower movement",
  920. spdMult: .3,
  921. bDmg: 3.3
  922. }, {
  923. id: 52,
  924. name: "Thief Gear",
  925. price: 15e3,
  926. scale: 120,
  927. desc: "steal half of a players gold when you kill them",
  928. goldSteal: .5
  929. }, {
  930. id: 55,
  931. name: "Bloodthirster",
  932. price: 2e4,
  933. scale: 120,
  934. desc: "Restore Health when dealing damage. And increased damage",
  935. healD: .25,
  936. dmgMultO: 1.2
  937. }, {
  938. id: 56,
  939. name: "Assassin Gear",
  940. price: 2e4,
  941. scale: 120,
  942. desc: "Go invisible when not moving. Can't eat. Increased speed",
  943. noEat: !0,
  944. spdMult: 1.1,
  945. invisTimer: 1e3
  946. }]
  947. hats.searchById = function(id) {
  948. return this.find((hat) => hat.id === id)
  949. }
  950. /* harmony default export */
  951. __webpack_exports__["default"] = (hats);
  952. /***/
  953. }),
  954. /***/
  955. "./src/game_configs/index.js":
  956. /*!***********************************!*\
  957. !*** ./src/game_configs/index.js ***!
  958. \***********************************/
  959. /***/
  960. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  961. __webpack_require__.r(__webpack_exports__);
  962. /* harmony export */
  963. __webpack_require__.d(__webpack_exports__, {
  964. /* harmony export */
  965. accessories: function() {
  966. return /* reexport safe */ _accessories_js__WEBPACK_IMPORTED_MODULE_0__["default"];
  967. },
  968. /* harmony export */
  969. aiTypes: function() {
  970. return /* reexport safe */ _aiTypes_js__WEBPACK_IMPORTED_MODULE_1__["default"];
  971. },
  972. /* harmony export */
  973. groups: function() {
  974. return /* reexport safe */ _groups_js__WEBPACK_IMPORTED_MODULE_2__["default"];
  975. },
  976. /* harmony export */
  977. hats: function() {
  978. return /* reexport safe */ _hats_js__WEBPACK_IMPORTED_MODULE_3__["default"];
  979. },
  980. /* harmony export */
  981. list: function() {
  982. return /* reexport safe */ _list_js__WEBPACK_IMPORTED_MODULE_4__["default"];
  983. },
  984. /* harmony export */
  985. projectiles: function() {
  986. return /* reexport safe */ _projectiles_js__WEBPACK_IMPORTED_MODULE_5__["default"];
  987. },
  988. /* harmony export */
  989. variants: function() {
  990. return /* reexport safe */ _variants_js__WEBPACK_IMPORTED_MODULE_6__["default"];
  991. },
  992. /* harmony export */
  993. weapons: function() {
  994. return /* reexport safe */ _weapons_js__WEBPACK_IMPORTED_MODULE_7__["default"];
  995. }
  996. /* harmony export */
  997. });
  998. /* harmony import */
  999. var _accessories_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ./accessories.js */ "./src/game_configs/accessories.js");
  1000. /* harmony import */
  1001. var _aiTypes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__( /*! ./aiTypes.js */ "./src/game_configs/aiTypes.js");
  1002. /* harmony import */
  1003. var _groups_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__( /*! ./groups.js */ "./src/game_configs/groups.js");
  1004. /* harmony import */
  1005. var _hats_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__( /*! ./hats.js */ "./src/game_configs/hats.js");
  1006. /* harmony import */
  1007. var _list_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__( /*! ./list.js */ "./src/game_configs/list.js");
  1008. /* harmony import */
  1009. var _projectiles_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__( /*! ./projectiles.js */ "./src/game_configs/projectiles.js");
  1010. /* harmony import */
  1011. var _variants_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__( /*! ./variants.js */ "./src/game_configs/variants.js");
  1012. /* harmony import */
  1013. var _weapons_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__( /*! ./weapons.js */ "./src/game_configs/weapons.js");
  1014. /***/
  1015. }),
  1016. /***/
  1017. "./src/game_configs/list.js":
  1018. /*!**********************************!*\
  1019. !*** ./src/game_configs/list.js ***!
  1020. \**********************************/
  1021. /***/
  1022. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  1023. __webpack_require__.r(__webpack_exports__);
  1024. /* harmony import */
  1025. var _groups_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ./groups.js */ "./src/game_configs/groups.js");
  1026. const list = [{
  1027. group: _groups_js__WEBPACK_IMPORTED_MODULE_0__["default"][0],
  1028. name: "apple",
  1029. desc: "restores 20 health when consumed",
  1030. req: ["food", 10],
  1031. consume: function(e) {
  1032. return e.changeHealth(20, e)
  1033. },
  1034. scale: 22,
  1035. holdOffset: 15
  1036. }, {
  1037. age: 3,
  1038. group: _groups_js__WEBPACK_IMPORTED_MODULE_0__["default"][0],
  1039. name: "cookie",
  1040. desc: "restores 40 health when consumed",
  1041. req: ["food", 15],
  1042. consume: function(e) {
  1043. return e.changeHealth(40, e)
  1044. },
  1045. scale: 27,
  1046. holdOffset: 15
  1047. }, {
  1048. age: 7,
  1049. group: _groups_js__WEBPACK_IMPORTED_MODULE_0__["default"][0],
  1050. name: "cheese",
  1051. desc: "restores 30 health and another 50 over 5 seconds",
  1052. req: ["food", 25],
  1053. consume: function(e) {
  1054. return e.changeHealth(30, e) || e.health < 100 ? (e.dmgOverTime.dmg = -10,
  1055. e.dmgOverTime.doer = e,
  1056. e.dmgOverTime.time = 5,
  1057. !0) : !1
  1058. },
  1059. scale: 27,
  1060. holdOffset: 15
  1061. }, {
  1062. group: _groups_js__WEBPACK_IMPORTED_MODULE_0__["default"][1],
  1063. name: "wood wall",
  1064. desc: "provides protection for your village",
  1065. req: ["wood", 10],
  1066. projDmg: !0,
  1067. health: 380,
  1068. scale: 50,
  1069. holdOffset: 20,
  1070. placeOffset: -5
  1071. }, {
  1072. age: 3,
  1073. group: _groups_js__WEBPACK_IMPORTED_MODULE_0__["default"][1],
  1074. name: "stone wall",
  1075. desc: "provides improved protection for your village",
  1076. req: ["stone", 25],
  1077. health: 900,
  1078. scale: 50,
  1079. holdOffset: 20,
  1080. placeOffset: -5
  1081. }, {
  1082. age: 7,
  1083. pre: 1,
  1084. group: _groups_js__WEBPACK_IMPORTED_MODULE_0__["default"][1],
  1085. name: "castle wall",
  1086. desc: "provides powerful protection for your village",
  1087. req: ["stone", 35],
  1088. health: 1500,
  1089. scale: 52,
  1090. holdOffset: 20,
  1091. placeOffset: -5
  1092. }, {
  1093. group: _groups_js__WEBPACK_IMPORTED_MODULE_0__["default"][2],
  1094. name: "spikes",
  1095. desc: "damages enemies when they touch them",
  1096. req: ["wood", 20, "stone", 5],
  1097. health: 400,
  1098. dmg: 20,
  1099. scale: 49,
  1100. spritePadding: -23,
  1101. holdOffset: 8,
  1102. placeOffset: -5
  1103. }, {
  1104. age: 5,
  1105. group: _groups_js__WEBPACK_IMPORTED_MODULE_0__["default"][2],
  1106. name: "greater spikes",
  1107. desc: "damages enemies when they touch them",
  1108. req: ["wood", 30, "stone", 10],
  1109. health: 500,
  1110. dmg: 35,
  1111. scale: 52,
  1112. spritePadding: -23,
  1113. holdOffset: 8,
  1114. placeOffset: -5
  1115. }, {
  1116. age: 9,
  1117. pre: 1,
  1118. group: _groups_js__WEBPACK_IMPORTED_MODULE_0__["default"][2],
  1119. name: "poison spikes",
  1120. desc: "poisons enemies when they touch them",
  1121. req: ["wood", 35, "stone", 15],
  1122. health: 600,
  1123. dmg: 30,
  1124. pDmg: 5,
  1125. scale: 52,
  1126. spritePadding: -23,
  1127. holdOffset: 8,
  1128. placeOffset: -5
  1129. }, {
  1130. age: 9,
  1131. pre: 2,
  1132. group: _groups_js__WEBPACK_IMPORTED_MODULE_0__["default"][2],
  1133. name: "spinning spikes",
  1134. desc: "damages enemies when they touch them",
  1135. req: ["wood", 30, "stone", 20],
  1136. health: 500,
  1137. dmg: 45,
  1138. turnSpeed: .003,
  1139. scale: 52,
  1140. spritePadding: -23,
  1141. holdOffset: 8,
  1142. placeOffset: -5
  1143. }, {
  1144. group: _groups_js__WEBPACK_IMPORTED_MODULE_0__["default"][3],
  1145. name: "windmill",
  1146. desc: "generates gold over time",
  1147. req: ["wood", 50, "stone", 10],
  1148. health: 400,
  1149. pps: 1,
  1150. turnSpeed: .0016,
  1151. spritePadding: 25,
  1152. iconLineMult: 12,
  1153. scale: 45,
  1154. holdOffset: 20,
  1155. placeOffset: 5
  1156. }, {
  1157. age: 5,
  1158. pre: 1,
  1159. group: _groups_js__WEBPACK_IMPORTED_MODULE_0__["default"][3],
  1160. name: "faster windmill",
  1161. desc: "generates more gold over time",
  1162. req: ["wood", 60, "stone", 20],
  1163. health: 500,
  1164. pps: 1.5,
  1165. turnSpeed: .0025,
  1166. spritePadding: 25,
  1167. iconLineMult: 12,
  1168. scale: 47,
  1169. holdOffset: 20,
  1170. placeOffset: 5
  1171. }, {
  1172. age: 8,
  1173. pre: 1,
  1174. group: _groups_js__WEBPACK_IMPORTED_MODULE_0__["default"][3],
  1175. name: "power mill",
  1176. desc: "generates more gold over time",
  1177. req: ["wood", 100, "stone", 50],
  1178. health: 800,
  1179. pps: 2,
  1180. turnSpeed: .005,
  1181. spritePadding: 25,
  1182. iconLineMult: 12,
  1183. scale: 47,
  1184. holdOffset: 20,
  1185. placeOffset: 5
  1186. }, {
  1187. age: 5,
  1188. group: _groups_js__WEBPACK_IMPORTED_MODULE_0__["default"][4],
  1189. type: 2,
  1190. name: "mine",
  1191. desc: "allows you to mine stone",
  1192. req: ["wood", 20, "stone", 100],
  1193. iconLineMult: 12,
  1194. scale: 65,
  1195. holdOffset: 20,
  1196. placeOffset: 0
  1197. }, {
  1198. age: 5,
  1199. group: _groups_js__WEBPACK_IMPORTED_MODULE_0__["default"][11],
  1200. type: 0,
  1201. name: "sapling",
  1202. desc: "allows you to farm wood",
  1203. req: ["wood", 150],
  1204. iconLineMult: 12,
  1205. colDiv: .5,
  1206. scale: 110,
  1207. holdOffset: 50,
  1208. placeOffset: -15
  1209. }, {
  1210. age: 4,
  1211. group: _groups_js__WEBPACK_IMPORTED_MODULE_0__["default"][5],
  1212. name: "pit trap",
  1213. desc: "pit that traps enemies if they walk over it",
  1214. req: ["wood", 30, "stone", 30],
  1215. trap: !0,
  1216. ignoreCollision: !0,
  1217. hideFromEnemy: !0,
  1218. health: 500,
  1219. colDiv: .2,
  1220. scale: 50,
  1221. holdOffset: 20,
  1222. placeOffset: -5
  1223. }, {
  1224. age: 4,
  1225. group: _groups_js__WEBPACK_IMPORTED_MODULE_0__["default"][6],
  1226. name: "boost pad",
  1227. desc: "provides boost when stepped on",
  1228. req: ["stone", 20, "wood", 5],
  1229. ignoreCollision: !0,
  1230. boostSpeed: 1.5,
  1231. health: 150,
  1232. colDiv: .7,
  1233. scale: 45,
  1234. holdOffset: 20,
  1235. placeOffset: -5
  1236. }, {
  1237. age: 7,
  1238. group: _groups_js__WEBPACK_IMPORTED_MODULE_0__["default"][7],
  1239. doUpdate: !0,
  1240. name: "turret",
  1241. desc: "defensive structure that shoots at enemies",
  1242. req: ["wood", 200, "stone", 150],
  1243. health: 800,
  1244. projectile: 1,
  1245. shootRange: 700,
  1246. shootRate: 2200,
  1247. scale: 43,
  1248. holdOffset: 20,
  1249. placeOffset: -5
  1250. }, {
  1251. age: 7,
  1252. group: _groups_js__WEBPACK_IMPORTED_MODULE_0__["default"][8],
  1253. name: "platform",
  1254. desc: "platform to shoot over walls and cross over water",
  1255. req: ["wood", 20],
  1256. ignoreCollision: !0,
  1257. zIndex: 1,
  1258. health: 300,
  1259. scale: 43,
  1260. holdOffset: 20,
  1261. placeOffset: -5
  1262. }, {
  1263. age: 7,
  1264. group: _groups_js__WEBPACK_IMPORTED_MODULE_0__["default"][9],
  1265. name: "healing pad",
  1266. desc: "standing on it will slowly heal you",
  1267. req: ["wood", 30, "food", 10],
  1268. ignoreCollision: !0,
  1269. healCol: 15,
  1270. health: 400,
  1271. colDiv: .7,
  1272. scale: 45,
  1273. holdOffset: 20,
  1274. placeOffset: -5
  1275. }, {
  1276. age: 9,
  1277. group: _groups_js__WEBPACK_IMPORTED_MODULE_0__["default"][10],
  1278. name: "spawn pad",
  1279. desc: "you will spawn here when you die but it will dissapear",
  1280. req: ["wood", 100, "stone", 100],
  1281. health: 400,
  1282. ignoreCollision: !0,
  1283. spawnPoint: !0,
  1284. scale: 45,
  1285. holdOffset: 20,
  1286. placeOffset: -5
  1287. }, {
  1288. age: 7,
  1289. group: _groups_js__WEBPACK_IMPORTED_MODULE_0__["default"][12],
  1290. name: "blocker",
  1291. desc: "blocks building in radius",
  1292. req: ["wood", 30, "stone", 25],
  1293. ignoreCollision: !0,
  1294. blocker: 300,
  1295. health: 400,
  1296. colDiv: .7,
  1297. scale: 45,
  1298. holdOffset: 20,
  1299. placeOffset: -5
  1300. }, {
  1301. age: 7,
  1302. group: _groups_js__WEBPACK_IMPORTED_MODULE_0__["default"][13],
  1303. name: "teleporter",
  1304. desc: "teleports you to a random point on the map",
  1305. req: ["wood", 60, "stone", 60],
  1306. ignoreCollision: !0,
  1307. teleport: !0,
  1308. health: 200,
  1309. colDiv: .7,
  1310. scale: 45,
  1311. holdOffset: 20,
  1312. placeOffset: -5
  1313. }]
  1314. for (var i = 0; i < list.length; ++i) {
  1315. list[i].id = i
  1316. if (list[i].pre) {
  1317. list[i].pre = i - list[i].pre
  1318. }
  1319. }
  1320. /* harmony default export */
  1321. __webpack_exports__["default"] = (list);
  1322. /***/
  1323. }),
  1324. /***/
  1325. "./src/game_configs/projectiles.js":
  1326. /*!*****************************************!*\
  1327. !*** ./src/game_configs/projectiles.js ***!
  1328. \*****************************************/
  1329. /***/
  1330. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  1331. __webpack_require__.r(__webpack_exports__);
  1332. /* harmony default export */
  1333. __webpack_exports__["default"] = ([{
  1334. indx: 0,
  1335. layer: 0,
  1336. src: "arrow_1",
  1337. dmg: 25,
  1338. speed: 1.6,
  1339. scale: 103,
  1340. range: 1e3
  1341. }, {
  1342. indx: 1,
  1343. layer: 1,
  1344. dmg: 25,
  1345. scale: 20
  1346. }, {
  1347. indx: 0,
  1348. layer: 0,
  1349. src: "arrow_1",
  1350. dmg: 35,
  1351. speed: 2.5,
  1352. scale: 103,
  1353. range: 1200
  1354. }, {
  1355. indx: 0,
  1356. layer: 0,
  1357. src: "arrow_1",
  1358. dmg: 30,
  1359. speed: 2,
  1360. scale: 103,
  1361. range: 1200
  1362. }, {
  1363. indx: 1,
  1364. layer: 1,
  1365. dmg: 16,
  1366. scale: 20
  1367. }, {
  1368. indx: 0,
  1369. layer: 0,
  1370. src: "bullet_1",
  1371. dmg: 50,
  1372. speed: 3.6,
  1373. scale: 160,
  1374. range: 1400
  1375. }]);
  1376. /***/
  1377. }),
  1378. /***/
  1379. "./src/game_configs/variants.js":
  1380. /*!**************************************!*\
  1381. !*** ./src/game_configs/variants.js ***!
  1382. \**************************************/
  1383. /***/
  1384. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  1385. __webpack_require__.r(__webpack_exports__);
  1386. /* harmony default export */
  1387. __webpack_exports__["default"] = ([{
  1388. id: 0,
  1389. src: "",
  1390. xp: 0,
  1391. val: 1
  1392. }, {
  1393. id: 1,
  1394. src: "_g",
  1395. xp: 3000,
  1396. val: 1.1
  1397. }, {
  1398. id: 2,
  1399. src: "_d",
  1400. xp: 7000,
  1401. val: 1.18
  1402. }, {
  1403. id: 3,
  1404. src: "_r",
  1405. poison: true,
  1406. xp: 12000,
  1407. val: 1.18
  1408. }]);
  1409. /***/
  1410. }),
  1411. /***/
  1412. "./src/game_configs/weapons.js":
  1413. /*!*************************************!*\
  1414. !*** ./src/game_configs/weapons.js ***!
  1415. \*************************************/
  1416. /***/
  1417. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  1418. __webpack_require__.r(__webpack_exports__);
  1419. /* harmony default export */
  1420. __webpack_exports__["default"] = ([{
  1421. id: 0,
  1422. type: 0,
  1423. name: "tool hammer",
  1424. desc: "tool for gathering all resources",
  1425. src: "hammer_1",
  1426. length: 140,
  1427. width: 140,
  1428. xOff: -3,
  1429. yOff: 18,
  1430. dmg: 25,
  1431. range: 65,
  1432. gather: 1,
  1433. speed: 300
  1434. }, {
  1435. id: 1,
  1436. type: 0,
  1437. age: 2,
  1438. name: "hand axe",
  1439. desc: "gathers resources at a higher rate",
  1440. src: "axe_1",
  1441. length: 140,
  1442. width: 140,
  1443. xOff: 3,
  1444. yOff: 24,
  1445. dmg: 30,
  1446. spdMult: 1,
  1447. range: 70,
  1448. gather: 2,
  1449. speed: 400
  1450. }, {
  1451. id: 2,
  1452. type: 0,
  1453. age: 8,
  1454. pre: 1,
  1455. name: "great axe",
  1456. desc: "deal more damage and gather more resources",
  1457. src: "great_axe_1",
  1458. length: 140,
  1459. width: 140,
  1460. xOff: -8,
  1461. yOff: 25,
  1462. dmg: 35,
  1463. spdMult: 1,
  1464. range: 75,
  1465. gather: 4,
  1466. speed: 400
  1467. }, {
  1468. id: 3,
  1469. type: 0,
  1470. age: 2,
  1471. name: "short sword",
  1472. desc: "increased attack power but slower move speed",
  1473. src: "sword_1",
  1474. iPad: 1.3,
  1475. length: 130,
  1476. width: 210,
  1477. xOff: -8,
  1478. yOff: 46,
  1479. dmg: 35,
  1480. spdMult: .85,
  1481. range: 110,
  1482. gather: 1,
  1483. speed: 300
  1484. }, {
  1485. id: 4,
  1486. type: 0,
  1487. age: 8,
  1488. pre: 3,
  1489. name: "katana",
  1490. desc: "greater range and damage",
  1491. src: "samurai_1",
  1492. iPad: 1.3,
  1493. length: 130,
  1494. width: 210,
  1495. xOff: -8,
  1496. yOff: 59,
  1497. dmg: 40,
  1498. spdMult: .8,
  1499. range: 118,
  1500. gather: 1,
  1501. speed: 300
  1502. }, {
  1503. id: 5,
  1504. type: 0,
  1505. age: 2,
  1506. name: "polearm",
  1507. desc: "long range melee weapon",
  1508. src: "spear_1",
  1509. iPad: 1.3,
  1510. length: 130,
  1511. width: 210,
  1512. xOff: -8,
  1513. yOff: 53,
  1514. dmg: 45,
  1515. knock: .2,
  1516. spdMult: .82,
  1517. range: 142,
  1518. gather: 1,
  1519. speed: 700
  1520. }, {
  1521. id: 6,
  1522. type: 0,
  1523. age: 2,
  1524. name: "bat",
  1525. desc: "fast long range melee weapon",
  1526. src: "bat_1",
  1527. iPad: 1.3,
  1528. length: 110,
  1529. width: 180,
  1530. xOff: -8,
  1531. yOff: 53,
  1532. dmg: 20,
  1533. knock: .7,
  1534. range: 110,
  1535. gather: 1,
  1536. speed: 300
  1537. }, {
  1538. id: 7,
  1539. type: 0,
  1540. age: 2,
  1541. name: "daggers",
  1542. desc: "really fast short range weapon",
  1543. src: "dagger_1",
  1544. iPad: .8,
  1545. length: 110,
  1546. width: 110,
  1547. xOff: 18,
  1548. yOff: 0,
  1549. dmg: 20,
  1550. knock: .1,
  1551. range: 65,
  1552. gather: 1,
  1553. hitSlow: .1,
  1554. spdMult: 1.13,
  1555. speed: 100
  1556. }, {
  1557. id: 8,
  1558. type: 0,
  1559. age: 2,
  1560. name: "stick",
  1561. desc: "great for gathering but very weak",
  1562. src: "stick_1",
  1563. length: 140,
  1564. width: 140,
  1565. xOff: 3,
  1566. yOff: 24,
  1567. dmg: 1,
  1568. spdMult: 1,
  1569. range: 70,
  1570. gather: 7,
  1571. speed: 400
  1572. }, {
  1573. id: 9,
  1574. type: 1,
  1575. age: 6,
  1576. name: "hunting bow",
  1577. desc: "bow used for ranged combat and hunting",
  1578. src: "bow_1",
  1579. req: ["wood", 4],
  1580. length: 120,
  1581. width: 120,
  1582. xOff: -6,
  1583. yOff: 0,
  1584. projectile: 0,
  1585. spdMult: .75,
  1586. speed: 600
  1587. }, {
  1588. id: 10,
  1589. type: 1,
  1590. age: 6,
  1591. name: "great hammer",
  1592. desc: "hammer used for destroying structures",
  1593. src: "great_hammer_1",
  1594. length: 140,
  1595. width: 140,
  1596. xOff: -9,
  1597. yOff: 25,
  1598. dmg: 10,
  1599. spdMult: .88,
  1600. range: 75,
  1601. sDmg: 7.5,
  1602. gather: 1,
  1603. speed: 400
  1604. }, {
  1605. id: 11,
  1606. type: 1,
  1607. age: 6,
  1608. name: "wooden shield",
  1609. desc: "blocks projectiles and reduces melee damage",
  1610. src: "shield_1",
  1611. length: 120,
  1612. width: 120,
  1613. shield: .2,
  1614. xOff: 6,
  1615. yOff: 0,
  1616. spdMult: .7
  1617. }, {
  1618. id: 12,
  1619. type: 1,
  1620. age: 8,
  1621. pre: 9,
  1622. name: "crossbow",
  1623. desc: "deals more damage and has greater range",
  1624. src: "crossbow_1",
  1625. req: ["wood", 5],
  1626. aboveHand: !0,
  1627. armS: .75,
  1628. length: 120,
  1629. width: 120,
  1630. xOff: -4,
  1631. yOff: 0,
  1632. projectile: 2,
  1633. spdMult: .7,
  1634. speed: 700
  1635. }, {
  1636. id: 13,
  1637. type: 1,
  1638. age: 9,
  1639. pre: 12,
  1640. name: "repeater crossbow",
  1641. desc: "high firerate crossbow with reduced damage",
  1642. src: "crossbow_2",
  1643. req: ["wood", 10],
  1644. aboveHand: !0,
  1645. armS: .75,
  1646. length: 120,
  1647. width: 120,
  1648. xOff: -4,
  1649. yOff: 0,
  1650. projectile: 3,
  1651. spdMult: .7,
  1652. speed: 230
  1653. }, {
  1654. id: 14,
  1655. type: 1,
  1656. age: 6,
  1657. name: "mc grabby",
  1658. desc: "steals resources from enemies",
  1659. src: "grab_1",
  1660. length: 130,
  1661. width: 210,
  1662. xOff: -8,
  1663. yOff: 53,
  1664. dmg: 0,
  1665. steal: 250,
  1666. knock: .2,
  1667. spdMult: 1.05,
  1668. range: 125,
  1669. gather: 0,
  1670. speed: 700
  1671. }, {
  1672. id: 15,
  1673. type: 1,
  1674. age: 9,
  1675. pre: 12,
  1676. name: "musket",
  1677. desc: "slow firerate but high damage and range",
  1678. src: "musket_1",
  1679. req: ["stone", 10],
  1680. aboveHand: !0,
  1681. rec: .35,
  1682. armS: .6,
  1683. hndS: .3,
  1684. hndD: 1.6,
  1685. length: 205,
  1686. width: 205,
  1687. xOff: 25,
  1688. yOff: 0,
  1689. projectile: 5,
  1690. hideProjectile: !0,
  1691. spdMult: .6,
  1692. speed: 1500
  1693. }]);
  1694. /***/
  1695. }),
  1696. /***/
  1697. "./src/hooks.js":
  1698. /*!**********************!*\
  1699. !*** ./src/hooks.js ***!
  1700. \**********************/
  1701. /***/
  1702. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  1703. __webpack_require__.r(__webpack_exports__);
  1704. /* harmony import */
  1705. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ./constants.js */ "./src/constants.js");
  1706. /* harmony import */
  1707. var _utils_CowUtils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__( /*! ./utils/CowUtils.js */ "./src/utils/CowUtils.js");
  1708. /*// define codec
  1709. _utils_CowUtils_js__WEBPACK_IMPORTED_MODULE_1__["default"].createHook({
  1710. property: "extensionCodec",
  1711. setter: (instance) => {
  1712. if (typeof _constants_js__WEBPACK_IMPORTED_MODULE_0__.codec.encoder !== 'undefined') {
  1713. _constants_js__WEBPACK_IMPORTED_MODULE_0__.codec.decoder = instance
  1714. _constants_js__WEBPACK_IMPORTED_MODULE_0__.codec.isReady = true
  1715. return
  1716. }
  1717. _constants_js__WEBPACK_IMPORTED_MODULE_0__.codec.encoder = instance
  1718. }
  1719. })*/
  1720. // define websocket
  1721. WebSocket.prototype.send = new Proxy(window.WebSocket.prototype.send, {
  1722. apply(target, instance, args) {
  1723. if (!_constants_js__WEBPACK_IMPORTED_MODULE_0__.socket.isReady) {
  1724. _constants_js__WEBPACK_IMPORTED_MODULE_0__.socket.setWebSocket(instance)
  1725. }
  1726. return target.apply(instance, args)
  1727. }
  1728. })
  1729. /***/
  1730. }),
  1731. /***/
  1732. "./src/modules/Placement.js":
  1733. /*!**********************************!*\
  1734. !*** ./src/modules/Placement.js ***!
  1735. \**********************************/
  1736. /***/
  1737. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  1738. __webpack_require__.r(__webpack_exports__);
  1739. /* harmony import */
  1740. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ../constants.js */ "./src/constants.js");
  1741. class Placement {
  1742. constructor() {
  1743. this.delay = 0
  1744. this.lastPlaceTick = 0
  1745. }
  1746. setDelay(_delay) {
  1747. this.delay = _delay
  1748. }
  1749. sendPlace(id, angle) {
  1750. const timeSincePlace = _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.ticker.ticks - this.lastPlaceTick
  1751. if (timeSincePlace < this.delay) return
  1752. const {
  1753. packets
  1754. } = _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.config.designations
  1755. const oldWeapon = _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.player.weaponIndex
  1756. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.sendPacket(packets.SELECT_BUILD, id)
  1757. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.sendPacket(packets.ATTACK_STATE, 1, angle, "by cowjs")
  1758. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.sendPacket(packets.ATTACK_STATE, 0, angle, "by cowjs")
  1759. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.sendPacket(packets.SELECT_BUILD, _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.player.weapons[Number(oldWeapon > 8)], true)
  1760. this.lastPlaceTick = _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.ticker.ticks
  1761. }
  1762. placeItem(groupIndex, {
  1763. angle
  1764. } = {}, callback) {
  1765. if (!_constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.player?.alive) return
  1766. const itemIndex = _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.player.items[groupIndex]
  1767. if (typeof itemIndex === 'undefined') return
  1768. const item = _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.items.list[itemIndex]
  1769. if (!_constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.player.isCanBuild(item)) return
  1770. angle = typeof angle === 'undefined' ? _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.player.lookAngle : angle
  1771. const scale = _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.player.scale + item.scale + (item.placeOffset || 0)
  1772. const placeX = _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.player.x2 + (scale * Math.cos(angle))
  1773. const placeY = _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.player.y2 + (scale * Math.sin(angle))
  1774. const isCanPlace = _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.objectsManager.checkItemLocation(placeX, placeY, item.scale, 0.6, item.id, false)
  1775. if (!item.consume && !isCanPlace) return
  1776.  
  1777. this.sendPlace(item.id, angle)
  1778.  
  1779. callback instanceof Function && callback()
  1780. }
  1781. }
  1782. /* harmony default export */
  1783. __webpack_exports__["default"] = (Placement);
  1784. /***/
  1785. }),
  1786. /***/
  1787. "./src/modules/Ticker.js":
  1788. /*!*******************************!*\
  1789. !*** ./src/modules/Ticker.js ***!
  1790. \*******************************/
  1791. /***/
  1792. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  1793. __webpack_require__.r(__webpack_exports__);
  1794. class Ticker {
  1795. constructor() {
  1796. this.ticks = 0
  1797. this.tickTasks = []
  1798. this.isClear = false
  1799. }
  1800. clear() {
  1801. this.tickTasks = []
  1802. this.isClear = true
  1803. }
  1804. addTickTask(callback) {
  1805. if (!(callback instanceof Function)) return
  1806. this.tickTasks.push(callback)
  1807. }
  1808. updateTicks() {
  1809. this.ticks += 1
  1810. if (this.isClear) {
  1811. this.isClear = false
  1812. return
  1813. }
  1814. if (this.tickTasks.length) {
  1815. this.tickTasks[0]()
  1816. this.tickTasks.shift()
  1817. }
  1818. }
  1819. }
  1820. /* harmony default export */
  1821. __webpack_exports__["default"] = (Ticker);
  1822. /***/
  1823. }),
  1824. /***/
  1825. "./src/modules/entities/Animal.js":
  1826. /*!****************************************!*\
  1827. !*** ./src/modules/entities/Animal.js ***!
  1828. \****************************************/
  1829. /***/
  1830. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  1831. __webpack_require__.r(__webpack_exports__);
  1832. /* harmony import */
  1833. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ../../constants.js */ "./src/constants.js");
  1834. /* harmony import */
  1835. var _Entity_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__( /*! ./Entity.js */ "./src/modules/entities/Entity.js");
  1836. class Animal extends _Entity_js__WEBPACK_IMPORTED_MODULE_1__["default"] {
  1837. constructor({
  1838. sid,
  1839. index,
  1840. x,
  1841. y,
  1842. dir
  1843. }) {
  1844. super({
  1845. sid
  1846. })
  1847. const {
  1848. CowUtils
  1849. } = window
  1850. let data = _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.items.aiTypes[index]
  1851. if (!data) data = {}
  1852. this.sid = sid
  1853. this.x = x
  1854. this.y = y
  1855. this.name = data.name || data.src
  1856. this.startX = data?.fixedSpawn ? x : null
  1857. this.startY = data?.fixedSpawn ? y : null
  1858. this.xVel = 0
  1859. this.yVel = 0
  1860. this.zIndex = 0
  1861. this.dir = CowUtils.fixAngle(dir)
  1862. this.dirPlus = 0
  1863. this.index = index
  1864. this.src = data.src
  1865. this.weightM = data.weightM
  1866. this.speed = data.speed
  1867. this.killScore = data.killScore
  1868. this.turnSpeed = data.turnSpeed
  1869. this.scale = data.scale
  1870. this.maxHealth = data.health
  1871. this.leapForce = data.leapForce
  1872. this.health = this.maxHealth
  1873. this.chargePlayer = data.chargePlayer
  1874. this.viewRange = data.viewRange
  1875. this.drop = data.drop
  1876. this.dmg = data.dmg
  1877. this.hostile = data.hostile
  1878. this.dontRun = data.dontRun
  1879. this.hitRange = data.hitRange
  1880. this.hitDelay = data.hitDelay
  1881. this.hitScare = data.hitScare
  1882. this.spriteMlt = data.spriteMlt
  1883. this.nameScale = data.nameScale
  1884. this.colDmg = data.colDmg
  1885. this.noTrap = data.noTrap
  1886. this.spawnDelay = data.spawnDelay
  1887. this.hitWait = 0
  1888. this.waitCount = 1000
  1889. this.moveCount = 0
  1890. this.targetDir = 0
  1891. this.runFrom = null
  1892. this.chargeTarget = null
  1893. this.dmgOverTime = {}
  1894. this.visible = true
  1895. }
  1896. disable() {
  1897. this.visible = false
  1898. }
  1899. setTickData(data) {
  1900. const time = Date.now()
  1901. this.index = data[1]
  1902. this.time1 = (this.time2 === undefined) ? time : this.time2
  1903. this.time2 = time
  1904. this.x1 = this.x
  1905. this.y1 = this.y
  1906. this.x2 = data[2]
  1907. this.y2 = data[3]
  1908. this.dir1 = (this.dir2 === undefined) ? data[4] : this.dir2
  1909. this.dir2 = data[4]
  1910. this.dir = this.dir2
  1911. this.health = data[5]
  1912. this.dt = 0
  1913. this.visible = true
  1914. }
  1915. }
  1916. /* harmony default export */
  1917. __webpack_exports__["default"] = (Animal);
  1918. /***/
  1919. }),
  1920. /***/
  1921. "./src/modules/entities/Entity.js":
  1922. /*!****************************************!*\
  1923. !*** ./src/modules/entities/Entity.js ***!
  1924. \****************************************/
  1925. /***/
  1926. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  1927. __webpack_require__.r(__webpack_exports__);
  1928. /* harmony import */
  1929. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ../../constants.js */ "./src/constants.js");
  1930. class Entity {
  1931. constructor({
  1932. id,
  1933. sid
  1934. }) {
  1935. this.id = id
  1936. this.sid = sid
  1937. this.name = "unknown"
  1938. this.dt = 0
  1939. this.x = 0
  1940. this.y = 0
  1941. this.x1 = this.x
  1942. this.y1 = this.y
  1943. this.x2 = this.x1
  1944. this.y2 = this.y1
  1945. this.dir = 0
  1946. this.dir1 = 0
  1947. this.dir2 = this.dir1
  1948. this.health = 100
  1949. this.maxHealth = this.health
  1950. this.scale = 35
  1951. this.zIndex = 0
  1952. }
  1953. get renderX() {
  1954. return this.x - _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.camera.xOffset
  1955. }
  1956. get renderY() {
  1957. return this.y - _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.camera.yOffset
  1958. }
  1959. setInitData(data) {
  1960. if (!Array.isArray(data) || !data?.length) return
  1961. this.id = data[0]
  1962. this.sid = data[1]
  1963. this.name = data[2]
  1964. this.x = data[3]
  1965. this.y = data[4]
  1966. this.dir = data[5]
  1967. this.health = data[6]
  1968. this.maxHealth = data[7]
  1969. this.scale = data[8]
  1970. if (typeof data[9] !== 'undefined') {
  1971. this.skinColor = data[9]
  1972. }
  1973. this.visible = false
  1974. }
  1975. setTo(x, y) {
  1976. if (typeof x !== 'number' || typeof y !== 'number') return
  1977. if (isNaN(x) || isNaN(y)) return
  1978. this.x = x
  1979. this.y = y
  1980. }
  1981. }
  1982. /* harmony default export */
  1983. __webpack_exports__["default"] = (Entity);
  1984. /***/
  1985. }),
  1986. /***/
  1987. "./src/modules/entities/GameObject.js":
  1988. /*!********************************************!*\
  1989. !*** ./src/modules/entities/GameObject.js ***!
  1990. \********************************************/
  1991. /***/
  1992. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  1993. __webpack_require__.r(__webpack_exports__);
  1994. /* harmony import */
  1995. var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ../../constants */ "./src/constants.js");
  1996. class GameObject {
  1997. constructor({
  1998. sid
  1999. }) {
  2000. const {
  2001. CowUtils
  2002. } = window
  2003. this.sid = sid
  2004. this.init = function(x, y, dir, scale, type, data, owner) {
  2005. data = typeof data === 'undefined' ? {} : data
  2006. this.x = x
  2007. this.y = y
  2008. this.dir = CowUtils.fixAngle(dir)
  2009. this.xWiggle = 0
  2010. this.yWiggle = 0
  2011. this.scale = scale
  2012. this.type = type
  2013. this.id = data.id
  2014. this.owner = owner
  2015. this.name = data.name
  2016. this.isItem = Boolean(this.id !== undefined)
  2017. this.group = data.group
  2018. this.health = data.health
  2019. this.maxHealth = data.health
  2020. this.layer = this.group !== undefined ? this.group.layer : this.type === 0 ? 3 : this.type === 2 ? 0 : this.type === 4 ? -1 : 2
  2021. this.sentTo = {}
  2022. this.gridLocations = []
  2023. this.doUpdate = data.doUpdate
  2024. this.colDiv = data.colDiv || 1
  2025. this.blocker = data.blocker
  2026. this.ignoreCollision = data.ignoreCollision
  2027. this.dontGather = data.dontGather
  2028. this.hideFromEnemy = data.hideFromEnemy
  2029. this.friction = data.friction
  2030. this.projDmg = data.projDmg
  2031. this.dmg = data.dmg
  2032. this.pDmg = data.pDmg
  2033. this.pps = data.pps
  2034. this.zIndex = data.zIndex || 0
  2035. this.turnSpeed = data.turnSpeed
  2036. this.turnSpeed2 = null
  2037. this.turnSpeed3 = null
  2038. this.req = data.req
  2039. this.trap = data.trap
  2040. this.healCol = data.healCol
  2041. this.teleport = data.teleport
  2042. this.boostSpeed = data.boostSpeed
  2043. this.projectile = data.projectile
  2044. this.shootRange = data.shootRange
  2045. this.shootRate = data.shootRate
  2046. this.shootCount = this.shootRate
  2047. this.spawnPoint = data.spawnPoint
  2048. this.visible = true
  2049. this.active = true
  2050. }
  2051. }
  2052. get renderX() {
  2053. return this.x + Number(this.xWiggle) - _constants__WEBPACK_IMPORTED_MODULE_0__.cow.camera.xOffset
  2054. }
  2055. get renderY() {
  2056. return this.y + Number(this.yWiggle) - _constants__WEBPACK_IMPORTED_MODULE_0__.cow.camera.yOffset
  2057. }
  2058. setVisible(_visible) {
  2059. if (typeof _visible !== 'boolean') return
  2060. this.visible = _visible
  2061. }
  2062. setActive(_active) {
  2063. if (typeof _active !== 'boolean') return
  2064. this.active = _active
  2065. }
  2066. getScale(scaleMult, hasColDiv) {
  2067. scaleMult = scaleMult || 1
  2068. const isVolume = this.isItem || this.type == 2 || this.type == 3 || this.type == 4
  2069. return this.scale * (isVolume ? 1 : (0.6 * scaleMult)) * (hasColDiv ? 1 : this.colDiv)
  2070. }
  2071. changeHealth(amount) {
  2072. amount = parseInt(amount)
  2073. this.health += amount
  2074. return this.health <= 0
  2075. }
  2076. doWiggle(dir) {
  2077. this.xWiggle += _constants__WEBPACK_IMPORTED_MODULE_0__.cow.config.gatherWiggle * Math.cos(dir)
  2078. this.yWiggle += _constants__WEBPACK_IMPORTED_MODULE_0__.cow.config.gatherWiggle * Math.sin(dir)
  2079. }
  2080. update() {
  2081. if (!this.visible) return
  2082. const {
  2083. renderer
  2084. } = _constants__WEBPACK_IMPORTED_MODULE_0__.cow
  2085. if (this.xWiggle) {
  2086. this.xWiggle *= Math.pow(0.99, renderer.delta)
  2087. }
  2088. if (this.yWiggle) {
  2089. this.yWiggle *= Math.pow(0.99, renderer.delta)
  2090. }
  2091. if (this.turnSpeed) {
  2092. this.dir += this.turnSpeed * renderer.delta
  2093. }
  2094. }
  2095. }
  2096. /* harmony default export */
  2097. __webpack_exports__["default"] = (GameObject);
  2098. /***/
  2099. }),
  2100. /***/
  2101. "./src/modules/entities/Player.js":
  2102. /*!****************************************!*\
  2103. !*** ./src/modules/entities/Player.js ***!
  2104. \****************************************/
  2105. /***/
  2106. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  2107. __webpack_require__.r(__webpack_exports__);
  2108. /* harmony import */
  2109. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ../../constants.js */ "./src/constants.js");
  2110. /* harmony import */
  2111. var _Entity_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__( /*! ./Entity.js */ "./src/modules/entities/Entity.js");
  2112. /* harmony import */
  2113. var _reloads_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__( /*! ./reloads.js */ "./src/modules/entities/reloads.js");
  2114. class Player extends _Entity_js__WEBPACK_IMPORTED_MODULE_1__["default"] {
  2115. constructor({
  2116. id,
  2117. sid
  2118. }) {
  2119. super({
  2120. id,
  2121. sid
  2122. })
  2123. this.skinColor = void 0
  2124. this.buildIndex = -1
  2125. this.weaponIndex = 0
  2126. this.weaponVariant = 0
  2127. this.team = ""
  2128. this.skinIndex = 0
  2129. this.tailIndex = 0
  2130. this.isLeader = false
  2131. this.iconIndex = 0
  2132. this.items = [0, 3, 6, 10]
  2133. this.weapons = [0]
  2134. this.skins = {}
  2135. this.tails = {}
  2136. const defineFreeCaps = (config, capType) => {
  2137. for (let i = 0; i < config.length; ++i) {
  2138. const cap = config[i]
  2139. if (cap.price > 0) continue
  2140. this[capType][cap.id] = true
  2141. }
  2142. }
  2143. defineFreeCaps(_constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.items.hats, "skins")
  2144. defineFreeCaps(_constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.items.accessories, "tails")
  2145. this.itemCounts = {}
  2146. this.gold = 100
  2147. this.stone = 100
  2148. this.wood = 100
  2149. this.food = 100
  2150. this.reloads = new _reloads_js__WEBPACK_IMPORTED_MODULE_2__["default"]()
  2151. this.maxXP = 300
  2152. this.XP = 0
  2153. this.age = 1
  2154. this.kills = 0
  2155. this.upgrAge = 2
  2156. this.upgradePoints = 0
  2157. this.hitTime = null
  2158. this.shameCount = 0
  2159. this.shameTimer = 0
  2160. this.speed = 0
  2161. this.moveDir = 0
  2162. this.isPlayer = true
  2163. this.lastDeath = {}
  2164. this.createdInstance = {}
  2165. this._updateCreatedInstance()
  2166. }
  2167. get isMe() {
  2168. return Boolean(this.sid === _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.player?.sid && _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.player?.alive)
  2169. }
  2170. get isAlly() {
  2171. return Boolean((this.sid === _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.player?.sid) || (this.team && this.team === _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.player.team))
  2172. }
  2173. get weapon() {
  2174. return _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.items.weapons[this.weaponIndex]
  2175. }
  2176. get lookAngle() {
  2177. return this.isMe ? _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.input.mouse.angle : (this.dir || this.dir2)
  2178. }
  2179. get skin() {
  2180. return _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.items.hats.searchById(this.skinIndex)
  2181. }
  2182. get tail() {
  2183. return _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.items.accessories.searchById(this.tailIndex)
  2184. }
  2185. _updateCreatedInstance() {
  2186. this.createdInstance = {}
  2187. const ignoreKeys = ["skins", "tails", "sid", "id", "lastDeath", "reloads"]
  2188. for (const key in this) {
  2189. if (key === "createdInstance") continue
  2190. if (ignoreKeys.includes(key)) continue
  2191. this.createdInstance[key] = this[key]
  2192. }
  2193. }
  2194. spawn() {
  2195. this.alive = true
  2196. if (!this.isMe) return
  2197. for (const key in this.createdInstance) {
  2198. const value = this.createdInstance[key]
  2199. this[key] = value
  2200. }
  2201. this._updateCreatedInstance()
  2202. this.reloads = new _reloads_js__WEBPACK_IMPORTED_MODULE_2__["default"]()
  2203. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.setInGame(true)
  2204. }
  2205. kill() {
  2206. if (!this.isMe) return
  2207. this.alive = false
  2208. this.lastDeath = {
  2209. x: this.x,
  2210. y: this.y
  2211. }
  2212. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.setInGame(false)
  2213. }
  2214. disable() {
  2215. this.visible = false
  2216. }
  2217. hasResources(item) {
  2218. for (let i = 0; i < item.req.length; i += 2) {
  2219. if (this[item.req[i]] >= Math.round(item.req[i + 1])) continue
  2220. return false
  2221. }
  2222. return true
  2223. }
  2224. isCanBuild(item) {
  2225. return this.hasResources(item)
  2226. }
  2227. setTickData(data) {
  2228. if (!Array.isArray(data) || !data?.length) return
  2229. const {
  2230. CowUtils
  2231. } = window
  2232. this.dt = 0
  2233. this.x1 = this.x
  2234. this.y1 = this.y
  2235. this.speed = CowUtils.getDistance(this.x2, this.y2, data[1], data[2])
  2236. this.x2 = data[1]
  2237. this.y2 = data[2]
  2238. this.moveDir = CowUtils.getDirection(this.x1, this.y1, this.x2, this.y2)
  2239. this.dir1 = this.dir2 !== null ? this.dir2 : data[3]
  2240. this.dir2 = data[3]
  2241. this.time1 = this.time2 !== null ? this.time2 : Date.now()
  2242. this.time2 = Date.now()
  2243. this.buildIndex = data[4]
  2244. this.weaponIndex = data[5]
  2245. this.weaponVariant = data[6]
  2246. this.team = data[7]
  2247. this.isLeader = data[8]
  2248. this.skinIndex = data[9]
  2249. this.tailIndex = data[10]
  2250. this.iconIndex = data[11]
  2251. this.zIndex = data[12]
  2252. this.visible = true
  2253. this.tick()
  2254. }
  2255. updateShame() {
  2256. const timeSinceHit = _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.ticker.ticks - this.hitTime
  2257. if (timeSinceHit < 2) {
  2258. this.shameCount += 1
  2259. if (this.shameCount >= 8) {
  2260. this.shameTimer = 30000
  2261. this.shameCount = 0
  2262. }
  2263. } else {
  2264. this.shameCount = Math.max(0, this.shameCount - 2)
  2265. }
  2266. }
  2267. changeHealth(_health) {
  2268. if (this.health < _health) {
  2269. this.updateShame()
  2270. this.hitTime = 0
  2271. } else {
  2272. this.hitTime = _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.ticker.ticks
  2273. }
  2274. this.health = _health
  2275. }
  2276. onGather(didHit, weaponIndex) {
  2277. const reloadType = weaponIndex > 8 ? "secondary" : "primary"
  2278. const currentReload = this.reloads[reloadType]
  2279. if (this.weaponIndex === currentReload.id) {
  2280. currentReload.count = 0
  2281. currentReload.date = Date.now()
  2282. }
  2283. const skin = this.skin
  2284. if (didHit) {
  2285. const {
  2286. CowUtils
  2287. } = window
  2288. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.objectsManager.eachVisible((gameObject) => {
  2289. if (!gameObject.isItem || gameObject.dontGather) return
  2290. const scale = gameObject.scale || gameObject.getScale()
  2291. const distance = CowUtils.getDistance(this, gameObject) - scale
  2292. const angle = CowUtils.getDirection(gameObject, this)
  2293. const angleDistance = CowUtils.getAngleDist(angle, this.dir2)
  2294. const isInAngle = angleDistance <= _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.config.gatherAngle
  2295. const isInRange = distance <= this.weapon.range
  2296. if (!isInAngle || !isInRange) return
  2297. const damage = this.weapon.dmg * (_constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.items.variants[this.weaponVariant].val || 1)
  2298. const damageAmount = damage * (this.weapon.sDmg || 1) * (skin?.bDmg || 1)
  2299.  
  2300. gameObject.changeHealth(-(damageAmount))
  2301. })
  2302. }
  2303. }
  2304. updateReloads() {
  2305. const reloadType = this.weaponIndex > 8 ? "secondary" : "primary"
  2306. const currentReload = this.reloads[reloadType]
  2307.  
  2308. if (currentReload.id != this.weapon.id) {
  2309. currentReload.setData(this.weapon, this.weaponVariant)
  2310. }
  2311. if (this.weaponVariant != currentReload.rarity) {
  2312. currentReload.rarity = this.weaponVariant
  2313. }
  2314. if (this.weaponIndex === currentReload.id && this.buildIndex === -1) {
  2315. if (currentReload.count < currentReload.max) {
  2316. currentReload.add()
  2317. }
  2318. }
  2319. this.reloads[reloadType] = currentReload
  2320. if (this.reloads.turret.count < this.reloads.turret.max) {
  2321. this.reloads.turret.add()
  2322. }
  2323. }
  2324. tick() {
  2325. this.updateReloads()
  2326. if (this.skinIndex != 45) {
  2327. if (this.shameCount === 8) {
  2328. this.shameTimer = 0
  2329. this.shameCont = 0
  2330. }
  2331. if (this.shameTimer > 0) this.shameTimer = 0
  2332. } else {
  2333. if (this.shameCount != 8) {
  2334. this.shameCount = 8
  2335. this.shameTimer = 270
  2336. }
  2337. if (this.shameTimer > 0) this.shameTimer -= 1
  2338. }
  2339. }
  2340. canSee(other) {
  2341. if (!other) return false
  2342. const dx = Math.abs(other.x - this.x) - other.scale
  2343. const dy = Math.abs(other.y - this.y) - other.scale
  2344. return dx <= (_constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.config.maxScreenWidth / 2) * 1.3 && dy <= (_constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.config.maxScreenHeight / 2) * 1.3
  2345. }
  2346. }
  2347. /* harmony default export */
  2348. __webpack_exports__["default"] = (Player);
  2349. /***/
  2350. }),
  2351. /***/
  2352. "./src/modules/entities/reloads.js":
  2353. /*!*****************************************!*\
  2354. !*** ./src/modules/entities/reloads.js ***!
  2355. \*****************************************/
  2356. /***/
  2357. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  2358. __webpack_require__.r(__webpack_exports__);
  2359. class Reload {
  2360. constructor(id, speed, ticks) {
  2361. const tick = 111
  2362. ticks = ticks || Math.ceil(speed / tick)
  2363. this.id = id
  2364. this.count = ticks
  2365. this.date = 0
  2366. this.date2 = this.date
  2367. this.max = ticks
  2368. this.max2 = speed
  2369. this.rarity = 0
  2370. this.done = true
  2371. this.active = false
  2372. const {
  2373. CowUtils
  2374. } = window
  2375. this._default = CowUtils.removeProto(this)
  2376. }
  2377. get dif() {
  2378. return this.count / this.max
  2379. }
  2380. get smoothValue() {
  2381. if (this.done) return 1
  2382. return (this.date2 - this.date) / this.max2
  2383. }
  2384. setData(weapon, weaponVariant) {
  2385. this.id = weapon.id
  2386. this.max = weapon.speed ? Math.ceil(weapon.speed / (1e3 / 9)) : 0
  2387. this.max2 = weapon.speed
  2388. this.count = parseInt(this.max)
  2389. this.done = true
  2390. this.rarity = weaponVariant
  2391. this.active = true
  2392. }
  2393. add() {
  2394. this.count += 1
  2395. this.count = parseInt(this.count)
  2396. this.done = this.count === this.max
  2397. }
  2398. clear() {
  2399. this.count = 0
  2400. this.done = false
  2401. this.date = Date.now()
  2402. }
  2403. }
  2404. class Reloads {
  2405. constructor() {
  2406. this.primary = new Reload(5, 300),
  2407. this.secondary = new Reload(15, 1500),
  2408. this.turret = new Reload(null, 2500, 23)
  2409. }
  2410. }
  2411. /* harmony default export */
  2412. __webpack_exports__["default"] = (Reloads);
  2413. /***/
  2414. }),
  2415. /***/
  2416. "./src/modules/input/Input.js":
  2417. /*!************************************!*\
  2418. !*** ./src/modules/input/Input.js ***!
  2419. \************************************/
  2420. /***/
  2421. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  2422. __webpack_require__.r(__webpack_exports__);
  2423. /* harmony import */
  2424. var _Keyboard_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ./Keyboard.js */ "./src/modules/input/Keyboard.js");
  2425. /* harmony import */
  2426. var _Mouse_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__( /*! ./Mouse.js */ "./src/modules/input/Mouse.js");
  2427. class Input {
  2428. constructor() {
  2429. this.keyboard = new _Keyboard_js__WEBPACK_IMPORTED_MODULE_0__["default"]()
  2430. this.mouse = new _Mouse_js__WEBPACK_IMPORTED_MODULE_1__["default"]()
  2431. }
  2432. }
  2433. /* harmony default export */
  2434. __webpack_exports__["default"] = (Input);
  2435. /***/
  2436. }),
  2437. /***/
  2438. "./src/modules/input/Keyboard.js":
  2439. /*!***************************************!*\
  2440. !*** ./src/modules/input/Keyboard.js ***!
  2441. \***************************************/
  2442. /***/
  2443. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  2444. __webpack_require__.r(__webpack_exports__);
  2445. class Keyboard {
  2446. constructor() {
  2447. this.activeKeys = new Map()
  2448. this.events = new Map()
  2449. this.init()
  2450. }
  2451. on(keyName, listener, options = {
  2452. repeat: true
  2453. }) {
  2454. if (!(listener instanceof Function)) return
  2455. if (!this.events.has(keyName)) {
  2456. this.events.set(keyName, new Map())
  2457. }
  2458. const listeners = this.events.get(keyName)
  2459. const id = parseInt(Date.now() / 1000 + (Math.random() * 100e3))
  2460. const value = {
  2461. listener,
  2462. options
  2463. }
  2464. listeners.set(id, value)
  2465. return {
  2466. rebind: (newKeyName) => {
  2467. const listener = this.events.get(keyName).get(id)
  2468. if (this.events.get(keyName).has(id)) {
  2469. this.events.get(keyName).delete(id)
  2470. }
  2471. return this.on(newKeyName, listener.listener, listener.options)
  2472. }
  2473. }
  2474. }
  2475. trigger(code, doRepeat) {
  2476. this.events.forEach((eventsChunk, keyName) => {
  2477. if (!eventsChunk.size || keyName !== code) return
  2478. eventsChunk.forEach((event) => {
  2479. if (!event?.options?.repeat && doRepeat) return
  2480. event.listener()
  2481. })
  2482. })
  2483. }
  2484. onKeydown(event) {
  2485. if (!this.activeKeys.get(event.code)) {
  2486. this.activeKeys.set(event.code, true)
  2487. this.activeKeys.set(event.which, true)
  2488. this.trigger(event.code)
  2489. this.trigger(event.which)
  2490. }
  2491. }
  2492. onKeyup(event) {
  2493. if (this.activeKeys.get(event.code)) {
  2494. this.activeKeys.set(event.code, false)
  2495. this.activeKeys.set(event.which, false)
  2496. }
  2497. }
  2498. update() {
  2499. this.activeKeys.forEach((state, keyName) => {
  2500. if (!state) return
  2501. this.trigger(keyName, true)
  2502. })
  2503. }
  2504. init() {
  2505. window.addEventListener("keydown", this.onKeydown.bind(this))
  2506. window.addEventListener("keyup", this.onKeyup.bind(this))
  2507. }
  2508. }
  2509. /* harmony default export */
  2510. __webpack_exports__["default"] = (Keyboard);
  2511. /***/
  2512. }),
  2513. /***/
  2514. "./src/modules/input/Mouse.js":
  2515. /*!************************************!*\
  2516. !*** ./src/modules/input/Mouse.js ***!
  2517. \************************************/
  2518. /***/
  2519. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  2520. __webpack_require__.r(__webpack_exports__);
  2521. /* harmony import */
  2522. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ../../constants.js */ "./src/constants.js");
  2523. class Mouse {
  2524. constructor() {
  2525. this.x = void 0
  2526. this.y = void 0
  2527. this.isDown = false
  2528. this.isUp = !this.isDown
  2529. this.lastClick = null
  2530. this.lastMove = null
  2531. window.addEventListener("load", this.init.bind(this))
  2532. }
  2533. get angle() {
  2534. const canvas = document.getElementById("gameCanvas") || _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.renderer.canvas
  2535. if (!canvas) return
  2536. const width = canvas.clientWidth / 2
  2537. const height = canvas.clientHeight / 2
  2538. return Math.atan2(this.y - height, this.x - width)
  2539. }
  2540. setTo(x, y) {
  2541. if (typeof x !== 'number' || typeof y !== 'number') return
  2542. this.x = x
  2543. this.y = y
  2544. this.lastMove = Date.now()
  2545. }
  2546. setState(_isDown) {
  2547. this.isDown = _isDown
  2548. this.isUp = !_isDown
  2549. this.lastClick = Date.now()
  2550. }
  2551. onMousemove(event) {
  2552. this.setTo(event.clientX, event.clientY)
  2553. }
  2554. onMousedown() {
  2555. this.setState(true)
  2556. }
  2557. onMouseup() {
  2558. this.setState(false)
  2559. }
  2560. init() {
  2561. const touchControls = document.getElementById("touch-controls-fullscreen")
  2562. touchControls.addEventListener("mousemove", this.onMousemove.bind(this))
  2563. touchControls.addEventListener("mousedown", this.onMousedown.bind(this))
  2564. touchControls.addEventListener("mouseup", this.onMouseup.bind(this))
  2565. }
  2566. }
  2567. /* harmony default export */
  2568. __webpack_exports__["default"] = (Mouse);
  2569. /***/
  2570. }),
  2571. /***/
  2572. "./src/modules/managers/AnimalsManager.js":
  2573. /*!************************************************!*\
  2574. !*** ./src/modules/managers/AnimalsManager.js ***!
  2575. \************************************************/
  2576. /***/
  2577. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  2578. __webpack_require__.r(__webpack_exports__);
  2579. /* harmony import */
  2580. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ../../constants.js */ "./src/constants.js");
  2581. /* harmony import */
  2582. var _entities_Animal_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__( /*! ../entities/Animal.js */ "./src/modules/entities/Animal.js");
  2583. /* harmony import */
  2584. var _entities_Player_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__( /*! ../entities/Player.js */ "./src/modules/entities/Player.js");
  2585. class AnimalsManager {
  2586. constructor() {
  2587. this.animals = new Map()
  2588. this.animalsInStream = 0
  2589. }
  2590. get list() {
  2591. return [...this.animals.values()]
  2592. }
  2593. getById(sid) {
  2594. return this.animals.get(sid)
  2595. }
  2596. each(callback) {
  2597. this.animals.forEach(callback)
  2598. }
  2599. eachVisible(callback) {
  2600. this.each((animal) => {
  2601. if (!animal.visible) return
  2602. callback(animal)
  2603. })
  2604. }
  2605. updateAnimals(content) {
  2606. const chunkSize = 7
  2607.  
  2608. this.animalsInStream = 0
  2609.  
  2610. this.each((animal) => animal.disable())
  2611.  
  2612. if (!content?.length) return
  2613.  
  2614. for (let i = 0; i < content.length; i += chunkSize) {
  2615. const chunk = content.slice(i, i + chunkSize)
  2616. if (!this.animals.has(chunk[0])) {
  2617. const animal = new _entities_Animal_js__WEBPACK_IMPORTED_MODULE_1__["default"]({
  2618. sid: chunk[0],
  2619. index: chunk[1],
  2620. x: chunk[2],
  2621. y: chunk[3],
  2622. dir: chunk[4]
  2623. })
  2624. this.animals.set(chunk[0], animal)
  2625. continue
  2626. }
  2627. const animal = this.animals.get(chunk[0])
  2628. animal.setTickData(chunk)
  2629. animal.visible = true
  2630. this.animalsInStream += 1
  2631. }
  2632. }
  2633. interpolate() {
  2634. const {
  2635. renderer
  2636. } = _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow
  2637. const lastTime = renderer.nowUpdate - (1000 / (window.config?.serverUpdateRate || 10))
  2638.  
  2639. this.eachVisible((animal) => {
  2640. animal.dt += renderer.delta
  2641. const rate = 170
  2642. const tmpRate = Math.min(1.7, animal.dt / rate)
  2643. const xDif = animal.x2 - animal.x1
  2644. const yDif = animal.y2 - animal.y1
  2645. animal.setTo(
  2646. animal.x1 + (xDif * tmpRate),
  2647. animal.y1 + (yDif * tmpRate)
  2648. )
  2649. })
  2650. }
  2651. update() {
  2652. this.interpolate()
  2653. }
  2654. }
  2655. /* harmony default export */
  2656. __webpack_exports__["default"] = (AnimalsManager);
  2657. /***/
  2658. }),
  2659. /***/
  2660. "./src/modules/managers/ObjectsManager.js":
  2661. /*!************************************************!*\
  2662. !*** ./src/modules/managers/ObjectsManager.js ***!
  2663. \************************************************/
  2664. /***/
  2665. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  2666. __webpack_require__.r(__webpack_exports__);
  2667. /* harmony import */
  2668. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ../../constants.js */ "./src/constants.js");
  2669. /* harmony import */
  2670. var _entities_GameObject_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__( /*! ../entities/GameObject.js */ "./src/modules/entities/GameObject.js");
  2671. class ObjectsManager {
  2672. constructor() {
  2673. this.objects = new Map()
  2674. this.objectsInStream = 0
  2675. }
  2676. get list() {
  2677. return [...this.objects.values()]
  2678. }
  2679. getById(sid) {
  2680. return this.objects.get(sid)
  2681. }
  2682. each(callback) {
  2683. this.objects.forEach(callback)
  2684. }
  2685. eachVisible(callback) {
  2686. const visibleObjects = this.list.filter((object) => object.active && object.visible)
  2687. for (let i = 0; i < visibleObjects.length; i++) {
  2688. const gameObject = visibleObjects[i]
  2689. if (!gameObject.visible || !gameObject.active) return
  2690. callback(gameObject)
  2691. }
  2692. }
  2693. disableAllObjects(sid) {
  2694. this.each((gameObject) => {
  2695. if (!gameObject.owner || gameObject.owner.sid !== sid) return
  2696. this.objects.delete(gameObject.sid)
  2697. })
  2698. }
  2699. onAddGameObject(gameObject) {}
  2700. add(sid, x, y, dir, scale, type, data, setSID, owner) {
  2701. let tmpObject = this.getById(sid)
  2702. if (!tmpObject) {
  2703. tmpObject = new _entities_GameObject_js__WEBPACK_IMPORTED_MODULE_1__["default"]({
  2704. sid
  2705. })
  2706. this.objects.set(sid, tmpObject)
  2707. }
  2708. if (setSID) tmpObject.sid = sid
  2709. tmpObject.init(x, y, dir, scale, type, data, setSID, owner)
  2710. this.onAddGameObject(tmpObject)
  2711. }
  2712. checkItemLocation(x, y, scale, scaleMult, indx, ignoreWater, getBuilding) {
  2713. const {
  2714. CowUtils
  2715. } = window
  2716. const position = {
  2717. x,
  2718. y
  2719. }
  2720. let isCanPlace = true
  2721. let building = null
  2722.  
  2723. this.eachVisible((gameObject) => {
  2724. if (!isCanPlace) return
  2725. const blockScale = (gameObject.blocker ? gameObject.blocker : (gameObject.isItem ? gameObject.scale : gameObject.getScale(scaleMult, gameObject.isItem)))
  2726. if (CowUtils.getDistance(position, gameObject) < (scale + blockScale)) {
  2727. isCanPlace = false
  2728. building = gameObject
  2729. }
  2730. })
  2731. if (
  2732. !ignoreWater && indx != 18 &&
  2733. y >= (_constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.config.mapScale / 2) - (_constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.config.riverWidth / 2) &&
  2734. y <= (_constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.config.mapScale / 2) + (_constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.config.riverWidth / 2)
  2735. ) {
  2736. isCanPlace = false
  2737. }
  2738. return !getBuilding ? isCanPlace : building
  2739. }
  2740. update() {
  2741. this.objectsInStream = 0
  2742. this.each((gameObject) => {
  2743. if (!_constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.player.canSee(gameObject)) {
  2744. return gameObject.setVisible(false)
  2745. }
  2746. gameObject.setVisible(true)
  2747. this.objectsInStream += 1
  2748. // if (!gameObject.doUpdate) return
  2749. gameObject.update()
  2750. })
  2751. }
  2752. }
  2753. /* harmony default export */
  2754. __webpack_exports__["default"] = (ObjectsManager);
  2755. /***/
  2756. }),
  2757. /***/
  2758. "./src/modules/managers/PlayersManager.js":
  2759. /*!************************************************!*\
  2760. !*** ./src/modules/managers/PlayersManager.js ***!
  2761. \************************************************/
  2762. /***/
  2763. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  2764. __webpack_require__.r(__webpack_exports__);
  2765. /* harmony import */
  2766. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ../../constants.js */ "./src/constants.js");
  2767. /* harmony import */
  2768. var _entities_Player_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__( /*! ../entities/Player.js */ "./src/modules/entities/Player.js");
  2769. class PlayersManager {
  2770. constructor() {
  2771. this.players = new Map()
  2772. this.playersInStream = 0
  2773. }
  2774. get list() {
  2775. return [...this.players.values()]
  2776. }
  2777. getById(sid) {
  2778. return this.players.get(sid)
  2779. }
  2780. each(callback) {
  2781. this.players.forEach(callback)
  2782. }
  2783. eachVisible(callback) {
  2784. this.each((player) => {
  2785. if (!player.visible) return
  2786. callback(player)
  2787. })
  2788. }
  2789. addPlayer(content, isYou) {
  2790. if (!this.players.has(content[1])) {
  2791. this.players.set(content[1], new _entities_Player_js__WEBPACK_IMPORTED_MODULE_1__["default"]({
  2792. id: content[0],
  2793. sid: content[1]
  2794. }))
  2795. }
  2796. const player = this.players.get(content[1])
  2797. player.visible = false
  2798. player.x2 = void 0
  2799. player.y2 = void 0
  2800. player.spawn()
  2801. player.setInitData(content)
  2802. if (isYou) {
  2803. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.setPlayer(player)
  2804. }
  2805. }
  2806. removePlayer(sid) {
  2807. if (!this.players.has(sid)) return
  2808. this.players.delete(sid)
  2809. }
  2810. updatePlayers(content) {
  2811. const chunkSize = 13
  2812. this.playersInStream = 0
  2813. this.eachVisible((player) => {
  2814. player.disable()
  2815. })
  2816. for (let i = 0; i < content.length; i += chunkSize) {
  2817. const chunk = content.slice(i, i + chunkSize)
  2818. if (!this.players.has(chunk[0])) continue
  2819. const player = this.players.get(chunk[0])
  2820. player.setTickData(chunk)
  2821. this.playersInStream += 1
  2822. }
  2823. }
  2824. interpolate() {
  2825. const {
  2826. CowUtils
  2827. } = window
  2828. const {
  2829. renderer
  2830. } = _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow
  2831. const lastTime = renderer.nowUpdate - (1000 / (window.config?.serverUpdateRate || 10))
  2832. this.eachVisible((player) => {
  2833. player.dt += renderer.delta
  2834. const total = player.time2 - player.time1
  2835. const fraction = lastTime - player.time1
  2836. const ratio = total / fraction
  2837. const rate = 170
  2838. const tmpRate = Math.min(1.7, player.dt / rate)
  2839. const xDif = player.x2 - player.x1
  2840. const yDif = player.y2 - player.y1
  2841. player.setTo(
  2842. player.x1 + (xDif * tmpRate),
  2843. player.y1 + (yDif * tmpRate)
  2844. )
  2845. player.dir = CowUtils.lerpAngle(player.dir2, player.dir1, Math.min(1.2, ratio))
  2846. })
  2847. }
  2848. update() {
  2849. this.interpolate()
  2850. this.eachVisible((player) => {
  2851. const reloadType = player.weaponIndex > 8 ? "secondary" : "primary"
  2852. const currentReload = player.reloads[reloadType]
  2853.  
  2854. if (player.weaponIndex === currentReload.id) {
  2855. if (currentReload.count < currentReload.max) {
  2856. currentReload.date2 = Date.now()
  2857. }
  2858. }
  2859. })
  2860. }
  2861. }
  2862. /* harmony default export */
  2863. __webpack_exports__["default"] = (PlayersManager);
  2864. /***/
  2865. }),
  2866. /***/
  2867. "./src/modules/plugins/AutoReconect.js":
  2868. /*!*********************************************!*\
  2869. !*** ./src/modules/plugins/AutoReconect.js ***!
  2870. \*********************************************/
  2871. /***/
  2872. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  2873. __webpack_require__.r(__webpack_exports__);
  2874. /* harmony import */
  2875. var _Plugin_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ./Plugin.js */ "./src/modules/plugins/Plugin.js");
  2876. class AutoReconect extends _Plugin_js__WEBPACK_IMPORTED_MODULE_0__["default"] {
  2877. constructor() {
  2878. super({
  2879. name: "auto-reconect",
  2880. description: "Automatically reloads the page after the connection is closed or the game could not be logged in",
  2881. once: true
  2882. })
  2883. }
  2884. execute() {
  2885. super.execute(() => {
  2886. location.reload()
  2887. })
  2888. }
  2889. }
  2890. /* harmony default export */
  2891. __webpack_exports__["default"] = (AutoReconect);
  2892. /***/
  2893. }),
  2894. /***/
  2895. "./src/modules/plugins/Plugin.js":
  2896. /*!***************************************!*\
  2897. !*** ./src/modules/plugins/Plugin.js ***!
  2898. \***************************************/
  2899. /***/
  2900. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  2901. __webpack_require__.r(__webpack_exports__);
  2902. class Plugin {
  2903. constructor({
  2904. name,
  2905. description,
  2906. once,
  2907. isCanChangeActiveState = true
  2908. }) {
  2909. this.name = name
  2910. this.description = description
  2911. this.once = once
  2912. this._isCanChangeActiveState = isCanChangeActiveState
  2913. this.isActiveState = false
  2914. this.lastActive = null
  2915. }
  2916. setActiveState(state) {
  2917. if (!this._isCanChangeActiveState) return
  2918. this.isActiveState = state
  2919. }
  2920. execute(callback) {
  2921. if (this.once && this.lastActive) return
  2922. if (callback instanceof Function) {
  2923. callback()
  2924. }
  2925. this.lastActive = Date.now()
  2926. }
  2927. }
  2928. /* harmony default export */
  2929. __webpack_exports__["default"] = (Plugin);
  2930. /***/
  2931. }),
  2932. /***/
  2933. "./src/modules/plugins/index.js":
  2934. /*!**************************************!*\
  2935. !*** ./src/modules/plugins/index.js ***!
  2936. \**************************************/
  2937. /***/
  2938. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  2939. __webpack_require__.r(__webpack_exports__);
  2940. /* harmony export */
  2941. __webpack_require__.d(__webpack_exports__, {
  2942. /* harmony export */
  2943. AutoReconect: function() {
  2944. return /* reexport safe */ _AutoReconect_js__WEBPACK_IMPORTED_MODULE_0__["default"];
  2945. }
  2946. /* harmony export */
  2947. });
  2948. /* harmony import */
  2949. var _AutoReconect_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ./AutoReconect.js */ "./src/modules/plugins/AutoReconect.js");
  2950. /***/
  2951. }),
  2952. /***/
  2953. "./src/modules/render/Camera.js":
  2954. /*!**************************************!*\
  2955. !*** ./src/modules/render/Camera.js ***!
  2956. \**************************************/
  2957. /***/
  2958. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  2959. __webpack_require__.r(__webpack_exports__);
  2960. /* harmony import */
  2961. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ../../constants.js */ "./src/constants.js");
  2962. class Camera {
  2963. constructor() {
  2964. this.x = 0
  2965. this.y = 0
  2966. this.distance = 0
  2967. this.angle = 0
  2968. this.speed = 0
  2969. this.xOffset = 0
  2970. this.yOffset = 0
  2971. }
  2972. setTo(x, y) {
  2973. this.x = x
  2974. this.y = y
  2975. }
  2976. update() {
  2977. if (_constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.player?.alive) {
  2978. const {
  2979. CowUtils
  2980. } = window
  2981. this.distance = CowUtils.getDistance(this, _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.player)
  2982. this.angle = CowUtils.getDirection(_constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.player, this)
  2983. this.speed = Math.min(this.distance * .01 * _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.renderer.delta, this.distance)
  2984. if (this.distance > .05) {
  2985. this.x += this.speed * Math.cos(this.angle)
  2986. this.y += this.speed * Math.sin(this.angle)
  2987. } else {
  2988. this.setTo(
  2989. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.player.x,
  2990. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.player.y
  2991. )
  2992. }
  2993. } else {
  2994. this.setTo(
  2995. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.config.mapScale / 2,
  2996. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.config.mapScale / 2
  2997. )
  2998. }
  2999. this.xOffset = this.x - _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.config.maxScreenWidth / 2
  3000. this.yOffset = this.y - _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.config.maxScreenHeight / 2
  3001. }
  3002. }
  3003. /* harmony default export */
  3004. __webpack_exports__["default"] = (Camera);
  3005. /***/
  3006. }),
  3007. /***/
  3008. "./src/modules/render/Renderer.js":
  3009. /*!****************************************!*\
  3010. !*** ./src/modules/render/Renderer.js ***!
  3011. \****************************************/
  3012. /***/
  3013. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  3014. __webpack_require__.r(__webpack_exports__);
  3015. /* harmony import */
  3016. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ../../constants.js */ "./src/constants.js");
  3017. class Renderer {
  3018. constructor() {
  3019. this.canvas = void 0
  3020. this.context = void 0
  3021. this.renders = new Map()
  3022. this.nowUpdate = void 0
  3023. this.lastUpdate = this.nowUpdate
  3024. this.delta = 0
  3025. window.addEventListener("load", this.init.bind(this))
  3026. }
  3027. addRender(renderKey, renderFunc) {
  3028. if (typeof renderKey !== 'string') return
  3029. if (!(renderFunc instanceof Function)) return
  3030. if (!this.renders.has(renderKey)) {
  3031. this.renders.set(renderKey, new Map())
  3032. }
  3033. const rendersChunk = this.renders.get(renderKey)
  3034. rendersChunk.set(rendersChunk.size + 1, renderFunc)
  3035. }
  3036. _updateAll() {
  3037. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.camera.update()
  3038. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.playersManager.update()
  3039. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.objectsManager.update()
  3040. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.animalsManager.update()
  3041. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.input.keyboard.update()
  3042. }
  3043. updateFrame() {
  3044. this.nowUpdate = Date.now()
  3045. this.delta = this.nowUpdate - this.lastUpdate
  3046. this.lastUpdate = this.nowUpdate
  3047. requestAnimationFrame(this.updateFrame.bind(this))
  3048. this._updateAll()
  3049. if (!_constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.player) return
  3050. this.renders.forEach((rendersChunk) => {
  3051. if (!rendersChunk.size) return
  3052. rendersChunk.forEach((render) => {
  3053. render()
  3054. })
  3055. })
  3056. }
  3057. init() {
  3058. this.canvas = document.getElementById("gameCanvas")
  3059. this.context = this.canvas.getContext("2d")
  3060. this.updateFrame()
  3061. }
  3062. }
  3063. /* harmony default export */
  3064. __webpack_exports__["default"] = (Renderer);
  3065. /***/
  3066. }),
  3067. /***/
  3068. "./src/modules/socket/Handler.js":
  3069. /*!***************************************!*\
  3070. !*** ./src/modules/socket/Handler.js ***!
  3071. \***************************************/
  3072. /***/
  3073. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  3074. __webpack_require__.r(__webpack_exports__);
  3075. /* harmony import */
  3076. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ../../constants.js */ "./src/constants.js");
  3077. /* harmony import */
  3078. var _events_getEvents_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__( /*! ./events/getEvents.js */ "./src/modules/socket/events/getEvents.js");
  3079. class Handler {
  3080. static handlerKeys = {
  3081. "socket-open": "onSocketOpen",
  3082. "socket-message": "onSocketMessage",
  3083. "socket-close": "onSocketClose"
  3084. }
  3085. constructor({
  3086. socket
  3087. }) {
  3088. this.socket = socket
  3089. this.packetsListeners = new Map()
  3090. this.firstMessage = false
  3091. }
  3092. onPacket(packetName, listener) {
  3093. if (typeof packetName !== 'string') return
  3094. if (!(listener instanceof Function)) return
  3095. if (!this.packetsListeners.has(packetName)) {
  3096. this.packetsListeners.set(packetName, new Map())
  3097. }
  3098. const listeners = this.packetsListeners.get(packetName)
  3099. listeners.set(listeners.size + 1, listener)
  3100. }
  3101. onSocketOpen() {}
  3102. onSocketMessage(event) {
  3103. if (!this.firstMessage) {
  3104. const events = (0, _events_getEvents_js__WEBPACK_IMPORTED_MODULE_1__["default"])()
  3105. for (const event in events) {
  3106. this.onPacket(event, events[event])
  3107. }
  3108. this.firstMessage = true
  3109. }
  3110. const {
  3111. data
  3112. } = event
  3113. if (!(data instanceof ArrayBuffer)) return
  3114. const binary = new Uint8Array(data)
  3115. const decoded = _constants_js__WEBPACK_IMPORTED_MODULE_0__.codec.decoder.decode(binary)
  3116. if (!decoded.length) return
  3117. const type = decoded[0]
  3118. const content = decoded[1]
  3119. this.packetsListeners.forEach((packetListeners, packetName) => {
  3120. if (!packetListeners.size) return
  3121. if (packetName !== type) return
  3122. packetListeners.forEach((packetListener) => {
  3123. packetListener(...content)
  3124. })
  3125. })
  3126. }
  3127. onSocketClose() {
  3128. const {
  3129. plugins
  3130. } = _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.config.designations
  3131. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.executePlugin(plugins.AUTO_RECONECT)
  3132. }
  3133. handle(handlerKey, event) {
  3134. const listenerName = Handler.handlerKeys[handlerKey]
  3135. if (typeof listenerName === 'undefined') return
  3136. const listener = this[listenerName]
  3137. if (!(listener instanceof Function)) return
  3138. listener.call(this, event)
  3139. }
  3140. }
  3141. /* harmony default export */
  3142. __webpack_exports__["default"] = (Handler);
  3143. /***/
  3144. }),
  3145. /***/
  3146. "./src/modules/socket/Manager.js":
  3147. /*!***************************************!*\
  3148. !*** ./src/modules/socket/Manager.js ***!
  3149. \***************************************/
  3150. /***/
  3151. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  3152. __webpack_require__.r(__webpack_exports__);
  3153. class Manager {
  3154. static triggerKeys = {
  3155. "set-websocket": "onWebSocketSetted"
  3156. }
  3157. constructor({
  3158. socket
  3159. }) {
  3160. this.socket = socket
  3161. }
  3162. onWebSocketSetted() {
  3163. const {
  3164. handler
  3165. } = this.socket
  3166. this.socket.onEvent("open", handler.handle.bind(handler, "socket-open"))
  3167. this.socket.onEvent("message", handler.handle.bind(handler, "socket-message"))
  3168. this.socket.onEvent("close", handler.handle.bind(handler, "socket-close"))
  3169. }
  3170. trigger(triggerKey, ...props) {
  3171. const listenerName = Manager.triggerKeys[triggerKey]
  3172. if (typeof listenerName === 'undefined') return
  3173. const listener = this[listenerName]
  3174. if (!(listener instanceof Function)) return
  3175. listener.call(this, ...props)
  3176. }
  3177. }
  3178. /* harmony default export */
  3179. __webpack_exports__["default"] = (Manager);
  3180. /***/
  3181. }),
  3182. /***/
  3183. "./src/modules/socket/Socket.js":
  3184. /*!**************************************!*\
  3185. !*** ./src/modules/socket/Socket.js ***!
  3186. \**************************************/
  3187. /***/
  3188. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  3189. __webpack_require__.r(__webpack_exports__);
  3190. /* harmony import */
  3191. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ../../constants.js */ "./src/constants.js");
  3192. /* harmony import */
  3193. var _Handler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__( /*! ./Handler.js */ "./src/modules/socket/Handler.js");
  3194. /* harmony import */
  3195. var _Manager_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__( /*! ./Manager.js */ "./src/modules/socket/Manager.js");
  3196. class Socket {
  3197. constructor() {
  3198. this.websocket = void 0
  3199. this.socketId = void 0
  3200. this.handler = new _Handler_js__WEBPACK_IMPORTED_MODULE_1__["default"]({
  3201. socket: this
  3202. })
  3203. this.manager = new _Manager_js__WEBPACK_IMPORTED_MODULE_2__["default"]({
  3204. socket: this
  3205. })
  3206. }
  3207. get isCreated() {
  3208. return Boolean(typeof this.websocket !== 'undefined')
  3209. }
  3210. get isReady() {
  3211. return Boolean(this.websocket?.readyState === 1)
  3212. }
  3213. send(type, content) {
  3214. if (!this.isReady) return
  3215. const encoded = _constants_js__WEBPACK_IMPORTED_MODULE_0__.codec.encoder.encode([type, content])
  3216. this.websocket.send(encoded)
  3217. }
  3218. onEvent(eventKey, listener) {
  3219. if (!this.isCreated) return
  3220. if (eventKey.startsWith("on")) {
  3221. this.websocket[eventKey] = listener
  3222. return
  3223. }
  3224. this.websocket.addEventListener(eventKey, listener)
  3225. }
  3226. setSocketId(_socketId) {
  3227. if (typeof _socketId !== 'number') return
  3228. this.socketId = _socketId
  3229. }
  3230. setWebSocket(_websocket) {
  3231. if (!_constants_js__WEBPACK_IMPORTED_MODULE_0__.codec.isReady) return
  3232. if (this.websocket instanceof WebSocket) return
  3233. if (!(_websocket instanceof WebSocket)) return
  3234. if (!/moomoo/.test(_websocket.url)) return
  3235. this.websocket = _websocket
  3236. this.manager.trigger("set-websocket")
  3237. }
  3238. }
  3239. /* harmony default export */
  3240. __webpack_exports__["default"] = (Socket);
  3241. /***/
  3242. }),
  3243. /***/
  3244. "./src/modules/socket/events/animals/loadAI.js":
  3245. /*!*****************************************************!*\
  3246. !*** ./src/modules/socket/events/animals/loadAI.js ***!
  3247. \*****************************************************/
  3248. /***/
  3249. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  3250. __webpack_require__.r(__webpack_exports__);
  3251. /* harmony import */
  3252. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ../../../../constants.js */ "./src/constants.js");
  3253.  
  3254. function loadAI(content) {
  3255. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.animalsManager.updateAnimals(content)
  3256. }
  3257. /* harmony default export */
  3258. __webpack_exports__["default"] = (loadAI);
  3259. /***/
  3260. }),
  3261. /***/
  3262. "./src/modules/socket/events/game_object/addProjectile.js":
  3263. /*!****************************************************************!*\
  3264. !*** ./src/modules/socket/events/game_object/addProjectile.js ***!
  3265. \****************************************************************/
  3266. /***/
  3267. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  3268. __webpack_require__.r(__webpack_exports__);
  3269. /* harmony import */
  3270. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ../../../../constants.js */ "./src/constants.js");
  3271.  
  3272. function addProjectile(x, y, dir, range, speed, indx, layer, sid) {
  3273. const isTurret = range == 700 && speed == 1.5 && indx === 1
  3274. const {
  3275. CowUtils
  3276. } = window
  3277. const offset = 70
  3278. const position = {
  3279. x: indx == 1 ? x : x - offset * Math.cos(dir),
  3280. y: indx == 1 ? y : y - offset * Math.sin(dir),
  3281. }
  3282. const reloadType = isTurret ? "turret" : "secondary"
  3283. const nearPlayer = _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.playersManager.list
  3284. .filter((player) => player.visible && CowUtils.getDistance(position.x, position.y, player.x2, player.y2) <= player.scale)
  3285. .sort((a, b) => {
  3286. a = CowUtils.getDistance(position.x, position.y, a.x2, a.y2)
  3287. b = CowUtils.getDistance(position.x, position.y, b.x2, b.y2)
  3288.  
  3289. return a - b
  3290. })[0]
  3291.  
  3292. if (nearPlayer) {
  3293. nearPlayer.reloads[reloadType].clear()
  3294. }
  3295. }
  3296. /* harmony default export */
  3297. __webpack_exports__["default"] = (addProjectile);
  3298. /***/
  3299. }),
  3300. /***/
  3301. "./src/modules/socket/events/game_object/killObject.js":
  3302. /*!*************************************************************!*\
  3303. !*** ./src/modules/socket/events/game_object/killObject.js ***!
  3304. \*************************************************************/
  3305. /***/
  3306. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  3307. __webpack_require__.r(__webpack_exports__);
  3308. /* harmony import */
  3309. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ../../../../constants.js */ "./src/constants.js");
  3310.  
  3311. function killObject(sid) {
  3312. const gameObject = _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.objectsManager.getById(sid)
  3313. if (!gameObject) return
  3314. gameObject.setActive(false)
  3315. }
  3316. /* harmony default export */
  3317. __webpack_exports__["default"] = (killObject);
  3318. /***/
  3319. }),
  3320. /***/
  3321. "./src/modules/socket/events/game_object/killObjects.js":
  3322. /*!**************************************************************!*\
  3323. !*** ./src/modules/socket/events/game_object/killObjects.js ***!
  3324. \**************************************************************/
  3325. /***/
  3326. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  3327. __webpack_require__.r(__webpack_exports__);
  3328. /* harmony import */
  3329. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ../../../../constants.js */ "./src/constants.js");
  3330.  
  3331. function killObjects(sid) {
  3332. if (!sid) return
  3333. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.objectsManager.disableAllObjects(sid)
  3334. }
  3335. /* harmony default export */
  3336. __webpack_exports__["default"] = (killObjects);
  3337. /***/
  3338. }),
  3339. /***/
  3340. "./src/modules/socket/events/game_object/loadGameObject.js":
  3341. /*!*****************************************************************!*\
  3342. !*** ./src/modules/socket/events/game_object/loadGameObject.js ***!
  3343. \*****************************************************************/
  3344. /***/
  3345. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  3346. __webpack_require__.r(__webpack_exports__);
  3347. /* harmony import */
  3348. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ../../../../constants.js */ "./src/constants.js");
  3349.  
  3350. function loadGameObject(content) {
  3351. const chunkSize = 8
  3352. for (let i = 0; i < content.length; i += chunkSize) {
  3353. const chunk = content.slice(i, i + chunkSize)
  3354. chunk[6] = _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.items.list[chunk[6]]
  3355. if (chunk[7] >= 0) {
  3356. chunk[7] = {
  3357. sid: chunk[7]
  3358. }
  3359. }
  3360. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.objectsManager.add(...chunk)
  3361. }
  3362. }
  3363. /* harmony default export */
  3364. __webpack_exports__["default"] = (loadGameObject);
  3365. /***/
  3366. }),
  3367. /***/
  3368. "./src/modules/socket/events/game_object/wiggleGameObject.js":
  3369. /*!*******************************************************************!*\
  3370. !*** ./src/modules/socket/events/game_object/wiggleGameObject.js ***!
  3371. \*******************************************************************/
  3372. /***/
  3373. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  3374. __webpack_require__.r(__webpack_exports__);
  3375. /* harmony import */
  3376. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ../../../../constants.js */ "./src/constants.js");
  3377.  
  3378. function wiggleGameObject(dir, sid) {
  3379. const gameObject = _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.objectsManager.getById(sid)
  3380. if (!gameObject) return
  3381. gameObject.doWiggle(dir)
  3382. }
  3383. /* harmony default export */
  3384. __webpack_exports__["default"] = (wiggleGameObject);
  3385. /***/
  3386. }),
  3387. /***/
  3388. "./src/modules/socket/events/getEvents.js":
  3389. /*!************************************************!*\
  3390. !*** ./src/modules/socket/events/getEvents.js ***!
  3391. \************************************************/
  3392. /***/
  3393. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  3394. __webpack_require__.r(__webpack_exports__);
  3395. /* harmony import */
  3396. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ../../../constants.js */ "./src/constants.js");
  3397. /* harmony import */
  3398. var _animals_loadAI_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__( /*! ./animals/loadAI.js */ "./src/modules/socket/events/animals/loadAI.js");
  3399. /* harmony import */
  3400. var _game_object_addProjectile_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__( /*! ./game_object/addProjectile.js */ "./src/modules/socket/events/game_object/addProjectile.js");
  3401. /* harmony import */
  3402. var _game_object_killObject_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__( /*! ./game_object/killObject.js */ "./src/modules/socket/events/game_object/killObject.js");
  3403. /* harmony import */
  3404. var _game_object_killObjects_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__( /*! ./game_object/killObjects.js */ "./src/modules/socket/events/game_object/killObjects.js");
  3405. /* harmony import */
  3406. var _game_object_loadGameObject_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__( /*! ./game_object/loadGameObject.js */ "./src/modules/socket/events/game_object/loadGameObject.js");
  3407. /* harmony import */
  3408. var _game_object_wiggleGameObject_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__( /*! ./game_object/wiggleGameObject.js */ "./src/modules/socket/events/game_object/wiggleGameObject.js");
  3409. /* harmony import */
  3410. var _player_addPlayer_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__( /*! ./player/addPlayer.js */ "./src/modules/socket/events/player/addPlayer.js");
  3411. /* harmony import */
  3412. var _player_gatherAnimation_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__( /*! ./player/gatherAnimation.js */ "./src/modules/socket/events/player/gatherAnimation.js");
  3413. /* harmony import */
  3414. var _player_killPlayer_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__( /*! ./player/killPlayer.js */ "./src/modules/socket/events/player/killPlayer.js");
  3415. /* harmony import */
  3416. var _player_removePlayer_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__( /*! ./player/removePlayer.js */ "./src/modules/socket/events/player/removePlayer.js");
  3417. /* harmony import */
  3418. var _player_updateHealth_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__( /*! ./player/updateHealth.js */ "./src/modules/socket/events/player/updateHealth.js");
  3419. /* harmony import */
  3420. var _player_updatePlayers_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__( /*! ./player/updatePlayers.js */ "./src/modules/socket/events/player/updatePlayers.js");
  3421. /* harmony import */
  3422. var _stats_updateItemCounts_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__( /*! ./stats/updateItemCounts.js */ "./src/modules/socket/events/stats/updateItemCounts.js");
  3423. /* harmony import */
  3424. var _stats_updateItems_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__( /*! ./stats/updateItems.js */ "./src/modules/socket/events/stats/updateItems.js");
  3425. /* harmony import */
  3426. var _stats_updatePlayerValue_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__( /*! ./stats/updatePlayerValue.js */ "./src/modules/socket/events/stats/updatePlayerValue.js");
  3427. /* harmony import */
  3428. var _system_setupGame_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__( /*! ./system/setupGame.js */ "./src/modules/socket/events/system/setupGame.js");
  3429.  
  3430. function getEvents() {
  3431. const events = {}
  3432. const {
  3433. packets
  3434. } = _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.config.designations
  3435. events[packets.SETUP_GAME] = _system_setupGame_js__WEBPACK_IMPORTED_MODULE_16__["default"]
  3436. events[packets.ADD_PLAYER] = _player_addPlayer_js__WEBPACK_IMPORTED_MODULE_7__["default"]
  3437. events[packets.KILL_PLAYER] = _player_killPlayer_js__WEBPACK_IMPORTED_MODULE_9__["default"]
  3438. events[packets.REMOVE_PLAYER] = _player_removePlayer_js__WEBPACK_IMPORTED_MODULE_10__["default"]
  3439. events[packets.UPDATE_PLAYERS] = _player_updatePlayers_js__WEBPACK_IMPORTED_MODULE_12__["default"]
  3440. events[packets.UPDATE_ITEM_COUNTS] = _stats_updateItemCounts_js__WEBPACK_IMPORTED_MODULE_13__["default"]
  3441. events[packets.UPDATE_PLAYER_VALUE] = _stats_updatePlayerValue_js__WEBPACK_IMPORTED_MODULE_15__["default"]
  3442. events[packets.UPDATE_HEALTH] = _player_updateHealth_js__WEBPACK_IMPORTED_MODULE_11__["default"]
  3443. events[packets.UPDATE_ITEMS] = _stats_updateItems_js__WEBPACK_IMPORTED_MODULE_14__["default"]
  3444. events[packets.GATHER_ANIMATION] = _player_gatherAnimation_js__WEBPACK_IMPORTED_MODULE_8__["default"]
  3445. events[packets.ADD_PROJECTILE] = _game_object_addProjectile_js__WEBPACK_IMPORTED_MODULE_2__["default"]
  3446. events[packets.LOAD_GAME_OBJECT] = _game_object_loadGameObject_js__WEBPACK_IMPORTED_MODULE_5__["default"]
  3447. events[packets.KILL_OBJECT] = _game_object_killObject_js__WEBPACK_IMPORTED_MODULE_3__["default"]
  3448. events[packets.KILL_OBJECTS] = _game_object_killObjects_js__WEBPACK_IMPORTED_MODULE_4__["default"]
  3449. events[packets.WIGGLE_GAME_OBJECT] = _game_object_wiggleGameObject_js__WEBPACK_IMPORTED_MODULE_6__["default"]
  3450. events[packets.LOAD_AI] = _animals_loadAI_js__WEBPACK_IMPORTED_MODULE_1__["default"]
  3451. return events
  3452. }
  3453. /* harmony default export */
  3454. __webpack_exports__["default"] = (getEvents);
  3455. /***/
  3456. }),
  3457. /***/
  3458. "./src/modules/socket/events/player/addPlayer.js":
  3459. /*!*******************************************************!*\
  3460. !*** ./src/modules/socket/events/player/addPlayer.js ***!
  3461. \*******************************************************/
  3462. /***/
  3463. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  3464. __webpack_require__.r(__webpack_exports__);
  3465. /* harmony import */
  3466. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ../../../../constants.js */ "./src/constants.js");
  3467.  
  3468. function addPlayer(content, isYou) {
  3469. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.playersManager.addPlayer(content, isYou)
  3470. }
  3471. /* harmony default export */
  3472. __webpack_exports__["default"] = (addPlayer);
  3473. /***/
  3474. }),
  3475. /***/
  3476. "./src/modules/socket/events/player/gatherAnimation.js":
  3477. /*!*************************************************************!*\
  3478. !*** ./src/modules/socket/events/player/gatherAnimation.js ***!
  3479. \*************************************************************/
  3480. /***/
  3481. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  3482. __webpack_require__.r(__webpack_exports__);
  3483. /* harmony import */
  3484. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ../../../../constants.js */ "./src/constants.js");
  3485.  
  3486. function gatherAnimation(sid, didHit, index) {
  3487. const player = _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.playersManager.getById(sid)
  3488. if (!player) return
  3489. player.onGather(didHit, index)
  3490. }
  3491. /* harmony default export */
  3492. __webpack_exports__["default"] = (gatherAnimation);
  3493. /***/
  3494. }),
  3495. /***/
  3496. "./src/modules/socket/events/player/killPlayer.js":
  3497. /*!********************************************************!*\
  3498. !*** ./src/modules/socket/events/player/killPlayer.js ***!
  3499. \********************************************************/
  3500. /***/
  3501. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  3502. __webpack_require__.r(__webpack_exports__);
  3503. /* harmony import */
  3504. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ../../../../constants.js */ "./src/constants.js");
  3505.  
  3506. function killPlayer() {
  3507. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.player.kill()
  3508. }
  3509. /* harmony default export */
  3510. __webpack_exports__["default"] = (killPlayer);
  3511. /***/
  3512. }),
  3513. /***/
  3514. "./src/modules/socket/events/player/removePlayer.js":
  3515. /*!**********************************************************!*\
  3516. !*** ./src/modules/socket/events/player/removePlayer.js ***!
  3517. \**********************************************************/
  3518. /***/
  3519. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  3520. __webpack_require__.r(__webpack_exports__);
  3521. /* harmony import */
  3522. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ../../../../constants.js */ "./src/constants.js");
  3523.  
  3524. function removePlayer(id) {
  3525. if (_constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.playersManager.players.size <= 1) return
  3526. const player = _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.playersManager.list.find((player) => player.id === id)
  3527. if (!player) return
  3528. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.playersManager.removePlayer(player.sid)
  3529. }
  3530. /* harmony default export */
  3531. __webpack_exports__["default"] = (removePlayer);
  3532. /***/
  3533. }),
  3534. /***/
  3535. "./src/modules/socket/events/player/updateHealth.js":
  3536. /*!**********************************************************!*\
  3537. !*** ./src/modules/socket/events/player/updateHealth.js ***!
  3538. \**********************************************************/
  3539. /***/
  3540. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  3541. __webpack_require__.r(__webpack_exports__);
  3542. /* harmony import */
  3543. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ../../../../constants.js */ "./src/constants.js");
  3544.  
  3545. function updateHealth(sid, value) {
  3546. const player = _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.playersManager.getById(sid)
  3547. if (!player) return
  3548. player.changeHealth(value)
  3549. }
  3550. /* harmony default export */
  3551. __webpack_exports__["default"] = (updateHealth);
  3552. /***/
  3553. }),
  3554. /***/
  3555. "./src/modules/socket/events/player/updatePlayers.js":
  3556. /*!***********************************************************!*\
  3557. !*** ./src/modules/socket/events/player/updatePlayers.js ***!
  3558. \***********************************************************/
  3559. /***/
  3560. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  3561. __webpack_require__.r(__webpack_exports__);
  3562. /* harmony import */
  3563. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ../../../../constants.js */ "./src/constants.js");
  3564.  
  3565. function updatePlayers(content) {
  3566. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.playersManager.updatePlayers(content)
  3567. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.ticker.updateTicks()
  3568. }
  3569. /* harmony default export */
  3570. __webpack_exports__["default"] = (updatePlayers);
  3571. /***/
  3572. }),
  3573. /***/
  3574. "./src/modules/socket/events/stats/updateItemCounts.js":
  3575. /*!*************************************************************!*\
  3576. !*** ./src/modules/socket/events/stats/updateItemCounts.js ***!
  3577. \*************************************************************/
  3578. /***/
  3579. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  3580. __webpack_require__.r(__webpack_exports__);
  3581. /* harmony import */
  3582. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ../../../../constants.js */ "./src/constants.js");
  3583.  
  3584. function updateItemCounts(index, value) {
  3585. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.player.itemCounts[index] = value
  3586. }
  3587. /* harmony default export */
  3588. __webpack_exports__["default"] = (updateItemCounts);
  3589. /***/
  3590. }),
  3591. /***/
  3592. "./src/modules/socket/events/stats/updateItems.js":
  3593. /*!********************************************************!*\
  3594. !*** ./src/modules/socket/events/stats/updateItems.js ***!
  3595. \********************************************************/
  3596. /***/
  3597. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  3598. __webpack_require__.r(__webpack_exports__);
  3599. /* harmony import */
  3600. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ../../../../constants.js */ "./src/constants.js");
  3601.  
  3602. function updateItems(data, isWeapon) {
  3603. if (!data?.length) return
  3604. const type = isWeapon ? "weapons" : "items"
  3605. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.player[type] = data
  3606. }
  3607. /* harmony default export */
  3608. __webpack_exports__["default"] = (updateItems);
  3609. /***/
  3610. }),
  3611. /***/
  3612. "./src/modules/socket/events/stats/updatePlayerValue.js":
  3613. /*!**************************************************************!*\
  3614. !*** ./src/modules/socket/events/stats/updatePlayerValue.js ***!
  3615. \**************************************************************/
  3616. /***/
  3617. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  3618. __webpack_require__.r(__webpack_exports__);
  3619. /* harmony import */
  3620. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ../../../../constants.js */ "./src/constants.js");
  3621.  
  3622. function updatePlayerValue(index, value, updateView) {
  3623. if (!_constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.player) return
  3624. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.player[index] = value
  3625. }
  3626. /* harmony default export */
  3627. __webpack_exports__["default"] = (updatePlayerValue);
  3628. /***/
  3629. }),
  3630. /***/
  3631. "./src/modules/socket/events/system/setupGame.js":
  3632. /*!*******************************************************!*\
  3633. !*** ./src/modules/socket/events/system/setupGame.js ***!
  3634. \*******************************************************/
  3635. /***/
  3636. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  3637. __webpack_require__.r(__webpack_exports__);
  3638. /* harmony import */
  3639. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ../../../../constants.js */ "./src/constants.js");
  3640.  
  3641. function setupGame(socketId) {
  3642. _constants_js__WEBPACK_IMPORTED_MODULE_0__.socket.setSocketId(socketId)
  3643. }
  3644. /* harmony default export */
  3645. __webpack_exports__["default"] = (setupGame);
  3646. /***/
  3647. }),
  3648. /***/
  3649. "./src/utils/CowUtils.js":
  3650. /*!*******************************!*\
  3651. !*** ./src/utils/CowUtils.js ***!
  3652. \*******************************/
  3653. /***/
  3654. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  3655. __webpack_require__.r(__webpack_exports__);
  3656. class CowUtils {
  3657. static removeProto(object) {
  3658. if (!(object instanceof Object)) return
  3659. return JSON.parse(JSON.stringify(object))
  3660. }
  3661. static randInt(min, max) {
  3662. return Math.floor(CowUtils.randFloat(min, max))
  3663. }
  3664. static randFloat(min, max) {
  3665. if (typeof max === 'undefined') {
  3666. max = min
  3667. min = 0
  3668. }
  3669. return (Math.random() * (max - min + 1)) + min
  3670. }
  3671. static toRadians(degree) {
  3672. return degree * 0.01745329251
  3673. }
  3674. static lerp(value1, value2, amount) {
  3675. return value1 + (value2 - value1) * amount
  3676. }
  3677. static kFormat(value) {
  3678. value = parseFloat(value)
  3679. return value > 999 ? `${(value / 1000).toFixed(1)}k` : value
  3680. }
  3681. static fixAngle(angle) {
  3682. return Math.atan2(Math.cos(angle), Math.sin(angle))
  3683. }
  3684. static getDistance(x1, y1, x2, y2) {
  3685. if (x1 instanceof Object && y1 instanceof Object) {
  3686. return Math.hypot(x1.y - y1.y, x1.x - y1.x)
  3687. }
  3688. return Math.hypot(y1 - y2, x1 - x2)
  3689. }
  3690. static getDirection(x1, y1, x2, y2) {
  3691. if (x1 instanceof Object && y1 instanceof Object) {
  3692. return Math.atan2(x1.y - y1.y, x1.x - y1.x)
  3693. }
  3694. return Math.atan2(y1 - y2, x1 - x2)
  3695. }
  3696. static getAngleDist(angleBetween, targetLookDir) {
  3697. const difference = Math.abs(targetLookDir - angleBetween) % (Math.PI * 2)
  3698. return (difference > Math.PI ? (Math.PI * 2) - difference : difference)
  3699. }
  3700. static lerpAngle(value1, value2, amount) {
  3701. const difference = Math.abs(value2 - value1)
  3702. if (difference > Math.PI) {
  3703. if (value1 > value2) {
  3704. value2 += Math.PI * 2
  3705. } else {
  3706. value1 += Math.PI * 2
  3707. }
  3708. }
  3709. const value = value2 + ((value1 - value2) * amount)
  3710. if (value >= 0 && value <= (Math.PI * 2)) return value
  3711. return (value % (Math.PI * 2))
  3712. }
  3713. static createHook({
  3714. property,
  3715. proto = Object.prototype,
  3716. setter,
  3717. getter
  3718. }) {
  3719. const symbol = Symbol(property)
  3720. Object.defineProperty(proto, property, {
  3721. get() {
  3722. typeof getter === 'function' && getter(this, this[symbol])
  3723. return this[symbol]
  3724. },
  3725. set(value) {
  3726. typeof setter === 'function' && setter(this, value)
  3727. this[symbol] = value
  3728. }
  3729. })
  3730. return symbol
  3731. }
  3732. }
  3733. /* harmony default export */
  3734. __webpack_exports__["default"] = (CowUtils);
  3735. /***/
  3736. }),
  3737. /***/
  3738. "./src/config.json":
  3739. /*!*************************!*\
  3740. !*** ./src/config.json ***!
  3741. \*************************/
  3742. /***/
  3743. (function(module) {
  3744. module.exports = JSON.parse('{"NAME":"Cow.JS","VERSION":"1.0.0","maxScreenWidth":1920,"maxScreenHeight":1080,"mapScale":14400,"riverWidth":724,"gatherAngle":1.208304866765305,"hitAngle":1.5707963267948966,"shieldAngle":1.0471975511965976,"gatherWiggle":10,"designations":{"plugins":{"AUTO_RECONECT":"auto-reconect","CHECK_PLACEMENT":"check-placement"},"packets":{"INIT_DATA":"A","DISCONNECT":"B","SETUP_GAME":"C","ADD_PLAYER":"D","REMOVE_PLAYER":"E","UPDATE_PLAYERS":"a","UPDATE_LEADERBOARD":"G","LOAD_GAME_OBJECT":"H","LOAD_AI":"I","ANIMATE_AI":"J","GATHER_ANIMATION":"K","WIGGLE_GAME_OBJECT":"L","SHOOT_TURRET":"M","UPDATE_PLAYER_VALUE":"N","UPDATE_HEALTH":"O","KILL_PLAYER":"P","KILL_OBJECT":"Q","KILL_OBJECTS":"R","UPDATE_ITEM_COUNTS":"S","UPDATE_AGE":"T","UPDATE_UPGRADES":"U","UPDATE_ITEMS":"V","ADD_PROJECTILE":"X","REMOVE_PROJECTILE":"Y","SERVER_SHUTDOWN_NOTICE":"Z","ADD_ALLIANCE":"g","DELETE_ALLIANCE":"1","ALLIANCE_NOTIFICATION":"2","SET_PLAYER_TEAM":"3","SET_ALLIANCE_PLAYERS":"4","UPDATE_STORE_ITEMS":"5","RECEIVE_CHAT":"6","UPDATE_MINIMAP":"7","SHOW_TEXT":"8","PING_MAP":"9","PING_SOCKET_RESPONSE":"0","ALLIANCE_JOIN_REQUEST":"P","KICK_FROM_CLAN":"Q","SEND_ALLIANCE_JOIN":"b","CREATE_ALLIANCE":"L","LEAVE_ALLIANCE":"N","STORE_EQUIP":"c","CHAT_MESSAGE":"6","RMD":"E","ATTACK_STATE":"d","MOVE_DIR":"a","MAP_PING":"S","AUTO_ATTACK":"K","SELECT_BUILD":"G","SPAWN":"M","SELECT_UPGRADE":"H","LOOK_DIR":"D","PING_SOCKET":"0"},"items":{"FOOD":0,"WALL":1,"SPIKE":2,"MILL":3,"TRAP":4,"TURRET":5}}}');
  3745. /***/
  3746. })
  3747. /******/
  3748. });
  3749. /************************************************************************/
  3750. /******/ // The module cache
  3751. /******/
  3752. var __webpack_module_cache__ = {};
  3753. /******/
  3754. /******/ // The require function
  3755. /******/
  3756. function __webpack_require__(moduleId) {
  3757. /******/ // Check if module is in cache
  3758. /******/
  3759. var cachedModule = __webpack_module_cache__[moduleId];
  3760. /******/
  3761. if (cachedModule !== undefined) {
  3762. /******/
  3763. return cachedModule.exports;
  3764. /******/
  3765. }
  3766. /******/ // Create a new module (and put it into the cache)
  3767. /******/
  3768. var module = __webpack_module_cache__[moduleId] = {
  3769. /******/ // no module.id needed
  3770. /******/ // no module.loaded needed
  3771. /******/
  3772. exports: {}
  3773. /******/
  3774. };
  3775. /******/
  3776. /******/ // Execute the module function
  3777. /******/
  3778. __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  3779. /******/
  3780. /******/ // Return the exports of the module
  3781. /******/
  3782. return module.exports;
  3783. /******/
  3784. }
  3785. /******/
  3786. /************************************************************************/
  3787. /******/
  3788. /* webpack/runtime/define property getters */
  3789. /******/
  3790. ! function() {
  3791. /******/ // define getter functions for harmony exports
  3792. /******/
  3793. __webpack_require__.d = function(exports, definition) {
  3794. /******/
  3795. for (var key in definition) {
  3796. /******/
  3797. if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  3798. /******/
  3799. Object.defineProperty(exports, key, {
  3800. enumerable: true,
  3801. get: definition[key]
  3802. });
  3803. /******/
  3804. }
  3805. /******/
  3806. }
  3807. /******/
  3808. };
  3809. /******/
  3810. }();
  3811. /******/
  3812. /******/
  3813. /* webpack/runtime/hasOwnProperty shorthand */
  3814. /******/
  3815. ! function() {
  3816. /******/
  3817. __webpack_require__.o = function(obj, prop) {
  3818. return Object.prototype.hasOwnProperty.call(obj, prop);
  3819. }
  3820. /******/
  3821. }();
  3822. /******/
  3823. /******/
  3824. /* webpack/runtime/make namespace object */
  3825. /******/
  3826. ! function() {
  3827. /******/ // define __esModule on exports
  3828. /******/
  3829. __webpack_require__.r = function(exports) {
  3830. /******/
  3831. if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  3832. /******/
  3833. Object.defineProperty(exports, Symbol.toStringTag, {
  3834. value: 'Module'
  3835. });
  3836. /******/
  3837. }
  3838. /******/
  3839. Object.defineProperty(exports, '__esModule', {
  3840. value: true
  3841. });
  3842. /******/
  3843. };
  3844. /******/
  3845. }();
  3846. /******/
  3847. /************************************************************************/
  3848. var __webpack_exports__ = {};
  3849. // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
  3850. ! function() {
  3851. /*!**********************!*\
  3852. !*** ./src/index.js ***!
  3853. \**********************/
  3854. __webpack_require__.r(__webpack_exports__);
  3855. /* harmony import */
  3856. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ./constants.js */ "./src/constants.js");
  3857. /* harmony import */
  3858. var _utils_CowUtils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__( /*! ./utils/CowUtils.js */ "./src/utils/CowUtils.js");
  3859. /* harmony import */
  3860. var _hooks_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__( /*! ./hooks.js */ "./src/hooks.js");
  3861. const watermark = setInterval(() => {
  3862. const linksContainer = document.getElementById("linksContainer2")
  3863. if (!linksContainer) return
  3864. const html = linksContainer.innerHTML
  3865. linksContainer.innerHTML = html.replace(/(v\d\.\d\.\d)/gi, `$1 </a> | <a href="#" target="_blank" class="menuLink" style="color: #9f1a1a">${_constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.config.NAME}</a>`)
  3866. clearInterval(watermark)
  3867. })
  3868. setTimeout(() => clearInterval(watermark), 30e3)
  3869. window.CowUtils = _utils_CowUtils_js__WEBPACK_IMPORTED_MODULE_1__["default"]
  3870. window.Cow = _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow
  3871. }();
  3872. /******/
  3873. })();
  3874. //# sourceMappingURL=bundle.js.map