[Plugin] RNPC - Recordfree NPCs | Control NPCs without recording | DEV
#41

Quote:
Originally Posted by BloodyEric
Посмотреть сообщение
The video looks awesome!

Although I realized that the NPC is floating a little over the ground before actually beginning to walk - is this fixable? Maybe applying the animation before setting the movement?

Apart from that its really great, I hope you can do some car-stuff too.
Thats because the npcs walk with constant speed, but normally players "accelerate" for a short time when starting to walk. I already thought about interpolating that acceleration, im gonna need this for vehicles anyways.

I also sent kalcor a PM about my problems with the vehicle recordings (and about aiming), hope hes gonna respond. The last 8 bytes of the vehicle recordings seem to be more impotrant than i thought at first, but i still couldnt decrypt their meaning. I think this is the last problem i got with the generation.
Damn, I like my work, im somehow proud of how well things are developing
Reply
#42

Nice, cant wait to see that

In a few minutes there will be a new version available. It mostly cleans the code from old functions, makes some things easier (like setting the correct walking animation for the specific speeds), and fixes some minor things. Also theres a new RNPC_GetBuildTime function to get the length of the currently active, or the last finished build.

Also theres now a Linux .so with it. I just compiled it (CentOS 5 x86/x64 combo), but didnt test it yet. Would be nice if someone else could do that
Reply
#43

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
Nice, cant wait to see that

In a few minutes there will be a new version available. It mostly cleans the code from old functions, makes some things easier (like setting the correct walking animation for the specific speeds), and fixes some minor things. Also theres a new RNPC_GetBuildTime function to get the length of the currently active, or the last finished build.

Also theres now Linux .so with it. I just compiled it, but didnt test it yet. Would be nice if someone else could do that
Awesome thanks! I got a idea to use with my server for on foot npcs

hey one problem though, why does it say I need msvcp100d.dll but I have Microsoft Visual C++ 2010 x86 Redistributable Package .. I even reinstalled it and it still won't work.
Reply
#44

Hm, Archer also reported a problem like this, it might be a problem about x86/x64 versions, or maybe you need a 2008 redist package, but not sure about that: I had the same problem once with another plugin, but dont know how it was fixed.

I uploaded two of the files that might be needed, try putting them in your server directory. No idea if it helps, but its a least a chance
msvcr100d.dll
msvcp100d.dll
Reply
#45

It works now, thanks
Reply
#46

pawn Код:
// This is a proof conception (possibly algorithm to find path !!)
enum info { Float:nX, Float:nY, Float:nZ };

new pathFind[MAX_ZUMBIS][info];
OnUpdate(playerid, npcid);
public OnUpdate(playerid, npcid) {

    static
            Float:p_X,
            Float:p_Y,
            Float:p_Z,
            Float:n_X,
            Float:n_Y,
            Float:n_Z,
            Float:n_A,
            Float:p_mapAndreas,
            Float:n_mapAndreas;

    GetPlayerPos(playerid, p_X, p_Y, p_Z);
    GetPlayerPos(npcid,    n_X, n_Y, n_Z);

    GetPlayerFacingAngle(npcid, n_A);
   
    if(pathFind[npcid][nX] == 0.0 && pathFind[npcid][nY] == 0.0)  {

        MoveRNPC(npcid, p_X, p_Y, p_Z, 0.0115);
       
        n_X += (5.0 * floatsin(-n_A, degrees)),
        n_Y += (5.0 * floatcos(-n_A, degrees));

        MapAndreas_FindZ_For2DCoord(p_X, p_Y, p_mapAndreas);

        MapAndreas_FindZ_For2DCoord(n_X, n_Y, n_mapAndreas);

        if(n_mapAndreas - n_Z > 2.5) {

           
            // possibility of have building on front off npcid
            if(p_Z != n_mapAndreas && p_mapAndreas - n_mapAndreas > 1.5) {
                SendClientMessageToAll(-1, "I FIND BUILDING OF FRONT NPC"); //debug
                // have building in front off player ..

                static
                    Float:n_Deg, Float:b_X,  Float:b_Y,  Float:b_Z;

                n_Deg = 0;

                // round for find alternative path (right side) (made you left side :mrgreen:)

                n_X -= (5.0 * floatsin(-n_A, degrees)),
                n_Y -= (5.0 * floatcos(-n_A, degrees));
       
                while(n_Deg < 90.0) {

                    n_Deg  += 5.0;

                    b_X = n_X + (10.0 * floatsin(-n_A+n_Deg, degrees)),
                    b_Y = n_Y + (10.0 * floatcos(-n_A+n_Deg, degrees));

                    MapAndreas_FindZ_For2DCoord(b_X, b_Y, b_Z);
                    b_Z = p_Z;

                    if(p_mapAndreas != n_mapAndreas) {

                        SendClientMessageToAll(-1, "I FIND ALTERNATIVE PATH IN RIGHT SIDE"); //debug
                        MoveRNPC(npcid, b_X, b_Y, p_mapAndreas, 0.0115);

                        pathFind[npcid][nX] = b_X;
                        pathFind[npcid][nY] = b_Y;
                        pathFind[npcid][nZ] = b_Z;

                    }

                }
            }
        }
    }
    else {
        if(IsPlayerInRangeOfPoint(npcid, 1.0, pathFind[npcid][nX], pathFind[npcid][nY], pathFind[npcid][nZ])) {

            pathFind[npcid][nX] = 0.0;
            pathFind[npcid][nY] = 0.0;
            pathFind[npcid][nZ] = 0.0;

            MoveRNPC(npcid, p_X, p_Y, p_Z, 0.0115);
        }
    }
    return true;
}
Use this, and, only fix the "distance" (i using 5.0 )
(i dont test, made here in editor post)
Reply
#47

