The following is meant to be used where the player is approaching an area with AI defending, in which they will react according to the detection level. I have no clue how it works in multiplayer. The detection works by seeing how much each AI group knows about EACH member of the player's group, then acting on the highest level found.
In the editor, I placed all the bad guy groups (that will react), then gave each of them two waypoints. The first waypoint has this in the condition field
kmDetected
Which will be a boolean. The second waypoint for everyone is a Seek an Destroy, and it doesn't matter where the waypoint is placed.
I then place a trigger, West Detected by East, Once, no timeout/countdown, with the following in the activation field:
kmDetected=true;[thislist,false] exec "CheckForEngaged.sqs"
Which calls the first script below:
; CheckForEngaged.sqs
_showMsgs=FALSE
_arrSeen = _this select 0
? count _this > 1:_showMsgs=_this select 1
#checkLoop
[_showMsgs] exec "Engagedv2.sqs"
? kmEngaged:goto "alreadyEngaged"
~6
goto "checkLoop"
#alreadyEngaged
~122
kmEngaged=false
goto "checkLoop"
Which periodically calls the main script below:
; Engagedv2.sqs
_showMsgs=false
_showMsgs = _this select 0
? kmEngaged && (Time - kmTime<240):exit
; Figure out how much is REALLY known
_arrBadGuys=[gWestSentry] + [gNorthSentry] + [gSouthSentry] + [gTruckGuys]
_arrBadGuys=_arrBadGuys + [gBMPGroup]
_arrGuys = units group player
_max=count _arrBadGuys
_maxGuys=count _arrGuys
_high=0
_current=0
_cur=0
_curGuy=0
_highGuy=-1
_highBadGuy=-1
#guyCount
_cur=0
_guy=_arrGuys select _curGuy
#loopCount
_current = (_arrBadGuys select _cur) knowsAbout _guy
? _current > _high:_high=_current;_highGuy=_curGuy;_highBadGuy=_cur
_cur=_cur+1
_current=0
? _cur<_max:goto "loopCount"
_curGuy=_curGuy+1
? _curGuy<_maxGuys:goto "guyCount"
? _showMsgs:hint format["Highest value=%1",_high]
? _high > 1.5:_guy=_arrGuys select _highGuy;goto "Engage"
? _high > 1.0:_guy=leader (_arrBadGuys select _highBadGuy);goto "Alert"
exit
#Alert
? kmAlerted && (Time-kmTime)<240:exit
kmAlerted=true
kmTime=Time
_pos=getpos _guy
;
; Get bad guys moving towards *bad guy that spotted/is alerted*
;
? _showMsgs:titleText["Enemy is alerted!","PLAIN DOWN"]
? _guy != leader gWestSentry:[gWestSentry,3] setWPPos _pos
? _guy != leader gNorthSentry:[gNorthSentry,3] setWPPos _pos
? _guy != leader gBMPGroup:[gBMPGroup,6] setWPPos _pos
? _guy != leader gSouthSentry:gSouthSentry setbehaviour "AWARE";{_x doMove _pos} foreach units gSouthSentry
exit
#Engage
kmEngaged=true
kmTime=Time
_pos=getpos _guy
;
; Get everybody moving towards spotted good guy
;
? _showMsgs:titleText["Your team has been spotted!","PLAIN DOWN"]
gWestSentry reveal _guy;{_x domove _pos} foreach units gWestSentry
gNorthSentry reveal _guy;{_x domove _pos} foreach units gNorthSentry
gBMPGroup reveal _guy;{_x domove _pos} foreach units gBMPGroup
gSouthSentry reveal _guy;{_x domove _pos} foreach units gSouthSentry
exit
The variables "gWestSentry", "gNorthSentry" etc... are group variables I assign in the editor. To reuse the script, just replace the group variables with your own, everywhere they appear. The array arrBadGuys is only used to see who knows about the player's group, so you can include any group or individuals you want here - even if they won't be moved or react. The moving is seperate from the detection in the script. In this case, you'll notice one of my groups has no waypoints to move, but instead is "DoMove"ed to the location...just a quirk of this particular mission.
The section where the group waypoints are moved, or where the members are DoMove'ed, is where you can customize the response to the situation. You may want some groups to stay in place but watch the designated area, while other groups move to the area, etc....
Typically, the KnowsAbout value will trigger the Alert before the Engage, so that is why I don't setWPPos in the Engage section...they have probably already reached the second waypoint by then so I just doMove. If they don't find anything after the domove, they will fall back to Seek and Destroy at the Alert location.
If you want to see what the ongoing highest "knowsAbout" value is as you play, just call the first script from the trigger with TRUE for the second parameter. It will then show the value in a Hint window until they Engage.
Make sense? Hope it helps.
[Edited error in script, "_arrBadGuys select _cur" should have been "_arrBadGuys select _highBadGuy"]