SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 01/04/2013, 04:26 AM   #11
cyber_punk
Huge Clucker
 
Join Date: Feb 2008
Location: Det. Mi. USA.....
Posts: 435
Reputation: 10
Default Re: PathFinder 0.11v by Pamdex

Why not use the GTA SA path nodes? The code is out on the net for a node reader. Using MapAndreas will not correctly calculate a "path" route..... think about objects less than 1 meter squared, your bots, players whatever you apply your path too can and will walk through those objects. A+ for the effort I like seeing A* instead of Dijkstra method but without the nodes the accuracy of this will not be at the level that it could be.
__________________
cyber_punk is offline   Reply With Quote
Old 01/04/2013, 04:46 AM   #12
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,856
Reputation: 1292
Default Re: PathFinder 0.11v by Pamdex

Quote:
Originally Posted by cyber_punk View Post
Why not use the GTA SA path nodes? The code is out on the net for a node reader. Using MapAndreas will not correctly calculate a "path" route..... think about objects less than 1 meter squared, your bots, players whatever you apply your path too can and will walk through those objects. A+ for the effort I like seeing A* instead of Dijkstra method but without the nodes the accuracy of this will not be at the level that it could be.
I think mostly the purpose is to calculate a path anywhere, I'm guessing the GTA SA path nodes would be limited at any rate this plugin has some serious issues making it unusable at the current time beyond those issues mentioned.
Pottus is offline   Reply With Quote
Old 01/04/2013, 07:10 AM   #13
pamdex
Little Clucker
 
pamdex's Avatar
 
Join Date: Jan 2010
Location: Poland
Posts: 40
Reputation: 79
Default Re: PathFinder 0.11v by Pamdex

Ok. I'll see what's wrong in code...

Test this code (without "clear"):
Code:
#include <a_samp>
#include <PathFinder>
#include <rnpc>
new zombie_moved[5];
new zombie_timer;
public OnPathCalculated(routeid,success,nodes[],nodes_size)
{
	if(success)
	{
		new Float:x,Float:y,Float:z,Float:x1,Float:y1,Float:z1;
		RNPC_CreateBuild(routeid,PLAYER_RECORDING_TYPE_ONFOOT);
		//Bot!
		for(new i; i < nodes_size-1; i++)
		{
			PathFinder_GetNodePos(nodes[i],x,y,z);
			PathFinder_GetNodePos(nodes[i+1],x1,y1,z1);
			RNPC_AddMovement(x,y,z+1,x1,y1,z1+1,RNPC_SPEED_RUN); //crappy :D
		}
		RNPC_FinishBuild();
		RNPC_StartBuildPlayback(routeid);
	}
	else
	{
		new text[126];
		format(text,sizeof(text),"Zombie: %d failed!",routeid);
		SendClientMessageToAll(-1,text);
		zombie_moved[routeid] = true;
	}
	return 1;
}
public OnFilterScriptInit()
{
	PathFinder_Init(1.0);
	ConnectRNPC("Zombie1"); //id 0
	ConnectRNPC("Zombie2");
	ConnectRNPC("Zombie3");
	ConnectRNPC("Zombie4");
	ConnectRNPC("Zombie5");
	return 1;
}
public OnPlayerCommandText(playerid,cmdtext[])
{
	if(!strcmp("/zombie_spawn",cmdtext,true))
	{
		new Float:x,Float:y,Float:z;
		GetPlayerPos(playerid,x,y,z);
		SetPlayerPos(0,x+5,y,z);
		SetPlayerSkin(0,200);
		SetPlayerPos(1,x-5,y,z);
		SetPlayerSkin(1,200);
		SetPlayerPos(2,x+5,y+5,z);
		SetPlayerSkin(2,200);
		SetPlayerPos(3,x+5,y-5,z);
		SetPlayerSkin(3,200);
		SetPlayerPos(4,x-5,y-5,z);
		SetPlayerSkin(4,200);
		return 1;
	}
	if(!strcmp("/zombie_start",cmdtext,true))
	{
		for(new i=0;i<5;i++)
		{
			zombie_moved[i] = true;
		}
		zombie_timer = SetTimerEx("ZombieRun",1000,1,"d",playerid);
		return 1;
	}
	if(!strcmp("/zombie_stop",cmdtext,true))
	{
		KillTimer(zombie_timer);
		return 1;
	}
	return 0;
}
public OnRNPCPlaybackFinished(npcid)
{
	zombie_moved[npcid] = true;
	return 1;
}
forward ZombieRun(playerid);
public ZombieRun(playerid)
{
	new Float:x,Float:y,Float:z,Float:x1,Float:y1,Float:z1;
	GetPlayerPos(playerid,x1,y1,z1);
	for(new i=0;i<5;i++)
	{
		if(zombie_moved[i])
		{
			GetPlayerPos(i,x,y,z);
			PathFinder_FindWay(i,x,y,x1+random(6)-3,y1+random(6)-3);
			zombie_moved[i] = false;
		}
	}
	return 1;
}
OK! I found problem . I'll fix it soon.

