|
1 | 1 | import 'dotenv/config'; |
2 | 2 |
|
3 | 3 | import { PlayerInfoProt, Visibility } from '@2004scape/rsbuf'; |
4 | | -import { CollisionFlag } from '@2004scape/rsmod-pathfinder'; |
| 4 | +import { CollisionFlag, CollisionType } from '@2004scape/rsmod-pathfinder'; |
5 | 5 |
|
6 | 6 | import Component from '#/cache/config/Component.js'; |
7 | 7 | import FontType from '#/cache/config/FontType.js'; |
@@ -37,7 +37,7 @@ import { PlayerQueueRequest, PlayerQueueType, QueueType, ScriptArgument } from ' |
37 | 37 | import { PlayerStat, PlayerStatEnabled, PlayerStatFree, PlayerStatNameMap } from '#/engine/entity/PlayerStat.js'; |
38 | 38 | import InputTracking from '#/engine/entity/tracking/InputTracking.js'; |
39 | 39 | import { WealthEventParams } from '#/engine/entity/tracking/WealthEvent.js'; |
40 | | -import { changeNpcCollision, changePlayerCollision, reachedEntity, reachedLoc, reachedObj } from '#/engine/GameMap.js'; |
| 40 | +import { changeNpcCollision, changePlayerCollision, findNaivePath, reachedEntity, reachedLoc, reachedObj } from '#/engine/GameMap.js'; |
41 | 41 | import { Inventory, InventoryListener } from '#/engine/Inventory.js'; |
42 | 42 | import ScriptFile from '#/engine/script/ScriptFile.js'; |
43 | 43 | import ScriptPointer from '#/engine/script/ScriptPointer.js'; |
@@ -1094,6 +1094,24 @@ export default class Player extends PathingEntity { |
1094 | 1094 | } |
1095 | 1095 | } |
1096 | 1096 |
|
| 1097 | + naivePathToTarget() { |
| 1098 | + if (!this.target) { |
| 1099 | + return; |
| 1100 | + } |
| 1101 | + let angle = 0; |
| 1102 | + if (this.target instanceof Loc) { |
| 1103 | + angle = this.target.angle; |
| 1104 | + } |
| 1105 | + |
| 1106 | + const { x, z } = CoordGrid.unpackCoord(this.waypoints[0]); |
| 1107 | + |
| 1108 | + // If no waypoint, or waypoint is further than 1 tile from target, set new dest |
| 1109 | + if (this.waypointIndex === -1 || Math.abs(this.target.x - x) > 1 || Math.abs(this.target.z - z) > 1) { |
| 1110 | + const waypoints = findNaivePath(this.level, this.x, this.z, this.target.x, this.target.z, this.width, this.length, this.target.width, this.target.length, angle, CollisionType.NORMAL); |
| 1111 | + this.queueWaypoints(waypoints); |
| 1112 | + } |
| 1113 | + } |
| 1114 | + |
1097 | 1115 | // https://youtu.be/_NmFftkMm0I?si=xSgb8GCydgUXUayR&t=79 |
1098 | 1116 | // to allow p_walk (sets player destination tile) during walktriggers |
1099 | 1117 | // we process walktriggers from regular movement in client input, |
|
0 commit comments