Home   Help Search Login Register  

Author Topic: alive foreach.... and count  (Read 2193 times)

0 Members and 1 Guest are viewing this topic.

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
alive foreach.... and count
« on: 06 Jun 2007, 15:14:22 »
is dere any way i can get a resault usin a foreach command ?

i need a condition 2 use when only 1 of da soldiers in da group is alive (count units is no good... cuz of time waitin till soldiers knows his ppl r dead....

so i need sometin along da lines of dis
Code: [Select]
? "count (alive _x)" foreach units groupname < 2 : someting
dis wont work cuz alive gimme true and false... but is dere nything dat looks like dat i can use ? (i want 1 line... i can do loops myself  ;) :P)

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: alive foreach.... and count
« Reply #1 on: 06 Jun 2007, 15:32:23 »
Um, ... you have failed to explain what you want, but I will try to guess what you mean. What you mean is that you want your snippet in correct syntax?
Code: [Select]
if (({alive _x} count forEach units myGroup) < 2) then { blah; blah blah; blah blah blahg;};
urp!

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: alive foreach.... and count
« Reply #2 on: 06 Jun 2007, 18:03:37 »
Quote
What you mean is that you want your snippet in correct syntax?

Ummmmmmmmmmmm.... yeah  ::) LOL

dat line gonna work ?

thx :D

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: alive foreach.... and count
« Reply #3 on: 06 Jun 2007, 21:27:58 »
Beware, alive command is treacherous, as units are alive or dead depending on the group leader knowledge. For example, you have a group of 8 units, the group splits in two or 4 each, one of the groups moves away of the other (where the leader is), and that group is suddenly destroyed by a bomb. Well, these units will be "alive" until the leader notices that his men are dead. This happens also with player's group, at some point to send a request status to some units and THEN, they dont reply, and THEN they are marked as dead and removed from your group. So, you better use damage _unit > 0.9.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: alive foreach.... and count
« Reply #4 on: 06 Jun 2007, 21:52:28 »
Ack, is that a new feature of ArmA?
urp!

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: alive foreach.... and count
« Reply #5 on: 06 Jun 2007, 21:57:30 »
Nope.
This was the case in OFP as well...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: alive foreach.... and count
« Reply #6 on: 06 Jun 2007, 23:57:02 »
den shud i use a getdammage command ? or somin like dat  ???

Code: [Select]
if (({getdammage _x >= 1} count forEach units myGroup) < 2) then { blah; blah blah; blah blah blahg;};]

wud dat work ?

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: alive foreach.... and count
« Reply #7 on: 07 Jun 2007, 00:02:38 »
That will never work, that line of code is a weird monstruosity  :blink:

Code: [Select]
if (({damage _x < 0.99} count units myGroup) < 2) then { Hint "We are few, we are alone, we are cowards, lets surrender";};

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: alive foreach.... and count
« Reply #8 on: 07 Jun 2007, 00:08:11 »
lookin @ my code again and its really a monster LOL  :no:

still i blame da new generation 4 dat  ::)

nywayz thx 4 da syntax Mando :D  :-*

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re: alive foreach.... and count
« Reply #9 on: 07 Jun 2007, 02:04:51 »
I don't know about ArmA, but in OFP the getDammage command was at least as treacherous as the alive-command. I did some testing way back, and found out that people could be dead and return values as low as 0.6 when I getDammaged them.

Anyway, I know there's a workaround to the alive-problem. I can't remember the syntax though, but I think it was just like Mr.Peanut's snippet. I would recommend doing a test where you shoot your lads without reporting them and see if it activates or not.

Offline DucusSumus

  • Members
  • *
  • I'm a llama!
Re: alive foreach.... and count
« Reply #10 on: 07 Jun 2007, 08:34:55 »
LCD, you can't put a loop in a condition field (forEach in this case); that doesn't make any sense.  Ultimately, you must wind up with a single boolean value in the condition field and nothing more for it to be valid. 

Mandoble, I know that count works that way ("count units grp" gives you the number of units that are thought to be alive in the group), but I'm 98% sure that alive is triggered when a unit is dead, whether or not the leader has realized it.  Hence, hardrock's note on Biki:

Quote
Take care when using count to determine how many units are left alive in a group: count units group player or count units groupname Will return the number of units the leader of the group thinks are alive. If some units have been killed out of sight of other members of the group then it may take sometime for this to be the actual numbers in the group. To determine exactly how many units are really alive in a group use:

Code: [Select]
{alive _x} count units group player
or

Code: [Select]
{alive _x} count units groupname

Checking damage to determine alive status is a bad idea with units because a unit doesn't need to have a damage value of 1 to be dead.  If you shoot someone in the head, for example, their damage value will be somewhere around .667, but they will always die. 
« Last Edit: 07 Jun 2007, 08:41:33 by DucusSumus »

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: alive foreach.... and count
« Reply #11 on: 07 Jun 2007, 15:05:28 »
Then again, does it really matter if alive works like it does? ???

I mean it doesn't take the leader ages to 'sense' that something might be wrong and starting to ask status reports so basicly within a minute (don't quote me on that, haven't measured the time ::) ) the alive count would go lower..
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: alive foreach.... and count
« Reply #12 on: 07 Jun 2007, 15:39:11 »
If alive fails, or if damage is not accurate, may be the most quick way would be to check canMove _unit, as dead units cannot move for sure.

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: alive foreach.... and count
« Reply #13 on: 07 Jun 2007, 23:10:37 »
@ DucusSumus

LOL... but i can use a loop as a condition...... or a very big and sentence... its just matter of scriptin... and big loop w/ alota ? : inside it dat will exit on da right time :D

@ -h

it takes a valuable 30 sec (or more sometimes)... da player kills da last man b4 it tells him 2 do watever he needs w/ em

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta