Jump to content

Recommended Posts

IT'S WORKING!

_Unit = [U1, U2, U3, U4, U5, U6, U7, U8];
_Helo = [H1, H2];
_a = 0;

while {_a < 8} do
	{
		_u = _Unit select _a;
		_h = _Helo call BIS_fnc_selectRandom;
		_u assignAsCargo _h;
		[_u] orderGetIn true;
		_a = _a + 1;
		uiSleep 1;
	};

After a lot of time trying different things, and theories and looking for arrays, variables etc.. I made it. xD

The only problem now, is that sometimes, there is one helicopter with 7 people inside, and the other with 5 and I'm using MH-9 so there is sometimes a guy left without any helicopter.

I'm going to try fixing this by limiting each helicopter "calls" in the script by 6.

Share this post


Link to post
Share on other sites
private ["_unit","_alive","_helo","_heloIndex"];

_unit = [];
{_unit pushBack _x} forEach units _grpName; //Replace _grpName with the name of your group being evac'ed.
_alive = (count _unit) - 1;

_helo = [H1,H2];
_heloIndex = 0;

for "_i" from 0 to _alive do {
	(_unit select _i) assignAsCargo (_helo select _heloIndex);
		if (_heloIndex == 0) then {
		_heloIndex = 1;
		} else {
		_heloIndex = 0;
	};
};

_unit orderGetIn true;

When this runs it will assign all the units in the group to either helo and order them to get in. The _heloIndex is there to alternate between the two helos. I haven't ever tried to split  group up between to helos like this before so there may be (probably is) a better way of doing it, but this will work. The for loop will increment _i each time it loops, beginning with 0.

  • Like 1

Share this post


Link to post
Share on other sites

Perhaps you could make use of https://community.bistudio.com/wiki/emptyPositions  

maybe make an array of the empty places and when a unit is assigned a seat remove that position from the index.

I understand what do you mean, but don't really know how to use this.

But i'll be trying, thanks.

 

private ["_unit","_alive","_helo","_heloIndex"];

_unit = [];
{_unit pushBack _x} forEach units _grpName; //Replace _grpName with the name of your group being evac'ed.
_alive = (count _unit) - 1;

_helo = [H1,H2];


for "_i" from 0 to _alive do {
	(_unit select _i) assignAsCargo (_helo select _heloIndex);
		if (_heloIndex == 0) then {
		_heloIndex = 1;
		} else {
		_heloIndex = 0;
	};
};

_unit orderGetIn true;

When this runs it will assign all the units in the group to either helo and order them to get in. The _heloIndex is there to alternate between the two helos. I haven't ever tried to split  group up between to helos like this before so there may be (probably is) a better way of doing it, but this will work. The for loop will increment _i each time it loops, beginning with 0.

 

Daamn that's some script. I understood almost everything, but the 12 units that have to get in the helicopter have no group, they are single units... but I think I can use the script without the 2 first lines, and instead of this, _unit = [u1 ,..... U12]

So, at the end it's something like this= 

private ["_unit","_alive","_helo","_heloIndex"];

_unit = [U1, U2, U3, U4, U5, U6, U7, U8, U9, U10, U11, U12];
_alive = (count _unit) - 1;

_helo = [H1,H2];
_heloIndex = 0;


for "_i" from 0 to _alive do {
	(_unit select _i) assignAsCargo (_helo select _heloIndex);
		if (_heloIndex == 0) then {
		_heloIndex = 1;
		} else {
		_heloIndex = 0;
	};
};

_unit orderGetIn true;

And it's working damn well, thanks a lot.

What is the private first line?

  • Like 1

Share this post


Link to post
Share on other sites

Yes I was over complicating it.

It could be made a little shorter by using _i as the index

private ["_unit","_alive","_helo"];

_unit = [U1, U2, U3, U4, U5, U6, U7, U8, U9, U10, U11, U12];
_alive = (count _unit) - 1;
_helo = [H1,H2];

for "_i" from 0 to _alive do {
    (_unit select _i) assignAsCargo (_helo select _i % 2);
};
_unit orderGetIn true;
  • Like 2

Share this post


Link to post
Share on other sites

the 12 units that have to get in the helicopter have no group, they are single units... but I think I can use the script without the 2 first lines

 

Ok, yeah I was working with them all as one group, sorry about that. Glad I could help, and I like how f2k sel has simplified it too.

 

What is the private first line?

 

https://community.bistudio.com/wiki/private - There's all the info, check the notes down the bottom for more info.

 

_helo = [H1,H2];

for "_i" from 0 to _alive do {
    (_unit select _i) assignAsCargo (_helo select _i % 2);
};

 

