#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; }
@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; } |
#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; }
Using this plugin for moving the NPCs is quite annoying |
@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 ?
|
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; }
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 for road ped only and closer A - B path, both will be very useful.
|
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
|