SA-MP Forums

Go Back   SA-MP Forums > SA-MP > Screenshots and Videos

Reply
 
Thread Tools Display Modes
Old 01/01/2019, 04:54 AM   #1
cessil
High-roller
 
cessil's Avatar
 
Join Date: Apr 2009
Posts: 1,353
Reputation: 296
Default Path finding in pawn

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
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,
};
cessil is offline   Reply With Quote
Old 01/01/2019, 06:12 AM   #2
KayJ
Gangsta
 
KayJ's Avatar
 
Join Date: Apr 2014
Posts: 674
Reputation: 64
Default Re: Path finding in pawn

Nice
__________________
SA:MP Wikipedia Profile

SA:MP Github Profile

Quote:
Originally Posted by ****** View Post
This is an extremely complex operation, revealed only to the best mathematicians in the world. It is called "multiplication"....
Quote:
Originally Posted by KayJ View Post
Go mobile or this will die. Many developers see and many don't but there will be heavy drop of playerbase in samp in next 5 years as people are going mobile and use pc mostly for next gen games not this decade old game.
KayJ is offline   Reply With Quote
Old 01/01/2019, 04:43 PM   #3
jop9888
Big Clucker
 
Join Date: Mar 2009
Posts: 116
Reputation: 6
Default Re: Path finding in pawn

Are you going to release the code?
jop9888 is offline   Reply With Quote
Old 01/01/2019, 05:09 PM   #4
Kar
Banned
 
Join Date: May 2010
Location: Black Asylum
Posts: 2,940
Reputation: 538
Default Re: Path finding in pawn

Good job. The GPS Plugin pretty much completes this.

I already made 2 more types of GPS styles, GTAIV/V and something like CrazyBobs with the plugin.

~9-11ms from Chilliad to KACC on my home host (Intel i7 7700HQ).
Kar is offline   Reply With Quote
Old 01/01/2019, 05:56 PM   #5
RogueDrifter
High-roller
 
RogueDrifter's Avatar
 
Join Date: Dec 2017
Location: SA-MP Drifting world.
Posts: 1,181
Reputation: 397
Default Re: Path finding in pawn

Path finding everywhere
__________________
Quote:
Originally Posted by Andy
My anti cheat is still relevant *puts shades on* https://github.com/RogueDrifter/Anti_cheat_pack

[Github]:Link [Gists]:Link [Forum]:Link [Server]:Link [Discord]:Link
RogueDrifter is offline   Reply With Quote
Old 02/01/2019, 02:36 AM   #6
cessil
High-roller
 
cessil's Avatar
 
Join Date: Apr 2009
Posts: 1,353
Reputation: 296
Default Re: Path finding in pawn

Quote:
Originally Posted by jop9888 View Post
Are you going to release the code?
If the gamer z plugin does the exact same thing but faster I don't see a point in doing so

Quote:
Originally Posted by Kar View Post
Good job. The GPS Plugin pretty much completes this.

I already made 2 more types of GPS styles, GTAIV/V and something like CrazyBobs with the plugin.

~9-11ms from Chilliad to KACC on my home host (Intel i7 7700HQ).
oh yeah I forgot I was going to make a text draw saying things like left turn in x m, another idea just crossed my mind is I could create a road naming program and use the script to say what road you're driving on.

I got the i5-8400

Quote:
Originally Posted by RogueDrifter View Post
Path finding everywhere
true, that's because it's fun to mess around and visualise
cessil is offline   Reply With Quote
Old 02/01/2019, 03:22 AM   #7
X337
Gangsta
 
Join Date: Sep 2014
Location: Indonesia
Posts: 879
Reputation: 287
Default Re: Path finding in pawn

oh cool good job
__________________
viva la sa-mp
X337 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Migrated from "old school Pawn" to sampctl and having trouble finding database location GRiMMREAPER Scripting Help 3 27/07/2018 07:59 PM
[HELP] Please help path / or without [Y_Ini] Luca12 Scripting Help 6 17/03/2015 05:20 PM
CONFIRMED: Gamer_z Path Finding Bug Kingmac Scripting Help 0 24/04/2013 01:58 PM
Path Finding Server Crash Kingmac Scripting Help 12 23/04/2013 09:00 AM
Path Finding cessil Discussion 6 10/07/2012 11:57 PM


All times are GMT. The time now is 12:31 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.