Jump to content
Sign in to follow this  
fleepee

take civilian hostages

Recommended Posts

HI script masters!

;)

I'm making a mission in which you play on the takistany OPFOR forces and you have to take civilian hostages in Rasman.

Everything works fine in the editor and hosting the game, but not on dedicated servers, of course!

The amount of hostages is set in the MP lobby, in a variable called NB_hostages.

In a (repeating) trigger condition field, I have:

(cursorTarget getVariable ["NORRN_unconscious",false])) and (alive cursorTarget) and (player distance cursorTarget <40) and (vehicle player== player) and (player knowsAbout cursortarget>3) 

In its activation field:

 New_threaten= true; publicVariable "New_threaten"; threaten_hostage = cursorTarget; publicVariable "threaten_hostage"; player sidechat (no_move select floor(random 4));  

another trigger with condition "New_threaten" has for activation field:

nul = [threaten_hostage] execVM "threaten_civ.sqf"; 

Here's the threaten_civ.sqf code:

//////////////////////////////////////////////////////////////////
// Function file for Armed Assault
// Created by: FleePee
//////////////////////////////////////////////////////////////////
_hostage = _this select 0;

sleep 0.05;
threaten_hostage= nil;
publicVariable "threaten_hostage";
New_threaten= false;
publicVariable "New_threaten";

_killed = _hostage addMPEventHandler ["mpkilled", {Null = _this execVM "hostage_killed.sqf";}];

if ((typeof _hostage == "TK_CIV_Woman01_EP1") or (typeof _hostage == "TK_CIV_Woman02_EP1") or (typeof _hostage == "TK_CIV_Woman03_EP1")) exitWith {
hint localize "STR_no_woman";
_hostage setVariable ["threaten", true, true]; 
};

if (_hostage distance camion1 >500) exitWith { hint localize "str_truck_too_far";};

_hostage setVariable ["threaten", true, true]; 

if (not (_hostage in list civ_rasman)) exitWith {
_hostage playmove "AmovPercMstpSsurWnonDnon";
sleep 3;
_list= (position _hostage) nearEntities [["soldierEB"],40];
_unit= _list select 0;
_hostage globalChat Localize "STR_not_from_rasman";
_hostage playMove "AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon";
sleep 3;
_unit sidechat localize "STR_not_from_rasman2";
};

_hostage playmovenow "AmovPercMstpSsurWnonDnon";
_hostage disableAI "ANIM"; 

capturer = _hostage addAction [("<t color=""#1A8DEB"">" + (localize "STR_Capture") + "</t>"), "capture_init.sqf"];

while {(alive _hostage) and (not (_hostage in assignedCargo camion1))} do {

_list= (position _hostage) nearEntities [["soldierEB"],40];

if (count _list ==0) exitWith {
	_hostage setVariable ["threaten", false, true];
	_hostage removeAction capturer;
	_hostage enableAI "ANIM";
	_hostage setbehaviour "careless";
	_hostage playMovenow "AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon"; 
	};

sleep 5;
};

In the first part, if the civilian unit is not in the trigger including Rasman, you can't take him hostage.

In the end of that script, if there is no OPFOR in a 40m perimeter around the threaten civilian, he's free again.

here's the capture_init.sqf:

_hostage = _this select 0;
_unit = _this select 1;

New_captured = true;
publicVariable "New_captured";
captured_hostage = _this select 0;
publicVariable "captured_hostage";

//hint format ["otage: %1", captured_hostage];
sleep 0.5;
_unit sidechat (board select floor(random 4));
_hostage removeAction capturer;

if (true) exitWith {};

I added a capture trigger with condition field: "New_captured"

and on its activation field:

nul = [captured_hostage] execVM "capture.sqf"; captured_hostage = nil; publicVariable "captured_hostage"; New_captured = false; publicVariable "New_captured";  

Here's the capture.sqf script:

//////////////////////////////////////////////////////////////////
// Function file for Armed Assault
// Created by: FleePee
//////////////////////////////////////////////////////////////////

