Quantcast

Jump to content

» «
Photo

Pathfind node types

8 replies to this topic
R3QQ
  • R3QQ

    Den som söker han finner

  • Members
  • Joined: 30 May 2015
  • Sweden

#1

Posted 20 February 2016 - 10:23 PM Edited by R3QQ, 23 February 2016 - 12:26 PM.

I recently found the parameter "nodeType" in PATHFIND::GET_CLOSEST_VEHICLE_NODE and PATHFIND::GET_CLOSEST_VEHICLE_NODE_WITH_HEADING. Probably exists in the GET_NTH as well. 

 

There seems to be 4 types of nodes:

1. Only asphalt road (0, 4, 8, etc).

2. Simple path/asphalt road (1, 5, 9, etc).

3. Under the map at always the same coords (probably x,y,z all set to 0), somewhat in the middle of the map (2, 6, 10, etc).

4. Water (3, 7, 11, 15, 19, 23, 27, 31, 35, 39... 239, etc).

 

The node types follows a pattern. They seems to repeat every fourth node. Asphalt road starts at 0 (0, 4, 8, etc), simple path/asphalt road at 1 (1, 5, 9, etc), under the map at 2 (2, 6, 10, etc) and water at 3 ( 3, 7, 11, 15, 19, 23, 27, 31, 35, 39... 239, etc).

 

I couldn't see any difference within the groups of repeating node types. I wonder why they repeat. These are used in the scripts: 0, 1, 8 and 12. 0 and 8 are both in the group  

"Only asphalt road". Why would they use them both if they mean the same thing? Maybe there's more to it. 

  • ClareXoBearrx3R9 likes this

Nacorpio
  • Nacorpio

    Proficient in C# and Java

  • Members
  • Joined: 05 May 2013
  • Sweden

#2

Posted 04 May 2016 - 02:48 PM

This looks very interesting.

Have you found anything else so far?


R3QQ
  • R3QQ

    Den som söker han finner

  • Members
  • Joined: 30 May 2015
  • Sweden

#3

Posted 04 May 2016 - 03:26 PM

I haven't done any further research other than testing. It works great in my mod FFFR. I'm only using the first occurrence of each nodetype.

Nacorpio
  • Nacorpio

    Proficient in C# and Java

  • Members
  • Joined: 05 May 2013
  • Sweden

#4

Posted 05 May 2016 - 02:02 PM

I haven't done any further research other than testing. It works great in my mod FFFR. I'm only using the first occurrence of each nodetype.

 

Do you have any example of you making use out of this in your mod?


R3QQ
  • R3QQ

    Den som söker han finner

  • Members
  • Joined: 30 May 2015
  • Sweden

#5

Posted 05 May 2016 - 03:12 PM Edited by R3QQ, 05 May 2016 - 03:19 PM.

 

I haven't done any further research other than testing. It works great in my mod FFFR. I'm only using the first occurrence of each nodetype.

 

Do you have any example of you making use out of this in your mod?

 

 

For example FFFR uses this when the player drives into water or presses the unstuck key. Basically the closest node to the player on land is searched for and the vehicle placed there. If the player already is on 

the node or close by, a new calculation is automatically made but this time don’t use the players position but instead an addition to it so that a node further away is found. This is important to avoid loops. 

 

When close to the sea or a lake and pressing the new vehicle/change vehicle key, the player will be teleported out into the water and given a boat. Basically the closest waternode and landnode are compared. When in a boat in water the calculation changes so that you can get back to a vehicle on land or spawn one and teleport to it when pressing the new vehicle/change vehicle key.

int nodeTypeAsphaltRoad = 0;
int nodeTypeSimplePathOrAsphaltRoad = 1;
int nodeTypeWater = 3;
PATHFIND::GET_CLOSEST_VEHICLE_NODE_WITH_HEADING(coordX, coordY, coordZ, &closestAsphaltRoad, &roadHeadingAsphaltRoad, nodeTypeAsphaltRoad, 3, 0);
PATHFIND::GET_CLOSEST_VEHICLE_NODE_WITH_HEADING(coordX, coordY, coordZ, &closestWater, &roadHeadingWater, nodeTypeWater, 3, 0);

I wrote this in the native db a few months back:

Example of usage, moving vehicle to closest path/road:

Vector3 coords = ENTITY::GET_ENTITY_COORDS(playerVeh, true);
Vector3 closestVehicleNodeCoords; 
float roadHeading; 
PATHFIND::GET_CLOSEST_VEHICLE_NODE_WITH_HEADING(coords.x, coords.y, coords.z, &closestVehicleNodeCoords, &roadHeading, 1, 3, 0); 
ENTITY::SET_ENTITY_HEADING(playerVeh, roadHeading);
ENTITY::SET_ENTITY_COORDS(playerVeh, closestVehicleNodeCoords.x, closestVehicleNodeCoords.y, closestVehicleNodeCoords.z, 1, 0, 0, 1);
VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(playerVeh);
  • ins1de likes this

Nacorpio
  • Nacorpio

    Proficient in C# and Java

  • Members
  • Joined: 05 May 2013
  • Sweden

#6

Posted 05 May 2016 - 05:51 PM

 

 

