Skip to content

Commit

Permalink
fix: check start==end coord before collision for los
Browse files Browse the repository at this point in the history
blurite/pathfinder@f81f6b5

Example: Casting telegrab on the same square when the tile is blocked
i.e. player/obj are inside a diagonal door
  • Loading branch information
Pazaz committed May 29, 2024
1 parent 2d7fbfa commit c9fa362
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@2004scape/rsmod-pathfinder",
"version": "5.0.0",
"version": "5.0.1",
"description": "A breadth-first search path finder.",
"main": "dist/rsmod-pathfinder.js",
"types": "dist/rsmod-pathfinder.d.ts",
Expand Down
8 changes: 4 additions & 4 deletions src/rsmod/LinePathFinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,17 @@ export default class LinePathFinder {
const startX: i32 = Line.coordinate(srcX, destX, srcWidth);
const startZ: i32 = Line.coordinate(srcZ, destZ, srcHeight);

if (los && this.flags.isFlagged(startX, startZ, level, flagLoc)) {
return LinePathFinder.EMPTY;
}

const endX: i32 = Line.coordinate(destX, srcX, destWidth);
const endZ: i32 = Line.coordinate(destZ, srcZ, destHeight);

if (startX == endX && startZ == endZ) {
return LinePathFinder.EMPTY;
}

if (los && this.flags.isFlagged(startX, startZ, level, flagLoc)) {
return LinePathFinder.EMPTY;
}

const deltaX: i32 = endX - startX;
const deltaZ: i32 = endZ - startZ;
const absoluteDeltaX: i32 = <i32>Math.abs(deltaX);
Expand Down
8 changes: 4 additions & 4 deletions src/rsmod/LineValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,17 @@ export default class LineValidator {
const startX: i32 = Line.coordinate(srcX, destX, srcWidth);
const startZ: i32 = Line.coordinate(srcZ, destZ, srcHeight);

if (los && this.flags.isFlagged(startX, startZ, level, flagLoc)) {
return false;
}

const endX: i32 = Line.coordinate(destX, srcX, destWidth);
const endZ: i32 = Line.coordinate(destZ, srcZ, destHeight);

if (startX == endX && startZ == endZ) {
return true;
}

if (los && this.flags.isFlagged(startX, startZ, level, flagLoc)) {
return false;
}

const deltaX: i32 = endX - startX;
const deltaZ: i32 = endZ - startZ;
const absoluteDeltaX: i32 = <i32>Math.abs(deltaX);
Expand Down

0 comments on commit c9fa362

Please sign in to comment.