I have a rough proof of concept working for ambient civilian traffic. I've attached my super-generic test mission. Basically, just start it and wait for the traffic to start.
The framework starts with the ambient civilian module. Each civilian is initiated with a 40% chance of spawning a civilian vehicle (from a local array). That vehicle is then assigned a move waypoint (either within the town where it spawned or a neighbor) and a cycle waypoint. For now, the civs basically just leave the city, but it won't be difficult to spawn them outside and have them enter the city.
I still need assistance in a few areas.
Ambient Civilian Module:
From the Biki (and experience in a mission I'm also making) I know the syntax to set an init line for a civ is
[**location**,"ALICE_civilianinit",[{**code**}]] call bis_fnc_variablespaceadd;
but, I don't want to specify a particular location. I want ALL civs to have the init, regardless where they are. I've worked around it by having the init.sqf create a list of all the city centers (BIS location function) and a forEach that runs through every one. That's rather inelegant.
I've tried syntax such as
[bis_alice_mainscope, "ALICE_civilianinit",[{if ((random 1) < .4) then {[_this] execVM "JTD_ambientCivTraffic.sqf"};}]] call bis_fnc_variablespaceadd;
and the civs just don't spawn. I know (from mistakes... err "experience") that the first element in the array passed to variablespaceadd should be an object, location, etc. I also tried a setVariable for ALICE_civilianinit and it didn't like it. Like I said, I just want something to put that init on every spawned civ. Ideally, either in the initialization of the ALICE module, or in a GL.
MP Players:
For now, this is SP only, because I need to delete the vehicles based on proximity to the player. As it stands in the proof of concept, when the civ that triggered the vehicle-spawn is removed based on the ALICE logic, the vehicle should be deleted. I would prefer to have the cycle waypoint contain code or execVM a script to check if the vehicle is near any players. If not, then delete. If it is, then wait for it to come back to the cycle waypoint. The only way I can come up with is to use an inelegant check of allGroups to see if a player is in any group. What is the best way to see if an MP player is near a location?
ALICE FSM:
I originally wanted to put the originally spawned civs behind the wheel. However, a moveInDriver didn't work, and an assignAsDriver followed by moveInDriver did work - the civ got in the vehicle, and even started the engine - but then they promptly got out and started moving onto their other wps apparently. Any suggestions on how to disable the ALICE-based logic? Oh, one thing I didn't try (dammit, why do these ideas only come to me when I'm posting?) is to delete all current waypoints, then generate the new ones....
Thanks in advance, as usual.
Edit:
Also, in going through kju's AllInOneConfig from d-h, I found this interesting tidbit.
class drive
{
condition = "_twnthreat <= 1 && _twnthreat >= 0 && !isnil 'bis_silvie_mainscope' && {_x getvariable 'ALICE_threat' <= 1} count _nearbyTowns > 0 && getnumber(configfile >> 'cfgvehicles' >> typeof (_this select 0) >> 'woman') == 0;";
fsm = "ca\modules\alice\data\actions\safe_drive.fsm";
rarity = 0.01;
locked = 1;
canRepeat = 0;
It looks like the ambient civs already have a 1% chance to drive, as long as the ambient vehicles are there, also. Now, that has a couple problems. One is that because of the algorithm it uses to decide how many civs to spawn, the only chance of getting that many is in the big cities like Chernogorsk. Also, it looks like it is influenced by some threat calculation.
Is there some way to change the condition/probability via script? Or, I guess an addon-type thing that changes the config? (That rapidly fades into stuff way beyond my ken....)
Edit:
Updated to a version I did on 29 Sept. Too much traffic, but am working on it.