You seen this http://www.gtamodding.com/index.php?title=GTA_SA_Paths, not if it will be useful
Reply
#48

Mauzen, test my code, should work ??
Reply
#49

Quote:
Originally Posted by [FeK]DraKiNs
Посмотреть сообщение
pawn Код:
// This is a proof conception (possibly algorithm to find path !!)
enum info { Float:nX, Float:nY, Float:nZ };

new pathFind[MAX_ZUMBIS][info];
OnUpdate(playerid, npcid);
public OnUpdate(playerid, npcid) {

    static
            Float:p_X,
            Float:p_Y,
            Float:p_Z,
            Float:n_X,
            Float:n_Y,
            Float:n_Z,
            Float:n_A,
            Float:p_mapAndreas,
            Float:n_mapAndreas;

    GetPlayerPos(playerid, p_X, p_Y, p_Z);
    GetPlayerPos(npcid,    n_X, n_Y, n_Z);

    GetPlayerFacingAngle(npcid, n_A);
   
    if(pathFind[npcid][nX] == 0.0 && pathFind[npcid][nY] == 0.0)  {

        MoveRNPC(npcid, p_X, p_Y, p_Z, 0.0115);
       
        n_X += (5.0 * floatsin(-n_A, degrees)),
        n_Y += (5.0 * floatcos(-n_A, degrees));

        MapAndreas_FindZ_For2DCoord(p_X, p_Y, p_mapAndreas);

        MapAndreas_FindZ_For2DCoord(n_X, n_Y, n_mapAndreas);

        if(n_mapAndreas - n_Z > 2.5) {

           
            // possibility of have building on front off npcid
            if(p_Z != n_mapAndreas && p_mapAndreas - n_mapAndreas > 1.5) {
                SendClientMessageToAll(-1, "I FIND BUILDING OF FRONT NPC"); //debug
                // have building in front off player ..

                static
                    Float:n_Deg, Float:b_X,  Float:b_Y,  Float:b_Z;

                n_Deg = 0;

                // round for find alternative path (right side) (made you left side :mrgreen:)

                n_X -= (5.0 * floatsin(-n_A, degrees)),
                n_Y -= (5.0 * floatcos(-n_A, degrees));
       
                while(n_Deg < 90.0) {

                    n_Deg  += 5.0;

                    b_X = n_X + (10.0 * floatsin(-n_A+n_Deg, degrees)),
                    b_Y = n_Y + (10.0 * floatcos(-n_A+n_Deg, degrees));

                    MapAndreas_FindZ_For2DCoord(b_X, b_Y, b_Z);
                    b_Z = p_Z;

                    if(p_mapAndreas != n_mapAndreas) {

                        SendClientMessageToAll(-1, "I FIND ALTERNATIVE PATH IN RIGHT SIDE"); //debug
                        MoveRNPC(npcid, b_X, b_Y, p_mapAndreas, 0.0115);

                        pathFind[npcid][nX] = b_X;
                        pathFind[npcid][nY] = b_Y;
                        pathFind[npcid][nZ] = b_Z;

                    }

                }
            }
        }
    }
    else {
        if(IsPlayerInRangeOfPoint(npcid, 1.0, pathFind[npcid][nX], pathFind[npcid][nY], pathFind[npcid][nZ])) {

            pathFind[npcid][nX] = 0.0;
            pathFind[npcid][nY] = 0.0;
            pathFind[npcid][nZ] = 0.0;

            MoveRNPC(npcid, p_X, p_Y, p_Z, 0.0115);
        }
    }
    return true;
}
Use this, and, only fix the "distance" (i using 5.0 )
(i dont test, made here in editor post)
Problems with this

