Jump to content

Recommended Posts

uKUIl9G.jpg

AI Driving Control

version 2.6.7

 

Description:

  • Gives more control to AI drivers.
  • Script uses nearEntities to find vehicles/men, calculates relative angles to nearest one and applies forceSpeed depending on situation.
  • Use "STEALTH" behaviour to temporarily bypass the script.

 

Features:

  • AI will brake and speed up for vehicles ahead.
  • AI gives way to vehicles approaching from the right.
  • Pedestrians have priority over vehicles.
  • Pedestrians are overtaken or followed if directly in front of vehicle.
  • Works on and offroad.
  • Have less (not avoid) crashes.
  • Engines turn off on idle if at final waypoint.
  • Vehicles on "STEALTH" behaviour bypass code until behaviour changes (setBehaviour, etc.).
  • Bypass script entirely on a vehicle's init with "this setVariable ["NOAIDRIVINGCONTROL", true, true]".
  • For a convoy use "<object> limitSpeed <km/h>" on lead vehicle.
  • Gates ("Land_BarGate_F", "Land_BarGate_01_open_F" and "Land_RoadBarrier_01_F") are detected when closed. Note: place gates BEFORE AI driver gets in vehicle/spawn/zeus/etc. i.e. not scanned in realtime. As a bonus, gates are made indestructible (by tanks as well unfortunately).
  • Addon and script version.

 

Download:

 

Usage:

  • Works with placed and spawned vehicles, single player and dedicated server.
  • Clients with AI drivers must be running the addon.
  • For Zeus, the player being Zeus must be running the addon.
  • Script version runs once on mission initialization and needs to remoteExec for each new spawn (except Zeus). Follow INSTALLATION.txt.
  • Hold movement keys for (up to) 3 seconds if your vehicle's fuel was removed and you're the commander.
  • Variables (vehicle's init field only):
    • Defines "bounding box" width, per vehicle, which detects men around and stops the vehicle. Where 1 = vehicle's width; 1.5 = default; 2 = default for tanks. Smaller values improve overtaking men but run them over more often, higher values will be safer but will halt more often. Higher than default should not be necessary:
      • this setVariable ["AIDCBBOXWIDTHCOEF", <coefficient>];
    • Defines "bounding box" length, per vehicle, which detects men around and stops the vehicle. Where 1 = vehicle's length; 1.5 = default:
      • this setVariable ["AIDCBBOXLENGTHCOEF", <coefficient>];
    • Defines setConvoySeparation for each vehicle on AI led groups only. AIDC overwrites that command by default so if it is to be used it must be defined here:
      • this setVariable ["AIDCCONVOYSEPARATION", <distance>];
    • Disable workaround of removing fuel of tanks when nearby infantry:
      • this setVariable ["AIDCNOFUELREMOVE", true];

 

Notes:

  • Any forceSpeed command (on affected land vehicles) will be overwritten by the script.
  • Does not cause dependency on missions.

 

Known issues:

  • When confronted with large groups of pedestrians, vehicles occasionally  stall (with accelerated time only probably).
  • Quadbikes are not detected by other vehicles on road (@BI: they always report "isOnRoad false"). Are detected offroad.
  • Does not work on ALiVE vehicles.
  • Incompatible with TPW SANITY (uses forceSpeed as well).

 

License:

APL-SA.png

  • Non Military - You may not use the content of this addon as a whole or any part of this addon for military purposes.
  • No Monetization - You may not use this addon as a whole or any part of this addon on monetized servers.
  • Attribution - You must attribute the material in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the material).
  • Noncommercial - You may not use this material for any commercial purposes.
  • Arma Only - You may not convert or adapt this material to be used in other games than Arma.
  • Share Alike - If you adapt, or build upon this material, you may distribute the resulting material only under the same license.

 

 

Credits:

 

Thanks to:

 

Media:

Spoiler

AI Driving Control v2.5

 

AI Driving Control v2.4 (vehicles only)

 

AI Driving Control v2.4 (vehicles with pedestrians)

 

AI Driving Control v2.4 (pedestrians only)

 

Vanilla AI

 

AI Driving Control

 

Vanilla AI

 

AI Driving Control

 

Changelog:

Spoiler

