OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Hellbender on 04 Jul 2008, 01:51:04

Title: SAR Script
Post by: Hellbender on 04 Jul 2008, 01:51:04
I was thinking about making a general SAR (search and Rescue) script for pilots, that kicks in when aircraft are shot down and the pilots bail out.

The idea is to set a new waypoint, to an extraction zone, for pilots that bail out or ditch their aircraft. Ideally, they should also be told to join any friendly units they meet on the way, or at the EZ.


Does anyone know how this could be done?
Title: Re: SAR Script
Post by: bedges on 06 Jul 2008, 22:54:19
Off the top of my head:

Title: Re: SAR Script
Post by: Hellbender on 07 Jul 2008, 00:06:47
Yeah, thanks Bedges!

That's pretty much what I had in mind! I know what has to be done, but exactly how to do it is more of a problem fo me since I'm not the most experienced scripter.  ???

I'm gonna give it another try, but any additional suggestions are extremely welcome!  :)
Title: Re: SAR Script
Post by: Mandoble on 07 Jul 2008, 10:54:55
You should not just add a waypoint, that added waypoint would the last one in the waypoint list of that group. You need first to remove any pending waypoint for the crew group. Also consider that a chopper crew might be composed by several groups so you first need to find out, from the surviving members, how many groups should be affected by the evacuation script. Then, for each group, remove all the existing waypoints (waypoints array and deleteWaypoint command in a loop for each member of the array). And now you can add the corresponding waypoints to the EZ. If the EZ is too far away, it is better to split that distance into several waypoints, this way the AI will be able to solve the paths between current position and next destination better.
Title: Re: SAR Script
Post by: bedges on 07 Jul 2008, 11:22:19
I was thinking about this a bit further...

A very simple option would be to add a final move waypoint at the EZ, and use a switch trigger with the !canmove aircraft conditional synchronized to the previous waypoint. If the aircraft is damaged and the crew are still alive, the AI routines will do the rest - assuming they remember to bail out.

The downside to this method is that trigger conditions are checked many times per second, so depending on how many aircraft use this method there may be a performance hit.
Title: Re: SAR Script
Post by: Wolfrug on 07 Jul 2008, 13:19:20
You don't need to remove the waypoints - just make the created waypoint the "current" one, and all the ones in-between get skipped automagically. As so:

Code: [Select]
_escapeWP = (group _pilot) addwaypoint [getpos _escapePoint, 0];
(group _pilot) setcurrentwaypoint _escapeWP;

Of course, you'll have to have the _escapepoint predefined (in this case it'd be an object, hence the getpos) and _pilot (being the pilot needing a new waypoint). Might also want to create a local variable for (group _pilot) to make things easier ;) But you get the jist of it!

Good luck!

Wolfrug out.
Title: Re: SAR Script
Post by: Hellbender on 12 Jul 2008, 00:25:53
Alright, thanks to you all!

I'll toy with it for awhile and let you know how it goes!