This script fixes a behavior issue when one AI group got attacked by the enemy while the other groups in the area keep patrolling in SAFE behavior.
When somebody got killed or somebody changes his behaviour all the other groups will change theirs too.
Here it is, groupchain..sqs, simple but very useful
; ***************************************
; GROUPCHAIN.sqs by Blanco
; 28 / 07 / 04
; ***************************************
; Execute it with :
; [name of the groups seperated by a comma] exec "groupchain.sqs"
;
; example
;
; [grp1,grp2,grp3] exec "groupchain.sqs"
;=========================================
_c = count _this
_allunits = []
_grpcount = 0
#REPEAT
_b = 0
_grp = _this select _grpcount
_u = units _grp
#CYCLE
_man = _u select _b
_allunits = _allunits + [_man]
_b =_b + 1
~0.2
?_b < count _u : goto "CYCLE"
?_grpcount < _c : _grpcount = _grpcount + 1;goto "REPEAT"
#CHECK
?"behaviour _x != ""SAFE""" count _allunits > 0 OR "!alive _x" count _allunits > 0 : goto "CHANGEBEH"
~1
goto "CHECK"
#CHANGEBEH
"_x SetBehaviour ""AWARE""" foreach _allunits
~1
#PICKONE
_countall = count _allunits
_r = random _countall
_r = _r - _r %1
_alarmguy = _allunits select _r
if (alive _alarmguy) then {goto "CHECKSIDE"} else {goto "PICKONE"}
#CHECKSIDE
?side _alarmguy == WEST : goto "W"
?side _alarmguy == EAST or side _alarmguy == RESISTANCE : goto "E"
#W
_WESTVOICES = ["eng20","eng21","eng40","eng18","eng19","eng12"]
_r = random (count _WESTVOICES)
_r = _r - _r %1
_alarmguy say (_WESTVOICES select _r)
exit
#E
_EASTVOICES = ["rus15","rus10","rus6","rus1"]
_r = random (count _EASTVOICES)
_r = _r - _r %1
_alarmguy say (_EASTVOICES select _r)
exit
Initialise your groups first with the group command and run it with
[groupnames seperated by a comma] exec "groupchain.sqs"
Example
[grp1,grp2,grp2] exec "groupchain.sqs"
You can also run it with a individual unit(s) (eg : A1) & groups (eg : grp1,grp2,grp3) with:
[grp1,grp2,grp2, group A1] exec "groupchain.sqs"
NOTE :
=====
- Make sure that every group or unit is in SAFE behavior when the script starts!
BUGS :
=====
None.