Home   Help Search Login Register  

Author Topic: Search and Rescue Groups  (Read 2333 times)

0 Members and 1 Guest are viewing this topic.

Offline Cold

  • Members
  • *
  • Mission Maker
Search and Rescue Groups
« on: 24 Apr 2011, 20:36:41 »
I have a mission created with three hostages: hostage_1, hostage_2, and hostage_3 respectively.

There are also 3 groups of operatives to rescue them, though no group will have to rescue any one specific hostage. One group could in fact rescue all of them.

My problem:

I am trying to make each hostage be added to the group of operatives that find them. Rather than create multiple triggers stating "hostage_1 assignTeam "player"" to with each activation being "player distance hostage_1 < 1" -- is there any way to consolidate all of this into a single script (multiplayer compatible) so that if any of the groups gets close to any of the hostages, the hostage they find gets added to the group that finds them?

This wouldn't be much of a problem except that it will be a multiplayer mission.

Thank you for your help - and if anything needs further clarification just let me know!
A leader is best when people barely know he exists, when his work is done, his aim fulfilled, they will say: we did it ourselves. <br />Lao Tzu

Offline mr_book.PXS.Pvt

  • Members
  • *
Re: Search and Rescue Groups
« Reply #1 on: 27 Apr 2011, 18:10:48 »
Hi Cold,
sounds like a nice idea, so here you have it. Tested and approved in SP and MP, on both hosted and dedicated server.
First off, create a script called "hostages.sqf" (or whatever name you like) and put this in it:
Code: [Select]
{
 _trg = createTrigger ["EmptyDetector", getpos _x];
 _trg setTriggerArea [1, 1, 0, false];
 _trg setTriggerActivation ["west", "present", false];
 _trg setTriggerStatements ["this", format ["[%1] join (thislist select 0)", _x], ""];
 _trg attachto [_x];
} foreach [hostage_1, hostage_2, hostage_3];
Later on, add this line to your mission's "init.sqf":
Code: [Select]
_nul=[] execvm "hostages.sqf"; The script will then be executed on mission startup.
A little explanation: the script creates a trigger (that's right - it's the easiest way to get things done here) for each hostage. Any BLUFOR unit (no matter whether it's a human player or A.I.) will activate that trigger and the hostage will then join that unit's group. That way, any group can rescue any hostage, pretty much as you intended.
Additionally, the trigger is attached to the hostage, just in case the hostage moves around.
Just try and see if this works for you. If so, let me know, if not, also.
G'day,
mr_book

Offline Cold

  • Members
  • *
  • Mission Maker
Re: Search and Rescue Groups
« Reply #2 on: 04 May 2011, 04:33:50 »
That worked beautifully!  :good:

The only thing I would think to add is the option of adding an action to actually rescue the hostage, rather than have them automatically join the groups. What I've run in to is that if the buildings across from said hostage have not been cleared, when the unit joins the group he gets "in formation" by running out of the building and getting himself shot... but I suppose that'll make having to have the town secure that much more interesting! Thanks again!
A leader is best when people barely know he exists, when his work is done, his aim fulfilled, they will say: we did it ourselves. <br />Lao Tzu

Offline mr_book.PXS.Pvt

  • Members
  • *
Re: Search and Rescue Groups
« Reply #3 on: 04 May 2011, 21:13:00 »
Hi Cold,
yay, worked nice, eh?
I thought about what you said there, the thing with the hostage just running off and getting shot and all. You could either smuggle a "setcaptive" command in there:
Code: [Select]
_trg setTriggerStatements ["this", format ["[%1] join (thislist select 0); %1 setcaptive true;", _x], ""];

But this would be a little unfair, because no enemy unit would ever shoot at the hostage. Rather unrealistic, eh?

Or, you could indeed add a "Free hostage"-action to each hostage. That way, just like in real life, you, the liberator, decide when it's time for the hostage to join you. Problem here: the rescue team leader HAS TO be human, as A.I. soldiers execute actions only when ordered by humans. But this mission is made for an MP environment anyway, so why not give it a try.

Replace the old line in your "init.sqf" with this:
Code: [Select]
{[_x, 0, 0, ["0"]] execvm "hostage.sqf"; sleep 0.1;} foreach [hostage_1, hostage_2, hostage_3];

And put this into "hostage.sqf":
Code: [Select]
_hostage = _this select 0;
_liberator = _this select 1;
_action = _this select 2;
_selections = _this select 3;
_selection = _selections select 0;

switch (_selection) do
{
 case "0":
 {
  _trg = createTrigger ["EmptyDetector", getpos _hostage];
  _trg setTriggerArea [2, 2, 0, false];
  _trg setTriggerActivation ["west", "present", true];
  _trg setTriggerStatements ["this", format ["freeman = %1 addaction [""Free hostage"", ""hostage.sqf"", [""1""], 100]", _hostage], format ["%1 removeaction freeman", _hostage]];
  _trg attachto [_hostage];
 };
 case "1":
 {
  [_hostage] join (_liberator);
  _hostage removeaction _action;
  deletevehicle _trg;
 };
 default {};
};

DISCLAIMER! This one is only tested in the editor, but should work fine, too. I'll leave all testing to you this time.

Good night,
mr_book

Offline Cold

  • Members
  • *
  • Mission Maker
Re: Search and Rescue Groups
« Reply #4 on: 16 May 2011, 16:25:37 »
@Mr_Brooks - that is exactly what I was looking for - and it worked without a hitch! I never play with AI turned on in MP games that I host - and it generally bothers me to have them on in any MP games I join. It's hard to have a stealth mission such as this with AI following 50m to your right or left going apesh*t every time they notice a member of the OPFOR. Well done, and thank you! :clap:
A leader is best when people barely know he exists, when his work is done, his aim fulfilled, they will say: we did it ourselves. <br />Lao Tzu

Offline zhenghir

  • Members
  • *
Re: Search and Rescue Groups
« Reply #5 on: 07 Jun 2011, 10:44:40 »
hi,
im trying to get this script to work with 3 independent hostages "Hostage_1  - 3" do the _hostage in the script count all 3 ?? or do i need to add them into the script.

hope that made any sense.

thank you.

Offline sharkattack

  • Former Staff
  • ****
Re: Search and Rescue Groups
« Reply #6 on: 09 Aug 2011, 13:30:13 »
mr_book.PXS.Pvt.

I have been trying to use the hostage script you posted above on our dedicated server.
It works a treat and does away with any problems  caused by anyone other than the group leader rescuing
the hostages.
However there is one problem, the action to release hostages is not removed on dedicated server,  any suggestions on how to fix this would be great.

Very nice script
best wishes shark-attack.
"HOLY SARDINE" - see Shark-Attack meet his match

Offline mr_book.PXS.Pvt

  • Members
  • *
Re: Search and Rescue Groups
« Reply #7 on: 16 Aug 2011, 21:23:24 »
Hi sharkattack,
sorry for the late reply, I haven't checked the forums for quite some time.
Anyway! So there's yet another damn tripwire in it, huh? Looks like it's not enough to test mp missions on a dedicated server when you're all alone in there. Arf!
Unfortunately, I have no real clue how to solve this. I already tried some things but haven't found a solution yet.
I guess the problem is that there a numerous triggers added to the hostage (one per client?) instead of just a single one. So the solution would probably be to limit the number of times the script is executed, but like I said, I haven't found the right way yet.
Any assistance is highly welcome!
Regards,
mr_book