Quantcast

Jump to content

» «
Photo

How to get the Speed Limit of the Street/Road/Freeway?

16 replies to this topic
qiangqiang101
  • qiangqiang101

    I'm Not MentaL

  • Members
  • Joined: 02 Feb 2010
  • Malaysia

#1

Posted 01 February 2017 - 08:45 AM

I found a mod that is in RagePluginHook have shown the Speed Limit on the Street: http://www.lcpdfr.co...coordsxyz-zone/

 

How to get the speed limit of the Street/Road/Freeway?


Jitnaught
  • Jitnaught

    ✰✰✰✰✰✰

  • Members
  • Joined: 24 Aug 2013
  • United-States

#2

Posted 01 February 2017 - 02:33 PM Edited by Jitnaught, 02 February 2017 - 03:13 AM.

If someone wants to try and deobfuscate/figure out the RageShowMyLocation code used for getting the speed limit, here it is:

Spoiler

 

Edit: edited some of the function names in the code to make it a bit more understandable.


qiangqiang101
  • qiangqiang101

    I'm Not MentaL

  • Members
  • Joined: 02 Feb 2010
  • Malaysia

#3

Posted 01 February 2017 - 04:28 PM

If someone wants to try and deobfuscate/figure out the RageShowMyLocation code used for getting the speed limit, here it is:

Spoiler

 

So there are no native to do that? it sucks


Jitnaught
  • Jitnaught

    ✰✰✰✰✰✰

  • Members
  • Joined: 24 Aug 2013
  • United-States

#4

Posted 02 February 2017 - 03:10 AM Edited by Jitnaught, 02 February 2017 - 08:44 PM.

Don't think so.

 

From looking at the code, it sort of looks like it just gets the current street name, checks an array if the street name is in it, and if it is, then set the speed limit to the one that is linked with that array. I can't confirm that, it just sort of looks like it.

  • Cyron43 likes this

jedijosh920
  • jedijosh920

    ⭐⭐⭐⭐⭐

  • Members
  • Joined: 01 Mar 2012
  • United-States

#5

Posted 02 February 2017 - 03:41 AM

Spawn a ped inside a vehicle for the street you want then MarkAsNoLongerNeeded() or make IsPersistent to false and get their speed while they drive.


Jitnaught
  • Jitnaught

    ✰✰✰✰✰✰

  • Members
  • Joined: 24 Aug 2013
  • United-States

#6

Posted 02 February 2017 - 08:43 PM Edited by Jitnaught, 02 February 2017 - 08:48 PM.

I was finally able to figure out how to deobfuscate the script. To do it I used NoFuserEx, ConfuserExSwitchKiller, and de4dot.

 

Here is the code relevant to getting the speed limit:

Spoiler

 

I was kinda close (but still pretty far) when I guessed that the script was checking an array for the string. It's actually just checking if the string contains certain keywords and is in a certain area.

  • Cyron43, flynhigh09 and uNiverselEgacy like this

Cyron43
  • Cyron43

    "I'm so bad I kick my own ass!" (GTA IV quote)

  • Members
  • Joined: 14 Apr 2013
  • Germany

#7

Posted 4 weeks ago

That sucks! I am still looking for a native which returns the speed limit for given street.
@Jitnaught Thanks anyway for your effort. :)

LeeC2202
  • LeeC2202

    Snitch

  • Members
  • Joined: 24 Oct 2015
  • United-Kingdom

#8

Posted 4 weeks ago

What you need is a list of every street name in the game. Then build that into a mod, where you just drive around the streets. When you drive on a new street, it will ask for the speed limit of that street and then store it. Once it has every street covered, it can write out a Dictionary<string, int> of street name, speed limit that you can use as a look-up source.

 

If someone knows how to get the street names, the rest is something I could possibly do with my infinite free-time. It'll be like therapy. :D I did the same kind of thing when I collected every bus-stop in the game.

 

I do have another mod that I used to collect all the CCTV camera locations but I don't think that would work for this. I was thinking that I could search for the speed limit road sign props, then get the nearest point on a road from the location of the sign but you can't guarantee that every road has a sign on it.


LeeC2202
  • LeeC2202

    Snitch

  • Members
  • Joined: 24 Oct 2015
  • United-Kingdom

#9

Posted 4 weeks ago Edited by LeeC2202, 3 weeks ago.

I don't know if this is any use to anyone but after digging through the global.oxt file and cross referencing with the GTA Wikia, I have this list, which is 220 218 Street names in alphabetical order. https://drive.google...iew?usp=sharing

 

GTA Wikia had around 164, so this list adds quite a few more.

 

I am going to drop this list into a mod and start driving round the map occasionally. As soon as I get a complete list of speed limits to match the streets, I will upload that data as well... unless someone else does it first.

 