f2k sel, what exactly is going on here? I played around with this a bit and it seems like what it does is to loop through an array by the amount after the %. So what I mean is, if I had an array with 10 elements and used select _i % 5, a loop would cycle through to the 5th element and start again (obviously while the loop's condition is true)? So in erwin's case they'll board H1, then H2, then H1 and so on?

  • Like 1

Share this post


Link to post
Share on other sites

It's called Modulo I won't attempt to describe it too much myself as I only have a slight grasp and don't want to give wrong info.

I just saw it being used yesterday and was wanting to test it out as it looks neater.

 

 Imagine if you wanted  sometimes to have three choppers instead of two you would increase the number %2 to 3% or better still using count

(_unit select _i) assignAsCargo  (_helo select _i  % (count helo));// may work not tested

 

if it were %3

_i           0 1 2 3 4 5 ect

% 3       0 1 2  0 1 2 ect when it reach three it modifies the result back to 0 and allow the count to proceed until it equals two

 

I also have used it for quite a while without taking the trouble to look at it.

 

In a trigger set repeating

cond   round (time %1) ==1

 

forces the trigger to repeat every second, I use this quite a lot when I want to read a changing value with hint in on act

cond   round (time %1) ==5// would update every 5 seconds

  • Like 2

Share this post


Link to post
Share on other sites

I just saw it being used yesterday and was wanting to test it out as it looks neater.

 

Definitely neater. What you described is what I was messing around with and getting those results. Very useful though, thanks for the input mate.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks a lot for all the help, this is very useful.

 

Is there a way to change this condition?

((!alive U1) OR (U1 in H1) 
AND ((!alive U2) OR (U2 in H1)) 
AND ((!alive U3) OR (U3 in H1)) 
AND ((!alive U4) OR (U4 in H2)) 
AND ((!alive U5) OR (U5 in H2)) 
AND ((!alive U6) OR (U6 in H2)) 
AND ((!alive U7) OR (U7 in H2)) 
AND ((!alive U8) OR (U8 in H1)) 
AND ((!alive U9) OR (U9 in H2)) 
AND ((!alive U10) OR (U10 in H1)) 
AND ((!alive U11) OR (U11 in H1)) 
AND ((!alive U12) OR (U12 in H2));

I'm trying to activate a trigger through a script, I know I can use a variable, put myvariable = 0 in init.sqf, but after this I don't know how to activate it through a script. The condition's trigger would be: myvariable == 1;

Share this post


Link to post
Share on other sites

Instead of cluttering the forum with another post, I want to ask something related :).

_pos1 = getMarkerPos "Land_Airbase";
_grp = group gunpilot;
_wp = _grp addWaypoint [_pos1, 0];
[_grp, 0] setWaypointType "GETOUT";

Why doesn't the helicopter land on this marker? It turns in that direction and just hovers, but doesn't land..

It DOES lands there when I give it a regular "get out" waypoint in the exact same spot as the marker, in the editor, at the same time.. Please help.

I think that, [_grp,0] setwaypoint... Indicates the default waypoint created at the spawn of the unit.

https://community.bistudio.com/wiki/setCurrentWaypoint has a note to that effect in its comments. This differs from how the editor assigns waypoint indices for display. If it's the first waypoint you add with commands it is [_grp, 1] setWaypoint.. Etc. Hope that helps.

Slightly odd, talks to pixels

Share this post


Link to post
Share on other sites

I haven tested this as I'm not at my PC right now but this may work. When all uits are in the vehicle the trigger activates, I'm not sure if that's what your asking.

{_x in H1 or _x in H2} count [U1,U2,U3,U4,U5,U6,U7,U8,U9,U10,U11,U12] == {alive _x} count [U1,U2,U3,U4,U5,U6,U7,U8,U9,U10,U11,U12]

I would however create an array in game init first

myunits = [U1,U2,U3,U4,U5,U6,U7,U8,U9,U10,U11,12];

then you can just use that array instead of making a new array every time, it also  makes editing it much easier as you only need to change it in the original array.

{_x in H1 or _x in H2} count myunits == {alive _x} count myunits;

Its better to use true false for the condition rather  than 0/1 which will work but it's not usual and can get confusing.

 

then cond for true would be

myvariable

and flase

!myvariable

 

 

and you change

myvariable = true;

or

myvariable = false 

  • Like 2

Share this post


Link to post
Share on other sites

Its better to use true false for the condition rather  than 0/1 which will work but it's not usual and can get confusing.

 

Been there, done that, and he's right!

Share this post


Link to post
Share on other sites

Thanks, I'm doing some work now, but when I end I'll check that. But what I want is to check if the units are dead or in the helicopters, so if there are 3 in the helicopters and 9 dead guys then, the mission is completed.

But I think just changing alive for !alive is ok.

 

But how I change the variable only when the guys are dead or in the helicopter? before that, I had a trigger with the next condition:

((!alive U1) OR (U1 in H1) 
AND ((!alive U2) OR (U2 in H1)) 
AND ((!alive U3) OR (U3 in H1)) 
AND ((!alive U4) OR (U4 in H2)) 
AND ((!alive U5) OR (U5 in H2)) 
AND ((!alive U6) OR (U6 in H2)) 
AND ((!alive U7) OR (U7 in H2)) 
AND ((!alive U8) OR (U8 in H1)) 
AND ((!alive U9) OR (U9 in H2)) 
AND ((!alive U10) OR (U10 in H1)) 
AND ((!alive U11) OR (U11 in H1)) 
AND ((!alive U12) OR (U12 in H2));

And when that triggers activates, the mission is accomplished.

Share this post


Link to post
Share on other sites

Well it should work as is as it counts the remaining alive units and when they are in the condition is true.

 

you would use another trigger to check for failed mission   {alive _x} count myunits == 0

Share this post


Link to post
Share on other sites

Thanks, I'm going to try this right now.

Share this post


Link to post
Share on other sites

But I think that "command" is not what I'm trying to achieve, that command count the units in both helicopters and the dead/alive ones, and what I want is: e.g. in an extraction, 2 of the 12 guys are dead, so 10 board both helicopters and 2 are dead, but the mission is completed.

so... is "In H1 or H2, OR !alive".

Share this post


Link to post
Share on other sites

I guess were trying to do something different , last stab otherwise I'm lost.

 

{_x in H1 or _x in H2} count myunits == {alive _x} count myunits and {!alive _x} count myunits > 2

 

can't test not at PC.

Share this post


Link to post
Share on other sites

Yes I was over complicating it.

It could be made a little shorter by using _i as the index

private ["_unit","_alive","_helo"];

_unit = [U1, U2, U3, U4, U5, U6, U7, U8, U9, U10, U11, U12];
_alive = (count _unit) - 1;
_helo = [H1,H2];

for "_i" from 0 to _alive do {
    (_unit select _i) assignAsCargo (_helo select _i % 2);
};

_unit orderGetIn true;

Let's try this, make a small edit to f2k sel's suggestion above so that it now reads:

private ["_unit","_alive","_helo"];

_unit = [];

{
	if (alive _x) then {
		_unit pushBack _x;
	};
} forEach [U1, U2, U3, U4, U5, U6, U7, U8, U9, U10, U11, U12];
_alive = (count _unit) - 1;
_helo = [H1,H2];

for "_i" from 0 to _alive do {
    (_unit select _i) assignAsCargo (_helo select _i % 2);
};

_unit orderGetIn true;

waitUntil {({_x in H1 or _x in H2} count _units) == count _units};
//endMission?

This will add any of those units only if they're alive, and so they'll be the only ones to enter the helos. Then it'll wait until they're all in the helo before moving onto the next part of the script, which I assume is where it'll end. How does that sound f2k sel?

Share this post


Link to post
Share on other sites

Hello again, thanks for being these days absent but I've been very busy learning Blender and left Arma some days. lol

Well, I tried all these scripts, but any of them is what I was asking for, sorry, maybe I didn't explained well :(

At the end I just used this(in a trigger condition):

((!alive U1) OR (U1 in H1) OR (U1 in H2))   
AND ((!alive U2) OR (U2 in H1) OR (U2 in H2))   
AND ((!alive U3) OR (U3 in H1) OR (U3 in H2))   
AND ((!alive U4) OR (U4 in H2) OR (U4 in H1))   
AND ((!alive U5) OR (U5 in H2) OR (U5 in H1))   
AND ((!alive U6) OR (U6 in H2) OR (U6 in H1))   
AND ((!alive U7) OR (U7 in H2) OR (U7 in H1))   
AND ((!alive U8) OR (U8 in H1) OR (U8 in H2))   
AND ((!alive U9) OR (U9 in H2) OR (U9 in H1))   
AND ((!alive U10) OR (U10 in H1) OR (U10 in H2))   
AND ((!alive U11) OR (U11 in H1) OR (U11 in H2))   
AND ((!alive U12) OR (U12 in H2) OR (U12 in H1));

And this is working fine, but it's "noob" scripting kind, but it's working :lol:

Share this post


Link to post
Share on other sites

Ok I'll bite

{(!alive _x) OR (_x in H1) OR (_x in H2)} count [U1, U2, U3, U4, U5, U6, U7, U8, U9, U10, U11,U12] == 12
  • Like 1

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

×