{"_id":"@2003scape/rsc-path-finder","_rev":"3-7f02cd0bdde8384fdd9f8917d7aaad36","name":"@2003scape/rsc-path-finder","dist-tags":{"latest":"1.1.1"},"versions":{"1.0.0":{"name":"@2003scape/rsc-path-finder","version":"1.0.0","description":"generate paths between points on a runescape classic map","main":"./src/index.js","repository":{"type":"git","url":"git+https://github.com/2003scape/rsc-path-finder.git"},"keywords":["runescape","rsc","landscape","paths","collision","astar","pathfinder","async"],"author":{"name":"2003Scape Team"},"license":"AGPL-3.0+","bugs":{"url":"https://github.com/2003scape/rsc-path-finder/issues"},"homepage":"https://github.com/2003scape/rsc-path-finder#readme","dependencies":{"@misterhat/easystarjs":"^0.5.3","bitfield":"^3.0.0","ndarray":"^1.0.18","canvas":"^2.6.0"},"peerDependencies":{"@2003scape/rsc-landscape":"^2.0.0"},"optionalDependencies":{"canvas":"^2.6.0"},"devDependencies":{"@2003scape/rsc-config":"^1.0.0","@2003scape/rsc-landscape":"^2.0.0"},"gitHead":"c8e3b58ddfaab4c64d4d88797621d72ef79b2294","_id":"@2003scape/rsc-path-finder@1.0.0","_nodeVersion":"12.14.0","_npmVersion":"6.13.4","_npmUser":{"name":"misterhat","email":"misterhat144@gmail.com"},"maintainers":[{"name":"misterhat","email":"misterhat144@gmail.com"}],"dist":{"integrity":"sha512-OXlnxqi6vZXasX8j4SyvovG6gpREbREJO/zrgAzMn3Hk7kxhunRFOpG32Bv9ZxblBnB688GtkCZbVYjo+JtxOg==","shasum":"76b0cfe7e3a9d7df607fabdfc7dd0659131c5ad4","tarball":"https://registry.npmjs.org/@2003scape/rsc-path-finder/-/rsc-path-finder-1.0.0.tgz","fileCount":16,"unpackedSize":772372,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeFSPxCRA9TVsSAnZWagAAKPgP/2qzCEyiJ849qQlKR0v5\nY54Akb7tadNulvaIDZTw0hEZvDwCeDvkuXCw2PMoEZ5C9Rp92zQj18fvsZer\nRk/nlHQFky/gVvL7BYfIYv2xAuC8GPRp2/2SMbs5NHd0jngSzcyZaP6DMY08\nO6jI/iaODXeRbnqnXSAdtV1+9Zb9FGHoarjF3ahGMDy+6lu0WsaWEkZzGEkN\nyLQWMMAGeoNwag6eOv1FH2vI93LhfLoNn82l+7uEKUmVv/NkaR3R+BrPcVg7\nmv/ObEtTOgcVQMqo6N9ODDIWxAjOkdQzWoHjRKKFwvYVP3JZWoYoi37k94Tm\nWIsnm22/mneHmr0wfGfISD98t+lMQBN/8BSDLjh/2kp/yKgs5cphyArGdK6Z\nRsrns+x0A1Za2yhneS+5Hxu/zsGvhbfUIO2KPU3wsNwhaObMWY4THPHiH3s5\nJCWLzIq2Iaj3Hp4ipWK72J8RV126ddx6nxYKgsC43Uvn/XB3IEPqKixmXMQK\nIneRtg5O5gzqfK8FpxGlTqVfmNXT0keIMF+7L5uKtTDdsndyiTGCqyt7LQVL\n4a8Xrzt0sCfpHXxVGAYF5JYLsbDcNnQ6y4kUFpHecp1m1kwyQTt9CRql2g1/\n/NdNsK3mXUd/oCxYWOCjofOVrLv6wePdkkvcVMShiTO9CtyLsXh38h4J8B0S\nPDPY\r\n=yzEg\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIG/RJSXFvkcOu/ewW1goAfTC/xhN9pu2blJVGk6hD+uEAiA0U1SwmN0Dpcmit6hWBfHC87KFWBri6TJHJ7GVsYJzEg=="}]},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rsc-path-finder_1.0.0_1578443760582_0.12951788771176154"},"_hasShrinkwrap":false},"1.1.0":{"name":"@2003scape/rsc-path-finder","version":"1.1.0","description":"generate paths between points on a runescape classic map","main":"./src/index.js","repository":{"type":"git","url":"git+https://github.com/2003scape/rsc-path-finder.git"},"keywords":["runescape","rsc","landscape","paths","collision","astar","pathfinder","async"],"author":{"name":"2003Scape Team"},"license":"AGPL-3.0+","bugs":{"url":"https://github.com/2003scape/rsc-path-finder/issues"},"homepage":"https://github.com/2003scape/rsc-path-finder#readme","dependencies":{"@misterhat/easystarjs":"^0.5.3","bitfield":"^4.0.0","ndarray":"^1.0.19","canvas":"^2.6.1"},"peerDependencies":{"@2003scape/rsc-landscape":"^2.0.1"},"optionalDependencies":{"canvas":"^2.6.1"},"devDependencies":{"@2003scape/rsc-config":"^1.0.1","@2003scape/rsc-landscape":"^2.0.1"},"gitHead":"d391551c15a4038cfdcd2488e7e66bf1ba29a80e","_id":"@2003scape/rsc-path-finder@1.1.0","_nodeVersion":"14.14.0","_npmVersion":"6.14.8","_npmUser":{"name":"misterhat","email":"misterhat144@gmail.com"},"maintainers":[{"name":"misterhat","email":"misterhat144@gmail.com"}],"dist":{"integrity":"sha512-MDhCk7ZeyQRFJYL7Y8EVmyiOTkdCPeHhTQX2SbUaG7E088JvUfouUjjq2JNLXOnp4ODFGx+2ihoEtyffLbf5VQ==","shasum":"3b90a1301b5b6c76488a497c7f909f4b05b6e71e","tarball":"https://registry.npmjs.org/@2003scape/rsc-path-finder/-/rsc-path-finder-1.1.0.tgz","fileCount":18,"unpackedSize":777522,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfoXSFCRA9TVsSAnZWagAA/ksP+QGQ2Lps+UOVPfvswRKG\nrR9iI/Ej2R8nNgjWwpE5U7atSV10VVyx+J9BzXf3YkI8OEfmzMVJnPk/qNBO\n1OWVXPoAVCg+iPLUseRkcDt/Nmpt2t3fOM+wd/djkLR0S+B3WbbvFVQZtgRB\nlmgi4iBPbDwswzZS67RAwa25MYvgf7/kHidaHpPc40ikP1ulYtZB2QyOdIBQ\nY/EDa9QW/Nhcw4ZjSALOKAAgyg08yOUoNEukkxNiFzoo/V4Hs74Qh6aOhO8f\nMlkp0onDzRL9myCIkPGkMLAqXTnQKXzKVh8P/l19deCRQOjmztFtJa2ijez7\n42lklmC3l1dua3M3cdKAOlgFMI5X1/vrSFqeGWJcGgw4MuA9OT1DmmmQdCDT\nSXcFZtVqOxErAddQGoe7lamG88YFVIwUBdWXrG9utreGUlJ+0EQIKHk4q5I8\niYN+I6aMKvTdTZo/jxfUuNMbRaZ5aPgw6+OJDng5MJzhR13ISPmEp/N1qcLh\nKhorHbaG/Ta+kU9PLMNbB6FoDdVwVL7LRZZsktHbvrHzFpbY+RZnxh3t3fJG\nq5OqKu5b2YmvPIFG7AELoueTPZBWbwBw/IzaM318mCPcGl33lAQzD2hedYeB\nuxi99XRF0pdKJEAAWF7nVGGCqEUmLKyKlWLZsf62/Vptz9/rCXFDR0lNv/Pk\noZY0\r\n=3FY7\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDK/Wvq59xkNmn8HHVHuzdaFiR9h3sC+xDr0ZKUHB4x8gIgEDeCEa+LNg1AEvMgTQtiwIQMmjdFCEahxrr/9o2bcOU="}]},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rsc-path-finder_1.1.0_1604416645360_0.846920417351331"},"_hasShrinkwrap":false},"1.1.1":{"name":"@2003scape/rsc-path-finder","version":"1.1.1","description":"generate paths between points on a runescape classic map","main":"./src/index.js","repository":{"type":"git","url":"git+https://github.com/2003scape/rsc-path-finder.git"},"keywords":["runescape","rsc","landscape","paths","collision","astar","pathfinder","async"],"author":{"name":"2003Scape Team"},"license":"AGPL-3.0+","bugs":{"url":"https://github.com/2003scape/rsc-path-finder/issues"},"homepage":"https://github.com/2003scape/rsc-path-finder#readme","dependencies":{"@misterhat/easystarjs":"^0.5.3","bitfield":"^4.0.0","ndarray":"^1.0.19","canvas":"^2.6.1"},"peerDependencies":{"@2003scape/rsc-landscape":"^2.0.1"},"optionalDependencies":{"canvas":"^2.6.1"},"devDependencies":{"@2003scape/rsc-config":"^1.0.1","@2003scape/rsc-landscape":"^2.0.1"},"gitHead":"014522c77fd9a6cfd54c126b74396d7069e7dfcc","_id":"@2003scape/rsc-path-finder@1.1.1","_nodeVersion":"14.14.0","_npmVersion":"6.14.8","_npmUser":{"name":"misterhat","email":"misterhat144@gmail.com"},"maintainers":[{"name":"misterhat","email":"misterhat144@gmail.com"}],"dist":{"integrity":"sha512-f9C7yD5K9Hqz7ic/7dmzjed1TBZ3bdx04ivI5ppUMVT76P9xmEe+Y3PPVWB9axo5mV80tgAEecvirJZ8H4RvbQ==","shasum":"f17ee63284646087fa3e01618b43335a00480056","tarball":"https://registry.npmjs.org/@2003scape/rsc-path-finder/-/rsc-path-finder-1.1.1.tgz","fileCount":18,"unpackedSize":778273,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfuDLkCRA9TVsSAnZWagAAuNMP+QAl+Yp/SPQCY3/gzyuf\nXmPr461JEgj5gx/AkHHXGUg/vMl+n5ObtaLg0c2Q5C32rztGXh6k5E17AOXm\nVg19kxgDuDdO/sGx3XUHr+mz5AEK5SCBaC0TEdQ2eAk0QNpf9b+GHoNIcGsK\n1CDQjHmsNf4vrzGm86jzqtmh5R244r8hHNoRGz7WusiU5M4dAzMVb88yQLpT\nfdSuus3Owt5EqUG4w7NeoXpA8N7RpAoRmN2YGIY4QLvH0Kxp1rcXrpjkNYWt\nW1UNlEakk460cQF7xZ3ts5Jh8uviJPAVZ2eye/eyytCUoTKlfOyFtVs3iOUf\naqNuEniTba1XegAyjbJ1o0gBtGPMYPOX3Fp6ulM1cQn3Ym00Xu0Uf6eFaNJH\nNoHzmJGMAQX/RCwTgbSuaKEz5TXpjSYHbifETZSSQ2xr2Ssfvuyk+cPcZ9Sh\nyLTCc/WGqA1uN2qS/EDBx0M8aF6jfuvitkMW/Yzu4JgcW58z9tQpDmLqFG+u\n8Bh6LLDJNxj5wyZLnUGga+BdyFM4wVQCMLM9eJyprmrl68uu36Xirrn/Ig8k\nLzMCNg42khUyk6AVF3rCQs+2MNHk6u9yhT/JRf5Kb0uAL4GkkHHR3Vbs/T0z\nHRNt+YfUCuwOS9w60NtSWUh0rRPXobMy5ewLI7GPDOD+YZRdEbn2qTCwkYWl\nDgQy\r\n=TJOv\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD5LSi3aosxAwE2+BDryN65hNhZPnaoQLhTeXI7IGH0+QIhAKDZ8lQRC2GQ5B+Wo2FB059w825wMAjhMrgVS1vBs06e"}]},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rsc-path-finder_1.1.1_1605907172344_0.2922276877884753"},"_hasShrinkwrap":false}},"time":{"created":"2020-01-08T00:36:00.343Z","1.0.0":"2020-01-08T00:36:00.799Z","modified":"2022-04-04T10:34:57.631Z","1.1.0":"2020-11-03T15:17:25.559Z","1.1.1":"2020-11-20T21:19:32.568Z"},"maintainers":[{"name":"misterhat","email":"misterhat144@gmail.com"}],"description":"generate paths between points on a runescape classic map","homepage":"https://github.com/2003scape/rsc-path-finder#readme","keywords":["runescape","rsc","landscape","paths","collision","astar","pathfinder","async"],"repository":{"type":"git","url":"git+https://github.com/2003scape/rsc-path-finder.git"},"author":{"name":"2003Scape Team"},"bugs":{"url":"https://github.com/2003scape/rsc-path-finder/issues"},"license":"AGPL-3.0+","readme":"# rsc-path-finder\ngenerate paths between points on a runescape classic map. each tile is\nexpanded into a 2x2 grid of booleans describing how the tile is blocked. this\nallows for horizontal, vertical and fully-blocked tile representation\n(diagonal walls are completely impassbale). once a path is found, the steps are\nsmoothed and converted to game coordinates.\n\nthis module is safe to use in a game loop as the computation is asynchronous.\n\n![](./doc/legends-path.png?raw=true)\n\n*path from Lumbridge to the Legend's Guild*\n\n![](./doc/bandit-path.png?raw=true)\n\n*path from Al Kharid to Bandit Camp*\n\n![](./doc/gnome-path.png?raw=true)\n\n*path to Tree Gnome Village entrance*\n\n\n## install\n\n    $ npm install @2003scape/rsc-path-finder\n\n## example\n```javascript\nconst fs = require('fs');\nconst { gunzipSync } = require('zlib');\nconst { Config } = require('@2003scape/rsc-config');\nconst { Landscape } = require('@2003scape/rsc-landscape');\nconst { PathFinder } = require('./src');\n\nconst config = new Config();\nconfig.loadArchive(fs.readFileSync('./config85.jag'));\n\nconst landscape = new Landscape();\nlandscape.loadJag(fs.readFileSync('./land63.jag'),\n    fs.readFileSync('./maps63.jag'));\nlandscape.loadMem(fs.readFileSync('./land63.mem'),\n    fs.readFileSync('./maps63.mem'));\nlandscape.parseArchives();\n\nconst pathFinder = new PathFinder(config, landscape);\nconst objectLocations =\n    JSON.parse(gunzipSync(fs.readFileSync('./object-locs.json.gz')));\nobjectLocations.forEach(obj => pathFinder.addObject(obj));\n\nconst wallObjectLocations = require('./wallObject-locs');\nwallObjectLocations.forEach(obj => pathFinder.addWallObject(obj));\n\n// replace the taverly gate with an open gate\npathFinder.addObject({ id: 58, x: 341, y: 487, direction: 4 });\n\n// close the door in gertrude's house\npathFinder.addWallObject({ id: 2, x: 163, y: 513, direction: 1 });\n// open it again\n// pathFinder.addWallObject({ id: 1, x: 163, y: 513, direction: 1 });\n\npathFinder.start();\n\n(async () => {\n    const path = await pathFinder.findPath(\n        { x: 126, y: 655 },\n        { x: 513, y: 552 });\n        //{ x: 72, y: 694 },\n        //{ x: 320, y: 290 });\n        //{ x: 672, y: 718 },\n        //{ x: 634, y: 706 });\n        //{ x: 138, y: 1594 },\n        //{ x: 131, y: 1602 });\n    console.log('found path to legends guild', path.length);\n\n    fs.writeFileSync('./legends-path.png',\n        pathFinder.toCanvas(path).toBuffer());\n\n    pathFinder.stop();\n})();\n```\n\n## api\n### pathFinder = new PathFinder(config, landscape, tickRate = 80)\ncreate a new pathfinding instance.\n\n`config` in the first argument must contain definitions of game and wall objects\nwith at least the following:\n\n```javascript\n{\n    // definitions for game objects (tree, altar, furnace, etc.)\n    objects: [\n        {\n            type: 'unblocked' || 'blocked || 'closed-door' || 'open-door',\n            width: Number,\n            height: Number\n        },\n        // ...\n    ],\n    // definitions for wall objects (doors, walls, boundaries, etc.)\n    wallObjects: [\n        {\n            blocked: true || false,\n        }\n        // ...\n    ]\n    // definitions for tiles (floors, water, roads, etc.)\n    tiles: [\n        {\n            blocked: true || false,\n        }\n        // ...\n    ]\n}\n```\n\n[objects](https://github.com/2003scape/rsc-config#configobjects),\n[wallObjects](https://github.com/2003scape/rsc-config#configwallobjects) and\n[tiles](https://github.com/2003scape/rsc-config#configtiles)\nare all members of an\n[rsc-config](https://github.com/2003scape/rsc-config#config--new-config)\ninstance.\n\n`landscape` is an instance of\n[rsc-landscape](https://github.com/2003scape/rsc-landscape#landscape--new-landscape).\n\n`tickRate` is how often (in ms) to poll for new paths to find when `findPath`\nisn't active.\n\n### pathFinder.addObject({ id, x, y, direction })\nadd game object to position. `id` corresponds to index in `config.objects`. if\n`open-door` or `closed-door` type objects are added, replace them with door\nwall objects.\n\n### pathFinder.addWallObject({ id, x, y, direction })\nadd wall object to position. `id` corresponds to index in `config.wallObjects`\narray. if an unblocked wall object is added, remove any existing obstacles\n(door with doorframes, spider web with blank, etc.).\n\n### pathFinder.start()\n### pathFinder.stop()\nenable and disable the pathfinding run loop.\n\n### async pathFinder.findPath({ x, y }, { x, y })\nfind a path between startPos and endPos. returns an array of game coordinates.\n\n### pathFinder.isValidGameStep({ x, y }, { deltaX, deltaY })\nreturn true if we can step from startPos in the step direction.\n\n### pathFinder.getLineOfSight({ x, y }, { x, y })\nfind a direct diagonal beeline path between two points.\n\n### pathFinder.toCanvas(path = undefined)\ncreate a canvas with all of the obstacles filled in with white. if path is\nspecified, fill the path tiles with red.\n\n## license\nCopyright 2020  2003Scape Team\n\nThis program is free software: you can redistribute it and/or modify it under\nthe terms of the GNU Affero General Public License as published by the\nFree Software Foundation, either version 3 of the License, or (at your option)\nany later version.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY\nWARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A\nPARTICULAR PURPOSE. See the GNU Affero General Public License for more details.\n\nYou should have received a copy of the GNU Affero General Public License along\nwith this program. If not, see http://www.gnu.org/licenses/.\n","readmeFilename":"README.md"}