Edit: I have just updated the list as I noticed a couple of duplicates. Jamestown St and South Shambles St were listed twice, sorry about that.


LeeC2202
  • LeeC2202

    Snitch

  • Members
  • Joined: 24 Oct 2015
  • United-Kingdom

#10

Posted 3 weeks ago

Okay, for anyone who is interested, the file on the link in the previous post has been updated and is now in this format:

 

0x8CD2E019, Abattoir Ave
0xDDCBDC74, Abe Milton Pkwy
0x4B7B2734, Ace Jones Dr
0x40D0731C, Adam's Apple Blvd

etc...

 

Doing a second search proved useful as I found some that I had missed, so there are now 228 listed.


LeeC2202
  • LeeC2202

    Snitch

  • Members
  • Joined: 24 Oct 2015
  • United-Kingdom

#11

Posted 3 weeks ago Edited by LeeC2202, 3 weeks ago.

Just to add one more update on this. I did some checking the other day with a few natives that returned floats. Some return bit-flags as well but nothing returned anything that would resemble speed limits. This was the main one I was using GET_VEHICLE_NODE_PROPERTIES but it seemed to change when there were turnoffs or road types changed. I also tried these but had no luck.

    edit float _0x29C24BFBED8AB8FB(float p0, float p1) // 29C24BFBED8AB8FB 3FE8C5A0
    edit float _0x8ABE8608576D9CE3(float p0, float p1, float p2, float p3) // 8ABE8608576D9CE3 3ED21C90
    edit float _0x336511A34F2E5185(float left, float right) // 336511A34F2E5185 A07C5B7D
    edit float _0x3599D741C9AC6310(float p0, float p1, float p2, float p3) // 3599D741C9AC6310 76751DD4

The other thing I noticed is that to do this, you would have to cross-reference road/street with zone name, because something like Route 68, goes through several zones and they don't all have the same speed limit. There are also truck speed limits in place on certain roads as well.

 

So based on what I have seen, I have to wonder if the speeds the AI drive at, are simply set as part of their tasks and not in response to any speed limits. They seem to drive very slow or very fast, no matter what the speed limits say. So maybe it's just a driving style that controls them and the road signs are simply there as real-life decoration.

 

If I find anything more, I will update the post...


K^2
  • K^2

    Vidi Vici Veni

  • Moderator
  • Joined: 14 Apr 2004
  • United-States
  • Best Poster [Technology / Programming] 2016
    Best Poster [Programming] 2015
    Most Knowledgeable [Web Development/Programming] 2013
    Most Knowledgeable [GTA Series] 2011
    Best Debater 2010

#12

Posted 3 weeks ago

It would be smart of developers to store flags on each node that report the type of road, and map these to a look-up table with actual speed limits. That would allow quickly changing the limits on a particular class of road without having to go through each node. So my money would be on this being the case.

LeeC2202
  • LeeC2202

    Snitch

  • Members
  • Joined: 24 Oct 2015
  • United-Kingdom

#13

Posted 3 weeks ago Edited by LeeC2202, 3 weeks ago.

Which would be a valid requirement, if the speed limits were relevant... but I suspect in this game, they're not. In a simulation, speed limits would be an essential factor but in a game where AI merely drives a world with preset tasks, just to put traffic on the roads, it's not so much an issue. They have driving styles which obey a limited set of rules and as such, have task processing that requires limited overhead. They don't need to care where they are on the map, just what their situation dictates that they do.

 

Given their already erratic behaviour, I would think that obeying another set of rules, would just cause them to create more obstacles, rather than drive freely. I think this is just a case of us requiring data that the game simply has no reason to store. My monitoring of the node flags showed no change at points in the road where speed limits were clearly being changed and I drove through several sections where speed limits were varying. This includes general traffic limits and isolated truck limits as well. I was watching them at a bit level, so any changes were very easy to spot.

 

As an example, I have just driven the full length of Route 68 again and 2 bits were used for the majority of the route. Bit 1 was set for the full length of the route and bit 7 was set when there was any kind of junction/intersection/turn-off. The only other variation on that was here, which I suspect marks the node as an access point to the roadside seller. Other than that it was either 130 or 2, those were the only values used and that road varies between 50mph and 60mph, with an additional 45mph limit for trucks.

 

wWsMTz0.jpg

 

There is a flag that marks a road as a slow road, which this native reads _GET_IS_SLOW_ROAD_FLAG(int nodeID)

  • ikt likes this

K^2
  • K^2

    Vidi Vici Veni

  • Moderator
  • Joined: 14 Apr 2004
  • United-States
  • Best Poster [Technology / Programming] 2016
    Best Poster [Programming] 2015
    Most Knowledgeable [Web Development/Programming] 2013
    Most Knowledgeable [GTA Series] 2011
    Best Debater 2010

#14

Posted 3 weeks ago

