Makinolo Posted November 23, 2018 Share Posted November 23, 2018 Hi guys I've been reviewing many threads and searching the forum but no luck. Is there a way to know what type of road (highway / secondary road / dirt road) a vehicle is driving over? And for that same vehicle, is there a way to get its weight and bounding box (for volume calculation) from within a script? Thank you! Link to comment Share on other sites More sharing options...
Guest Posted November 23, 2018 Share Posted November 23, 2018 You can use GET_NTH_CLOSEST_VEHICLE_NODE_ID to get the nearest vehicle node and GET_VEHICLE_NODE_PROPERTIES to get the properties. It's all held in bitflags though and they're a pain to try and work out. You can also use the SHAPE_TEST functions to return the material type by casting a ray at the ground below the vehicle. For the weight you would have to use memory accessing to get the mass value from the handling.meta and for the bounding box you can use GET_MODEL_DIMENSIONS If you're using ScriptHookVDotNet, SHAPE_TEST has an equivalent in World.Raycast() and there is an Entity.Model.GetDimensions(). I am not sure if there are equivalents for the vehicle node functions. Link to comment Share on other sites More sharing options...
Makinolo Posted November 26, 2018 Author Share Posted November 26, 2018 Thank you so much! I've tested the ray casting against the ground and it works. It gives me the material underneath the vehicle. Only thing is SHAPE_TEST natives have changed names apparently and the documentation is not up to date. WORLDPROBE::_START_SHAPE_TEST_RAY is called WORLDPROBE::_CAST_RAY_POINT_TO_POINT and WORLDPROBE::_GET_SHAPE_TEST_RESULT_EX is called WORLDPROBE::_GET_RAYCAST_RESULT_2. Just in case someone wants to do the same thing: Vector3 vcoords = ENTITY::GET_ENTITY_COORDS(vehicle, TRUE); int rayHandle = WORLDPROBE::_CAST_RAY_POINT_TO_POINT( vcoords.x, vcoords.y, vcoords.z, vcoords.x, vcoords.y, vcoords.z - 10, 1, vehicle, 7); BOOL hit; Entity entityHit; Hash materialHash; Vector3 hitCoords, normal; WORLDPROBE::_GET_RAYCAST_RESULT_2(rayHandle, &hit, &hitCoords, &normal, &materialHash, &entityHit ); if (hit) { int etype = ENTITY::GET_ENTITY_TYPE(entityHit); // Do your thing with the ground type } There seems to be a comprehensive material list here: pastebin.com/gyHjsYBK NModds 1 Link to comment Share on other sites More sharing options...
Guest Posted November 26, 2018 Share Posted November 26, 2018 9 hours ago, Makinolo said: Only thing is SHAPE_TEST natives have changed names apparently and the documentation is not up to date. WORLDPROBE::_START_SHAPE_TEST_RAY is called WORLDPROBE::_CAST_RAY_POINT_TO_POINT and WORLDPROBE::_GET_SHAPE_TEST_RESULT_EX is called WORLDPROBE::_GET_RAYCAST_RESULT_2. If you notice on http://www.dev-c.com/nativedb/ they are all called SHAPE_TEST. That's the goto place to find the latest info. The _CAST_RAY and _GET_RAYCAST names were the original names before they worked out what they were really called. You can usually tell because natives that start with _ are names that have been given by the community. Names that don't have that are what have been discovered by hash reversal. It can get really confusing because SHVDN isn't up to date with what that page says. So quite often you will find names on there that don't exist in SHVDN, or SHVDN will still be using the old names. I suspect that there are so many mods out there now, they can't change anything because it would break all those existing mods. And given that a huge number of mod authors can't be bothered to fix bugs anyway, it's just too risky. But it does leave the C++ and .Net modders using different information, which is a definite problem. Good to hear you got it to work though. Link to comment Share on other sites More sharing options...