OFPEC Forum

Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started by: CaptainBravo on 28 Sep 2009, 10:41:31

Title: trigger activated by different groups ?
Post by: CaptainBravo on 28 Sep 2009, 10:41:31
Hi everyone,

I have a simple question ..  how do you get a trigger activated by different groups present ?
I know how to get one group by joining it with trig. But how about if you have 4 other groups and you want trig activated as soon as ANY of these groups present??

Thanks for your help.
Title: Re: trigger activated by different groups ?
Post by: bedges on 28 Sep 2009, 10:58:34
I'm assuming it's the same as the OFP method:

name your 4 groups (groupName = group this in the init of the leader where groupName is whatever you like)
in the condition of the trigger

Code: [Select]
({_x in thislist} count units groupName > 0) || ({_x in thislist} count units groupName > 0) || etc
That will detect any single unit from the given groupNames. If you want all of a given group to be present before the trigger fires

Code: [Select]
({_x in thislist} count units groupName == {alive _x} count units groupName) || ({_x in thislist} count units groupName == {alive _x} count units groupName) || etc
Untested.
Title: Re: trigger activated by different groups ?
Post by: CaptainBravo on 28 Sep 2009, 11:04:02
Thanks bedges for your quick response. I shall test it this evening.

How do you place group names in trigger? ({g1,g2,g3} replace ({_x in thislist} (g1,g2,g3 is group names) ?

Thanks
Title: Re: trigger activated by different groups ?
Post by: bedges on 28 Sep 2009, 11:27:32
Scratch it, it won't work. It's been so long since I did any of this stuff I forgot that you can't use thislist in a trigger conditional, something about giving the trigger time to poll its contents.

It will need a slowly looping script, something along the lines of

Code: [Select]
#loop
~1

?(({_x in groupsPresent} count units groupName) == ({alive _x} count units groupName)) || (({_x in groupsPresent} count units groupName2) == ({alive _x} count units groupName2)):goto "fired"

goto "loop"


#fired
hint "trigger fired"

The script can be run from the beginning of the mission, and the ~1 could be changed to ~5 depending on how quickly you want to know any of the groups are there. More time = less lag.

The trigger will be set up as Anybody present, repeating, condition this, on activation groupsPresent = thislist.

Tested in OFP and works fine.
Title: Re: trigger activated by different groups ?
Post by: Shuko on 28 Sep 2009, 14:06:34
Quote
It's been so long since I did any of this stuff I forgot that you can't use thislist in a trigger conditional, something about giving the trigger time to poll its contents.

What?

thislist works perfectly fine in trigger condition.
Title: Re: trigger activated by different groups ?
Post by: bedges on 28 Sep 2009, 14:30:55
Aye, I thought that 10 minutes after posting. It's when you're using a thislist trigger to get all units of a given side on the map from the beginning of the mission that you need to give the engine a second or so to populate the array before using it.

To summarize then:

your trigger will be set up as Anybody present, repeating, condition

Code: [Select]
this && (({_x in thislist} count units g1) == ({alive _x} count units g1)) || ({_x in thislist} count units g2) == ({alive _x} count units g2)) || ({_x in thislist} count units g3) == ({alive _x} count units g3)) || ({_x in thislist} count units g4) == ({alive _x} count units g4)))
which translates as when any of the 4 (complete) groups is in the trigger.
Title: Re: trigger activated by different groups ?
Post by: CaptainBravo on 30 Sep 2009, 16:45:40
Thanks for the help guys. I just tested and it gives me error: missing ;
I am not sure where it is missing? Any ideas?

Thanks.

this && (({_x in thislist} count units g1) == ({alive _x} count units g1)) || ({_x in thislist} count units g2) == ({alive _x} count units g2)) || ({_x in thislist} count units g3) == ({alive _x} count units g3)) || ({_x in thislist} count units g4) == ({alive _x} count units g4)))
Title: Re: trigger activated by different groups ?
Post by: Shuko on 30 Sep 2009, 17:24:00
That error often means you are missing a bracket of some kind instead of a semicolon. Which was my first guess as well, looking at the code. :)

There is one ( missing after the first ||.
Title: Re: trigger activated by different groups ?
Post by: CaptainBravo on 30 Sep 2009, 17:34:40
I have added ( and still same error ..  ???
Title: Re: trigger activated by different groups ?
Post by: Shuko on 30 Sep 2009, 18:32:14
That was just the first one I saw. You should make the condition in a notepad or something similar instead of the small box in editor. Make sure the brackets sum up.

Code: [Select]
this &&
(
  (
    ({_x in thislist} count units g1) == ({alive _x} count units g1)
  ) ||
  (
    ({_x in thislist} count units g2) == ({alive _x} count units g2)
  ) ||
  (
    ({_x in thislist} count units g3) == ({alive _x} count units g3)
  ) ||
  (
    ({_x in thislist} count units g4) == ({alive _x} count units g4)
  )
)