01.04.2013, 11:42
[Plugin] PathFinder by Pamdex
01.04.2013, 13:05
Thats exactly what I planned for RNPC, really nice work. Ill give it a closer look later.
01.04.2013, 15:59
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 ?
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 ?
01.04.2013, 16:38
@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; }
01.04.2013, 16:52
Quote:
@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 have your version 0.12.. what now ?
01.04.2013, 17:07
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):
You should set point on map (near you) and use command :P.
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; }
02.04.2013, 09:28
(
Last edited by AIped; 02/04/2013 at 11:29 AM.
)
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 ?
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 ?
02.04.2013, 11:57
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?
Edit: Does this detect object collision?
02.04.2013, 12:05
(
Last edited by pamdex; 02/04/2013 at 02:15 PM.
)
@UP Only GTA SA objects (building etc.) - height difference
I'm making special function for smooth moving (in PAWN or in RNPC).
Quote:
Using this plugin for moving the NPCs is quite annoying |
02.04.2013, 12:13
@pamdex awesome! can't wait.
02.04.2013, 12:26
Awesome work!
02.04.2013, 13:02
(
Последний раз редактировалось justinnater; 02.04.2013 в 14:13.
)
nvm. ._.
02.04.2013, 14:19
This is awesome!
02.04.2013, 18:23
02.04.2013, 18:57
02.04.2013, 19:07
New video!! <- smooth movement (PAWN CODE)
[ame]http://www.youtube.com/watch?v=lmsGNk7k2k8[/ame]
This PAWN code clears paths for NPC (example):
@AIped
Path calculation fails usually when calculation reaches the limit (maxnodes). Look at PathFinder_Init.
[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; }
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 ? |
02.04.2013, 23:14
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.
03.04.2013, 00:15
03.04.2013, 01:11
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
03.04.2013, 01:28
« Next Oldest | Next Newest »
Users browsing this thread: 3 Guest(s)