Home   Help Search Login Register  

Author Topic: SAR Script  (Read 1564 times)

0 Members and 1 Guest are viewing this topic.

Offline Hellbender

  • Members
  • *
SAR Script
« 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?
« Last Edit: 04 Jul 2008, 06:06:40 by Hellbender »

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: SAR Script
« Reply #1 on: 06 Jul 2008, 22:54:19 »
Off the top of my head:

  • create a script which loops slowly, checking the status of whichever pilot is sent to the script
  • if the pilot's ride is busted, eject the pilot and exit the loop
  • begin another loop (same script) containing a domove command pointing at the EZ, and a condition checking how far the pilot is from it
  • once the pilot reaches the EZ, exit the loop and have the pilot sit down and roll a fat one

Offline Hellbender

  • Members
  • *
Re: SAR Script
« Reply #2 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!  :)

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: SAR Script
« Reply #3 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.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: SAR Script
« Reply #4 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.

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: SAR Script
« Reply #5 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.
"When 900 years YOU reach, look as good you will not!"

Offline Hellbender

  • Members
  • *
Re: SAR Script
« Reply #6 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!