Author: LSValmont
Author Website:

Requirements: No addons required

Version: 1.3

Short description: improves Ai Driving and Civilian Pedestrian Simulation. It will also increase your FPS rather than decrease it!

Date: 2020-05-24 11:39

Comments: (0)




Improved Ai Driving and Civilian Pedestrian Simulation will now also increase your FPS rather than decrease it!

While it started as a simple script to help Arma 3 vehicles brake better, AS OF VERSION 13, vAiDriving has expanded to become a fully fledged CIVILIAN vehicle and pedestrian handling script that does not require any input/extra work from the mission makers to work as intended and to have all its features enabled.

It provides mission makers whose missions involve Ai vehicular driving and/or Ai civilian pedestrians with ALL the tools they need in order to have a more immersive, performance friendly and overall better Arma 3 experience.


vAiDrive Main Features:
1) Greatly reduces the chances of Ai Driven Vehicles colliding with objects, vehicles and other units.
2) Instead of having a toll on server performance this script actually INCREASES the performance (FPS) on the server!
3) Stress free execution, just place a bunch of civilians and some vehicles with drivers in them with the eden Editor and YOU ARE DONE!
So no messing with waypoints or commands or init fields, the script does it all for you.
An accident free, city like environment for Arma 3 that doesn't bring your FPS down to 5.

Extra Features:
1) Ai units in the way of vehicles will move away from the streets and into buildings.
2) Ai vehicle Drivers will occasionally use their horns.
3) Ai Drivers are optimized for driving only! And if their vehicle run out of fuel then they exit the vehicle and the script stops (liberating resources).
4) The script uses a combination of scheduled and unscheduled Environments to achieve that virtual CERO impact on performance.

Installation / Usage:
For usage instructions and information of how to use the vAiDriving please refer to the included documentation and/or example mission.

- Put the vAiDriving.sqf file in your mission directory like so: "missionDirectory\vScripts\vAiDriving\vAiDriving.sqf".
- On your initServer.sqf add the following lines:
call compile preprocessFileLineNumbers "vScripts\vAiDriving\vAiDriving.sqf";
waitUntil {sleep 1; time > 1};
[] call vAiDriving_init;
In your mission add the vehicles with Ai Drivers using EDEN and hopefully give them move waypoints on roads. (This Script does not deal with vehicle movement so you will need waypoints or another script for that!)

Script Optional Configs:
Open "vAiDriving.sqf" with a text editor and change these lines to your liking:
vAiDriving_useLinesIntersectWith = true; // Helps vehicles reduce speed when facing obstacles other than other vehicles and men.
vAiDriving_show3DLine = true; // Set to true to draw a visual line for the LINES INTERSECT.
vAiDriving_handleBargates = true; // Should the vehicles open BarGates automatically?
vAiDriving_debug = true; // If you want to see why a car hit the breakes etc.
vAiDriving_handlePedestrians = true; // Set to true to optimize Ai Civilian units and give them waypoints to look "realistic". // New since v12

How it works:
It is a very simple script but sometimes simple is enough for most specially if performance is key on the server.
The script runs on each Ai driver and periodically checking nearObjects (for units and vehicles) and lineIntersectsWith (for objects and structures).
If an "OBSTACLE" is detected then the Ai Driver hits the "brakes" rather harshly but it should in most cases diminish deadly collisions.
What makes this script so efficient is that it only runs if the FPS is above 15 and the speed of the vehicle is greater than 1.
Since the vehicles speeds are many times below 1 due to constant breaking that gives the server room to finish its schedule.

Known issues:
- Due to having performance as a focus the script is rather rough when dealing with immersion. (Vehicles hit the brakes and move a little harshly)
- The vehicles move rather slow but that is a sacrifice I had to make in order to keep those checks from saturating the server and also to avoid having to make the vehicles come to a full stop on every obstacle.
- Was tested on a Hosted server with up to 40 vehicles and 80 civilians without performance degradation but more could have a toll on your system.

Credits & Thanks:
Enjoy and I am looking forward for suggestions and testing input!
Special thanks to @RCA3 again for his work and sharing his amazing scripts and mods with us!

Inspired by (And adapted from) the work of the Ai Driving master @RCA3!

- vAiDrive now has the option handle the waypoints of vehicles automatically so that players and mission makers do not have to set up each vehicle and each waypoint individually nor have other vehicle movement scripts running.(vAiDriving_handleVehWaypoints=true).
- vAiDrive now has the option to automatically cache vehicles and units to preserve resources when players are far away. (vAiDriving_handleVehCache=true)
- It is now possible to set the vehicles handled by vAiDrive to never run out of fuel. (vAiDriving_vehUnlimitedFuel=true)
- vAiDrive can now also randomize the look of pedestrians automatically. (vAiDriving_dressPedestrians=true)
- All vAiDrive settings are now set by editing the "vAiDrivingCONFIG.sqf" instead of the main fnc file.
- Fixed Ai civilians not looking at nearby pedestrians when "talking" to them.
- Fixed Bargates sometimes not being handled correctly.

"Handle Civilians" Release Highlights:
- Added the game changer vAiDriving_handlePedestrians param. If set to true the script will automatically optimize all civilians on the mission, turning them into
performance friendly agents that roam the map smartly, going into buildings, "talking" to other civies and avoiding walking on the middle of roads for long periods.
- vAiDriving_handlePedestrians increases the server FPS even further than before! WAY WAY MORE!
- Further optimization and tweaking not worth detailing.
- After version 12 update the number of civilian casualties due to bad Ai Driving is virtually CERO.
DISCLOSURE: No pedestrians were harmed during the development of this script version. (FINALLY!)

Forum topic:
- BI forums

Enable javascript to be able to download from Armaholic please!