Jump to content
engima

[RELEASE] Engima's Traffic Script

Recommended Posts

y4m2-p4euGWv1A2Hgcds2rYSvN5yTGQIrMTpSKe-

 

Engima's Traffic v1.7

by Engima

 
Description:
Script that adds dynamic traffic to any map. Vehicles are spawned in out of sight for the player(s) and are removed again when they get at a certain distance.

You can customize traffic by editing the file Engima/Traffic/ConfigAndStart.sqf. Customizable parameters are side, vehicle classes, amount of vehicles, spawn distances, crew's skill, map area, and you can also add callbacks that fire when vehicles are spawning and being removed.

Works in SP, MP, Dedi and JIP.
 
Download:
Download Link at Armaholic
Also released as CPack Engima.Traffic for the TypeSqf Editor
 
Installation:
1. Copy folder "Engima" to root of your mission folder.
2. Create the file "init.sqf" in your mission folder (if you don't already have it). Add the following line to the top of the init.sqf:

call compile preprocessFileLineNumbers "Engima\Traffic\Init.sqf";

3. Customize the traffic behavior in the file "Engima\Traffic\ConfigAndStart.sqf".

Documentation and a complete reference of set up parameters can be found in file "Engima\Traffic\Documentation.txt";
 
Usage:
Here is an example of how to initialize the traffic in the file Engima/Traffic/ConfigAndStart.sqf:

// Set traffic parameters.
_parameters = [
	["SIDE", east],
	["VEHICLES", ["O_MRAP_02_F", "O_Quadbike_01_F", "O_Truck_02_transport_F"]],
	["VEHICLES_COUNT", 10],
	["MAX_GROUPS_COUNT", 12],
	["MIN_SPAWN_DISTANCE", 800],
	["MAX_SPAWN_DISTANCE", 1200],
	["MIN_SKILL", 0.4],
	["MAX_SKILL", 0.6],
	["AREA_MARKER", "EnemyMarker1"],
	["HIDE_AREA_MARKER", true],
	["ON_UNIT_CREATING", { true }],
	["ON_UNIT_CREATED", {}],
	["ON_UNIT_REMOVING", {}],
	["DEBUG", false]
];

// Start an instance of the traffic
_parameters spawn ENGIMA_TRAFFIC_StartTraffic;

You may create more than one instance of the script, if you want different kinds of traffic with different behavior. See the documentation for how that is done.

How to update from older version:
Manually:
1. Back up your own customization file (Engima\Traffic\ConfigAndStart.sqf).
2. Replace the folder Engima\Traffic with the corresponding folder in the download package.
3. Replace the original ConfigAndStart.sqf with your own ConfigAndStart.sqf that was backed up in step 1.

TypeSqf:
1. Open the CPack console and run command "update Engima.Traffic".

Change log:

v1.7

- Fixed: The same car had different random texture on different clients. Now all players see the same texture on all cars.

- Fixed: Script error when no players are in the mission.

 

v1.6.1
- Adjusted vehicle spawn distances.
- Improved traffic flow by removing immobile vehicles outside visual range.
- Fixed: Many traffic units not moving at all on maps with several small islands (like Tanoa).
- Fixed: Units get stuck on small paths in the woods (like on Tanoa). Paths are now ignored.
- Fixed: Number of vehicles not relative to traffic area coverage in some cases.
- Added callback ON_UNIT_CREATING which fires right before a vehicle spawns.
- Replaced callback ON_SPAWN_CALLBACK with ON_UNIT_CREATED.
- Replaced callback ON_REMOVE_CALLBACK with ON_UNIT_REMOVING.
- Fixed: Vehicles tend to spawn more often behind the players than ahead of them.
- Added support for headless client.
- Script no longer tries to terminate scripts executed in spawn callback.

 

v1.30
- Possibility to select areas (markers) where the traffic will be.
- Better performance on large maps (like Altis).

v1.25
- First version published on Armaholic.com.

Licence:
Free to use, but if you release anything with it, please write my name somewhere suitable.

Requirements:
Arma 3.

  • Like 12
  • Thanks 2

Share this post


Link to post
Share on other sites

Does the script bases on the ambient traffic from A2 Escape? Or is this completly new?

I used it in Escape Chernarus for Arma 2, but this is a new and better version of it.

Share this post


Link to post
Share on other sites

Sounds great! So I will upgrade the traffic script in A3 Escape to your new version (despite the current version in Escape is already modified).

 

I will post some feedback if I managed to get it in.

Share this post


Link to post
Share on other sites

Ok, well I don't know how traffic has been modified in Escape för A3, but I think the interface is exactly the same.

Two important new features from then (maybe useful in Escape) is 1) Better performance (in A3 the script hung during init) and 2) you will no longer need to put out road corner markers.

At the same time... Don't fix anything that already works. :)

Good luck!

Share this post


Link to post
Share on other sites

I removed the roadmarkers already in the current version and also the "nullroad" (I think it was also used for roadblocks).

 

I have everything under version control, so I can plugin your new script and check if it works better... if not, I simply switch back ;)

Share this post


Link to post
Share on other sites

Wow, I just drove the Great Altis Highway at night with this script and it barely missed a beat.

 

At one point, two sports hatchbacks whizzed by me like two kids having a race. It was awesome.

 

Passed a traffic accident or two, but that's AI driving skills for you.

 

A few cars decided to drive with their lights off, but I don't know if that's something you can fix or not.

 

I got one script error, as follows:

