Here's what I came up with to solve this for something I'm working on, too.
It works, mostly.
The idea is to make a pretty good sized trigger, with a bunch of civilians inside it, and waypoints (6 in my case, labeled "CivDest#" with # = 1 to 6). For each civilian in the trigger (well, I think it would also do it for soldiers, so be careful), it will create a set of 2-5 move waypoints, with an additional last cycle waypoint, for a total of 3-6 wps. Each unit will have the waypoints in a random order. The end result SHOULD be a bunch of civilians wandering around randomly. Also, they will occasionally run a few steps, but they mostly walk.
I can post a screenshot of an earlier version of this, if it'll help picture what the trigger looks like.
Codeness:
/* JTD Civilian Ambling script
by Trexian
Purpose: have civilians wander between six markers
Implementation: executed from activation of trigger
*/
// defines and establishes scopes
// generate list of units in trigger
_civs = thislist;
_pop = count _civs;
_rndNum = 3; // minimum of 3 waypoints
_rndMarker = 1; // default to first marker
_markPos = getMarkerPos "CivDest1"; // default to first marker
// if no civs within trigger, then exit
if (_pop == 0) exitWith {};
// for each unit, remove from group
{ // start foreach loop
[_x] join grpNull; // makes each unit individual
sleep .5;
_x setBehaviour "SAFE";
_x setSpeedMode "LIMITED";
_rndNum = _rndNum + floor random 3; // results in random number between 3 and 6
for [{_i = 0}, {_i <= _rndNum}, {_i = _i + 1}] do
{ // start wp index iterative loop
_rndMarker = ceil random 6; // picks one of 6 markers 1 to 6
switch (_rndMarker) do
{ // start switch loop
case 1:
{
_markPos = getMarkerPos "CivDest1";
sleep 1;
};
case 2:
{
_markPos = getMarkerPos "CivDest2";
sleep 1;
};
case 3:
{
_markPos = getMarkerPos "CivDest3";
sleep 1;
};
case 4:
{
_markPos = getMarkerPos "CivDest4";
sleep 1;
};
case 5:
{
_markPos = getMarkerPos "CivDest5";
sleep 1;
};
case 6:
{
_markPos = getMarkerPos "CivDest6";
sleep 1;
};
}; // end switch loop
_priGrp = group _x; // really just a group of 1, but addwaypoint needs a group
_wp = _priGrp addWaypoint [_markPos, _i]; // adds waypoint selected at index _i
// conditional to decide which kind of waypoint to make it
if (_i == _rndNum) then
{
[_priGrp, _i] setWaypointType "CYCLE";
} else
{
[_priGrp, _i] setWaypointType "MOVE";
};
}; // end wp index iterative loop
} // end foreach loop
foreach _civs;
//done
Now, the biggest issue is that when I've run this, there are usually a few AI that don't seem to get the marching orders. They just stand around. Now, depending on where they're placed, it can add to the ambiance, since some guys just aren't going anywhere.
But, when they're standing in the middle of the road, it is a bit awkward.
This may be related to a minor issue, in that this script builds each unit's waypoint group in a series, so it must wait until the first dude's wp set is established before moving on to the second dude. This can be mitigated in a couple ways.
1) reduce the time in each case down a bit, to maybe .4 or so. For some reason, it seemed to run more smoothly with a brief delay, but YMMV.
2) have an initial foreach that gets all of them moving to a specific (or random) position, then proceeds to break them into individuals. This should cover the fact that each is getting individual waypoints.
But really, any ideas as to what my cause some dudes not to get the waypoints?
Thanks!
T