Home   Help Search Login Register  

Author Topic: trigger activated by different groups ?  (Read 3743 times)

0 Members and 1 Guest are viewing this topic.

Offline CaptainBravo

  • Members
  • *
trigger activated by different groups ?
« 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.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: trigger activated by different groups ?
« Reply #1 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.
« Last Edit: 28 Sep 2009, 11:00:11 by bedges »

Offline CaptainBravo

  • Members
  • *
Re: trigger activated by different groups ?
« Reply #2 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
« Last Edit: 28 Sep 2009, 11:09:57 by CaptainBravo »

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: trigger activated by different groups ?
« Reply #3 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.

Offline Shuko

  • Members
  • *
Re: trigger activated by different groups ?
« Reply #4 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.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: trigger activated by different groups ?
« Reply #5 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.

Offline CaptainBravo

  • Members
  • *
Re: trigger activated by different groups ?
« Reply #6 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)))

Offline Shuko

  • Members
  • *
Re: trigger activated by different groups ?
« Reply #7 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 ||.

Offline CaptainBravo

  • Members
  • *
Re: trigger activated by different groups ?
« Reply #8 on: 30 Sep 2009, 17:34:40 »
I have added ( and still same error ..  ???

Offline Shuko

  • Members
  • *
Re: trigger activated by different groups ?
« Reply #9 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)
  )
)