v2.6.7

Fixed: Vehicles' event handlers were overwritten. Smoke launcher, etc. would fail. Thanks to @AirShark.

Added: Optional vehicle variable "AIDCNOFUELREMOVE". It helps bypass close-by infantry. Use on vehicle's init:  this setVariable ["AIDCNOFUELREMOVE", true];

 

v2.6.6 - Added: Ability to move vehicle, after it's fuel was removed, from men approaching vehicle.

                 Fixed: Script version wasn't initializing for vehicles with crew already in it.

 

v2.6.5 - Fixed: Addon and script versions were initializing twice per vehicle! (Init EH and GetIn EH). Sorry about that. Script version also changed initPlayerLocal.sqf.

                Added: "Motorcycle" class to addon version.

                Added: CUP patch for some APC's not initializing on addon version ("CUP_LAV25_Base","CUP_BTR80_Base","CUP_BTR80A_Base","CUP_BTR90_Base","CUP_AAV_Base").

 

v2.6.4 - Fixed: Detect quadbikes.

                Tweaked: "Bounding box" length default coefficient reduced from 2 to 1.5.

 

v2.6.3 - Tweaked: Following distance is dynamically calculated from followed car speed.

 

v2.6.2 - Fixed: Vehicle would halt/lose formation when too close to group leader. Fix #4.

                Changed: Script version Zeus initialization to BIS_fnc_addScriptedEventHandler.

                Tweaked: Minor tweaks and optimizations.

 

v2.6.1 - Fixed: Problem moving after loading cargo, stuck on "bounding box" loop.

 

v2.6 - Fixed: Vehicle would halt/lose formation when too close to group leader. Fix #3. AI led groups only.

            Fixed: Player led AI would return to formation after reaching destination since 2.5.5.1.

            Added: Tanks now stop when men enter vehicle's "bounding box": setFuel workaround.

            Added: Bypass enemy vehicles.

            Added: Optional vehicle variable "AIDCBBOXLENGTHCOEF" to define "bounding box" length.

            Added: Optional vehicle variable "AIDCCONVOYSEPARATION". AI led groups only.

            Tweaked: Minor optimizations and tweaks.

 

v2.5.5.1 - Hotfix: Vehicle would halt/lose formation when too close to group leader. Fix #2.

 

v2.5.5 - Fixed: Vehicle would halt/lose formation when too close to group leader.

                Added: Bypass pedestrians when on "STEALTH".

                Tweaked: Minor optimizations.

                Changed: License to APL-SA.

                Changed: New key and key name (you may delete RCA3.bikey).

 

v2.5.4 - Fixed: Script version: wrong function passed to cfgremoteexec.hpp.
                Removed: Script exit on vehicle damage (as long as driver is alive keep running).
                Added: Close gaps to ~20 meters when vehicle ahead is stopped.
                Added: Discriminate between friend or foe pedestrians (i.e. ignore foes).

 

v2.5.3 - Fixed: "Bounding box" loop would not exit for driver disembark, death or vehicle damaged.
                [Warning] Changed: Script version makes use of remoteExec on zeus and optional spawns. Meaning client/server's AI will have controlled driving on non-locally created vehicles (same as in addon version). Read INSTALLATION.txt for new instructions.
                Changed: Renamed functions main class.

 

v2.5.2 - Tweaked: Oncoming traffic vehicle rotation is now < 30º, more is considered crossing. Gives vehicles more time to cross.
                Tweaked: Followed vehicle's angle and rotation is combined to find following angle. It should reduce number of overtaking occurrences.
                Tweaked: Smoothed slow down/speed up when following vehicles.
                Tweaked: Minor tweak to vehicle versus men speed.
                Tweaked: Scan radius.
                Changed: Passed a few math operations to pre-processor #define.
                Added: Optional vehicle variable "AIDCBBOXWIDTHCOEF" to define "bounding box" width.
                Added: Detection of all three military gates "Land_BarGate_F", "Land_BarGate_01_open_F" and "Land_RoadBarrier_01_F".

 

v2.5.1 - Fixed: Animals were still being evaluated.
                Tweaked: Minimum scan radius reduced from 50m to 25m.
                Tweaked: Minor tweak to "bounding box" search.

 