_hostage = _this select 0;
_hour = daytime;


_hostage setVariable ["captured", true, true];
_hostage enableAI "ANIM";
_hostage setbehaviour "careless";
_hostage assignAsCargo camion1; 
[_hostage] orderGetIn true;

waitUntil {(vehicle _hostage == camion1) or (not alive _hostage) or (camion1 emptyPositions "cargo" ==0) or (daytime > _hour + (1/12))};

if (not alive _hostage) exitWith {};

/////////////////////////
//Added to force hostages to be in the truck
/////////////////////////
if ((daytime > _hour + (1/12)) and (camion1 emptyPositions "cargo" !=0) and (vehicle _hostage==_hostage)) then {
_hostage moveinCargo camion1;
_hostage disableAI "MOVE";
_hostage disableAI "ANIM";
};
////////////////////////

if (camion1 emptyPositions "cargo" ==0) exitWith {
hint_cargo=true;
publicVariable "hint_cargo";
while {(_hostage getvariable ["threaten", true]) and (_hostage getvariable ["captured", true])} do {
	_list= (position _hostage) nearEntities [["soldierEB"],40];
	if (count _list ==0) then {
		_hostage setVariable ["threaten", false, true];
		_hostage setVariable ["captured", false, true];
		unassignvehicle _hostage;
		_hostage enableAI "ANIM";
		_hostage setbehaviour "careless";
		};
	sleep 5;
	};
};

WaitUntil {vehicle _hostage == camion1};

_hostage disableAI "MOVE";
_hostage disableAI "ANIM";

if (not (_hostage in list_hostages)) then {
list_hostages = list_hostages +[_hostage];
publicVariable "list_hostages";
};

list_hostages_aboard = crew camion1;
publicVariable "list_hostages_aboard";

sleep 0.1;

hint format ["count list A bord: %1:\nlist: %2\ncount crew: %3", count list_hostages_aboard, list_hostages_aboard, count crew camion1];

//hint_hostage=true;
//publicVariable "hint_hostage";

if (count list_hostages >= NB_hostages) then {
NB_hostages_reached=true;
publicVariable "NB_hostages_reached";
};

if (true) exitWith {};

As there are only 13 cargo spaces in the truck, when it's full of hostages, you have to go back to the camp to unload the truck before going again to Rasman and take some more hostages if NB_hostages>13.

The truck is synced with a trigger at the camp, when the truck enters it, another script make hostages disembark and set them to a position from which they won't move:

//////////////////////////////////////////////////////////////////
// Function file for Armed Assault
// Created by: FleePee
//////////////////////////////////////////////////////////////////
list_hostages_aboard = list_hostages_aboard - [driver camion1];
camion1 engineOn false;

{unassignVehicle _x} forEach list_hostages_aboard;

{_x action ["eject", camion1]; sleep 0.2} foreach list_hostages_aboard; 

{_pos= [(getpos flag_priso select 0) - 10+(random 20), (getpos flag_priso select 1) - 10+(random 20)];
_dir= floor (random 360);

if (side _x != east) then {
_x disableAI "MOVE";
sleep 0.1;
_x setpos _pos;
_x setdir _dir;
_x setCaptive true; 
_x playMove "AmovPercMstpSsurWnonDnon"; 
_x disableAI "ANIM";
list_hostages_aboard = list_hostages_aboard - [_x];
};

} foreach list_hostages_aboard;

publicVariable "list_hostages_aboard";

1 setRadioMsg "NULL";

if (true) exitWith {}; 

Here's the problem: some of hostage in truck don't disembark, and if I go back to Rasman to take some more civilian hostages, I can monitor that these embarked hostages are just P3Ds instead of AI hostages, perhaps because they are spanwned with the ALICE module?

:confused:

I hope you'll find it interesting to solve.

Thanks in advance for your time and answers.

:D

FleePee

P.S: I can send the mission folder if needed...

