Home   Help Search Login Register  

Author Topic: Search & Rescue/Downed Pilot  (Read 688 times)

0 Members and 3 Guests are viewing this topic.

Kilo11

  • Guest
Search & Rescue/Downed Pilot
« on: 03 Oct 2003, 23:56:38 »
Hello all,
     It has been a while since I have posted, I've been busy doing some editing, but anyways, to the point.  I am currently making a simple Search & Resuce mission for a downed piot in enemy territory.  Now here is my problem, I want a simple script that will:
  • Once within a certain amount of distance, the pilot will join that group (which may be ANY* group) close to his area.  
  • Now I got the whole "join" command, but the problem  lies within the fact the pilot may join more then just one squad.  Whitchever squad may be closes, I want him to join the squad that is closes to him.
  • Now, at the same time, the script/trigger can NOT be activated by certain vehicles/members.  (Another BIG problem)  I have to do this b/c I will have certain planes (A-10's) flying overhead, and I do not want them to trigger it, have the pilot join them, when they are flying around giving CAS.

So if anybody could help me with the commands or if you have a script or if your even willing to make one, I would GREATLY appreciate it.  Thanks agian.

-=Kilo=-
« Last Edit: 03 Oct 2003, 23:57:39 by Kilo11 »

deaddog

  • Guest
Re:Search & Rescue/Downed Pilot
« Reply #1 on: 04 Oct 2003, 01:25:25 »
Put the names of all the groups the pilot is capable of joining into an array:


;**** rescue.sqs

_rescuer=[alpha,bravo,charlie, etc]

_pilot=name of pilot here

#check

~5

_dis=99999

{_d=_pilot distance (leader _x);if (_d<_dis) then {_dis=_d;_closest=_x}} foreach _rescuer

?_dis > 25:goto "check"   ;change to whatever distance you like

[_pilot] join _closest

exit


Run this script from init.sqs (or whenever you want to start it).

This will find the closest group the pilot is capable of joining and when they get close enough, he will join.
 :)

Kilo11

  • Guest
Re:Search & Rescue/Downed Pilot
« Reply #2 on: 05 Oct 2003, 04:57:11 »
Hey, thank you very much, just one little problem, it doesnt work.  LOL, no worries though.  This is all that I have:

-rescue.sqs (with all that you gave me in it)

Quote
_rescuer=[alpha,bravo,charlie,delta]

_pilot=pilot

#check

~5

_dis=99999

{_d=_pilot distance (leader _x);if (_d<_dis) then {_dis=_d;_closest=_x}} foreach _rescuer

?_dis > 10:goto "check"  

[_pilot] join _closest

exit
-init.sqs ([] exec "rescue.sqs")
-several squads (alpha-delta) that have the "alpha = groupthis" in their init fields.
-A pilot named "Pilot"

The script works fine, but I think the "Join" command line is worng, because that is the only thing that the pilot does not do, join the actual group.  

Im not sure though, so if you find the problem, let me know.  Thanks again!  

-=Kilo=-

deaddog

  • Guest
Re:Search & Rescue/Downed Pilot
« Reply #3 on: 05 Oct 2003, 06:19:33 »
I found the problem.  For some reason, you have to initialize the "_closest" variable before using it:

Code: [Select]
_rescuer=[alpha,bravo,charlie,delta]

_closest=""
_pilot=pilot

#check

~5

_dis=99999

{_g=_x;if (("alive _x" count units _g) == 0) then {_rescuer=_rescuer - [_g]}} foreach _rescuer

{_d=_pilot distance (leader _x);if (_d<_dis) then {_dis=_d;_closest=_x}} foreach _rescuer

?_dis > 10:goto "check"  

[_pilot] join _closest

exit

I actually tested it this time :)

I checked the script to see how it would react if all the units of one of the groups are dead.  It didn't seem to affect it but just to be on the safe side, I added that other foreach line.

if a group is all dead then this will remove that group name from the array.
« Last Edit: 05 Oct 2003, 06:35:13 by deaddog »

Kilo11

  • Guest
Re:Search & Rescue/Downed Pilot
« Reply #4 on: 05 Oct 2003, 20:58:58 »
Hmmm.... still doenst work.  Would you happen to have an example mission (just a simple one) that you would be willing to send to me?  I must be doing something minor wrong.  THank you so much for your help.  If you do have an example mission, please send it to SCHardy@ricochet.com.


-=Kilo=-

deaddog

  • Guest
Re:Search & Rescue/Downed Pilot
« Reply #5 on: 05 Oct 2003, 23:17:38 »
Hera ya go (also sent to email)