There is a flag that marks a road as a slow road, which this native reads _GET_IS_SLOW_ROAD_FLAG(int nodeID)

I was about to say, while actual speed limits might not be necessary, there has to be some way of telling what speed AI should drive on the road that correlates with it. But are there really just two speed modes? Slow and fast?

LeeC2202
  • LeeC2202

    Snitch

  • Members
  • Joined: 24 Oct 2015
  • United-Kingdom

#15

Posted 3 weeks ago Edited by LeeC2202, 3 weeks ago.

 

There is a flag that marks a road as a slow road, which this native reads _GET_IS_SLOW_ROAD_FLAG(int nodeID)

I was about to say, while actual speed limits might not be necessary, there has to be some way of telling what speed AI should drive on the road that correlates with it. But are there really just two speed modes? Slow and fast?

 

 

The main thing that leads me to believe that the speed isn't a critical factor in their AI, is this page http://gtaforums.com...driving-styles/

 

There are flags to obey traffic lights, avoid peds, avoid vehicles etc... but none that say "Drive within the speed limit", which I find rather odd if speed limits are in fact used. So what my thoughts were, is that when a vehicle is spawned, a task is set with a speed based on the type of road that spawn location is on. Then perhaps the transition onto a slow road occurs when a vehicle goes from freeway/highway to urban roads, reducing the speed the AI drives at to a slower rate. Or if they are spawned on a slow road, then their speed is increased when they transition onto a non-marked road.

 

I am going to add that slow road check to my output, to see what is going on, maybe seeing what are classed as slow roads, might open up a bit more information. I just need to chain a few natives together as it requires a nodetype to be passed to it and I have to work out if the int part of GET_NODE_PROPERTIES is the nodetype value it wants. All GET_NTH_CLOSEST_VEHICLE_NODE_ID says is "Returns the id.". So I will look through the scripts later and see what exactly it wants.

 

It has my interest peaked because as a game designer, I always find it interesting to see what decisions were made and how they implement those into the design. Separating the speed from the driving style is a curious decision, so I am intrigued to discover why. It also gives me an excuse to write lots of simple mods that just output debug data, which I find curiously entertaining. :D

 

Edit: Incidentally, that 111 value in the previous post that I thought was related to the roadside seller, that value is also used on the airfield near Trevor's house, on the sandy area in front of the main hangar. So it looks like that was maybe just catching the off-road flags for the side road I had wandered onto.


LeeC2202
  • LeeC2202

    Snitch

  • Members
  • Joined: 24 Oct 2015
  • United-Kingdom

#16

Posted 3 weeks ago

Here's a small sample of what the game classes as "Slow" roads. It seems to be off-roads, limited access, that kind of thing.

 

JIrWLZo.jpg


LeeC2202
  • LeeC2202

    Snitch

  • Members
  • Joined: 24 Oct 2015
  • United-Kingdom

#17

Posted 2 weeks ago

Just a bit more info on where I am up to with this little research project.

 

I discovered a file the other night called paths.xml, a rather large (130MB+) xml file that seems to contain all the node data for the roads. Inside that, I found some interesting entries such as this:

<object guid="5B21040A-AE2A-4689-9DE2-395CBB4162FE" name="vnode23399" class="vehiclenode" superclass="helper">
	<transform>
		<object>
			<position x="852.431763" y="96.631592" z="68.512962" />
		</object>
		<node>
			<position x="852.431763" y="96.631592" z="68.512962" />
		</node>
	</transform>
	<attributes class="VehicleNode" guid="{4F0E2CD1-0BCB-4ED6-8E9A-B9DB400DD3F6}">
		<attribute name="Speed" type="int" value="3" />
		<attribute name="Highway" type="bool" value="true" />
		<attribute name="Density" type="int" value="12" />
	</attributes>
	<paramblocks />
	<scene_link_hierarchy />
	<user_properties />
	<custom_attrs />
</object>

You can see there is an attribute called Speed. So I thought I had hit on something useful, until I did a search for all instances of Speed in that document. There were 8717 instances IIRC and they had 1 of 3 values, 0, 2 or 3. There were no instances of 1 anywhere in the document.

 

So armed with that info, I started to cross reference locations, so that I could drive to ones that corresponded to each value, to see what the flags returned. This was the outcome on 3 of them.

 

HxLVDrZ.jpg

 

So the bit patterns showed nothing that reflected the node flag attributes regarding the speed. I looked through the other natives and I cannot find anything that seems to return values that relate to the speeds. I had a look in Codewalker and that did show other flags but none of them showed the speed related info either, as you can see from this image.

 

xdMIZQR.jpg

 

So the end result is that I don't really know where else to look to get this info in-game. If anyone else has any further ideas, shout up and I will look into it. At this point though, I am going to return back to current projects.

  • K^2 likes this




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users