NPC Following players?
#1

Alright, if you're here to tell me to search and stuff you can just leave. I've searched alot and all what I've found are movable NPCs but not actual following NPCs, I know that I can do it by applying animation and move them but it still looks stupid, let's be honest. Is there a way I can reach the same NPC control that is used in GTA SA when you get followed in a specific mission etc?

Like I know you would say an NPC get connected so it's pretty laggy to keep him following but real players following eachother wouldn't be as laggy even if they had high ping. I would just like to know why NPC following is really a big deal if it's already in the game, like can't it just be made with a single function by SAMP team maybe since I'm not as good? Once again, I've searched for few days and all what I've found are moving NPCs.
Reply
#2

You can use timer for getting player's pos
Then set the NPC's pos according to the distance.

Код:
new npctimer;

npctimer = SetTimerEx("NPCFollow", 100, true, "d", playerid); // where you want to start the NPC to follow.

forward NPCFollow(playerid);
public NPCFollow(playerid)
{
   new Float:x, Float:y, Float:z, pName[50];
   if(!IsPlayerNPC(playerid))
   {
     GetPlayerPos(playerid, x, y, z);
   }
   for(new i=0; i<MAX_PLAYERS; i++)
   {
     if(IsPlayerConnected(i) && IsPlayerNPC(i))
     {
        if(GetDistanceBetweenPlayers(playerid, i)<15)
        {
          SetPlayerPos(i, x-2, y, z);
        }
     }
   }
   return 1;
}
Reply
#3

Quote:
Originally Posted by Adam_Hardy
Посмотреть сообщение
I would just like to know why NPC following is really a big deal if it's already in the game, like can't it just be made with a single function by SAMP
Because everything is controlled by the server, and the server is not running the client logic. It doesn't use client computed data like other games (eg GTA O) which syncs the Ped AIs between clients. The SAMP Server has no knowledge about the world nor the AI and it does not trust the client with such tasks for good reasons.

That's why it is not as easy as just calling a single function and we have synced Peds...

Anyway, this requires FCNPC or RNPC for actual NPC control (SAMP's NPCs are useless in this regard), a plugin that holds info about the world (MapAndreas, or better yet ColAndreas) and, if you want to have NPCs that aren't "brute-forcing" their way to the player, also a Path Finder.

You'll need to control the NPCs movements manually (which is the easy part), check for walkable surfaces by RayCasting and find a path. The path finding is the hardest part.


Look into FCNPC/RNPC and MapAndreas/ColAndreas. That's your best bet for making an NPC that is capable of following Players similar to SP.
Reply
#4

Quote:
Originally Posted by NaS
Посмотреть сообщение
Look into FCNPC/RNPC and MapAndreas/ColAndreas. That's your best bet for making an NPC that is capable of following Players similar to SP.
That's what I was using already but thanks, I'm using RNPC right now but I've found a bug that the NPC keep setting his angle to 0 whenever the timer restarts, I tried to find if there's anything that does that up like SetPlayerFacingAngle but the include seems neat. Can you help me by any chance and check RNPC include if it resets the angle everytime the NPC reaches me?
Reply
#5

I will give you my take of what you need to do at least you can get a sample of the scope of what you would like to achieve.

When it comes to achieving results in SA-MP you are almost always at ground zero. There is often sufficient resources to achieve results but the resources have no backbone implementation to support a contingency of plugins working as a singular entity.

This is where ingenuity comes into play and you need to work BACKWARDS by examining the results you would like to achieve. That means broadening the perspective of your end result to do more than just follow players because that very ability encompasses so much more than just following a player. Such as jumping walls, navigating around collision, attacking the player, handling of NPC creation the list goes on but the point I am trying to make is once you KNOW all your end results it makes it a lot easier to breakdown the systems you will need.

NPC Handler - Connect / Disconnect / Spawn / Primary Functions
World Navigation System
Action control system

Side utilities
Create an editor to view NPC recordings you will need to see exactly how say a climbing animation works
Create a method to translate playbacks to a specified coordinate and z-rotation (This is critical)
I would suggest migrating to FCNPC HOWEVER you can still use RNPC to create recording playbacks

From my experience to actually breakthrough to the next evolution of NPC's it is going to take a lot of work. I think it is more than possible all the resources are there it just needs someone to put the pieces together. I could do it myself but I just don't have the time to do but that doesn't mean I don't know what to do
Reply
#6

Quote:
Originally Posted by Pottus
Посмотреть сообщение
I will give you my take of what you need to do at least you can get a sample of the scope of what you would like to achieve.
I really appreciate the sweet words from you, I've already made something impressive tbh. I'll consider everything you said also we can talk somewhere else maybe Skype if you would like to share stuff, I'll check your server though.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)