Skip to content

Commit

Permalink
Fixed pathfinding not being able to attack towards solid blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Anuken committed Jul 1, 2023
1 parent ea8d796 commit 05874ad
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions core/src/mindustry/ai/ControlPathfinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public boolean getPathPosition(Unit unit, int pathId, Vec2 destination, Vec2 out
}

//destination is impassable, can't go there.
if(solid(team, costType, world.packArray(World.toTile(destination.x), World.toTile(destination.y)))){
if(solid(team, costType, world.packArray(World.toTile(destination.x), World.toTile(destination.y)), false)){
return false;
}

Expand Down Expand Up @@ -380,7 +380,7 @@ private static boolean permissiveRaycast(int team, PathCost type, int x1, int y1
int err = dx - dy;

while(x >= 0 && y >= 0 && x < ww && y < wh){
if(solid(team, type, x + y * wwidth)) return true;
if(solid(team, type, x + y * wwidth, true)) return true;
if(x == x2 && y == y2) return false;

//no diagonals
Expand Down Expand Up @@ -429,9 +429,9 @@ private static boolean avoid(int team, PathCost type, int tilePos){
return cost == impassable || cost >= 2;
}

private static boolean solid(int team, PathCost type, int tilePos){
private static boolean solid(int team, PathCost type, int tilePos, boolean checkWall){
int cost = cost(team, type, tilePos);
return cost == impassable || cost >= 6000;
return cost == impassable || (checkWall && cost >= 6000);
}

private static float tileCost(int team, PathCost type, int a, int b){
Expand Down

0 comments on commit 05874ad

Please sign in to comment.