Jump to content
Sign in to follow this  
_qor

Leave group and be free to join another one

Recommended Posts

I am trying with a simple hostage script.

This is the "Follow Me" script which enables the AI to move and to join the player's group.

H1 enableAI "MOVE";

H2 enableAI "MOVE";

H3 enableAI "MOVE";

H1 switchMove "AidlPpneMstpSnonWnonDnon_SleepA_standUp";

H2 switchMove "AidlPpneMstpSnonWnonDnon_SleepA_standUp";

H3 switchMove "AidlPpneMstpSnonWnonDnon_SleepA_standUp";

_talker = _this select 0;

_bother = _this select 1;

_action = _this select 2;

_talker removeAction _action;

_talker globalChat format["Bring me out'a hear!", name _bother];

H2 removeAction _action;

H3 removeAction _action;

[H1] join player;

[H2] join player;

[H3] join player;

H1 addAction ["Wait","waitH1.sqf"];

H2 addAction ["Wait","waitH2.sqf"];

H3 addAction ["Wait","waitH3.sqf"];

And this the "Wait" script which disables the AI's movement and let it leave the player's group.

H1 disableAI "MOVE";

H2 disableAI "MOVE";

H3 disableAI "MOVE";

_talker = _this select 0;

_bother = _this select 1;

_action = _this select 2;

_talker removeAction _action;

_talker globalChat format["Are you sure?", name _bother];

[H1] joinSilent grpNull;

[H2] joinSilent grpNull;

[H3] joinSilent grpNull;

H2 removeAction _action;

H3 removeAction _action;

H1 addAction ["Follow","followH1.sqf"];

H2 addAction ["Follow","followH2.sqf"];

H3 addAction ["Follow","followH3.sqf"];

But what I want to achieve is, that any enemy unit can "catch" the hostages so they are member of that group.

I already tried to remove the "_talker removeAction _action;" line so its alway possible to let the hostages follow. Unfortunately this doesnt work as well as when the hostages leave the friendly group.

Shortly, I want all the BLUFOR and OPFOR and RESISTANCE to have the option to let the hostages follow their group at anytime.

Have you got ideas?

Would be great if this would be possible in multiplayer as well.

Edited by _qoR

Share this post


Link to post
Share on other sites

Okay, let's get it done :D

Put this into the init-field of the hostages:

this setCaptive 1;
null = this addAction ["Follow me!", "hostageFollow.sqf", true, 6, true, true, "", "_target distance _this <= 2 && captiveNum _target == 1"];
null = this addAction ["Wait here!", "hostageFollow.sqf", false, 6, true, true, "", "_target distance _this <= 2 && captiveNum _target == 2"];

Create a script named "hostageFollow.sqf" and put this code into it:

_hostage	= _this select 0;
_caller		= _this select 1;
_following	= _this select 3;
_allHostages= [H1, H2, H3];

if (_following) then
{
{
	_x enableAI 	"MOVE";
	_x switchMove 	"AidlPpneMstpSnonWnonDnon_SleepA_standUp";
	_x setCaptive	2;
} forEach _allHostages;

_hostage 		globalChat 	"Bring me out'a here";
_allHostages 	join 		(group player);
}
else
{
{
	_x disableAI 	"MOVE";
	_x setCaptive	1;
} forEach _allHostages;
_hostage 		globalChat 	"Are you sure?";
_allHostages	joinSilent	grpNull;
};

Please note that you don't revert the animation back when you want them to wait: if they're following you again, they will be lying down and standing up from the ground, which looks somehow weird because they were standing right before that xD

Either use the original animation with playMove and let them lay down upon leaving the group or use a global variable and isNil to play the animation just one time.

Furthormore this will be MP compatible but for the switchMove part - you have to use either RE, setVehicleInit or other means of broadcasting this command to all connected clients.

/edit:

ooooh, full stop! I'm just realizing that this won't work as wanted - every other guy could go to your hostages and could command them to wait/follow independant of their current status and rescuing side.

You have to assign them a "rescuer" so others can't "steal" them from you, or was this intended?

/edit²:

Okay, after giving this another thought I think I can't support you with a working script until I know what exactly you want to have in your mission, I mean there are a couple of scenarios here that you have to cope with, so delivering you just some random code won't help ya at all.

Edited by XxAnimusxX

Share this post


Link to post
Share on other sites

Yah right,

I want the BLUFOR to get the hostages to a rescue point and the OPFOR to avoid that.

So the OPFOR needs to have the possibility to "steel" the hostages back. Besides OPFOR should have the possibility to hide the hostages previously.

But apparently it doesnt work that the hostages leave a group via join grpNull. I tried with a BLUFOR and another playable OPFOR unit.

Unfortunately, being an OPFOR unit I couldnt "use" the hostages although they has left the BLUFOR group before via grpNull.

Really dont know why, got some ideas but they turned out as wrong.

And is still questioning myself how this is possible in multiplayer when there is more than one "player"...

Edited by _qoR

Share this post


Link to post
Share on other sites

Okay, if there are several players who can get the hostages, we have to assign some "owner" or "rescuer" to the hostages so other players can't get them without using the appropriate means.

So we need a public variable which holds the current "owner", we'll define it in the init.sqf:

if (isNil "hostagesOwner") then
{
   hostagesOwner = objNull;
};

This goes into the init-field of your hostages:

this setCaptive 1;
null = this addAction ["Follow me!", "hostageFollow.sqf", true, 6, true, true, "", "_target distance _this <= 2 && hostagesOwner != _this && group _target != group _this"];
null = this addAction ["Wait here!", "hostageFollow.sqf", false, 6, true, true, "", "_target distance _this <= 2 && hostagesOwner == _this"];

And this code goes into hostageFollow.sqf:

_hostage    = _this select 0;
_caller     = _this select 1;
_following  = _this select 3;
_allHostages= [H1, H2, H3];

_allHostages    joinSilent    grpNull;
if (_following) then
{
   {
       _x enableAI     "MOVE";
   } forEach _allHostages;

hostagesOwner = _caller;

   _hostage         globalChat   "Bring me out'a here";
   _allHostages     join         (group _caller);
}
else
{
   {
       _x disableAI     "MOVE";
   } forEach _allHostages;

hostagesOwner = objNull;

   _hostage        globalChat    "Are you sure?";
};  
publicVariable "hostagesOwner";

Every side can get to the hostages and let them follow you if:

  • You are not the owner of the hostages, and
  • You are not in the same group as the hostages

This prevents that every other player in your group can steal your hostages away from you, but lets everyone else from other groups do it.

Once you order them to wait, they'll leave your group and will be open to be ordered from anyone else.

I didn't test this out but I'm pretty sure that this is somewhat MP compatible.

Edited by XxAnimusxX

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×