Jump to content
Sign in to follow this  
Militant1006

Civilian vehicle setCaptive

Recommended Posts

Ok, I searched and did not find what I was looking for, I am making a mission where I have Spec Ops going around a town to look for a HVT at certain areas, now they are dressed as regular spec ops, but they are using a SUV, I was wondering if there is a way to make them setCaptive true when in a vehicle and when out and on foot they are setCaptive false, and it needs to be repeatable so they can get out and in and have it still work.

Share this post


Link to post
Share on other sites

Tested. It will run till there are no more units in the group.

Put this in the group leaders init.....

nul = [this] execVM "myscript.sqf";

And the script...

myscript.sqf

private ["_ldr","_i","_unit"];

_ldr = _this select 0;

while {count (units group _ldr) >=1} do {

for [{_i=0},{_i<count (units group _ldr)},{_i=_i+1}] do {
	_unit = (units group _ldr) select _i;
	if (vehicle _unit == _unit) then {
		if (captive  _unit) then {_unit setcaptive false};
	} else {
		if (! captive  _unit) then {_unit setcaptive true};
	};
	sleep 0.01;
};
sleep 1;
};

Edited by twirly
Script had an error...now tested and works!

Share this post


Link to post
Share on other sites

Im using this script in a mission, I drive all over the map undetected! Works great.. I'd like to request a modification to it please :) could some randomness be added to it, for example a 15% chance it doesn't work.

Actually as I write this I realize what I'm wanting may not be doable? What I was wanting is randomness of only some enemy units might detect me? The effect I want is I can drive around safe until maybe one enemy decides I'm not civilian.

And/or

If I get out and engage enemy units and hop back in I'm instantly setcaptive again, can it be made that it's not instant until your not known by enemy or something similar to that effect?

Edited by Katipo66

Share this post


Link to post
Share on other sites

Hey man.... I added the randomness part and it should work. I did a quick test and it seemed too. Give it a spin and see what you think.

I'll have a think about the not being detectable right away as you get into the car after being detected. I see that could be a problem.

private ["_ldr","_i","_unit","_rndwait"];

_ldr = _this select 0;

while {count (units group _ldr) >=1} do {

[color="Red"]	if (random 100 < 15) then {
	_rndwait = 60 + random 60;
	hint format ["Detectable for %1 seconds",_rndwait];
} else {
	_rndwait = 1;
               hint "Un-detectable";
};
[/color]
for "_i" from 0 to (count (units group _ldr))-1 do {
	_unit = (units group _ldr) select _i;
	if (vehicle _unit == _unit) then {
		if (captive  _unit) then {_unit setcaptive false};
	} else {
		if (! captive  _unit [color="Red"]&& _rndwait == 1[/color]) then {_unit setcaptive true};
	};
	sleep 0.01;
};
sleep [color="Red"]_rndwait[/color];
};

Share this post


Link to post
Share on other sites

Awesome Twirly!

Ill test it tonight and give feedback...

Edit*

Hey Twirly,

Been testing this for a good hour now... im not sure if its working but then im not sure if i understand how the script works.... is it when its in Detectable status the enemy will definitely know about me, or is it they will have a chance to know about me.

I tested in normal time and found if i was spotted within the first cycle they will open fire, if im at a distance and wait until the 2nd cycle and move in they will not open fire, thats after about 10 cycles in normal time, and 20 odd in X4 fast time.

Also i found i could get out and kill a few and ill still be captive until the next detectable cycle came up then they would open fire

Edited by Katipo66

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  

×