Edited by fleepee
I edited the capture script...

Share this post


Link to post
Share on other sites

i can point something for starters. When you use moveincargo you should before use assignascargo.

Share this post


Link to post
Share on other sites
i can point something for starters. When you use moveincargo you should before use assignascargo.

You'll find it 7 lines above in the script...

Share this post


Link to post
Share on other sites

Ok sorry. But next time also use code to post a script. Spoiler is not really suitable.

Share this post


Link to post
Share on other sites

I modified my first post.

As the code is a bit long, I thought the post was more readable with code in a spoiler...

Share this post


Link to post
Share on other sites

I forgot to mention that animations on civilians don't work too on a dedicated server.

Most of the civilians are spawned with the ambiant civilian module, a few are placed in the editor, to have some appearing in the intro.

Share this post


Link to post
Share on other sites

I think I found one more idea about this...

AIs are local to the server but the scripts are launched on a client machine, so...

But I didn't have time yet to edit the mission and scripts.

Has someone thought about it?

I'll be glad to have any piece of advice...

Edited by fleepee

Share this post


Link to post
Share on other sites
if you want something doing, do it yourself!

Thanks to FleePee, it's not great scripting, but it's working great!

Anybody cares?

(code of first post not updated)

Edited by fleepee

Share this post


Link to post
Share on other sites

I'd have the hostages moved to the player's group. I believe that should then make them local to the player, able to run animations for the player and you're able to order them into a vehicle rather than rely on scripts to do so.

Share this post


Link to post
Share on other sites
I'd have the hostages moved to the player's group. I believe that should then make them local to the player, able to run animations for the player and you're able to order them into a vehicle rather than rely on scripts to do so.

I know it is the simpliest way, but I didn't want to care about them and give them orders, as you can have 20 or more hostages in your team whilst being in a big urban fight...

The method I'm using is almost perfect now...

---------- Post added at 03:42 PM ---------- Previous post was at 02:29 PM ----------

One thing I don't understand is how I can have P3Ds counted in the crew of the truck?!!

Edited by fleepee

Share this post


Link to post
Share on other sites

Perhaps just "rescue" them then increase a counter and forget about exactly where the physical model is? Just capture the hostage, tell the player they are in the vehicle, increase some variable counting them on the truck, then once that number is at 13 or whatever tell the player they can drive the truck to safety or whatever. Just don't bother with actually keeping track of bodies and who's in what truck.

On paper it's a nice idea, but it will break in game and it's apparently turning into a problem to even get to that point, so keep it simple and streamlined and worry more about gameplay then details perhaps?

Share this post


Link to post
Share on other sites

I captured 13 hostages, went to the camp to unload the truck, but some didn't disembark.

I went back to Rasman, captured some more hostages, and here is what I get:

pk3_er10.jpg

This hint is inserted for testing in the capture.sqf script to monitor who is aboard:

list_hostages_aboard = crew camion1;
publicVariable "list_hostages_aboard";

sleep 0.1;

hint format ["count list A bord: %1:\nlist: %2\ncount crew: %3", count list_hostages_aboard, list_hostages_aboard, count crew camion1];

What's happening?!!

---------- Post added at 04:40 PM ---------- Previous post was at 04:33 PM ----------

Thanks for your response.

I posted and read your message afterwards.

keep it simple and streamlined and worry more about gameplay then details perhaps?

Yes, sure...

Everything else in the mission is working allright (secondary tasks), but as this is the main task, i'm doing my best to have it working.

Perhaps the problem comes from civilians being spawned by the ALICE module?

---------- Post added at 05:13 PM ---------- Previous post was at 04:40 PM ----------

I updated codes of the first post...

---------- Post added at 06:33 PM ---------- Previous post was at 05:13 PM ----------

Perhaps the problem comes from civilians being spawned by the ALICE module?

The answer is : YES!!!

Everything is allright with editor placed civilians, so I've suppressed the ALICE module...:(

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  

×