Jump to content
56Curious

Activate trigger when defined amount of side units present

Recommended Posts

Hello, I want to activate a trigger when, after counting the current amount of units present, will activate after say, 3/4 of total is BLUFOR, for example. This is similar to the sector control modules work with the defined amount of units present to switch.

 

More info can be provided if needed,

 

- Curious

Share this post


Link to post
Share on other sites
private _trg = createTrigger ["EmptyDetector", SECTOR_POS];
_trg setTriggerActivation ["ANY", "PRESENT", true];
_trg setTriggerStatements [
	"count (thisList select {side _x isEqualTo west})/count thisList isEqualTo 0.75",
	"hint '3/4 BLUFOR'",
	""
];

Define your sector coordinates as 'SECTOR_POS' for the above code.

I hope this helps

  • Like 1

Share this post


Link to post
Share on other sites

hey Nik thanks for replying! One thing, getting an error at

16 hours ago, Nikander said:

west})/count

where the /count is causing an error. I tried removing it and fixing the condition, but still get it?

Share this post


Link to post
Share on other sites
6 hours ago, 56Curious said:

One thing, getting an error

 

Let me guess what that error might be - oh yes, silly me, it has to be the infamous zero divisor error occurring when nobody is in the trigger area

Here, let me fix that for you

private _trg = createTrigger ["EmptyDetector", SECTOR_POS];
_trg setTriggerActivation ["ANY", "PRESENT", true];
_trg setTriggerStatements [
	"count thisList > 0 && {count (thisList select {side _x isEqualTo west})/count thisList isEqualTo 0.75}",
	"hint '3/4 BLUFOR'",
	""
];

 

Share this post


Link to post
Share on other sites

Ah, I had another error via drawIcon3D at the time and couldn't see that seperated one untill I checked RPT files aha. Thank you :D

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×