Welcome, Guest Saturday 19th April 2014, 23:06:28
   Home   Help Search Login Register  

OFPEC Forum

Author Topic: trigger activated by different groups ?  (Read 572 times)
0 Members and 1 Guest are viewing this topic.
CaptainBravo
*
Offline Offline


« on: 28 Sep 2009, 09: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.
Logged
bedges
Administrator
*****
Offline Offline


WWW
« Reply #1 on: 28 Sep 2009, 09: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:
({_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:
({_x in thislist} count units groupName == {alive _x} count units groupName) || ({_x in thislist} count units groupName == {alive _x} count units groupName) || etc

Untested.
« Last Edit: 28 Sep 2009, 10:00:11 by bedges » Logged
CaptainBravo
*
Offline Offline


« Reply #2 on: 28 Sep 2009, 10: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
« Last Edit: 28 Sep 2009, 10:09:57 by CaptainBravo » Logged
bedges
Administrator
*****
Offline Offline


WWW
« Reply #3 on: 28 Sep 2009, 10: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:
#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.
Logged
Shuko
*
Offline Offline


« Reply #4 on: 28 Sep 2009, 13: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.
Logged
bedges
Administrator
*****
Offline Offline


WWW
« Reply #5 on: 28 Sep 2009, 13: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:
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.
Logged
CaptainBravo
*
Offline Offline


« Reply #6 on: 30 Sep 2009, 15: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)))
Logged
Shuko
*
Offline Offline


« Reply #7 on: 30 Sep 2009, 16: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. Smiley

There is one ( missing after the first ||.
Logged
CaptainBravo
*
Offline Offline


« Reply #8 on: 30 Sep 2009, 16:34:40 »

I have added ( and still same error ..  Huh?
Logged
Shuko
*
Offline Offline


« Reply #9 on: 30 Sep 2009, 17: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:
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)
  )
)
Logged
Pages: [1]   Go Up
  Send this topicPrint  
 
Jump to: