Hostage Capture Script (addAction)


Milosan on the BIS forums wanted an addAction controlled hostage script.  Here’s how I did it:

It used a preset list of units, addAction, a script and a trigger.

Preset list of units set in init.sqf or somewhere similar, in this demo it’s done in the init field of the player:

POWS = [p1,p2,p3,p4]

p1 through p4 are captured civilians in a storage container. They are grouped, but since we’re using the array we just declared they wouldn’t have to be. The group leader has the following addAction in his init field:

this addAction ["Rescue POWs","rescuePows.sqf",[POWS],1,false,true,"","(_target distance _this) < 3"];

That will present the player with a “Rescue POWs” action prompt if they are within 3m of the group leader. Upon selecting that action this script will run:

_per = _this select 0;  // Person who had the addAction
_ldr = _this select 1;  // Person who used the addAction
_act = _this select 2;  // ID of the addAction

// Group given in the arguments section (ie: [POWS]
_grp = _this select 3 select 0;

// Remove the rescue option
_per removeAction _act;

// Join preselected units (POWS) to callers group, silently.
{[_x] joinSilent _ldr} forEach _grp;

The units will join the player’s group, following him and following his orders as normal units would. In this demo the player is to turn around and tell the POWs to board the waiting Mi-17 (named rescue1) that just landed. This will mark them as “rescued” according to a trigger once they are onboard the helo. The condition of the trigger is such that if some should die, the rest can still be saved.

Trigger Condition =

{alive _x && (_x in rescue1)} count POWS == {alive _x} count POWS

Trigger onAct =

hint "POWs rescued!";{[_x] joinSilent grpNull} forEach POWS

This will remove the POWs from the player’s group. You might want to mark an objective complete at this point perhaps.

An interactive demo mission of this technique is available.

  1. #1 by K9 on August 18, 2010 - 5:47 PM

    You have two missions showing Hostage Rescue, and what are the biggest difference and what you prefer?

    • #2 by kylania on August 18, 2010 - 8:58 PM

      The main difference between this one and the Capture the Warlord one is how they join your group. This one a group member has an addAction option on them, meaning you have to go up to the unit and click on it to make it join your group.

      The other method is a trigger area of a few meters around which activates when you get near. This way the player doesn’t have to do anything but approach the hostage. Either way works really, the main difference would be what kind of experience you want for the player.

  2. #3 by K9 on August 19, 2010 - 4:22 PM

    Great job, but if the squad leadder die?Can other time mate do the job?

    • #4 by kylania on August 19, 2010 - 4:49 PM

      Anyone from the group can make them join the squad, but only the Leader can tell them where to go once they are in the squad. If a squad leader dies, the next one in line would be able to command them.

  3. #5 by K9 on August 19, 2010 - 8:37 PM

    Ok, good work

  4. #6 by thedog on October 4, 2010 - 6:48 PM

    is this mp compatible? dedicated?

    • #7 by kylania on October 4, 2010 - 7:40 PM

      Yup, should be. 🙂

  5. #8 by Adesso on December 18, 2010 - 7:27 PM

    in this example you use the addAction with a array of player names, is it possible to pass the current unit reference to the called script without an array?

    instead of
    this addAction [“Rescue POWs”,”rescuePows.sqf”,[POWS]…
    have
    this addAction [“Rescue POWs”,”rescuePows.sqf”,[this]…

    and then in the script do
    _per joinSilent _ldr

    I just can’t get this to work.

  6. #9 by Adesso on December 19, 2010 - 2:56 PM

    I solved it 😉

    passing the object as [this] was correct, but the refference inside the script need the object as:
    _person = _this select 3;
    and the last line is just
    _person joinSilent _caller;

    Why not make a demo of this, it could help alot to have a example . Thanks for the other demos, they reall are very usefull.

    Merry X-mas

  7. #10 by doc on February 20, 2011 - 4:11 AM

    The scripts on this site helped me alot. I got 1 problem with this pow script i can’t figure out. If i kill all 4 pow’s before they board rescue1, i get a message say’n pow’s rescued. Is there a way to check if pow’s are dead to fail mission. I try’d !alive instead of alive, but that does not work.

Comments are closed.