Home   Help Search Login Register  

Author Topic: Count units  (Read 667 times)

0 Members and 3 Guests are viewing this topic.

Uldics

  • Guest
Count units
« on: 28 Nov 2004, 17:39:23 »
How can I count all enemy soldiers on my map, the walking ones and boarded in choppers, cars, tanks?

Purpose is feedback at the end of the mission. The problem is, that using:
Quote
enemykilled = enemycount - (count list enemyleft)
I get different killed counter every time, as some soldiers have boarded some vehicles and are more than one in them - counts as one. Even if I dont kill anybody and two guys board a chopper, then both counts as one unit and I get one counted as killed.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Count units
« Reply #1 on: 28 Nov 2004, 20:14:32 »
crew _vehicle

will give you all the units in _vehicle.  Does that help or do you need more?

Offline Tyger

  • Former Staff
  • ****
  • I was at OFPEC when it still had dirt floors...
    • OFPEC
Re:Count units
« Reply #2 on: 28 Nov 2004, 20:57:26 »
you cannot find the number of enemy units and ground units at the same time, methinks. BUt to find all ground units on the map:
Code: [Select]
groundUnits = "Land" countType thislistthat would go in a trigger activation. (ya know, set to true)
then you could probably do:
Code: [Select]
westGround = WEST countSide thislist
eastGround = groundUnits - westGround
not sure if its "WEST" or WEST, you'll have to fiddle. u can change the sides accordingly - WEST, EAST, RESISTANCE, and CIVILIAN
dat should work :P
"People sleep soundly at night only because rough men stand ready to do violence on their behalf." - George Orwell

MSG Mike Everret - We Will Never Forget - '75-'08

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Count units
« Reply #3 on: 28 Nov 2004, 22:00:41 »
thislist in a trigger returns a count of 1 for each unit it finds.   A vehicle counts as one unit, so a tank will count as 1.   In other words, you need to take each element in the thislist array and do a crew command on it, to count how many actual loons there are.   This will also grab any loons from different groups that are in cargo.
Plenty of reviewed ArmA missions for you to play

Offline Tyger

  • Former Staff
  • ****
  • I was at OFPEC when it still had dirt floors...
    • OFPEC
Re:Count units
« Reply #4 on: 28 Nov 2004, 22:05:24 »
oh, crap, ur right maccy.  :P
oh well, can't say I didn't bloody well try.  ;D
"People sleep soundly at night only because rough men stand ready to do violence on their behalf." - George Orwell

MSG Mike Everret - We Will Never Forget - '75-'08

Kammak

  • Guest
Re:Count units
« Reply #5 on: 28 Nov 2004, 22:34:26 »

guysLeft=0:{guysLeft = guysLeft + (count (crew _x))} foreach list enemyleft


guysLeft should then give you a count of all bad guys on the map (not including vehicles).  This is assuming the trigger is named "enemyleft" per your initial example.


note - not tested, just best guess

Uldics

  • Guest
Re:Count units
« Reply #6 on: 28 Nov 2004, 23:41:02 »
That works, Kammak! Thanks. I had just about same line, just the syntax was bad. Now I see, foreach is actually another form of "while", or "for...next".

Quote
1. edit
Bugger!! >:( When I tested it, I found a problem! It only counts soldiers that are unmounted or mounted as driver (I think also as gunner and commander). But it is not counting soldiers, that are inside a car as passengers - cargo. As there is no command for "cargo _vehicle" and command "_soldier in _vehicle" is only working for a specific soldier on a specific vehicle, I cannot see a solution.

How can I then count all soldiers in a vehicle, not only crewmembers?

Quote
2. edit
No, wait it is not true! The problem is another place in the whole project, not in count line! If the unit has no driver, then it is not inside triggers list as it then counts as civilian vehicle and all east units inside are not even looked at!

Quote
3. edit
Ok now I have found the stone of wisdom. As I realize, my trigger has to be to anybody, so it can take also civilian vehicles (without driver) with east units in them. And the count line has to be {drums, increasing volume} that:

{eastcount = eastcount + ("side _x == east" count (crew _x))} foreach list unitsleft

I was so happy, that the two "_x" did not clash together making the same variable instead of two! A small problem there still is, if the unit is just in the same moment gettingin/disembarking a vehicle, he can be lost in space and not counted in that.
« Last Edit: 29 Nov 2004, 23:21:22 by Uldics »