Jump to content
Sign in to follow this  
RazorHead1

Single units as a group

Recommended Posts

I searched for this and really didn't find an answer. Please forgive if it is out there and I missed it.

Is there a way to take single units and make them a group?

What I mean here is: say I have a squad of 4 men. Instead of naming each guy one by one, is there a way to identify them as one group.

Say for a truck to see if my squad is on board. Instead of this:

man1 in truck1; man2 in truck1; man3 in truck1; man4 in truck1;

maybe this?????:

group1 in truck1;

Is this possible?

Share this post


Link to post
Share on other sites

yea, "group".

take one of the soldiers, preferably the leader, and do this:

group1 = group this;

in his init field, or if declaring somewhere else:

group1 = group man1;

You really could have figured this out on your own if you searched around for just a minute probably, get some resources like the comref and biki bookmarked!

Edited by JDog
to scrutinize OP

Share this post


Link to post
Share on other sites

no no I am aware of that but I think you misunderstood my question.

Here is my porblem:

I have a squad. I want a truck to begin it's waypoints after all my men are on board. It works with the single name ie: unit1 in truck1; unit2 in truck1; etc etc.

When I try what you are saying. The truck will not respond to 'group1 in truck1; It only see the individuals name.

Any thoughts?

Share this post


Link to post
Share on other sites

I'm not sure, but can't you just use an array? Like:

[unit1,unit2,unit3] in truck;

Or is that impossible?

Share this post


Link to post
Share on other sites

Ah I see, sorry I misunderstood.

Not sure how to use a group name or "group" for what you're trying to achieve. However here is a simple other way to do it:

count crew truck == 5;

Assuming there's only a driver in your truck to start with, that will make it go on to the next waypoint when your 4 troops have entered it. Of course, if ANY 4 units enter, it will continue. But if those are the only units who will be entering anyway it doesn't matter.

ALSO: No, Pete, I don't think passing an array works for this.

Edited by JDog

Share this post


Link to post
Share on other sites

You can. I was just trying to shave some time off the process. It can be a pain especially if you have a large group. It would be nice if you could refer to them as a single entity for the sake of ease.

---------- Post added at 11:20 PM ---------- Previous post was at 10:55 PM ----------

Thanks JDOG I will give it a try. Thanks for the patience.

Share this post


Link to post
Share on other sites

You could name the array, then use the name to refer to it.

eg :

_mySoldiers = [unit1,unit2,unit3,unit4];

{removeAllWeapons _x} forEach _mySoldiers;

Edited by ceeeb

Share this post


Link to post
Share on other sites

How would you do that exactly? Could you explain by step?

Unlike alot of you I ARMA2 is the first of this type of game for me. I never played the first one or any of the OFP games.

Share this post


Link to post
Share on other sites

Good idea ceeeb, I tried that out too, but doesn't seem to work in this case. I really don't think you can check an array for "in vehicle".

From the Biki:

Syntax:
   person in vehicle 
Parameters:
   person: Object
   vehicle: Object

So, it's gotta be an object, not an array.

Share this post


Link to post
Share on other sites

RazorHead1,

The equal sign is used to declare variables (names). Search for a scripting tutorial to get an introduction to the basics, anything related to the OFP/Arma engine will still be relevant, although it may not work exactly. Unfortunately I do not know any good tutorials, but try browsing through the Editors Depot at OFPEC

JDog, what you need is the count command.

eg:

waitUntil {{_x in _myTruck} count _mySoldiers == count _mySoldiers};

{hint "Let's go"};

disclaimer: I haven't done any scripting for over a year, code is untested :(

Edited by ceeeb

Share this post


Link to post
Share on other sites

JDog, what you need is the count command.

I'm the one who suggested that >.> lol... maybe you missed that post. And your little line of code there will do the exact same thing as my simpler one, but neither will check to see WHICH units are in the transport, only how many.

EDIT:

My god.... that worked. In my head at first, your line of code just checked number, but now I get the first half of it only increasing count based on the condition being true. Man... I been on this comp too much today lol. Good work.

Razor, here is ceeeb's code remade so you can put it in a waypoint condition field:

({_x in [i]truckName[/i]} count [i]arrayName[/i]) == (count [i]arrayName[/i]);

Edited by JDog
cuz i talked before testing

Share this post


Link to post
Share on other sites

sorry mate, i'm focusing on the original post's intentions.

So you want an array containing members of another array that are aboard a specific vehicle? I'll find my Arma2 DVD (just moved house) and make sure I get the script correct.

Share this post


Link to post
Share on other sites

No I don't want that lol I was just trying to figure out how to solve Razor's problem as well, to find out whether or not an entire group is aboard a vehicle. You got it right, I just changed it slightly to work in a condition field instead of a script. Thanks tho.

Share this post


Link to post
Share on other sites

If it's in a script (and not in editor code that seems to make a mess whenever I try to use local variables in it), you can use:

// assuming P1 a group member
waitUntil
{
  _bTmp=true;
  {_bTmp = _bTmp && _x in myTruck} forEach (units (group P1));
  _bTmp;
};
// if this line is reached, it means all group members (of unit P1) are in myTruck

You could of course turn it into a complete script that receives [a truck, unit that represents the group] or [a truck, group], using _this select 0 instead of myTruck and _this select 1 instead of P1 or group P1 and thus get a generic script you can call from the editor multiple times for different trucks/groups.

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  

×