OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Kilo11 on 03 Oct 2003, 23:56:38

Title: Search & Rescue/Downed Pilot
Post by: Kilo11 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:

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=-
Title: Re:Search & Rescue/Downed Pilot
Post by: deaddog 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.
 :)
Title: Re:Search & Rescue/Downed Pilot
Post by: Kilo11 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=-
Title: Re:Search & Rescue/Downed Pilot
Post by: deaddog 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.
Title: Re:Search & Rescue/Downed Pilot
Post by: Kilo11 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=-
Title: Re:Search & Rescue/Downed Pilot
Post by: deaddog on 05 Oct 2003, 23:17:38
Hera ya go (also sent to email)