Home   Help Search Login Register  

Author Topic: Moving Waypoints  (Read 740 times)

0 Members and 1 Guest are viewing this topic.

RTechnix

  • Guest
Moving Waypoints
« on: 13 Apr 2004, 22:51:32 »
I have this thing where I want the enemy to attack in the direction of the last sighting of your player.  Anyhow, instead of just like dofollow or something like that, I have a whole set of waypoints for how they approach in each direction but the way I have it set up, they're just gonna go to the North plan of action, then East, South, West instead of just taking the one direction I want them to and stopping at the end.  How can I get this to work?

Kammak

  • Guest
Re:Moving Waypoints
« Reply #1 on: 27 Apr 2004, 01:31:28 »
I just recently did this very thing!

For each group I just use two waypoints.  The first waypoint sets them to SAFE etc... and has a CONDITION of some boolean.  The second waypoint is a Seek and Destroy, with the corresponding formation and behaviour changes.

Then, I use a DETECTED trigger to kick off the scripting.  Once the DECTECTED trigger fires, I go through each group and check their "knowsAbout" level for the player's group.

If the high is between 1.0 and 1.5, I call that "Alerted", and move all the other groups towards the high group's location (flip the bool to TRUE so they all move to their second waypoint, and move the WP to the location of the high group (using setWPPos).

If the high is over 1.5, I call that "Engaged", and do as above but move the WPs to the last enemy sighted location instead.

Once started, the scripts runs every five seconds until "Engaged" is true, then runs every 2 minutes after that (in case they lose contact then re-spot the player).

It plays out pretty well, so that if you snipe a bad guy, it alerts his buddies and the other groups move towards the group that took the casualty...but if you are actually spotted and they start shooting at you (knowsAbout > 1.5), then all the other groups move towards YOU (or your last location).

Note that it doesn't default to setting the WPPos to the player, but to whoever was actually spotted...so you can split up your group and setup a base of fire, then have one or two guys draw out the guards...just like in real life.

I love this game!  :)


Does that help you at all or do you need script samples?

RTechnix

  • Guest
Re:Moving Waypoints
« Reply #2 on: 27 Apr 2004, 02:56:55 »
Oops, accidently pressed notify...I think i deactivated it but just in case - theres your explanation.

Anyhow, it all sounds good, but I'm not very good at scripting so some samples would help a lot.  Thanks.

Kammak

  • Guest
Re:Moving Waypoints
« Reply #3 on: 27 Apr 2004, 03:46:51 »
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:

Code: [Select]
; 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:

Code: [Select]
; 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"]
« Last Edit: 29 Apr 2004, 10:09:31 by Kammak »