Pathfinder for FNCPC?
#1

How to i make pathfinder for FCNPC?
Reply
#2

Quote:
Originally Posted by Z3nx31L
View Post
How to i make pathfinder for FCNPC?
hi, you use Pathfinder.inc

example:
PHP 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 inodes_size-1i++)
        {
            
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;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)