CarlGustaffa 4 Posted October 7, 2007 Hi I hae a trigger where I'm trying to determine if my whole squad is in. I can't (in this particular case) use a linked-to-unit trigger. Can I use forEach loops in a condition? If so, how? Tried something in the realms of: ({_x in uVeh} forEach units uMyGroup) but the editor won't accept it. Do I really have to test each single unit? What if he's dead already? Share this post Link to post Share on other sites
Op4 BuhBye 0 Posted October 7, 2007 Set the trigger, close it, then select group on the right and drag a line from the trigger to the group leader. Then open the trigger and select "Whole Group" in the dropdown. And set it to present. If the whole group is present the trigger will be active. Share this post Link to post Share on other sites
sickboy 13 Posted October 7, 2007 <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">({_x in (crew uVeh)} count (units uMyGroup))==count (units uMyGroup) or in a script: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_vehUnits=crew uVeh; _units=units uMyGroup; myGroupCondition=(({_x in _vehUnits} count uMyGroupUnits)==count _units); myGroupCondition will then either be false or true what also might work in the condition is this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">myGroupCondition=true; { if ( !(_x in (crew uVeh)) ) then { myGroupCondition=false } } forEach (units uMyGroup); myGroupCondition But I guess the first option is the easiest. Share this post Link to post Share on other sites
vova _fox 0 Posted October 7, 2007 <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">({_x in (crew uVeh)} count (units uMyGroup))==count (units uMyGroup) ({!(_x in (crew uVeh))} count (units uMyGroup))==0 Share this post Link to post Share on other sites
weedomatic 0 Posted October 7, 2007 I know you problem seems to be solved, but as a general note: A condition can either be true or false, hence the expression/variable in the condition field has to return such type of value (via e.g. comparison operations) or the variable has to be of type boolean. Loops don't return anything per se. Share this post Link to post Share on other sites
CarlGustaffa 4 Posted October 8, 2007 Thanks a lot. Looking forward to try this when I get home. Who ever invented so long work hours? Share this post Link to post Share on other sites
CarlGustaffa 4 Posted October 9, 2007 Oh yeah, thank you Works like a charm. Share this post Link to post Share on other sites
sickboy 13 Posted October 13, 2007 Good point vova _fox :-) Share this post Link to post Share on other sites