Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!   (85,416 visits to this link)

    2. News

    1. GTA Online

      1. Find Lobbies & Players
      2. Guides & Strategies
      3. Vehicles
      4. Content Creator
      5. Help & Support
    2. Crews

      1. Events
      2. Recruitment
    1. Grand Theft Auto Series

    2. GTA Next

    3. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    4. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    5. GTA Chinatown Wars

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    9. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    12. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    3. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption 2

    2. Red Dead Redemption

    3. Rockstar Games

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Forum Support

    2. Site Suggestions

R3QQ

Pathfind node types

Recommended Posts

R3QQ

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.

Edited by R3QQ

Share this post


Link to post
Share on other sites
Nacorpio

This looks very interesting.

Have you found anything else so far?

Share this post


Link to post
Share on other sites
R3QQ

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.

Share this post


Link to post
Share on other sites
Nacorpio

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?

Share this post


Link to post
Share on other sites
R3QQ

 

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);
Edited by R3QQ

Share this post


Link to post
Share on other sites
Nacorpio

 

 

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.

Share this post


Link to post
Share on other sites
Eddlm

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.

Share this post


Link to post
Share on other sites
fastman92

It's a flood fill ID.

 

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

Share this post


Link to post
Share on other sites
lasyan3

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 :)

Edited by lasyan3

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.