Jump to content
Sign in to follow this  
Clifford

Checking for whole group in vehicle

Recommended Posts

I´ve got a group of four BAS rangers extracting with the BAS Blackhawks built-in extraction-script. (radio 001 and the chopper comes flying, no WP´s or scripts needed)

Now I want the mission to end when everyone alive is aboard that chopper, not just the group leader. I´ve tried different approaches, often involving the "foreach"-command, but I just can´t get it to work.

How do I make it end when the WHOLE group is aboard the chopper, not just one guy?

I can´t name the guys a,b,c,d and then check if they´re in the chopper, because if one of them is dead, he can´t board, and the mission won´t end.

What should I do?

Share this post


Link to post
Share on other sites

"_x in chopper1" foreach (units groupname)

Syntax not guaranteed.

Share this post


Link to post
Share on other sites

"vehicle _x == vehicle_name" count (units groupname) == xSide countSide (units groupname)

vehicle_name stands for the name of the vehicle biggrin_o.gif

and xSide stands for the side the group is from (west/east/guer)

The side countside thingy is needed for the case that

there are some dead guys in the group, not yet noticed

by the commander (usually done by right-clicking the

dead body, or by looking at him)

~S~ CD

Share this post


Link to post
Share on other sites

actually this has been used quite a lot, have a go...

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">@{_x in blackHawk||!(alive _x)}count _units == count _units

_units you can assign through _units = units groupwhatever;

Share this post


Link to post
Share on other sites

What about?

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">Count ((units Group_Name)-(Crew Vehicle_Name))==0

Share this post


Link to post
Share on other sites

m21man: Tried dozens of variations on that, seems it won´t accept it as a condition in the trigger.

SgtWilson: Good one, had to change it slightly, since the pilots aren´t part of the group, therefore it should equal -2 rather than 0.

Only problem is if one of the pilots are dead, then the mission won´t end.

Haven´t tried the other two yet, will do now.

Share this post


Link to post
Share on other sites

It only deletes the units from the group array, that it finds in the crew array. So it will ignore any pilots and additional groups.

Plus you cant have an array that returns a negative count.

Share this post


Link to post
Share on other sites

Ahh. thanks a lot. Stuff you can´t find in your average tutaorial, I´m afraid.

Share this post


Link to post
Share on other sites

Well, Sgt. Wilsons way works, if you know exactly

what you are checking for, when you are doing it, and

what you need it for.

This means: count (units groupname) - (crew vehiclename)

must be done exactly at the time, when the group has

to enter the vehicle.

However, you have already figured out by yourself, that

it's easy to break thru that count by a dead pilot.

m21man's way and what you've tried dozens of times

cannot work and will never work, as forEach can't be used

that way as a CONDITION.

You could use forEach in a condition, if you do it by and

IF THEN statement.

e.g: "if (_x in vehicle == count units _x) then {blabla}" forEach units groupname

But as an ordinary condition you would have to go for either

mine or BN880's method.

The difference between BN880's and mine is:

mine: condition can only become met, as long as at least

1 member of the group to board is alive

BN880: condition will also become met, in case the whole

group has been eliminated. In some cases this one may

become senseless, as there is no group to be transported

anymore. Especially when it belongs to the player's group,

this one could disturb another condition, where you are checking for "all got killed in that group" wink_o.gif

~S~ CD

Share this post


Link to post
Share on other sites

I still stand by my solution smile_o.gif  The only way a dead unit might come into play would be if a unit was killed as it boards the helicopter, a slight delay in reporting the death would mean you might call the condition a couple of extra times in the loop.

((units Group_Name)-(Crew Vehicle_Name))

Is the same as:

[Man1,Man2,Man3]-[Pilot,#Dead Gunner,Man1,Man2,Man3]=[]

Of course if all the boarding group are dead (empty array) it might return true, but I think it would just bomb out as a dead group returns null. But then I assumed you would not try to get a dead group to board a helicopter.

Or am I missing something?

Share this post


Link to post
Share on other sites

Sgt. Wilson:

Would that last example line produce a zero, then?

And another problem I´m facing here is whether the hostage counts or not. Is it added to the group when it joins them?

Still haven´t tried every solution, I want it done right, so I´m playing through the mission several times to check for bugs.

Probably played it through over a hundred times already, for various reasons ;)

Share this post


Link to post
Share on other sites
The difference between BN880's and mine is:

mine: condition can only become met, as long as at least

1 member of the group to board is alive

BN880: condition will also become met, in case the whole

group has been eliminated. In some cases this one may

become senseless, as there is no group to be transported

anymore. Especially when it belongs to the player's group,

this one could disturb another condition, where you are checking for "all got killed in that group" wink_o.gif

~S~ CD

Hey man, there are about half a dozen more checks you can implement to any piece of code. The difference again is after the line I suggested you can do a seperate check, thus always using much less CPU power than with your method. wink_o.gif

Cheers.

Share this post


Link to post
Share on other sites

For example what you should really do if you're carefull

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_c=blackHawk

_u=[man1,man2....]

_i=count _u

_t=_time+_timeout

@{_x in _c||!(alive _x)}count _u==_i||_time>_t||!(canmove _c)

?_time>_t:goto"timed out"

?{alive _x}count _u==0:goto"men_died"

?!(alive driver _c)||!(canmove _c):goto"bird_dead"

?fuel _c<0.1:goto"bird_hungry"

#takeoff

Share this post


Link to post
Share on other sites
Quote[/b] ]Hey man, there are about half a dozen more checks you can implement to any piece of code.  The difference again is after the line I suggested you can do a seperate check, thus always using much less CPU power than with your method.

Piece m8,

i didn't want to sell any method, nor did i want to downgrade

the one you suggested.

I was just telling about the difference that your condition

will also become active when the whole group gets killed,

and the way i suggested, doesn't.

I know there are a whole lott'a methods. You know too that

i know and i know too that you know more of 'em  wink_o.gif

Use whatever codes you want and need Clifford.

If it works correct that way you want it to work, then go

for it - no problem with that here in Austria  smile_o.gif

~S~ CD

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  

×