@EDIT! OK fixed Wait a moment for update (max 30 minutes)
__________________
...

Last edited by pamdex; 01/04/2013 at 08:08 AM.
pamdex is offline   Reply With Quote
Old 01/04/2013, 08:09 AM   #14
RajatPawar
High-roller
 
RajatPawar's Avatar
 
Join Date: Aug 2011
Location: ヽ༼ຈل͜ຈ༽ノ
Posts: 2,183
Reputation: 311
Default Re: PathFinder 0.11v by Pamdex

I did this:
pawn Code:
PathFinder_GetNodePos(51, tx, ty, tz);
    PathFinder_FindWay(1, x, y, tx, ty);
print("Command called.");

and this:
pawn Code:
public OnPathCalculated(routeid, success, nodes[], nodes_size)
{
    new Float:X, Float:Y, Float:Z, Float:X1, Float:Y1, Float:Z1;
    print("OnPathCalculated called.");
    if(routeid == 1)
    {
        if(success)
        {
                 // .......
However, the "OnPathCalculated" message doesn't even get printed. Anything I am doing wrong?
RajatPawar is offline   Reply With Quote
Old 01/04/2013, 08:13 AM   #15
AIped
Gangsta
 
AIped's Avatar
 
Join Date: Feb 2011
Location: Netherlands
Posts: 619
Reputation: 46
Default Re: PathFinder 0.11v by Pamdex

I was looking for this ! Thanks man!
AIped is offline   Reply With Quote
Old 01/04/2013, 08:35 AM   #16
pamdex
Little Clucker
 
pamdex's Avatar
 
Join Date: Jan 2010
Location: Poland
Posts: 40
Reputation: 79
Default Re: PathFinder 0.12v by Pamdex

PathFinder 0.12v released!
  • New parameter in PathFinder_Init (maxnodes)
  • Little bug-fix

Download in first post!

@Rajat_Pawar
NodeID to X, Y is:
Code:
new Float:x = (nodeid % 6000) - 3000;
new Float:y = (((nodeid - (x+3000)) / 6000) / -1) + 3000;
or
Code:
new Float:x = (nodeid % 6000) - 3000;
new Float:y = ((nodeid - (x+3000)) / -6000) + 3000;
X, Y to NodeID:
Code:
new nodeid = (((y - 3000) * -1) * 6000) + (x + 3000);
__________________
...
pamdex is offline   Reply With Quote
Old 01/04/2013, 09:09 AM   #17
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,856
Reputation: 1292
Default Re: PathFinder 0.11v by Pamdex

Seems to work properly now thanks.

Suggestions - Create some sort of tolerance for along side buildings I'm finding my zombies get too close to buildings it would be nice if the path could be adjusted away from buildings by say 1.5 meters if that isn't possible then find a center average between the two buildings.
Pottus is offline   Reply With Quote
Old 01/04/2013, 09:56 AM   #18
Kyle
High-roller
 
Join Date: Mar 2009
Location: United Kingdom
Posts: 2,278
Reputation: 330
Default Re: PathFinder 0.11v by Pamdex

What is the difference in this than RouteCalculator Plugin?
Kyle is offline   Reply With Quote
Old 01/04/2013, 10:16 AM   #19
Niko_boy
High-roller
 
Niko_boy's Avatar
 
Join Date: Aug 2010
Location: Somewhere i belong
Posts: 1,338
Reputation: 138
Default Re: PathFinder 0.11v by Pamdex

this is so super !
__________________
nope[IMG]http://*******/1r0SOkH_[/IMG]
•••[CLOSED]LCS•Freeroam•DM•Stunts•••AutoArena [0.3z][No SkinShot][sixtytiger.com]Want a decent Attack Defend Gamemode?
N/A176.31.229.148:7830Get This! Attack-Defend(v2.3.1)
Niko_boy is offline   Reply With Quote
Old 01/04/2013, 10:44 AM   #20
TheArcher
High-roller
 
TheArcher's Avatar
 
Join Date: Dec 2009
Location: Home
Posts: 2,338
Reputation: 251
Default Re: PathFinder by Pamdex

MAN! Thanks a lot! Gonna try this out OMG THANKS
__________________
TheArcher 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



All times are GMT. The time now is 02:49 AM.


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