Assuming you're putting this in a Move Route script command, there is no reason to do this:
JavaScript:
$gameMap._events[this._eventId]
It is completely equivalent to just
this, which is shorter. Even if for whatever reason you can't put it in a Move Route script command and must put it in a regular script command, the following is again 100% equivalent and also shorter:
That wouldn't be the cause of your issue though (since, as I said, both forms are 100% equivalent). Note that the shortened forms are context-sensitive though – one
only works in Move Route scripts and the other
only works in event Script calls.
Okay, now I'll try to describe what I think are the issues you're seeing, and you can confirm if I got it right.
In the first video, there are two occasions where I see the event is about to touch you but then you back away and the event in turn reverses direction as well. Also, there is one place where it looks like it got stuck at a corner, trying to go down (into the wall) when the correct choice would have been to go left. I'm not quite sure what would cause it to get stuck, unless there's a bug in the passability settings. Reversing direction could happen if it thought the route that appears longer is actually shorter.
In the second video, it appears that the event stops before reaching its goal on several occasions. In other words, it simply won't progress any further until the player moves again. This seems like it could be a bug in the system that caches the path to avoid expensive recomputation on every step – that cache is automatically cleared when the destination changes, so the fact that it comes unstuck when the player moves is a pretty good sign that this is the cause.
Does that seem correct? I see 3 separate issues – getting stuck at a corner, reversing direction when you back away, and stopping randomly. The first and third might be the same, but they might not be.
For the issue of seemingly choosing a "longer" path than optimal, I'd suggest checking a few things:
- What's the search limit? Did you change it or leave it at the default? This isn't that complicated of a map, so I wouldn't expect problems with the default search limit, but it's possible it could be related.
- Can you reproduce similar issues by moving the player with the mouse? Like, click in various locations and see whether the player chooses the shortest path to get there.
- Are there any invisible events on the map? If so, be sure to set them to THROUGH so the enemy can pass over them.