OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: LCD 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 ? "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
-
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?
if (({alive _x} count forEach units myGroup) < 2) then { blah; blah blah; blah blah blahg;};
-
What you mean is that you want your snippet in correct syntax?
Ummmmmmmmmmmm.... yeah ::) LOL
dat line gonna work ?
thx :D
LCD OUT
-
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.
-
Ack, is that a new feature of ArmA?
-
Nope.
This was the case in OFP as well...
-
den shud i use a getdammage command ? or somin like dat ???
if (({getdammage _x >= 1} count forEach units myGroup) < 2) then { blah; blah blah; blah blah blahg;};]
wud dat work ?
LCD OUT
-
That will never work, that line of code is a weird monstruosity :blink:
if (({damage _x < 0.99} count units myGroup) < 2) then { Hint "We are few, we are alone, we are cowards, lets surrender";};
-
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
-
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.
-
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:
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:
{alive _x} count units group player
or
{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.
-
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..
-
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.
-
@ 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