Jump to content
Sign in to follow this  
JacobJ

How to make units inside vehicles captive?

Recommended Posts

Hey all

I have thought of making a feature for my mission where units inside a car is set to captive, so that they can drive through enemy territory wihtou getting shot at. If they then get out of the vehicle and the enemy knowsabout those units, then they can't just jump into the vehicle again and then they are captive again. Its a one-time opportunity, if they areant knownabout.

But how its done I don't know.. I have thought of triggers and a while function that checks all the time if and who is inside the vehicle, but that seems a bit to overkill or what would you suggest?

/Jacob

Share this post


Link to post
Share on other sites

this should do it, place code in init of vehicle:

this addEventHandler ["GetIn", {
_unit = _this select 2;
if ( ({alive _x AND side _x == east AND _x knowsabout _unit > 1} count allUnits) == 0 ) then {
	_unit setCaptive true;
};
}];
this addEventHandler ["GetOut", {
(_this select 2) setCaptive false;
}];

Explanation: adds eventhandler for units getting in and out of vehicle.

on getting in: if noone from east side wich is alive knowsabout the unit value is higher than 1, then unit is set captive upon entering vehicle.

on getting out: unit is set to no longer be captive, wich in turn works with the getin part.

Share this post


Link to post
Share on other sites

Okay cool, looks like this is a much more cleaver solution, than the one I have thought of. Can you explain why the unit is _this select 2? What is _this select 0 and _this select 1? But thank you very much for your help, I will try this out when I get home.

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  

×