18:05:17 Error in expression <speed = "NORMAL"; if (_vehicle distance _destinationSegment < 500) then {_speed>
18:05:17   Error position: <_destinationSegment < 500) then {_speed>
18:05:17   Error Undefined variable in expression: _destinationsegment
18:05:17 File E:\Paul\My Documents\Arma 3 - Other Profiles\DreadPirate\mpmissions\EnigmasTrafficScript.Altis\Engima\Traffic\Server\Functions.sqf, line 86

Two questions:

  1. Would it be possible to have random civilians as well as random cars? So I could have Takistanis driving instead of Altians?
  2. Do you use many A3-only scripting commands? Or could I change the classnames and use it in A2?

Share this post


Link to post
Share on other sites

I got one script error, as follows: [...]

Two questions:

  • Would it be possible to have random civilians as well as random cars? So I could have Takistanis driving instead of Altians?
  • Do you use many A3-only scripting commands? Or could I change the classnames and use it in A2?

Ok, I'll look into that.

Yes, it is possible if you use the spawn callback (ON_SPAWN_CALLBACK). Send in a function that changes the crew units.

It may work in A2, I don't know of any A3 specific code, but it's only tested in A3.

Share this post


Link to post
Share on other sites

Great script, thank you!

 

Question out of curiosity: does setting the skill actually have any effect? I never set any skills on civilians as I didnt know it made a difference.

Share this post


Link to post
Share on other sites

Great script, thank you!

 

Question out of curiosity: does setting the skill actually have any effect? I never set any skills on civilians as I didnt know it made a difference.

Glad you like it!

Skill makes difference if for example side is EAST and vehicle is a tank. :) With other words: traffic can be of any side and vehicle classes, and not necessary civilian.

  • Like 1

Share this post


Link to post
Share on other sites

Sorry for the noobish question: how do I set up a blackmarker area?

Sorry. Not supported. I used this in an old mission called Escape Chernarus, where there was only civilian and opfor traffic over the whole map. But I've already realized it would be quite useful, so I will release an update sometime soon.

Share this post


Link to post
Share on other sites

Thanks engima, I'll give this a shot sometime. Since you know your way around scripts, do you know of one that can easily populate towns with civvies to go along with the traffic? TPW's civ mode no longer works for me.

Share this post


Link to post
Share on other sites

Sorry. Not supported. I used this in an old mission called Escape Chernarus, where there was only civilian and opfor traffic over the whole map. But I've already realized it would be quite useful, so I will release an update sometime soon.

Thank you and keep up the good work. I'm working on a mission where there's a large NATO base, and right now I have civis driving around the base limits.NOT very realistic. Looking forward to the update.

 

Thanks engima, I'll give this a shot sometime. Since you know your way around scripts, do you know of one that can easily populate towns with civvies to go along with the traffic? TPW's civ mode no longer works for me.

I'm interested as well,thank you.

Share this post


Link to post
Share on other sites

Thank you and keep up the good work. I'm working on a mission where there's a large NATO base, and right now I have civis driving around the base limits.NOT very realistic. Looking forward to the update.

 

I'm interested as well,thank you.

Ok, here you are! Now it's possible to have different kinds of traffic in different areas. I didn't really found out a good way to add black areas, without just having the vehciles disappear if they enter it, so I took the other solution, so now you can have as many traffics you want in different or overlapping areas.

This feels like a good one. I believe this script can be extremely handy - thinking of my own future mission editing.

Good luck!

  • Like 2

Share this post


Link to post
Share on other sites

Ok, here you are! Now it's possible to have different kinds of traffic in different areas. I didn't really found out a good way to add black areas, without just having the vehciles disappear if they enter it, so I took the other solution, so now you can have as many traffics you want in different or overlapping areas.

This feels like a good one. I believe this script can be extremely handy - thinking of my own future mission editing.

Good luck!

YOU'RE DA MAN!!!!!!!!

Share this post


Link to post
Share on other sites

I get a bunch of these errors randomly popping up, what I did I mess up?

 

20:47:34 Error in expression <le "dre_scriptHandle";
if (!(scriptDone _scriptHandle)) then {
terminate _script>
20:47:34   Error position: <_scriptHandle)) then {
terminate _script>
20:47:34   Error Undefined variable in expression: _scripthandle
20:47:34 File C:\Users\AccuracyThruVolume\Documents\Arma 3\missions\8th_ATV_01_WelcomeToAlRayak.pja310\Engima\Traffic\Server\Functions.sqf, line 490
 
 
EDIT:  Found the error, one of the classname declarations for the vehicles to spawn was wrong.  If you see this error, check your array of vehicle classnames  ;)

Share this post


Link to post
Share on other sites

Its a great script but unfortunately in the heat of a battle they will go offroad and start driving anywhere and everywhere, and eventually abandon their vehicles and run right into a gun fight.. i realize nothing can be done about this behavior but it would be nice if they could stick to the road and just speed through, reminds me of some Syrian footage ive seen where the Syrian army were fighting insurgents using tanks and apc's on what looked like a main artery or even a highway and in amongst it were civilian vehicles speeding through, crazy stuff but highlighted an interesting aspect of civilians going about their business even in the middle of a war.

 

Edit: Found the clip, its one of my favorite footage of the war, lots going on  and poor ole civilians hitting the gaps! 

 

Share this post


Link to post
Share on other sites

Anyway this will work with Civilain air assets, like the M900?

Share this post


Link to post
Share on other sites

Awesome script Enigma!  Works perfectly, just like your simple civilians.  I'm now using it in my missions!  Thank you for making and sharing!

Share this post


Link to post
Share on other sites

Great script. But there are two things I'm really missing:

- Possibility to add an eventhandler to the crew of the vehicle (this feature is in the civilians script, why not here? If you count civ-murdering, drivers from the traffic script are excluded)

- Possibility to add blacklist markers as in the civilians script (traffic ignores the blacklist markers from civilians)

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

×