OFPEC Forum
Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started 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.
-
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
({_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
({_x in thislist} count units groupName == {alive _x} count units groupName) || ({_x in thislist} count units groupName == {alive _x} count units groupName) || etc
Untested.
-
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
-
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
#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.
-
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.
-
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
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.
-
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)))
-
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 ||.
-
I have added ( and still same error .. ???
-
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.
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)
)
)