Heres a segment out of my patrol replacement script in the kolgujev contract. Any spawned unit(s) require an existing group. You can do as Kreig just stated and place a unit, identify his group name and then kill him off(I prefer deletion to just remove the dead body) Any unit then created in that group will follow the waypoints set out for the first deleted group or those kia.(If you have assigned them waypoints)
The below script will check the number of units in a group and then spawn additional units until the total listed number is met. In this case...3. If you require an entire group, simply up that number to 12. It also adds a killed eventhandler which runs a deletion script to remove the dead body. It setpositions each spawned unit to a marker called "patrolmarker". This as well as the group name can be changed to fit your needs of course.
#patrol1start
_alpha = {alive _x} count units patrol1
? _alpha == 3 : goto "patrol2start"
#create1
_NUMBERS = 20
_NUMB = Random _NUMBERS
?(_numb < 1) : "soldierE" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "corporal"]
?( (_numb > 1) and (_numb <= 2) ) : "soldierElaw" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "corporal"]
?( (_numb > 2) and (_numb <= 3) ) : "soldierEMG" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "corporal"]
?( (_numb > 3) and (_numb <= 4) ) : "soldierEG" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "private"]
?( (_numb > 4) and (_numb <= 5) ) : "soldierE" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "private"]
?( (_numb > 5) and (_numb <= 6) ) : "soldierEMedic" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "corporal"]
?( (_numb > 6) and (_numb <= 7) ) : "soldierE" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "private"]
?( (_numb > 7) and (_numb <= 8) ) : "soldierESniper" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "corporal"]
?( (_numb > 8) and (_numb <= 9) ) : "soldierE" createUnit [getMarkerPos "PatrolMarker", patrol1,"AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "private"]
?( (_numb > 9) and (_numb <= 10) ) : "soldierE" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "private"]
?( (_numb > 10) and (_numb <= 11) ) : "soldierE" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "private"]
?( (_numb > 11) and (_numb <= 12) ) : "soldierE" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "private"]
?( (_numb > 12) and (_numb <= 13) ) : "soldierESniper" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "corporal"]
?( (_numb > 13) and (_numb <= 14) ) : "soldierE" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "private"]
?( (_numb > 14) and (_numb <= 15) ) : "soldierElaw" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "corporal"]
?( (_numb > 15) and (_numb <= 16) ) : "soldierEMG" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "corporal"]
?( (_numb > 16) and (_numb <= 17) ) : "soldierE" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "private"]
?( (_numb > 17) and (_numb <= 18) ) : "soldierEG" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "private"]
?( (_numb > 18) and (_numb <= 19) ) : "soldierEMedic" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "corporal"]
?( (_numb > 19) and (_numb <= 20) ) : "soldierE" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "private"]
~.01
goto "patrol1start"
The coed box autoreturned the code above, splitting the lines into two. If you use it, make sure all the code appears behind each question mark.
You will not have to order the units back into formation since the leader will do this automatically. And they will automatically know the information that any of the other group members have reported such as enemy position, until the information expires of course.
Below is the code for the deletehandler script called from the killed eventhandler. It has a 10 second loop and a distance check. Both of which can obviously be tweaked to your needs.
_unit = _this select 0
_unit removealleventhandlers "killed"
#loop
?(player distance _unit >= 400): deletevehicle _unit; exit
~10
goto "loop"
Hope it helps.