Gio,
Thanks for the reply.
I looked into it a little bit and implemented variable grid movment costs and movement limitations in the iso source code.
Movement costs mean that different grids have different costs. This is accomplished through the setDetail function.
For example, a grid which is swampy would have a movement cost higher (say 3) than a grass grid (say 1).
If you never call setDetail, then the movement costs default to 1 for each grid.
Movement limits are a way of dynamically allowing/preventing iso objects from passing through grids.
For example, if you had a character who couldn't cross water and then they acquired some water walking shoes,
you could reset the characters costLimit so that it could walk on the water.
Or if you had characters which were land bound versus characters that could fly, they would have different movment limits.
This is simply a number which is checked against an individual grids movement cost. If your movement limit is less than the grid movment cost, then you can't go through that grid. It seems like you currently do this with collision maps, but this would be another simple way of doing it. If no movment limit is set, then just do pathing based on movement costs like usual.
Here are the changes to the iso source code in a nutshell
- terrainBehavior.js: Added cost field to the setDetail data structure.To set a movement cost for a grid, you would call setDetail and include {cost: number} in the data field. If no cost is associated with a grid, then it defaults to 1 like in the old findPath routine.
- isoCharacter.js: Added isoObjCostLimit parameter to setDestination() parameters
- iso.js: Added isoObjCostLimit parameter to findPath() parameters. Modified code in findPath to ignore a grid if it's movment cost exceeds the objects cost limit. Modified code so that movement costs of grids is taken into account when finding best path.If no movement limit is passed in, then just carry on like usual.
I think it is less then 20 lines of code in total.
If you search the iso source files for 'Ashatej', you can find the specific sections
I created a little demo where an iso world is created . There is a blue guy who goes to grids based on where you click. The grids go green-blue-red-black in order of movment cost. The current setting is that the costLimit does not allow the character to move over the black grids.
To modify the player cost limit, search for player.avatar.costLimit or COST_LIMIT in the game file.
To modify the costs associated with grids, look at how the costs are assigned in the world file.
Assignment of the grid colors is in the levelData.json file.
I tested it out and it seems to work as expected.
I have zipped up the code and the test files and attached them to this reply.
It should run right out of the box once you unzip it.
Anyway, I know there is a lot on you plate, but this would seem to be a simple and useful thing to add to the iso plugin if you have the time.
cheers,
Shri