v2.5 - Changed: Vehicle versus pedestrians speed is now dynamically calculated.
             Removed: Pedestrians's military/civilian discrimination.
             Removed: Pedestrians's on/off road discrimination.
             Added: New server key.

 

v2.4.1 - Added: A 360 degrees "bounding box" around vehicle which detects pedestrians and stops the vehicle.
                Tweaked: Increased/improved pedestrians overtake speed.
                Tweaked: Minor tweak to scan radius.
                Fixed: Gates being detected outside of range.
                Fixed: Animals were being evaluated as men.
                Changed: Script version installation and respective notes.

 

v2.4 - Added: New timeout system which starts only if crossing vehicle ahead is not moving. Results in much smoother traffic.
            Fixed: Oncoming traffic was being evaluated as crossing (delaying traffic). Oncoming traffic vehicle rotation is now <45º, more is considered crossing.
            Released: Script version.
            Added: New server key.

 

v2.3.1 - Hotfix: FSM was running on every vehicle's passenger.

 

v2.3 - Changed: Passed main function and parts of code to CfgFunctions.
            Changed: Code optimized when vehicle is stopped by vehicle/man ahead to ~0.19ms (benchmark) no matter how many vehicles/men around.
            Changed: Optimized vehicles array sorting.
            Changed: Vehicles stop on initialization while scanning for bargates.
            Changed: Engine off on idle moved to separate FSM resulting on optimization to ~0.37ms (benchmark) for 10x men/cars scan.
            Tweaked: Optimized main branch.
            Fixed: On road vehicles were evaluating offroad vehicles.
            Removed: Unnecessary BIS_fnc_getAngleDelta call removed.
            Removed: Duplicated getDir removed.
            Tweaked: Front buffer increased by 5 meters.
            Tweaked: Give way right traffic timeout decreased back to 10 seconds.
            Added: New server key.

 

v2.02.2 - Hotfix: Vehicles weren't resuming after opening gates.

 

v2.02.1 - Fixed: Vehicles relative position was being wrongfully checked according to their internal direction. Improves overall traffic and convoy behaviour.
                  Tweaked: Added one more distance check increasing pedestrians safety.
                  Tweaked: Give way right traffic timeout increased from 10 to 30 seconds.
                  Tweaked: Minimum scan radius increased to 50 meters.

 

v2.02 - Changed: Reverted to civilian vehicle convoys offroad being possible as of v1.01. 15 meters width (overtake) buffer for all vehicles.

 

v2.01.3 - Fixed: Minor fix where offroad vehicles could be following without proper angle.

 

v2.01.2 - Fixed: On road vehicles were following offroad vehicles.

 

v2.01.1 - Tweaked: Applied Pythagorean theorem to civilians buffer. It's a safer distance.

 

v2.01 - Changed: AI tries to bypass civilians up until the last moment. Infantry are (still) followed at a more respectable distance.
               Tweaked: Buffer width offroad is now 10 meters instead of 15 meters for infantry.

 

v2.0 -  Changed: Addon name changed from Road Control AI Addon to AI Driving Control.
             [Warning] Changed: Variable to disable script is now "NOAIDRIVINGCONTROL".
             Added: Scan radius is now dynamic with vehicle speed. Should increase performance.
             Fixed: Maintain speed of front.

 

v1.02 - Tweaked: Code optimized from ~0.49ms to ~0.38ms for 10 men/cars scan.
               Added: Maintain speed of front.
               Tweaked: Buffer width is now 15 meters on and offroad except for civilians. Offroad mil vehicles keep convoy, civs are overtaken.
               Added: Demo missions.

 

v1.01 - Tweaked: Wider offroad buffer now affected by military personnel only.

 

  • Like 21

Share this post


Link to post
Share on other sites

This is fantastic RCA3 !

 

Thank you very much for sharing !  :thumbs-up:

  • Like 3
  • Thanks 1

Share this post


Link to post
Share on other sites

What makes it incompatible with ALiVE?

  • Like 1

Share this post


Link to post
Share on other sites
On 5/23/2019 at 11:49 PM, JD Wang said:

What makes it incompatible with ALiVE?

 

Good question.

