ziggi / FCNPC

FCNPC - Fully Controllable NPC
Apache License 2.0
138 stars 31 forks source link

Certain nodes - bots fly above ground on first point? #197

Closed dennorske closed 12 months ago

dennorske commented 5 years ago

So, I am making this issue on behalf of a friend of mine that always keeps asking me for help, and his english is quite questionable, so he asked me to create this issue on his behalf.

So some background on what is being done;

He makes a server where he spawns 100's of NPCs around all over SA. I dont know much what the NPCs are supposed to do, other than walk around inside their node and serve their tasks. Well, while spawning these NPC's, there are ALWAYS a few bots determined to fly from their starting point to another unknown point in their node. And after they have done that, they walk normally on ground level.

The thing is, after debugging node IDs we came over that for example node 26 and 17 made this happen every time we tried. Not sure why though. Removing them left us with different nodes where the NPCs are flying around. I will paste the creation of the bots (code) below, so you can see how this is done. It is inside a loop.

if(npcid == INVALID_PLAYER_ID)
        {
            printf("Warning: Failed to create NPC ID %d (%s)", i, name);
            continue;
        }

        do 
        {
            node = random(FCNPC_MAX_NODES);
        } 
        while (!IsValidZones(node));

        new vehnodes, pednodes, navinodes;
        FCNPC_GetNodeInfo(node, vehnodes, pednodes, navinodes);

        new Float:x, Float:y, Float:z;
        if (pednodes != 0) 
        {
            point = random(pednodes - 1) + vehnodes + 1;
        }

        FCNPC_SetNodePoint(node, point);
        FCNPC_GetNodePointPosition(node, x, y, z);
        printf("%.2f, %.2f, %.2f", x, y, z);
        switch(random(3))
        {
            case 0:
            {

                FCNPC_Spawn(npcid, rand(31, 200), x, y, z);

            }
            case 1:
            {
                if(drugdealersNpc <= 2)
                {
                    drugdealersNpc++;
                    FCNPC_Spawn(npcid, rand(28, 30), x, y, z);
                }
                else 
                {
                    FCNPC_Spawn(npcid, rand(31, 200), x, y, z);
                }   
            }
            case 2:
            {
                if(Copnpc <= 5)
                {
                    Copnpc++;
                    FCNPC_Spawn(npcid, rand(300, 307), x, y, z);
                }
                else 
                {
                    FCNPC_Spawn(npcid, rand(31, 200), x, y, z);
                }
            }   
        }
        FCNPC_PlayNode(npcid, node, 0);
        FCNPC_SetPosition(npcid, x, y, z);
        new Float:x1, Float:y1, Float:z1;
        FCNPC_GetPosition(npcid,  x1, y1, z1);
        printf("%.2f, %.2f, %.2f", x1, y1, z1);

The main intent with this issue is to get help how to proceed debugging and actually figure out why the NPCs are so determined to fly at their initial point.

I can ask/provide more information as the thread goes on. I am guessing by now that the plugin might have a bug, however I might also be totally wrong, so I am open for suggestions and ideas here.

Crayder commented 5 years ago

Do you mean like they are flying way above where they should or is it just like they are not actually on the ground? If they are just sliding between nodes it's likely just the difference from the real map and MapAndreas's nodes. MapAndreas is not that accurate in some cases, especially slopes in SF for some reason, the slopes are actually backwards in some places (in which case it looks like the NPC would be walking up a staircase on some streets).

dennorske commented 5 years ago

MapAndreas is not used he says, and I don't know if it is included in the plugin. Node 26 is at SF airport though.

They are only sliding between points (in air) from when they spawn until they arrive at the next point. After that is done, he can't really see it occurring again..