01.01.2019, 03:54
background
I started this project around 2015 just to see if I could remake what I believe would have been the hardest part of Crazybob's CnR script, then I got bored, lacked motivation and dropped it for several years..
I picked it up only to create a script to detect if you're driving on the wrong side of the road and then dropped it again.
Seeing a couple threads on path finding in the last couple of days inspired me to go through it again and I found several errors in my past scripts, I fixed them up and completed it, here's a short example of a path from LS stadium to LS docks
download
I created it in flash first to save me many hours loading, reloading the game which can be downloaded here
https://ufile.io/9s2ym
instructions
hold any key and move mouse to pan
mouse wheel to zoom
click a start position and an end position to create a path
after that, porting it over was pretty quick.
I haven't used anything of the other users work from here (gps wise), I used Aschratts to decompile the nodes, ran macros over to be able to put it into flash and then ran more scripts to fix it up and make it useable
I went with two different sets of nodes, one with just intersections and another with all the nodes
I ran the algorithm over the intersections to create the path and then used a function to highlight the nodes in between each intersection
I wanted to see what it'd look like on the minimap with icons, but it's really ugly having all those icons down there perhaps gangzones would look nicer.
speed
I really wasn't too fussed with performance, but I thought others would be, it took 154ms from KACC to the top of mount chilliad which you can see above checks just about every node in that case, it could be sped up as it's using square root distances but I'm not fussed, another way would be to do what real GPS' do and prioritise main roads
here's the enums I used in pawn
I started this project around 2015 just to see if I could remake what I believe would have been the hardest part of Crazybob's CnR script, then I got bored, lacked motivation and dropped it for several years..
I picked it up only to create a script to detect if you're driving on the wrong side of the road and then dropped it again.
Seeing a couple threads on path finding in the last couple of days inspired me to go through it again and I found several errors in my past scripts, I fixed them up and completed it, here's a short example of a path from LS stadium to LS docks
download
I created it in flash first to save me many hours loading, reloading the game which can be downloaded here
https://ufile.io/9s2ym
instructions
hold any key and move mouse to pan
mouse wheel to zoom
click a start position and an end position to create a path
after that, porting it over was pretty quick.
I haven't used anything of the other users work from here (gps wise), I used Aschratts to decompile the nodes, ran macros over to be able to put it into flash and then ran more scripts to fix it up and make it useable
I went with two different sets of nodes, one with just intersections and another with all the nodes
I ran the algorithm over the intersections to create the path and then used a function to highlight the nodes in between each intersection
I wanted to see what it'd look like on the minimap with icons, but it's really ugly having all those icons down there perhaps gangzones would look nicer.
speed
I really wasn't too fussed with performance, but I thought others would be, it took 154ms from KACC to the top of mount chilliad which you can see above checks just about every node in that case, it could be sped up as it's using square root distances but I'm not fussed, another way would be to do what real GPS' do and prioritise main roads
here's the enums I used in pawn
Code:
enum IntersectionInfo { Float:Int_xpos, Float:Int_ypos, Float:Int_zpos,//xyz NID,//node id, the index of this node in the array that contains all the nodes iN1,//intersection neighbour 1 n1,//neighbour 1 in the all nodes array g1,//g cost or value from this node to intersection neighbour 1 iN2, n2, g2, iN3, n3, g3, iN4, n4, g4, }; enum NodeInfo { Float:Node_xpos, Float:Node_ypos, Float:Node_zpos,//xyz nn1,//node neighbour 1 nn2, nn3, nn4, };