Jump to content

Is there an equivalent method for finding a random position on street in RDR2?


SteveOhByte
 Share

Recommended Posts

In GTA5 RagePluginHook we could use World.GetRandomPositionOnStreet(), and I was wondering if anyone new of a way to do this in RDR2.

 

I thought about using native methods, such as the "GET_CLOSEST_ROAD" native, to cobble-together a solution, but I was met with a rage crash and the log file telling me that it attempts to read or write protected memory, and therefore throws an access violation.

 

I'm trying to create a basic script to spawn someone in a carriage some distance away, and have them drive to the player. Currently I have them, the carriage, and the horses spawning correctly, they all hitch up and get in the driver's seat, but they continuously get spawned into a tree or rock or some such and are unable to follow through on the driver's task to "DriveToPosition"

 

Has anyone tried to do something similar to this that could offer some insight?

Everyone wants happiness, no one wants pain. But you can't have a rainbow, without a little rain.

Link to comment
Share on other sites

Admittedly it has been a long time since I messed with RDR2 pathfinding natives, but from what I recall they were extremely limited in finding positions that were even just a little bit farther away from the player. Perhaps all nodes are streamed. That being said, the natives themselves do work:

 

Vector3 outPos = Vector3.Zero;
if (Game.CallNative<bool>("GET_CLOSEST_VEHICLE_NODE", position.X, position.Y, position.Z, &outPos, nodeType, 300f, 200f))
{
    foundPosition = outPos;
    return true;
}

Vector3 outPos = Vector3.Zero;
int node = 0;
if (Game.CallNative<bool>("GET_RANDOM_VEHICLE_NODE", position.X, position.Y, position.Z, radius, false, false, false, &outPos, &node))
{
    foundPosition = outPos;
    nodeId = node;
    return true;
}

 

Link to comment
Share on other sites

9 hours ago, LMS said:

Admittedly it has been a long time since I messed with RDR2 pathfinding natives, but from what I recall they were extremely limited in finding positions that were even just a little bit farther away from the player. Perhaps all nodes are streamed. That being said, the natives themselves do work:

 

Vector3 outPos = Vector3.Zero;
if (Game.CallNative<bool>("GET_CLOSEST_VEHICLE_NODE", position.X, position.Y, position.Z, &outPos, nodeType, 300f, 200f))
{
    foundPosition = outPos;
    return true;
}

Vector3 outPos = Vector3.Zero;
int node = 0;
if (Game.CallNative<bool>("GET_RANDOM_VEHICLE_NODE", position.X, position.Y, position.Z, radius, false, false, false, &outPos, &node))
{
    foundPosition = outPos;
    nodeId = node;
    return true;
}

 

Thanks for the help, yeah the more I play around with these and other natives the more I realise how much work is going to be involved in creating a system to get a proper point, especially since there are mountain paths that are sometimes considered nodes to look out for. Thanks again though.

Everyone wants happiness, no one wants pain. But you can't have a rainbow, without a little rain.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...