I haven't done any further research other than testing. It works great in my mod FFFR. I'm only using the first occurrence of each nodetype.

 

Do you have any example of you making use out of this in your mod?

 

 

For example FFFR uses this when the player drives into water or presses the unstuck key. Basically the closest node to the player on land is searched for and the vehicle placed there. If the player already is on 

the node or close by, a new calculation is automatically made but this time don’t use the players position but instead an addition to it so that a node further away is found. This is important to avoid loops. 

 

When close to the sea or a lake and pressing the new vehicle/change vehicle key, the player will be teleported out into the water and given a boat. Basically the closest waternode and landnode are compared. When in a boat in water the calculation changes so that you can get back to a vehicle on land or spawn one and teleport to it when pressing the new vehicle/change vehicle key.

int nodeTypeAsphaltRoad = 0;
int nodeTypeSimplePathOrAsphaltRoad = 1;
int nodeTypeWater = 3;
PATHFIND::GET_CLOSEST_VEHICLE_NODE_WITH_HEADING(coordX, coordY, coordZ, &closestAsphaltRoad, &roadHeadingAsphaltRoad, nodeTypeAsphaltRoad, 3, 0);
PATHFIND::GET_CLOSEST_VEHICLE_NODE_WITH_HEADING(coordX, coordY, coordZ, &closestWater, &roadHeadingWater, nodeTypeWater, 3, 0);

I wrote this in the native db a few months back:

Example of usage, moving vehicle to closest path/road:

Vector3 coords = ENTITY::GET_ENTITY_COORDS(playerVeh, true);
Vector3 closestVehicleNodeCoords; 
float roadHeading; 
PATHFIND::GET_CLOSEST_VEHICLE_NODE_WITH_HEADING(coords.x, coords.y, coords.z, &closestVehicleNodeCoords, &roadHeading, 1, 3, 0); 
ENTITY::SET_ENTITY_HEADING(playerVeh, roadHeading);
ENTITY::SET_ENTITY_COORDS(playerVeh, closestVehicleNodeCoords.x, closestVehicleNodeCoords.y, closestVehicleNodeCoords.z, 1, 0, 0, 1);
VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(playerVeh);

 

Thank you.

I appreciate it.


Eddlm
  • Eddlm

    Newie

  • Members
  • Joined: 24 Aug 2015
  • Spain

#7

Posted 07 May 2016 - 05:22 PM

Thanks to the information given in this thread I've been able to code a reliable Spawnpoint generator. Here it is, written in C#:

    public enum Nodetype { AnyRoad, Road, Offroad, Water }

    public static Vector3 GenerateSpawnPos(Vector3 desiredPos, Nodetype roadtype, bool sidewalk)
    {

        Vector3 finalpos = Vector3.Zero;
        bool ForceOffroad = false;


        OutputArgument outArgA = new OutputArgument();
        int NodeNumber = 1;
        int type = 0;

        if (roadtype == Nodetype.AnyRoad) type = 1;
        if (roadtype == Nodetype.Road) type = 0;
        if (roadtype == Nodetype.Offroad) { type = 1; ForceOffroad = true; }
        if (roadtype == Nodetype.Water) type = 3;


        int NodeID = Function.Call<int>(Hash.GET_NTH_CLOSEST_VEHICLE_NODE_ID, desiredPos.X, desiredPos.Y, desiredPos.Z, NodeNumber, type, 300f, 300f);
        if (ForceOffroad)
        {
            while (!Function.Call<bool>(Hash._GET_IS_SLOW_ROAD_FLAG, NodeID) && NodeNumber < 500)
            {
                NodeNumber++;
                NodeID = Function.Call<int>(Hash.GET_NTH_CLOSEST_VEHICLE_NODE_ID, desiredPos.X, desiredPos.Y, desiredPos.Z, NodeNumber, type, 300f, 300f); 
            }
        }
        Function.Call(Hash.GET_VEHICLE_NODE_POSITION, NodeID, outArgA);
        finalpos = outArgA.GetResult<Vector3>();

        if (sidewalk) finalpos = World.GetNextPositionOnSidewalk(finalpos);
        return finalpos;
    }

It returns the a valid Vector3 for you to use for spawning peds, cars or even boats. You can add +50 z to it for flying helicopters or planes.

It doesn't return a heading, though.

  • R3QQ and ins1de like this

fastman92
  • fastman92

    фастман92 | ف

  • Members
  • Joined: 28 Jul 2009
  • Poland
  • Best Conversion 2016 [GTA: Underground] [Contribution]
    Contribution Award [Mods]

#8

Posted 07 May 2016 - 05:47 PM

It's a flood fill ID.

The nodes that can be reached from one to another will have the same flood fill ID.
  • R3QQ likes this

lasyan3
  • lasyan3

    Player Hater

  • Members
  • Joined: 22 Nov 2016
  • France

#9

Posted 08 December 2016 - 07:21 PM Edited by lasyan3, 08 December 2016 - 07:21 PM.

Hi fastman92 (it seems we cannot send you private message so I try here),

 

Could you please give me some details about this "flood fill ID"? How to look for nodes linked together?

 

Thanks for your help :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users