pawn Код:
MapAndreas_FindZ_For2DCoord(p_X, p_Y, p_mapAndreas);
that is called pretty early in the movie... (should be called after the height check)

pawn Код:
if(n_mapAndreas - n_Z > 2.5)
why not if(n_mapAndreas > n_Z) ?

pawn Код:
if(p_Z != n_mapAndreas && p_mapAndreas - n_mapAndreas > 1.5)
Hardly chance of getting the exact same z with p_Z, try a range check instead. also the same issue as above with height

pawn Код:
MapAndreas_FindZ_For2DCoord(b_X, b_Y, b_Z);
                    b_Z = p_Z;
I'm sure you can see the bug here. b_Z = p_Z? just after getting the Z from map andreas? erm
Reply
#50

Quote:

why not if(n_mapAndreas > n_Z) ?

For does not bug occur with small increases!

Quote:

Problems with this

pawn Code:
MapAndreas_FindZ_For2DCoord(p_X, p_Y, p_mapAndreas);

that is called pretty early in the movie... (should be called after the height check)

Oh Yeap, thanks !! (I had not noticed haha )

pawn Код:
enum info { Float:nX, Float:nY, Float:nZ };

new pathFind[MAX_ZUMBIS][info];
OnUpdate(playerid, npcid);
public OnUpdate(playerid, npcid) {

    static
            Float:p_X,
            Float:p_Y,
            Float:p_Z,
            Float:n_X,
            Float:n_Y,
            Float:n_Z,
            Float:n_A,
            Float:b_A,
            Float:p_mapAndreas,
            Float:n_mapAndreas;

    GetPlayerPos(playerid, p_X, p_Y, p_Z);
    GetPlayerPos(npcid,    n_X, n_Y, n_Z);

    GetPlayerFacingAngle(npcid, n_A);
    b_A = atan2(n_Y - p_Y, n_X - p_X);
   
    if(pathFind[npcid][nX] == 0.0 && pathFind[npcid][nY] == 0.0)  {

        MoveRNPC(npcid, p_X, p_Y, p_Z, 0.0065);

        n_X += (5.0 * floatsin(-n_A, degrees)),
        n_Y += (5.0 * floatcos(-n_A, degrees));

        MapAndreas_FindZ_For2DCoord(n_X, n_Y, n_mapAndreas);

        if(n_mapAndreas - n_Z > 2.5) {

            MapAndreas_FindZ_For2DCoord(p_X, p_Y, p_mapAndreas);
                   
            // possibility of have building on front off npcid
           
            if( (p_Z != n_mapAndreas) && (n_mapAndreas != p_mapAndreas ) ) {
           
                SendClientMessageToAll(-1, "I FIND BUILDING OF FRONT NPC"); //debug
                // have building in front off player ..

                static
                    Float:n_Deg, Float:b_X,  Float:b_Y,  Float:b_Z;

                n_Deg = 0;

                // round for find alternative path (right side) (made you left side :mrgreen:)

                n_X -= (5.0 * floatsin(-n_A, degrees)),
                n_Y -= (5.0 * floatcos(-n_A, degrees));

                while(n_Deg < 90.0) {

                    n_Deg  += 4.5;

                    // here right, left side.
                    // need fix (working +- haha :p)
                    if(b_A > 180.0) {
                        b_X = n_X + (10.0 * floatsin(-n_A-n_Deg, degrees)),
                        b_Y = n_Y + (10.0 * floatcos(-n_A-n_Deg, degrees));
                    }
                    else {
                        b_X = n_X + (10.0 * floatsin(-n_A+n_Deg, degrees)),
                        b_Y = n_Y + (10.0 * floatcos(-n_A+n_Deg, degrees));
                    }

                    MapAndreas_FindZ_For2DCoord(b_X, b_Y, b_Z);

                    if(p_mapAndreas != b_Z) {

                        SendClientMessageToAll(-1, "I FIND ALTERNATIVE PATH");
                        MoveRNPC(npcid, b_X, b_Y, p_mapAndreas, 0.0065);

                        pathFind[npcid][nX] = b_X;
                        pathFind[npcid][nY] = b_Y;
                        pathFind[npcid][nZ] = b_Z;
                    }
                }
            }
        }
    }
    else {
        if(IsPlayerInRangeOfPoint(npcid, 1.0, pathFind[npcid][nX], pathFind[npcid][nY], pathFind[npcid][nZ])) {

            pathFind[npcid][nX] = 0.0;
            pathFind[npcid][nY] = 0.0;
            pathFind[npcid][nZ] = 0.0;

            MoveRNPC(npcid, p_X, p_Y, p_Z, 0.0115);
        }
    }
    return true;
}


