Home   Help Search Login Register  

Author Topic: Counting units inside vehicles  (Read 867 times)

0 Members and 1 Guest are viewing this topic.

Offline surpher

  • Members
  • *
Counting units inside vehicles
« on: 09 May 2004, 13:21:33 »
Hi there!  :wave:

New to scripting and just wondering how you would count the number of units inside a vehicle. I intend to use it as a condition for a trigger to make sure that all unit are out of a helicopter before it takes off.


Thx in advance  :)

PsyWarrior

  • Guest
Re:Counting units inside vehicles
« Reply #1 on: 09 May 2004, 15:01:32 »
Greetings, Surpher,
And
Welcome to the Forums!

I believe you could use something along the lines of:
Code: [Select]
count (units in chopper) == 0In the 'condition' line of the trigger (with 'chopper' being the name given to the helicopter). The above will trigger if the helicopter is completely empty (including crew). To ensure that the crew remain aboard, use '2' instead of '0'.

The above is completely untested, so no guarantees on it... ::) There may be some syntax problems, so play around with the order of things.

But I believe that the 'Count' command is what you are looking for.

-Supreme Commander PsyWarrior
-Psychic Productions Studios.

Offline surpher

  • Members
  • *
Re:Counting units inside vehicles
« Reply #2 on: 09 May 2004, 17:39:07 »
Thanks PsyWarrior helped alot  :cheers:

Had some syntax problems but all I had to do was drop the brackets and the in command.

Code: [Select]
count units chopper == 2
Thanks again for putting me on the right track :)

Offline Blanco

  • Former Staff
  • ****
Re:Counting units inside vehicles
« Reply #3 on: 10 May 2004, 21:18:19 »
???
Count units chopper == 2?
???

Is chopper a groupname then?

should be something like :

Code: [Select]
"_x in chopper" count units yourgroupname == 0



« Last Edit: 10 May 2004, 21:35:08 by Blanco »
Search or search or search before you ask.

Offline surpher

  • Members
  • *
Re:Counting units inside vehicles
« Reply #4 on: 10 May 2004, 22:39:08 »
chopper is the name of my helicopter.

Im loading two groups into a BAS mh47 piloted by ai. Then they get dropped off and the chopper waits until there are only two units left in chopper (pilot & gunner). Once all unit are out chopper moves on.

It works fine for me :)

Offline Blanco

  • Former Staff
  • ****
Re:Counting units inside vehicles
« Reply #5 on: 11 May 2004, 17:43:30 »
That's strange , I always thought that count units must be followed by a groupname, not an object...


 
Search or search or search before you ask.

PsyWarrior

  • Guest
Re:Counting units inside vehicles
« Reply #6 on: 11 May 2004, 23:34:16 »
Quote
I always thought that count units must be followed by a groupname, not an object...
Not necessarily, Blanco. I believe that Count Units/ count can be followed by any array of units.

So:
count units group player
Would count all the units in the players group

count units in chopper
Would create an array (in chopper) with all the units in the unit called 'chopper', and then count them
[No. It does not]

count [unit1, unit2, unit3, orange]
Assuming you have no unit called orange, would return 3

It can be used with groups, but does not have to be.

-Psy|W

EDIT: The above is now correct, I believe.
« Last Edit: 15 May 2004, 15:08:57 by PsyWarrior »

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:Counting units inside vehicles
« Reply #7 on: 14 May 2004, 11:29:33 »
hmm.... yeah... sort of ;)

the line:

count units chopper...

will only work if either a group or unit is called 'chopper'. (And it's the right unit/group!)

What you guys are after is:

count (crew chopper)

where chopper is the name of your helicopter.


The units keyword is a device that turns a group into an array. The count command needs to work with an array. So you need to use it like:

count Array

However, the units keyword makes a group an array, so:

count units group

is the same as the previous example.

PsyWarrior

  • Guest
Re:Counting units inside vehicles
« Reply #8 on: 14 May 2004, 15:33:50 »
Greets, Sui

What of:
count units in chopper

Would that not count all the units inside the chopper? I know that "player in RedJeep" returns true if the player is inside a unit called RedJeep. And would (crew chopper) return crew and cargo, or just crew (pilot/ gunner)?

-Psy|W

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:Counting units inside vehicles
« Reply #9 on: 14 May 2004, 17:34:59 »
crew vehicle returns pilot/gunner/passengers in an array

unit in vehicle is either true or false and does not return
an array or unit

count units in vehicle should return nothing or an error

as units in vehicle is not a valid array

unit/group are both seen as a group or a unit
think about that a group can also consist of only one single unit
which gives more sense to that
also think about how the forEach command is used very often:

"_x doAnyThing" forEach units this

which also gives more sense to that

units unit/group is a valid array

~S~ CD
« Last Edit: 14 May 2004, 17:36:30 by Chris Death »
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

PsyWarrior

  • Guest
Re:Counting units inside vehicles
« Reply #10 on: 14 May 2004, 19:03:14 »
Ah well...at least I got the Count command right... ::)

I once again submit to your greater knowledge, Chris.

Appropriate corrections have been made.

-Psy|W
« Last Edit: 14 May 2004, 19:05:30 by PsyWarrior »

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:Counting units inside vehicles
« Reply #11 on: 15 May 2004, 06:09:22 »
Yeah... the nuances are a bit confusing huh? ;)

Chris has covered most of it...

As for the 'units in chopper' thing, you can do it that way. The correct line would look like this:

"_x in chopper" count units group

Which will count how many of one particular group are in the chopper.

Just bear in mind that the keyword units doesn't actually refer to units... it must always be used in conjunction with a group (as it turns the group into an array so count knows what to do with it).

Hopefully I didn't confuse you even more :P
The whole units/groups/count/foreach thing is a bit of a handful sometimes...

PsyWarrior

  • Guest
Re:Counting units inside vehicles
« Reply #12 on: 15 May 2004, 15:13:08 »
Right...Got it.

Again, the effects of sleep deprivation become apparent... ::)

Cheers, Sui/ CD. I have clarified my earlier post.

-Psy|W