After trouble shooting for about 5 hours I fixed the bug where if the map height is greater than its width, units would stop moving at coordinate y = map.height.
I don't know how I fixed it but I did change the conditional from gridSize to $gameMap.width() and $gameMap.height(). I also realised i was referencing variables (mixing x and y values) incorrectly which seems to actually fix the problem
I've pushed the new update to my github
I'll consider adding support to terrain support (and if so, zone of control)
Which terrain control plugin are you using? The srpg_TerrainControl.js one or RangeControl.js?
EDIT:
I've added compatability with RangeControl.js and its implementation of terrain movement restriction. It's a hack compatability job but it allows units to traverse through tiles with movement cost of more than 1 (which the original script assume all tiles would be)
The flow for movement selection (at least with nearest/furthest target) is as follows:
1. Go through all events on the map and pick all valid targets
2. Find the shortest route to all valid targets ignoring movement cost
3. Find the location that is closest to the best target
4. Work out a set of movement sequences to get to the best square and ensure its reachable
5. Set the location via aiPos and let SRPG_AIcontrol.js do the rest (match the location with the unit's move table (which is affected by terrain movement cost) and if valid move unit to location)
The issue was SRPG_AIControl creates moveTables (an associative array that contains how 'far' a map tile is from the unit based on unit's srpgMove and terrain passability/ZoC) which is slightly different to how SRPG_Pathfinding.js creates its own 'moveTable' (I called it grid) - my implementation ignores terrain passability
I fixed this issue by making routes that go through 'terrain-restricting-tiles' result in a valid destination as what is defined in the unit's moveTable range.
The issues are as follows:
1. I only changed the PathToCoordinate function that just spits out a bunch of directions to the target destination but not the PathTo function that actually calculates the best path to take. This means units will always take the shortest route, even if it means they travel through really slowly along tiles that restrict movement.
View attachment 183220
2. Zone of Control is not implemented and any unit blocked by zone of control will not move as they will have a 'best location' set outside its moveTable. Probably less of an issue because if a unit is within a ZoC it's probably not going to use a predictive formula to find the best path to the target as the target is within range (may be an issue for AI that ignore targetting when valid targets are within movement range).