[Plugin] PathFinder by Pamdex
#21

Quote:
Originally Posted by KyleSmith
View Post
What is the difference in this than RouteCalculator Plugin?
Uses mapandreas to get average z-height positions (or along the lines) - Gamer_Z's is strictly on AI nodes by gta itself (seems for me, tried making a fast path-finder work on that plugin)
Reply
#22

Thats exactly what I planned for RNPC, really nice work. Ill give it a closer look later.
Reply
#23

OnPathCalculated is still not working for me. I did update but it doesnt get the succes thingy..
maybe im doing something wrong.
Can you make a small example to make a npc walk from point A to B by using a simple command and without a timer ?
Reply
#24

@UP
Code:
#include <a_samp>
#include <PathFinder>
#include <rnpc>
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[50];
		format(text,sizeof(text),"Zombie: %d failed!",routeid);
		SendClientMessageToAll(-1,text);
	}
	return 1;
}
public OnFilterScriptInit()
{
	PathFinder_Init(1.0); //test
	ConnectRNPC("Bot"); //id 0
	return 1;
}
public OnPlayerCommandText(playerid,cmdtext[])
{
	if(!strcmp("/bot_test",cmdtext,true))
	{
		new Float:x,Float:y,Float:z;
		GetPlayerPos(playerid,x,y,z);
		PathFinder_FindWay(0,x,y,x+random(100)-50,y+random(100)-50);
		return 1;
	}
	return 0;
}
Reply
#25

Quote:
Originally Posted by pamdex
View Post
@UP
Code:
#include <a_samp>
#include <PathFinder>
#include <rnpc>
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[50];
		format(text,sizeof(text),"Zombie: %d failed!",routeid);
		SendClientMessageToAll(-1,text);
	}
	return 1;
}
public OnFilterScriptInit()
{
	PathFinder_Init(1.0); //test
	ConnectRNPC("Bot"); //id 0
	return 1;
}
public OnPlayerCommandText(playerid,cmdtext[])
{
	if(!strcmp("/bot_test",cmdtext,true))
	{
		new Float:x,Float:y,Float:z;
		GetPlayerPos(playerid,x,y,z);
		PathFinder_FindWay(0,x,y,x+random(100)-50,y+random(100)-50);
		return 1;
	}
	return 0;
}
I just did that.. i went ingame put in the command and it said : Zombie: 0 failed
I have your version 0.12.. what now ?
Reply
#26

Sometimes calculation fails (e.g. when end point is in water). I tested this plugin on my public server with 5 zombies and it worked fine.

To test use this (previous code isn't good for testing):
Code:
#include <a_samp>
#include <PathFinder>
#include <rnpc>
new Float:Point[MAX_PLAYERS][3];
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);
	}
	return 1;
}
public OnFilterScriptInit()
{
	PathFinder_Init(1.0); //test
	ConnectRNPC("Bot"); //id 0
	return 1;
}
public OnPlayerCommandText(playerid,cmdtext[])
{
	if(!strcmp("/bot_test",cmdtext,true))
	{
		new Float:x,Float:y,Float:z;
		GetPlayerPos(playerid,x,y,z);
		PathFinder_FindWay(0,x,y,Point[playerid][0],Point[playerid][1]);
		return 1;
	}
	return 0;
}
public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
{
	Point[playerid][0] = fX;
	Point[playerid][1] = fY;
	Point[playerid][2] = fZ;
	return 1;
}
You should set point on map (near you) and use command :P.
Reply
#27

Iknow..and now i tried yours and i had the same problem..damn i must be doing something wrong but what else can it be.

EDIT: Okay i realize that it does work sometimes.
If i set point on the map and use the command after it mostly fails. But if sometimes after clicking the map and using the command again it does work.
Any ideas why ?
Reply
#28

Using this plugin for moving the NPCs is quite annoying, cause they go to every point of a node, so they look bugged, I think you can apply the run/sprint/walk animation to make them look smooth.

Edit: Does this detect object collision?
Reply
#29

@UP Only GTA SA objects (building etc.) - height difference

Quote:

Using this plugin for moving the NPCs is quite annoying

I'm making special function for smooth moving (in PAWN or in RNPC).
Reply
#30

@pamdex awesome! can't wait.
Reply
#31

Awesome work!
Reply
#32

nvm. ._.
Reply
#33

This is awesome!
Reply
#34

Quote:
Originally Posted by pamdex
Посмотреть сообщение
@UP Only GTA SA objects (building etc.) - height difference


I'm making special function for smooth moving (in PAWN or in RNPC).
If possible; Are you also planning some kind of road searcher..so an rnpc will only go threw roads from A to B ?
Reply
#35

