GMS 2 [SOLVED!] MP_ functions unable to path through blocked corners

Tidbit

Member
Hello there, I've been fiddling with a roguelike for the past few days and opted into using GM's built in path functions to avoid having to mess around with writing a pathfinding system myself.
My RL has 8 direction movement and the player can cross over blocked corners but it seems as though GM's built in pathfinding is unable to.
Here are some screenshots showing whats going on with the path:
Before crossing a blocked corner:

After crossing blocked corner:

As you can see, after crossing through the blocked corner, the built in mp_ functions GM provides are no longer able to path to the minotaur.
This is less than ideal since normally the enemies should be able move according to the same way a player is able to.

I'm generating the grid in the way that you would expect but since I'm working with a turn based system, I'm handing the movement a bit differently in a script that the enemy calls when its turn is up:
Code:
var dir, components, dx, dy, _id;

dir = argument0;
_id = 0;

components = global.components[dir];
dx = components[0];
dy = components[1];

_id  = instance_place(x+16*dx, y+16*dy, oPlayer)
if (_id = noone) {
   if (mp_grid_path(pGrid.map_grid, path, x,y,target.x ,target.y, 0)) {
       target_x = path_get_point_x(path, path_step);
       target_y = path_get_point_y(path, path_step);
       
       x_pos = target_x div tile_width;
       y_pos = target_y div tile_height;
   }
}
I've done a sizeable amount of digging through other threads and wasn't able to specifically find anything relating to this sort of issue so I'm hoping there's a way I can bend the rules without having to take the time to write something up from scratch.
I was thinking about perhaps checking for when the player crosses between corners and create an instance which would become the new target for the currently seeking enemy. When the enemy reached it, the other instance would have stored in it which diagonal the player traveled and would then have the enemy perform that as its next movement direction. Then the enemy would be able to resume standard pathfinding like before.
This would be probably the simplest option but I wanted to see if anyone else had any better ideas or perhaps solutions which would allow me to enhance the current suite of mp_ commands to allow for this sort of movement.

Thanks in advance for the help!
 

Tidbit

Member
So I just went and wrote my own.
heavily referenced this video here (WxYqSKPU4C4 - posting the video ID since I can't post links yet) which really breaks down things nicely.
Just had to change the diagonal movement to allow for what I wanted to do. And in case anyone in the future wants the same thing I wanted and is also looking for solutions and happens to find this thread... I'll go ahead and show what I changed to get diagonal movement and crossing blocked corners to work:
Code:
 var diagonal=((i+j) == (curX+curY)); // originally ((i+j)%2 == (curX+curY)%2)
        var canWalk=false;
        var distFromCurrentToIJ=0;
        if(diagonal){
            canWalk=pField.walkable[i,j]
            distFromCurrentToIJ=1.414;
This is a part of the processCurrentNode script that the vid walks through.
Anyways, I'm going to go ahead and mark this as solved, cheers all!
 
Top