Eddlm Posted September 30, 2015 Share Posted September 30, 2015 (edited) Based on the information shared in this thread. Driving Styles work as a list of 32 bits converted to a decimal integer. Each bit acts as a flag, and enables or disables a function inside the driving abilities of the AI ped you're scripting. You can translate these bits to integers (and viceversa) with a converter like this one. You apply the driving style to the ped like this: C# (ScriptHookVDotNet)ped.DrivingStyle=DrivingStyle.Rushed or GTA.Native.Function.Call(GTA.Native.Hash.SET_DRIVE_TASK_DRIVING_STYLE, ped, int);C++AI::SET_DRIVE_TASK_DRIVING_STYLE(ped,int) Here are all the flags, their corresponding integers and the known functionalities: FLAG ENABLED - CONVERTED INTEGER - DESCRIPTION00000000000000000000000000000001 - 1 - stop before vehicles00000000000000000000000000000010 - 2 - stop before peds00000000000000000000000000000100 - 4 - avoid vehicles00000000000000000000000000001000 - 8 - avoid empty vehicles00000000000000000000000000010000 - 16 - avoid peds00000000000000000000000000100000 - 32 - avoid objects 00000000000000000000000001000000 - 64 - ?00000000000000000000000010000000 - 128 - stop at traffic lights00000000000000000000000100000000 - 256 - use blinkers00000000000000000000001000000000 - 512 - allow going wrong way (only does it if the correct lane is full, will try to reach the correct lane again as soon as possible)00000000000000000000010000000000 - 1024 - go in reverse gear (backwards)00000000000000000000100000000000 - 2048 - ?00000000000000000001000000000000 - 4096 - ?00000000000000000010000000000000 - 8192 - ?00000000000000000100000000000000 - 16384 - ?00000000000000001000000000000000 - 32768 - ?00000000000000010000000000000000 - 65536 - ?00000000000000100000000000000000 - 131072 - ?00000000000001000000000000000000 - 262144 - Take shortest path (Removes most pathing limits, the driver even goes on dirtroads)00000000000010000000000000000000 - 524288 - Probably avoid offroad?00000000000100000000000000000000 - 1048576 - ?00000000001000000000000000000000 - 2097152 - ?00000000010000000000000000000000 - 4194304 - Ignore roads (Uses local pathing, only works within 200~ meters around the player)00000000100000000000000000000000 - 8388608 - ?00000001000000000000000000000000 - 16777216 - Ignore all pathing (Goes straight to destination)00000010000000000000000000000000 - 33554432 - ?00000100000000000000000000000000 - 67108864 - ?00001000000000000000000000000000 - 134217728 - ?00010000000000000000000000000000 - 268435456 - ?00100000000000000000000000000000 - 536870912 - avoid highways when possible (will use the highway if there is no other way to get to the destination)01000000000000000000000000000000 - 1073741824 - ? Here are some examples of Driving Styles, gotten from ScriptHookVDotNet: FLAGS - CONVERTED INTEGER - NAME/DESC OF THE DRIVING STYLE01000000000011000000000000100101 - 1074528293 - "Rushed"00000000000011000000000000100100 - 786468 - "Avoid Traffic"00000000000000000000000000000110 - 6 - "Avoid Traffic Extremely"00000000000011000000000010101011 - 786603 - "Normal"00000000001011000000000000100101 - 2883621 - "Ignore Lights"00000000000000000000000000000101 - 5 - "Sometimes Overtake Traffic" Now that we know some flags what they do, lets analyze these known Driving Styles, starting with the simpler ones. NOTE: flags not highlighted (marked with ^ ) are ignored by this guide, as we don't know what they do yet. 6 - Avoid Traffic Extremely 00000000000000000000000000000110 ^^10 - 2 - Stop before peds100 - 4 - Avoid vehicles This driving style is the simpler of them all, as you see. The driver will only avoid vehicles, but stop before peds. 5 - Sometimes Overtake Traffic 00000000000000000000000000000101 ^ ^1 - 1 - Stop before vehicles100 - 4 - Avoid vehicles This one, although simple, its also interesting. The driver will both stop before a vehicle and avoid it! How? This is not a paradox or anything, it simply means the driver can stop before a vehicle or avoid it, probably at random. 1074528293 - Rushed, probably more used, works the same way: 01000000000011000000000000100101 ^ ^ ^ 1 - 1 - Stop before vehicles100 - 4 - Avoid vehicles100000 - 32 - Avoid Objects We all know what this one does, it's used in a lot of scripts. The driver will brake when a vehicle is nearby, but sometime after, he will end up passing the vehicle. It will avoid vehicles that are completely stopped, too. That, added to the fact that it also avoids objects too, makes this driving style a somwehat careful one. 786603 - Normal 00000000000011000000000010101011 ^ ^^1 - 1 - Stop before vehicles10 - 2 - Stop before peds10000000 - 128 - Stop at Traffic Lights This seems to be the default style drivers use. Makes sense. 2883621 - Ignore Lights 00000000001011000000000000100101 ^ ^ ^ ^1 - 1 - Stop before vehicles100 - 4 - Avoid vehicles100000 - 32 - Avoid Objects10000000 - 128 - Stop at Traffic Lights [OFF] I've highlighted the bit that would make it stop at traffic lights. You can see it is off this time. 786468 - Avoid Traffic 00000000000011000000000000100100 ^ ^100 - 4 - Avoid vehicles100000 - 32 - Avoid Objects Another simple one, with only 4 flags on. Having understood all of this, you can now create your own driving styles by setting ON any flags you need to. 1076 - Example 00000000000000000000010000110100 ^ ^^ ^100 - 4 - Avoid vehicles10000 - 16 - Avoid peds100000 - 32 - Avoid Objects10000000000 - Reverse only This driving style would be a pretty crazy one. the driver would avoid peds, vehicles and objects, all while going in reverse! 8388614 - Example2 00000000100000000000000000010110 ^ ^ ^^1 - 1 - Stop before vehicles10 - 2 - Stop before peds100000 - 32 - Avoid Objects100000000000000000000000 - 4194304 - Ignore roads This one would be fitting for any precise driving task. Careful, stopping at anything that moves, avoiding objects, and ignoring roads so the driver gets the vehicle exactly where you want. Other natives that set the Driving Style There are other natives that seem to override the Driving Style, you can set the Driving Style from there too. Here's a list of the ones confirmed to set a Driving Style: AI::TASK_VEHICLE_DRIVE_TO_COORDAI::TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGEAI::TASK_VEHICLE_DRIVE_WANDERAI::TASK_VEHICLE_ESCORTAI::_TASK_VEHICLE_FOLLOW Driver Ability You can set the driver ability with PED:SET_DRIVING_ABILITY. While I am not sure if the max ability is 100f or 10f, I know that 100f works. An higher value means that the AI reaction times and avoiding ability are better. __________________The lists above will be updated as more flags/natives are discovered, so stay tuned. Remember that you pass the translated integer to the DrivingStyle native, not the binary presentation. Edited February 2, 2018 by Eddlm NModds, ardaozkal, whorse and 9 others 12 Link to comment Share on other sites More sharing options...
ISOFX Posted September 30, 2015 Share Posted September 30, 2015 Good work! will be using this thread in the future. thanks Link to comment Share on other sites More sharing options...
ardaozkal Posted September 30, 2015 Share Posted September 30, 2015 Nice job! Link to comment Share on other sites More sharing options...
Cyron43 Posted October 3, 2015 Share Posted October 3, 2015 Great job. Link to comment Share on other sites More sharing options...
elsewhat Posted October 6, 2015 Share Posted October 6, 2015 Thank you so much for the research. Have implemented driving modes support in the latest version 1.3.1 of my Scene Director mod https://www.gta5-mods.com/scripts/scene-director I have seven different driving styles: Aggressive, Careful, Cruise, Impatient, Offroad and reverse. Here is the code I'm using driving_mode.h: #pragma once#include <vector>struct DrivingMode{ int value; std::string name; bool useVehicleMaxSpeed; float manualMaxSpeed;};enum DRIVING_FLAGS{ FLAG1_STOP_VEHS=1, FLAG2_STOP_PEDS=2, FLAG3_AVOID_VEHS=4, FLAG5_AVOID_PEDS=16, FLAG6_AVOID_OBJS=32, FLAG8_STOP_LIGHTS=128, FLAG11_REVERSE=1024, FLAG23_IGN_ROADS=4194304,};std::vector<DrivingMode> getAllDrivingModes();DrivingMode getDefaultDrivingMode();DrivingMode getNextDrivingMode(DrivingMode drivingMode); driving_mode.cpp: #include "driving_mode.h"#include <vector>#include <algorithm>std::vector<DrivingMode> gtaDrivingModes= { { FLAG3_AVOID_VEHS|FLAG5_AVOID_PEDS|FLAG6_AVOID_OBJS, "Aggressive", true, 0.0 }, {FLAG1_STOP_VEHS|FLAG2_STOP_PEDS|FLAG8_STOP_LIGHTS, "Careful", false, 15.0 }, { FLAG1_STOP_VEHS | FLAG2_STOP_PEDS | FLAG8_STOP_LIGHTS, "Cruise", false, 5.0 }, { FLAG1_STOP_VEHS | FLAG3_AVOID_VEHS, "Impatient", false, 30.0 }, { FLAG23_IGN_ROADS | FLAG6_AVOID_OBJS, "Offroad",true, 0.0 }, {FLAG3_AVOID_VEHS|FLAG5_AVOID_PEDS|FLAG6_AVOID_OBJS|FLAG11_REVERSE, "Reverse", true,0.0 },};std::vector<DrivingMode> getAllDrivingModes() { return gtaDrivingModes;}DrivingMode getDefaultDrivingMode() { return gtaDrivingModes[0];}DrivingMode getNextDrivingMode(DrivingMode drivingMode){ int foundIndex = std::find_if(gtaDrivingModes.begin(), gtaDrivingModes.end(), [=](DrivingMode const& compDrivingMode) { return (compDrivingMode.value == drivingMode.value && compDrivingMode.manualMaxSpeed == drivingMode.manualMaxSpeed); }) - gtaDrivingModes.begin(); if (foundIndex + 1 >= gtaDrivingModes.size()) {//not found or in last element return gtaDrivingModes[0]; } else { return gtaDrivingModes[foundIndex + 1]; }} Link to comment Share on other sites More sharing options...
Eddlm Posted October 13, 2015 Author Share Posted October 13, 2015 (edited) I've found two flags more. 1000000000000000000 - 262144 - "Take shortest path"1000000000000000000000000 - 16777216 - "Ignore all pathing" (Goes straight to destination) 262144 Is pretty cool, the driver will take the shortest path to get to its destination. It uses every road/dirtroad available, even special intersections that normal drivers don't usually use, like the 180º turns on the highways. 16777216 Can be useful for drag races. I've added them to the OP list. Edited October 13, 2015 by Eddlm Link to comment Share on other sites More sharing options...
gtaVmod Posted October 13, 2015 Share Posted October 13, 2015 Guys who on earth taught you to use decimals as flag values?? It's either binary or hexadecimals ! jedijosh920 1 Link to comment Share on other sites More sharing options...
InfamousSabre Posted October 13, 2015 Share Posted October 13, 2015 Guys who on earth taught you to use decimals as flag values?? It's either binary or hexadecimals ! Who on earth taught you that they are any different? They represent the exact same data. Link to comment Share on other sites More sharing options...
gtaVmod Posted October 13, 2015 Share Posted October 13, 2015 Yes, same data but impossible to understand binary value. Imho table should be converted to this style to be handy: (1<<N) | 0xHEXVALUE Link to comment Share on other sites More sharing options...
Eddlm Posted October 14, 2015 Author Share Posted October 14, 2015 (edited) Yes, same data but impossible to understand binary value. Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGE, Squad1Leader, GetLastVehicle(Squad1Leader), pos.X, pos.Y, pos.Z, 70f, 4 | 16 | 32| 262144, 10f); Using integers to represent the flags, this works perfectly. Is there any problem in C++ or something? Anyway, if there is people that use HEX values instead of decimals, I should add the coversion too. You can convert them with the converter mentioned in the guide, too. Edited October 14, 2015 by Eddlm Link to comment Share on other sites More sharing options...
InfamousSabre Posted October 14, 2015 Share Posted October 14, 2015 Yes, same data but impossible to understand binary value. Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGE, Squad1Leader, GetLastVehicle(Squad1Leader), pos.X, pos.Y, pos.Z, 70f, 4 | 16 | 32| 262144, 10f); Using integers to represent the flags, this works perfectly. Is there any problem in C++ or something? Anyway, if there is people that use HEX values instead of decimals, I should add the coversion too. You can convert them with the converter mentioned in the guide, too. integers work fine in C++. Honestly, I just use binary and convert it at run time, but yes, some people will use hex. Link to comment Share on other sites More sharing options...
gtaVmod Posted October 14, 2015 Share Posted October 14, 2015 Using integers to represent the flags, this works perfectly.Yes, but very amateurish. Link to comment Share on other sites More sharing options...
InfamousSabre Posted October 15, 2015 Share Posted October 15, 2015 (edited) Using integers to represent the flags, this works perfectly. Yes, but very amateurish. You've no place to say what is or isn't "amateurish". Guess HazardX is amateurish too. Who knew? public enum AnimationFlags { Unknown12 = 2048, Unknown11 = 1024, Unknown10 = 512, Unknown09 = 256, Unknown08 = 128, Unknown07 = 64, Unknown06 = 32, Unknown05 = 16, Unknown04 = 8, Unknown03 = 4, Unknown02 = 2, Unknown01 = 1, None = 0 } Oh, look. The same exact thing as what Eddlm posted, but the integers are now in an enum. enum DRIVING_FLAGS{ FLAG1_STOP_VEHS=1, FLAG2_STOP_PEDS=2, FLAG3_AVOID_VEHS=4, FLAG5_AVOID_PEDS=16, FLAG6_AVOID_OBJS=32, FLAG8_STOP_LIGHTS=128, FLAG11_REVERSE=1024, FLAG19_SHORTEST_PATH=262144, FLAG23_IGN_ROADS=4194304,};Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGE, Squad1Leader, GetLastVehicle(Squad1Leader), pos.X, pos.Y, pos.Z, 70f, FLAG3_AVOID_VEHS | FLAG5_AVOID_PEDS | FLAG6_AVOID_OBJS | FLAG19_SHORTEST_PATH, 10f); Do it how you want. You don't like the way this method looks, but it is fundamentally the same. If you don't like it, don't do it in your code. Edited October 16, 2015 by InfamousSabre Link to comment Share on other sites More sharing options...
gtaVmod Posted October 15, 2015 Share Posted October 15, 2015 Instead of wasting time arguing you better educate yourself why do people use hex for flags. Link to comment Share on other sites More sharing options...
Eddlm Posted October 16, 2015 Author Share Posted October 16, 2015 (edited) Still not getting, in my infinite ignorance and criminal uneducated casualness, why hexadecimals are masterrace over ints and enums. Stupid masterracing aside, I've been testing all the remaining unknown flags, without sucess. Nothing seems to change. I think I've seen the driver take curves faster while testing, but I couldn't confirm it. I'm currently hunting the flag that allows the driver to drive against traffic, like the police does when they chase you. Also, looks like SET_DRIVE_TASK_DRIVING_STYLE sets the driving style instantly, which could be really useful in certain situations. Going to do some tests and then updating the guide. Edited October 16, 2015 by Eddlm Link to comment Share on other sites More sharing options...
gtaVmod Posted October 16, 2015 Share Posted October 16, 2015 Still not getting, in my infinite ignorance and criminal uneducated casualness, why hexadecimals are masterrace over ints and enums. Here's example: Try OR two operands (0x80000000 and 0x04000000) in mind. It's as simple as it could be: 0x84000000. Now good luck to you doing same with decimal representation... Link to comment Share on other sites More sharing options...
InfamousSabre Posted October 16, 2015 Share Posted October 16, 2015 (edited) Still not getting, in my infinite ignorance and criminal uneducated casualness, why hexadecimals are masterrace over ints and enums. Stupid masterracing aside, I've been testing all the remaining unknown flags, without sucess. Nothing seems to change. I think I've seen the driver take curves faster while testing, but I couldn't confirm it. I'm currently hunting the flag that allows the driver to drive against traffic, like the police does when they chase you. Also, looks like SET_DRIVE_TASK_DRIVING_STYLE sets the driving style instantly, which could be really useful in certain situations. Going to do some tests and then updating the guide. I think that has to do with the particular task they are using. I've noticed if using VEHICLE_CHASE (pretty sure this is what police use) to make a driver chase you, and you are both facing the correct direction on a road, but you are behind them and the last direction you moved was the direction you're facing, they wont even move. They will wait for you to catch up. If you never move, they'll sit there forever. The second you go the wrong way, whether you're reversing or otherwise, they'll turn around and come after you. Edited October 17, 2015 by InfamousSabre Link to comment Share on other sites More sharing options...
Eddlm Posted October 17, 2015 Author Share Posted October 17, 2015 Lets hope there's a way to set it on a driver without having him chasing anything! Also, I've discovered stuff about PED::SET_DRIVER_ABILITY. Added to the guide. Link to comment Share on other sites More sharing options...
gtaVmod Posted October 18, 2015 Share Posted October 18, 2015 There is also SET_DRIVER_AGGRESSIVENESS but i didn't noticed either it nor SET_DRIVER_ABILITY to affect anything. Link to comment Share on other sites More sharing options...
Eddlm Posted October 18, 2015 Author Share Posted October 18, 2015 There is also SET_DRIVER_AGGRESSIVENESS but i didn't noticed either it nor SET_DRIVER_ABILITY to affect anything. Spawn two AI drivers with their cars and tell them to go to a far place. SET_DRIVER_ABILITY to 0.0 in one and 100.0 in the second one. Notice how each one avoids traffic. I think SET_DRIVER_AGGRESSIVENESS defines how aggresive they are when chasing, I need to do some tests. SET_TASK_VEHICLE_CHASE_IDEAL_PURSUIT_DISTANCE and SET_TASK_VEHICLE_CHASE_BEHAVIOR_FLAG are worth some time of research, too. Link to comment Share on other sites More sharing options...
elsewhat Posted October 19, 2015 Share Posted October 19, 2015 Tested out SET_DRIVER_AGGRESSIVENESS in scene director, but end up disabling it as I saw no difference. (might be some difference but very hard to detect) void action_increase_aggressiveness(Ped ped, bool suppress_msgs) { log_to_file("action_increase_aggressiveness"); int actorIndex = get_index_for_actor(ped); if (actorIndex != -1) { float currentAggressiveness = actorDriverAgressiveness[actorIndex]; if (currentAggressiveness >= 1.0f) { return; } currentAggressiveness = currentAggressiveness + 0.1f; if (currentAggressiveness > 1.0f) { currentAggressiveness = 1.0f; } PED::SET_DRIVER_AGGRESSIVENESS(ped, currentAggressiveness); actorDriverAgressiveness[actorIndex] = currentAggressiveness; } else { set_status_text("Actor must be stored in a slot to increase aggressiveness"); }} Link to comment Share on other sites More sharing options...
Eddlm Posted October 19, 2015 Author Share Posted October 19, 2015 (edited) You didn't notice differences because you used 1.0 like it is the max. The max is probably 10.0 (or 100.0), check this. Edited October 19, 2015 by Eddlm Link to comment Share on other sites More sharing options...
Cyron43 Posted October 23, 2015 Share Posted October 23, 2015 (edited) Hi @Eddlm. First let me say thank you for this list. I use this in my VAutodrive mod now instead of the DrivingStyle values provided by the scripthookVdotnet. However, using a new "Normal" driving style, calculated with your table, caused a misbehavior. I used this value 0x400C00A3, which is 1000000000011000000000010100011 binary. The value provided by scripthookVdotnet is 0xC00AB (0000000000011000000000010101011). Driving with the old value behaves as expected, while the new value causes the vehicle to stop before parked cars and not move anymore. This is interesting because the difference is in two unknown bits (bit 31 and bit 4). For better comparison: 1000000000011000000000010100011 = stops before parked cars 0000000000011000000000010101011 = avoids parked cars I will do further tests tomorrow to find out which of those two bits causes it. Edited October 24, 2015 by Cyron43 InfamousSabre 1 Link to comment Share on other sites More sharing options...
Cyron43 Posted October 24, 2015 Share Posted October 24, 2015 (edited) Tried 0xC00AB - 8 = car does not stop before parked carsTried 0xC00AB + 0x40000000 (bit 31) = car does not stop before parked carsTried the old value from yesterday (0x400C00A3) where the misbehavior happened = car does not stop before parked cars I don't get it! Edited October 24, 2015 by Cyron43 Link to comment Share on other sites More sharing options...
Eddlm Posted October 24, 2015 Author Share Posted October 24, 2015 Lulz, that's interesting The flags "stop before cars" and "stop before peds" have their "avoid" counterparts, maybe "stop before parked cars" has another counterpart somewhere. I don't know if the drivers avoid parked cars by default, though. the fourth bit would make sense to be about parked cars, as the third one is about avoiding driven cars. Maybe 1 means stop and 0 means avoid? Link to comment Share on other sites More sharing options...
Cyron43 Posted October 24, 2015 Share Posted October 24, 2015 Lulz, that's interesting The flags "stop before cars" and "stop before peds" have their "avoid" counterparts, maybe "stop before parked cars" has another counterpart somewhere. I don't know if the drivers avoid parked cars by default, though. the fourth bit would make sense to be about parked cars, as the third one is about avoiding driven cars. Maybe 1 means stop and 0 means avoid? It was the opposite at bit 4 but anyway, why this didn't have any effect today is totally beyond me and honestly I am a bit fed up with testing today. I made a new feature release of VAutodrive yesterday and some hours later I found out about this by pure coincidence at a tour around the golf club (many parked cars along the streets) and I rushed to get the bugfix released asap. Those incidents are somewhat exhausting for me but I guess I will continue testing tomorrow. Link to comment Share on other sites More sharing options...
Eddlm Posted October 24, 2015 Author Share Posted October 24, 2015 1000000000011000000000010100011 = stops before parked cars I thought that was the bit you were talking about I like to test these things (with help of my bodyguard squad) so don't worry about research if it's not urgent for you Cyron43 1 Link to comment Share on other sites More sharing options...
3dplanet Posted November 20, 2015 Share Posted November 20, 2015 (edited) Found this : 00100000000000000000000000000000 - 536870912 = driver do not go on highway When using this on highway 00000000000000000000000000000100 - 4 - avoid vehicles driver often stay stuck behind a vehicle (when the 2 lanes are full of vehicles for example). Using 00000000000000000000100000000000 - 2048 - ? and 00000000000000000001000000000000 - 4096 - ? make the driver trying to go right and left to avoid vehicle after being stucked 00000000000000000000100000000000 - 2048 - ? not sure, but it could be "left overtake" and 00000000000000000001000000000000 - 4096 - ? not sure, but it could be "right overtake" tested with AI::TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGE Edited November 20, 2015 by 3dplanet elsewhat 1 Link to comment Share on other sites More sharing options...
InfamousSabre Posted November 25, 2015 Share Posted November 25, 2015 (edited) Any info on SET_TASK_VEHICLE_CHASE_BEHAVIOR_FLAG? I'm trying to figure out how to make them stop waiting for me to catch up when I'm behind them, but no luck so far. Edited December 3, 2015 by InfamousSabre Link to comment Share on other sites More sharing options...
Eddlm Posted March 5, 2016 Author Share Posted March 5, 2016 (edited) I've added two new flags I've found 8 - avoid empty vehicles256 - use blinkers Interestingly, normal NPCs never seem to use the last flag. It would be a good idea to make a roleplayish script that forces this flag on most vehicles. Edited March 5, 2016 by Eddlm InfamousSabre 1 Link to comment Share on other sites More sharing options...