I'm thinking of something interesting. On putting +90-90 it create a triangle:
The invalid path is hypotenuse and the "adjacent" side will always be the new path (interestingly, it is this part, is the size of the construction .. )

I tested a lot, it works with buildings. The problem is that if the NPC is under one roof and the player not. The NPC BUG, or stairs for example

The algorithm is correct, but there are exceptions in San Andreas. I think one way to deal with these exceptions, is to check a given area is a building.

For checking a point is a building. I think we do four points and check MapAndreas Z POS, if the same Z POS in four points. Yes, is a building

Example:
PHP код:
static
    
Float:4points,
    
i,
    
Float:zPoint;
for(
0!= 4i++) {
    
pontoX edificioX + (5.0 floatsin(-90.0 idegrees)),
    
pontoY edificioY +(5.0 *  floatcos(-90.0 idegrees));
    
MapAndreas_FindZ_For2DCoord(pontoXpontoYzPoint);
    
4points += zPoint;
}
if(
floatround(4points) % 90 == 0) {
    
// 4 points have the same MapAndreas Z Pos
    //   x
    // x   x
    //   x
    // 5 * 4 = 20 metters
    

Reply
#51

If talking about nodes, maybe this can help . If you go to C:\Program Files\Rockstar Games\GTA San Andreas\data\Paths you'll see a lot of nodes. I think this is NPC nodes in single player mode. This can help too.
Reply
#52

Quote:
Originally Posted by zgintasz
Посмотреть сообщение
If talking about nodes, maybe this can help . If you go to C:\Program Files\Rockstar Games\GTA San Andreas\data\Paths you'll see a lot of nodes. I think this is NPC nodes in single player mode. This can help too.
Made by Nodes would only do for the players to walk the streets (not in specifics local), would be bad!
Reply
#53

Waiting for the easier release
Reply
#54

Couldnt test your code yet, my current rnpc include is extremely messed up as im changing some major things in the structure, and am too lazy to use another version for testing
But Ill test it as soon as everything is working again.

I noticed a major syncing problem with the npcs that causes more work than I expected: As NPCs run in their own thread, the script does not wait e.g. for them to join the server when connecting. So codes like
pawn Код:
new id = ConnectRNPC("lol");
MoveRNPC(id, whatever);
Do not work in general, as after connecting the NPC isnt really there. Means I need to rearrange the whole system to join the npc threads. Mainly the RNPC_StartBuildPlayback function will set a mark to execute the playback when the npc actually connects in OnPlayerConnect. This will also bring changes to the vehicle system, as it is the same for functions like PutPlayerInVehicle. The NPC isnt in the vehicle instantly, but with a slight delay (<1 ms), this is also the reason for most of the current problems with the vehicles.
Im still not 100% sure about how ill realize all this in detail, but am doing my best to make a way more stable version available soon, the current 0.3 is a real mess to be honest
Reply
#55

Something i thought of earlier:
Lets say you have the command /followplayer <player> that would make a npc follow the player specified.

What if there is a fence between them that can be climbed normally?.

As it is now i assume the npc would just wrap through the fence, which might not be that nice to see...
Reply
#56

Okay, one little issue with 0.3

acceleration and speed, when setting speed, is acceleration the acceleration linked with the speed? or are they both different. I don't understand how it works. do you need speed for acceleration to work? do you need acceleration for speed to work? (seems logical)
Reply
#57

Very nice, It's very usefull REP+ MAN
Reply
#58

Make NPC function that he had shot at certain coordinates
Reply
#59

Quote:
Originally Posted by Kar
Посмотреть сообщение
Okay, one little issue with 0.3

acceleration and speed, when setting speed, is acceleration the acceleration linked with the speed? or are they both different. I don't understand how it works. do you need speed for acceleration to work? do you need acceleration for speed to work? (seems logical)
Speed in any case is the maximum speed in m/ms. If acceleration is bigger than 0, it starts at 0 speed and accelerates until the speed is reached, else it starts with the max speed. The acceleration is in speed/s, or (m/ms)/s, so if speed is 0.1, and acceleration is 0.01, it will need 10 seconds to reach the max speed.
Reply
#60

I don't have any idea how to set this up, when i try to run the server it says that a .dll file is missing, i download it and then it says "can't find command _lib_something in the .dll library" or something like that, i really need this, if you could give me a brief response of how i should install this, thanks.

EDIT: Nevermind, i found out that i didn't download the .dll file correctly.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)