Hi SW
Among my various half baked projects I have been working on a script that I've called "trumanShow.sqs". What the script is intended to do is create a mob of mingling civilians in each town that the player visits no matter where he goes, then delete them as soon as the player leaves the area.
What the script will eventually (!!) do is camcreate a group of civilians at the town nearest to each player then set them mingling in a semi-random fashion. Each tick of the cycle a random civilian will doMove to either a random nearby point or to a random nearby civilian. Once the payer moves on to another town all the civvies will be camDeleted and new civvies will be created at the new town.
The final version of the script will allow the mission designer to specify which areas are towns and what the population of each one is. Ideally, the mission designer shouldn't have to define which unit is a player, the script should just work out which unit needs to be able to "see" civvies and create them accordingly.
My current sticking point is working out how to keep the script from constantly identifying a certain town as the "nearest object" for the first time. The script should say "okay - your nearest town is now Montignac, here's 35 people wandering around. So long as you don't move any closer to Gravatte you can watch them wander, but if you move 10m to the north then all the little Montignards will disappear and I will create 15 new Gravattians for you to watch . . .". What it shouldn't do is keep saying "okay, you're still next to Montignac, here's another 35 Montignards for you to watch . . .".
For your purposes, you could use a similar script that only creates viewable units whenever the player is within "range" of it. With a viewdistance of (say) 800m and the usual intervening foliage I'd say that a reasonable distance would be around 500m. In other words, move your group leaders, and if they are within 500m of a (the?) player then add the appropriate units to the group.
Another script that I am just finishing makes a hunting group continuously move towards a specified target group, unless the group count is below a certain (morale) level). Combined with a respawn script it makes for a tense mission as the players continually knock back their pursuers, trying to finish them off for good while dodging the other pursuers that are still on their trail.
The first mission that I've used this in has six full strength Soviet groups (approximately 60 units at full strength) vs one group of Resistance payers with respawn to group and a script that allows recruiting at each town. It gives a pretty good feel of a running battle. Last night I tested it out with a friend, we played it four times, with one run through that lasted about two hours with the last three members of our group running out of town at least three times with two BMP squads and a T72 platoon in hot pursuit each time !
Once I get this mission working exactly as I like I intend to try using the hunt script in a head to head style mission, with 5-6 groups on each side battering each other senseless. So far I've tested it with one squad vs one squad and the results have been pretty impressive. I've tested it playing as a civvie observer - it's fun watching one side then the other charge, get whittled down, then run away with the other side in hot pursuit. Even with just the one group on each side there is a good running battle feel to it.
So to answer your questions -
1 - Yes, it is possible to use single units or even just array variables to substitute for whole groups until the player runs in to them. I see no reason why you couldn't have an infinite number of units recorded in arrayready for use as and when required.
2 - Yes, it is very easy to have one version of this script running, with a whole mess of different variables defined for each group.
In the above hunt and seek mission that I detailed I have six versions of the hunt and seek script running throughout the mission, with no less than ten variables defining the behaviour of each group. Some groups are cautious and slow, others are aggressive and quick, some are elite, some aren't etc.
3 - See the above hunt script. My script is pretty involved and has lots of gloss (groups set up camp at night etc) but the core is dead simple.
All I've done is create six groups, each with one waypoint. The script then locks this waypoint so that it is never "finished", then keeps moving the waypoint position (setWPPos) either on to the nearest enemy unit (if the group is okay) or back to the group's start point (if group is broken).
Easy as !
4 - I haven't used onMapSingleClick command yet but I've always thought that it would be a REALLY great way to control multiple groups.
Since this command returns the click position, all you need to do is write the script so that if the click is within (say) 50m of a group (using an array of each group's leader's position) then the click will "select" that group, otherwise it will move the selected group's waypoint to the clicked position (setWPPos).
I hope that any of this helps.
Cheers
Roni