Refactored path calculating method, based somewhat on Maxi's (http://www.rune-server.org/runescape-development/rs2-client/snippets/462823-100-refactored-317-pathfinding.html)