Quote:
Originally Posted by AIped
Посмотреть сообщение
If possible; Are you also planning some kind of road searcher..so an rnpc will only go threw roads from A to B ?
Path for road ped only and closer A - B path, both will be very useful.
Reply
#36

New video!! <- smooth movement (PAWN CODE)
[ame]http://www.youtube.com/watch?v=lmsGNk7k2k8[/ame]

This PAWN code clears paths for NPC (example):
Код:
stock CompareZ(Float:fZ,Float:fZ2,Float:difference)
{
	new Float:zdiff = floatabs(fZ-fZ2);
	if(zdiff == 0.0) return 1;
	else if(fZ < 0 && fZ2 < 0)
	{
		if(zdiff <= difference) return 1;
		return 0;
	}
	else if(fZ > 0 && fZ2 > 0)
	{
		if(zdiff <= difference) return 1;
		return 0;
	}
	return 0;
}
public OnPathCalculated(routeid,success,nodes[],nodes_size)
{
	if(success)
	{
		RNPC_CreateBuild(routeid,PLAYER_RECORDING_TYPE_ONFOOT);
		new i;
		new Last_i = -1;
		new Float:Last_A = -1;
		new Float:Last_Z = -1;
		new Float:x,Float:y,Float:z,Float:x1,Float:y1,Float:z1;
		while(i < nodes_size)
		{
			if(i == 0)
			{
				Last_i = i;
				PathFinder_GetNodePos(nodes[i],x,y,z);
				PathFinder_GetNodePos(nodes[i+1],x1,y1,z1);
				Last_A = floatabs(270.0 - atan2( x1-x,y1-y));
				Last_Z = (z1-z);
				i++;
			}
			else if(i < nodes_size -1)
			{
				PathFinder_GetNodePos(nodes[i],x,y,z);
				PathFinder_GetNodePos(nodes[i+1],x1,y1,z1);
				if(Last_A == floatabs(270.0 - atan2(x1-x,y1-y)) && CompareZ(Last_Z,(z1-z),0.3)) //0.3 is good
				{
					i++;
				}
				else
				{
					Last_A = floatabs(270.0 - atan2(x1-x,y1-y));
					Last_Z = (z1-z);
					PathFinder_GetNodePos(nodes[Last_i],x,y,z);
					PathFinder_GetNodePos(nodes[i],x1,y1,z1);
					RNPC_AddMovement(x,y,z+1,x1,y1,z1+1,RNPC_SPEED_RUN);
					PathFinder_GetNodePos(nodes[i+1],x,y,z); //new node
					RNPC_AddMovement(x1,y1,z1+1,x,y,z+1,RNPC_SPEED_RUN);
					Last_i = i+1;
					i++;
				}
			}
			else
			{
				if(Last_i != nodes_size - 1)
				{
					PathFinder_GetNodePos(nodes[Last_i],x,y,z);
					PathFinder_GetNodePos(nodes[nodes_size-1],x1,y1,z1);
					RNPC_AddMovement(x,y,z+1,x1,y1,z1+1,RNPC_SPEED_RUN);
				}
				i++;
			}
		}
		RNPC_FinishBuild();
		RNPC_StartBuildPlayback(routeid);
	}
	return 1;
}
@AIped
Quote:

EDIT: Okay i realize that it does work sometimes.
If i set point on the map and use the command after it mostly fails. But if sometimes after clicking the map and using the command again it does work.
Any ideas why ?

Path calculation fails usually when calculation reaches the limit (maxnodes). Look at PathFinder_Init.
Reply
#37

Still looks pretty ugly around 50 sec+ there is a lot of glitches here with the NPC's teleportporting around, I'm guessing is has mostly to do with RNPC being pretty lousy in it's self.
Reply
#38

Quote:
Originally Posted by TheArcher
Посмотреть сообщение
Path for road ped only and closer A - B path, both will be very useful.
Erm for that you have RouteConnector Lol ; o

Anyway, seems like an useful plugin.
Reply
#39

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
Still looks pretty ugly around 50 sec+ there is a lot of glitches here with the NPC's teleportporting around, I'm guessing is has mostly to do with RNPC being pretty lousy in it's self.
You people aren't understanding, the RNPC plugin at it's current state is not stable in movement... lol? you guys are blaming the guy's plugin and you haven't even looked back at the rnpc plugin
Reply
#40

Quote:
Originally Posted by Kar
Посмотреть сообщение
You people aren't understanding, the RNPC plugin at it's current state is not stable in movement... lol? you guys are blaming the guy's plugin and you haven't even looked back at the rnpc plugin
That is why I stay far and clear of that crappy plugin
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)