I implemented some kind of pathfinding.
I think it is Djikstra.
When the map is loaded, a whole load of nodes are created depending on the tile and it’s surroundings.
Solid tiles are left without nodes.
Tiles on top of solids are ‘ground nodes’
Tiles 2 above solids are ‘aboveground nodes’
Climbable tiles are ‘climbable nodes’
(There are also nodes for tiles next to climbables, but they are just to allow jumping off ladders)
Each node has rules for which directions it leads to.
Ground nodes can’t go down. (Because it would be invalid)
AboveGround nodes can’t go up (Because double jumping doesn’t apply)
Ladders can go any direction. (Up down, or jump to the sides)
Of course if there is no node then it can’t lead to that direction anyway.
Then it uses recursion + an arraylist to find all the possible paths that lead to the goal. Once it hits the goal, the arraylist is passed back up. Then it is compared to the lists for the other directions, and the shortest is passed up and so on.
Unfortunately, the maximum path length is 10. Otherwise there is LAGGGGG.
The good news is that targeting only works in a 16x16 area, so most of the time it will be fine.