I tried running Alive and see if vehicles picked up the script, and they did, but they would close it almost immediately.

If you know how to run init vehicle code particularly on Alive vehicles or you know how Alive vehicles can run permanent while{alive}do{} loops, please let me know. Thank you.

 

Edit:

Changed "incompatible" to "Does not work on ALiVE vehicles." since you may still use your own vehicles.

Edited by RCA3
Changed Known Issues ALiVE note
  • Like 1

Share this post


Link to post
Share on other sites

This seems to be working very well.  I run several repeatable SP games, more than half involving road marches of BTRs and T-72s, and I can see a definitive improvement in road march behavior.  The AI also moves itself, so it will be interesting to see if all AI controlled enemy QRFs arrive safely to  the area of operation.

 

Well done.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Changelog:

v2.0 -  Changed: Addon name changed from Road Control AI Addon to AI Driving Control.
             [Warning] Changed: Variable to disable script is now "NOAIDRIVINGCONTROL".
             Added: Scan radius is now dynamic with vehicle speed. Should increase performance.
             Fixed: Maintain speed of front.

 

I had to change the addon name because I believe people were coming here looking for something else.

  • Like 2

Share this post


Link to post
Share on other sites

Changelog:

v2.01 - Changed: AI tries to bypass civilians up until the last moment. Infantry are (still) followed at a more respectable distance.
               Tweaked: Buffer width offroad is now 10 meters instead of 15 meters for infantry.

  • Like 2

Share this post


Link to post
Share on other sites

Changelog:

v2.01.1 - Tweaked: Applied Pythagorean theorem to civilians buffer. It's a safer distance.

  • Like 2

Share this post


Link to post
Share on other sites

@RCA3 Thanks for your efforts. Incidentally, any chance you could upload this to Steam's Workshop?

  • Like 1

Share this post


Link to post
Share on other sites
10 hours ago, domokun said:

@RCA3 Thanks for your efforts. Incidentally, any chance you could upload this to Steam's Workshop?

You're welcome. No Steam, sorry.

 

7 hours ago, otarius-big said:

will it works side mods ai?

I think you mean all the AI combat enhancement mods/addons;  I believe you'll have no problem using them together.

 

- -

 

Thank you to everyone supporting me so far. Thanks to Foxhound for the Armaholic page.

 

v2.01.3 is out.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Interested in trying this but the readme states that there is an issue with tanks? Could you please elaborate?

  • Like 2

Share this post


Link to post
Share on other sites
12 hours ago, arma131 said:

Interested in trying this but the readme states that there is an issue with tanks? Could you please elaborate?

"Something is wrong with tanks: ~10 tanks overloads the script, ~5 seems fine. "

 

Try it out, if it overloads (drastic FPS drop) reduce number of tanks.

Can't tell you exactly why this happens. I know it doesn't happen with other vehicles, APC's, etc.

  • Like 1

Share this post


Link to post
Share on other sites

Changelog:

v2.02 - Changed: Reverted to civilian vehicle convoys offroad being possible as of v1.01. 15 meters width (overtake) buffer for all vehicles.

 

- -

 

Thought about it and realized it would be better (humanitarian convoys, etc). Sorry for the constant updating. This should be the last one unless something unforeseen comes up.

  • Like 3

Share this post


Link to post
Share on other sites

OMFG RCA3 ... you have done something that even BIS cannot do ... SORTED AI DRIVING !  What kind of friggen magic is this ?  I watched as trucks FAILED to run over friendlies, FAILED to crash into objects, FAILED to crash into walls ..... this is not the BIS way 🙂

 

For the love of all things sacred .. please keep working on this!

  • Like 3
  • Thanks 1
  • Haha 2

Share this post


Link to post
Share on other sites

 

5 minutes ago, kremator said:

OMFG RCA3 ... you have done something that even BIS cannot do ... SORTED AI DRIVING !  What kind of friggen magic is this ?  I watched as trucks FAILED to run over friendlies, FAILED to crash into objects, FAILED to crash into walls ..... this is not the BIS way 🙂

 

For the love of all things sacred .. please keep working on this!

 

Agree totally ^^^  Very nice work

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

@kremator @Rockapes You're too kind, literally:

 

On 6/8/2019 at 11:55 PM, kremator said:

I watched as trucks FAILED to run over friendlies <- - - That's me.

FAILED to crash into objects, <- - - That's luck!

FAILED to crash into walls <- - - That's luck!

😄😄😄 I'm just scanning for cars and men.

 

On 6/8/2019 at 11:55 PM, kremator said:

this is not the BIS way 🙂

I know you're joking but Bohemia did improve on AI driving back in 2016ish swerving off things and are still improving as of last week.

 

On 6/8/2019 at 11:55 PM, kremator said:

For the love of all things sacred .. please keep working on this!

Thanks, I'll do my best although this is pretty much at the peak of my capabilities. :tounge:

  • Like 1

Share this post


Link to post
Share on other sites

@arma131

"Something is wrong with tanks: ~10 tanks overloads the script, ~5 seems fine."

 

I'm not so sure about this one anymore. Last testing wasn't as bad as before and I think it could have to do with my PC to begin with.

 

If someone could confirm or deny this issue would be awesome.

 

Here's a test mission with 10 tanks:

https://drive.google.com/open?id=1iR9Fv7Ff9RCUTG4IO_iYw-cCja8c38-c

  • Like 1

Share this post


Link to post
Share on other sites

Testing now.

 

EDIT:  Not seeing any problems so far.

 

EDIT2:  A proper test would be 5 tanks approaching another 5 tanks.   Just added 5 more tanks into the mix, going to opposite way.  Mod handled it pretty well..... unforunately bloody stupid Physx ended with some tanks in the air or on their sides!

  • Thanks 1

Share this post


Link to post
Share on other sites

@kremator

Thanks bro!

I'll strike that issue now.

 

Cheers!

Share this post


Link to post
Share on other sites

Is there anything you can do to fix the 'crash, interminably long pause, reverse in the wrong direction, recrash, anothre long pause, reverse in EXACTLY the same way as before, crash ...... etc' ?  I suppose I'm asking if there is a way to detect vehicle crashes.

 

Checked the mod on a dedi server (not fully optimised) and it does improve things .. but needs a little more tweaking I guess

 

  • Like 1

Share this post


Link to post
Share on other sites
5 hours ago, kremator said:

Is there anything you can do to fix the 'crash, interminably long pause, reverse in the wrong direction, recrash, anothre long pause, reverse in EXACTLY the same way as before, crash ...... etc' ?  I suppose I'm asking if there is a way to detect vehicle crashes.

 

Checked the mod on a dedi server (not fully optimised) and it does improve things .. but needs a little more tweaking I guess

 

Ok, what's not fully optimized, the addon or the server? Where do you see tweaking being needed?

 

As for crashie... I ain't even touching that. All I do is apply brakes and restore speed if there's someone/thing ahead or not. The long pause can be the script preventing move, or the game itself finding new paths. One note though: scans are all made from the front (hood) of the vehicle, so anything behind that isn't detected (e.g. like reversing on top of a man).

 

I'm guessing you're getting those results on the Altis test or somewhere where the road isn't very wide. As a rule of thumb give vehicles as much space as you can. Account for the vehicle types you're using and a realistic path for them.

 

Edit:

I did try and change timeout values with AICarSteeringComponent from https://forums.bohemia.net/forums/topic/191515-ai-driving-feedback-topic but without success. Maybe someone can build a patch with better values to complement my addon (specifically longer timeouts I find would be useful).

Share this post


Link to post
Share on other sites

Someone needs to write a pedestrian script where after the first person gets run over by a giant military truck the rest get the heck off the road. I understand the frustration of your own infantry getting run over by your own vehicles when in column but when civilians stroll down the road and refuse to get out of the way of traffic even after someone has been killed is ridiculous.

  • Like 1

Share this post


Link to post
Share on other sites
13 hours ago, dr@gon said:

Someone needs to write a pedestrian script where after the first person gets run over by a giant military truck the rest get the heck off the road. I understand the frustration of your own infantry getting run over by your own vehicles when in column but when civilians stroll down the road and refuse to get out of the way of traffic even after someone has been killed is ridiculous.

There surely must be a way to check if people are walking/running towards a moving vehicle and redirect them a few metres away from that danger (apart from then loading etc)?  

 

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×