Jump to content
Tankbuster

trigger, unexpected behaviour

Recommended Posts

in the case, cpt_position was  [11003,9711.09,0] and cpt_radius was 225.

trg2 = createTrigger ["EmptyDetector", cpt_position];
trg2 setTriggerArea [(cpt_radius),(cpt_radius),0,false];
trg2 setTriggerActivation  ["EAST", "NOT PRESENT", false];
trg2 setTriggerStatements ["this", "", ""];

Players reported the trigger wasn't firing, so I went into the server and using spectator, found the area (Vagala, Tanoa) was clear of OPFOR. The nearest one was some distance away so I teleported there and killed him - and the trigger activated. The problem is that this guy was 2500m from the cpt_position.
I don't understand? What's going on?

Share this post


Link to post
Share on other sites

When do you create the trigger? Are the enemy there before or after? Also, where is cpt_position defined?

Share this post


Link to post
Share on other sites

Not sure the trigger doesn't work... There is nothing to trigger:

trg2 setTriggerStatements ["this", " ", " "];

  • Like 1

Share this post


Link to post
Share on other sites
trg2 setTriggerActivation  ["EAST", "NOT PRESENT", false];

Shouldn't this be okay for the trigger? If enemy are there before trigger is created, which is why I asked. Hmm.

Share this post


Link to post
Share on other sites

if enemies are there prior to the trigger, the non-presence returns false, til all died or out of area.

If enemies aren't spawned, the non-presence is true > trigger is activated.

Share this post


Link to post
Share on other sites

The

6 hours ago, HazJ said:

When do you create the trigger? Are the enemy there before or after? Also, where is cpt_position defined?

The trigger is created after the enemies are spawned, there's a few seconds between them. cpt_position is defined earlier by another script.

Share this post


Link to post
Share on other sites
2 hours ago, pierremgi said:

if enemies are there prior to the trigger, the non-presence returns false, til all died or out of area.

If enemies aren't spawned, the non-presence is true > trigger is activated.

As I said. Again, which is what I asked Tankbuster. Read my post.

@Tankbuster

Does this happen every time or just sometimes? Need some more info... What is cpt_position?

Share this post


Link to post
Share on other sites

cpt_position is the centre of the target town. The variable is created by an earlier script. There's also a marker created there that is the same size as the trigger.

It doesn't happen every time.. this is what's so annoying.

What so odd is that this particular guy was so far out of the trigger area, he was nearly 2500m away from the trigger centre (so, ~2200m OUTSIDE the trigger area), yet when I killed him, the trigger activated immediately.

Share this post


Link to post
Share on other sites
4 hours ago, pierremgi said:

Not sure the trigger doesn't work... There is nothing to trigger:

trg2 setTriggerStatements ["this", " ", " "];

That's not how this works. setTriggerStatements do take priority over setTriggerActivation, but as you can see, they are blank.

Share this post


Link to post
Share on other sites

I will look at this when I get home tonight. On mobile currently.

  • Like 1

Share this post


Link to post
Share on other sites

I'm out too. I'll edit the post to show formatting better.

 

** done. the code is in pastebin now

*** pastebin formatting supports sqf? cool.

 

Share this post


Link to post
Share on other sites

If I'm right, you execVM some script for spawning Reds. The execVMed script runs in parallel of your main one, so the triggers trg2 & trg3  are probably created earlier than the end of spawning result.

You should wait for any Red presence before creating these triggers.

Btw, I'm not sure to understand the use of trg2 as trg3 is also EAST NOT PRESENT, so the trg2 activation condition is useless (except for something elsewhere?).

 

Share this post


Link to post
Share on other sites

Now I'm confused. :rofl:

Enemy must be there before trigger as I said, as @pierremgi said too (I think). I personally wouldn't use the trigger if just checking for clear. Just use waitUntil? A snippet from my project.

waitUntil
{
	{alive _x} count units _banditGroup isEqualTo 0 || !alive _vehicle
};

Could add a sleep in there too if you want.

Share this post


Link to post
Share on other sites
30 minutes ago, HazJ said:

Now I'm confused. :rofl:

Enemy must be there before trigger as I said, as @pierremgi said too (I think). I personally wouldn't use the trigger if just checking for clear. Just use waitUntil? A snippet from my project.


waitUntil
{
	{alive _x} count units _banditGroup isEqualTo 0 || !alive _vehicle
};

Could add a sleep in there too if you want.

 


The trigger, even non-repeatable, can be kept for checking a presence in area. It's easier. The reason why I didn't suggest to remove it.

If you want the same intended result without trigger, you have to check a distance anyway, or use the marker shape (cpt_marker) as area and inArea command.

Share this post


Link to post
Share on other sites
2 hours ago, pierremgi said:

If I'm right, you execVM some script for spawning Reds. The execVMed script runs in parallel of your main one, so the triggers trg2 & trg3  are probably created earlier than the end of spawning result.

You should wait for any Red presence before creating these triggers.

Btw, I'm not sure to understand the use of trg2 as trg3 is also EAST NOT PRESENT, so the trg2 activation condition is useless (except for something elsewhere?).

 

I do execVM the creation of the units, but there's a waituntil at line 47. The triggers are created after the units are spawned.

 

there's another trigger because you can't have statements and activation on the same trigger. If you do, the activation is ignored. That's why trg3 has triggeractiveated trg2 as one of it's conditions in the statements.

 

But we're getting away from the central question. Most of the time, the triggers work as expected. Sometimes, the activation of trg2 is held up by a unit being alive when he's well outside the trigger.

Share this post


Link to post
Share on other sites
1 hour ago, HazJ said:

Now I'm confused. :rofl:

Enemy must be there before trigger as I said, as @pierremgi said too (I think). I personally wouldn't use the trigger if just checking for clear. Just use waitUntil? A snippet from my project.


waitUntil
{
	{alive _x} count units _banditGroup isEqualTo 0 || !alive _vehicle
};

Could add a sleep in there too if you want.

Yes, I'm begining to come to the same conclusion. I'm going to have to have a repeated check, though I'll use inarea rather than counting the created units because this being Arma, they often run away from the AO.

Share this post


Link to post
Share on other sites
1 hour ago, Tankbuster said:

I do execVM the creation of the units, but there's a waituntil at line 47. The triggers are created after the units are spawned.

 

Do not hesitate to add some extra sleep or change your check.

For example, not sure it's your case, you can execVM a code that spawns units so that doesn't mean your units are spawned then the execVMed code is done.

 

Main scheduled code

   |     >> execVM sqf

   |              |         >>  bis_fnc_spawnGroup

   |             variable true if done

waitUntil variable true   // doesn't mean spawned group because of 2 scopes of parallel scripts

  

1 hour ago, Tankbuster said:

there's another trigger because you can't have statements and activation on the same trigger. If you do, the activation is ignored. That's why trg3 has triggeractiveated trg2 as one of it's conditions in the statements.

 

trg2 setTriggerArea [(cpt_radius),(cpt_radius),0,false];

trg2 setTriggerActivation  ["EAST", "NOT PRESENT", false];

and

trg3 setTriggerArea [(cpt_radius + 200),(cpt_radius + 200),0,false];

trg3 setTriggerActivation  ["EAST", "NOT PRESENT", false];

 

if trg3 is OK, so trg2 is. No matter the extra condition for trg3 . trg2 is included in trg3. I still can't see the need of trg2 in your script.

 

1 hour ago, Tankbuster said:

Most of the time, the triggers work as expected. Sometimes, the activation of trg2 is held up by a unit being alive when he's well outside the trigger.

 

I understand your trigger activation seems to depend on the status of a Red unit out of the trigger. The only thing I have on mind is a remaining EAST logic inside the area, erased when unit dies.

Difficult without test. I don't know how your spawnprimarytargetunits.sqf is scripted. You could add a "real time" counter for EAST sided things (logic,vehicles..) inside the trigger area.

For sure, there is something EAST present, linked with your remote unit.

 

Share this post


Link to post
Share on other sites
20 minutes ago, pierremgi said:

 

Do not hesitate to add some extra sleep or change your check.

For example, not sure it's your case, you can execVM a code that spawns units so that doesn't mean your units are spawned then the execVMed code is done.

 

Main scheduled code

   |     >> execVM sqf

   |              |         >>  bis_fnc_spawnGroup

   |             variable true if done

waitUntil variable true   // doesn't mean spawned group because of 2 scopes of parallel scripts

 

 

 

Yes, it does. It means exactly that.

 

20 minutes ago, pierremgi said:

trg2 setTriggerArea [(cpt_radius),(cpt_radius),0,false];

trg2 setTriggerActivation  ["EAST", "NOT PRESENT", false];

and

trg3 setTriggerArea [(cpt_radius + 200),(cpt_radius + 200),0,false];

trg3 setTriggerActivation  ["EAST", "NOT PRESENT", false];

 

if trg3 is OK, so trg2 is. No matter the extra condition for trg3 . trg2 is included in trg3. I still can't see the need of trg2 in your script.

 

 

 

You aren't reading or understanding what I wrote. If you have statements AND activation on a trigger, the activation is IGNORED. So, the activation on trg3 is irrelevant, though I admit, potentially confusing to the reader. The activation for trg3 could be anything, but you must put something in there.
 

 

23 minutes ago, pierremgi said:

I understand your trigger activation seems to depend on the status of a Red unit out of the trigger. The only thing I have on mind is a remaining EAST logic inside the area, erased when unit dies.

Difficult without test. I don't know how your spawnprimarytargetunits.sqf is scripted. You could add a "real time" counter for EAST sided things (logic,vehicles..) inside the trigger area.

For sure, there is something EAST present, linked with your remote unit.

 

 

There was no OPFOR units inside the trigger. I confirmed this with spectator. Not only that, I only had to kill one OPFOR, a long way outside the trigger for it to activate.

Share this post


Link to post
Share on other sites
1 hour ago, Tankbuster said:

You aren't reading or understanding what I wrote. If you have statements AND activation on a trigger, the activation is IGNORED. So, the activation on trg3 is irrelevant, though I admit, potentially confusing to the reader. The activation for trg3 could be anything, but you must put something in there.
 

 

Just try:

trg2 = createTrigger ["EmptyDetector", cpt_position];

trg2 setTriggerArea [(cpt_radius),(cpt_radius),0,false];

trg2 setTriggerActivation  ["EAST", "NOT PRESENT", false];

trg2 setTriggerStatements ["this", "", ""];

 

trg3 = createTrigger ["EmptyDetector", cpt_position];

trg3 setTriggerArea [(cpt_radius),(cpt_radius),0,false];

trg3 setTriggerActivation  ["EAST", "NOT PRESENT", false];

trg3 setTriggerStatements [" this and  {(not (alive pt_radar) ) and (not (alive pt_hq)) and (roadblockscleared) and (civvecsmustbekilledflag)}", "execVM 'server\assaultphasefinished.sqf'", ""];

 

 

The statement "this & something more" makes you benefit for predetermined trigger's condition and extra ones. Simple as that.

NB: I don't see why you created 2 different radius, but it's not useful in the way you wrote your two triggers.

 

The bis_fnc_spawnGroup is a scheduled code on its own, even if called! In heavy scenario, you can experience some uncompleted spawn and scheduler pass the hand to other code (3 ms limitation).

Never mind. Have fun with your scripts.

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, pierremgi said:

 

Just try:

trg2 = createTrigger ["EmptyDetector", cpt_position];

trg2 setTriggerArea [(cpt_radius),(cpt_radius),0,false];

trg2 setTriggerActivation  ["EAST", "NOT PRESENT", false];

trg2 setTriggerStatements ["this", "", ""];

 

trg3 = createTrigger ["EmptyDetector", cpt_position];

trg3 setTriggerArea [(cpt_radius),(cpt_radius),0,false];

trg3 setTriggerActivation  ["EAST", "NOT PRESENT", false];

trg3 setTriggerStatements [" this and  {(not (alive pt_radar) ) and (not (alive pt_hq)) and (roadblockscleared) and (civvecsmustbekilledflag)}", "execVM 'server\assaultphasefinished.sqf'", ""];

 

 

The statement "this & something more" makes you benefit for predetermined trigger's condition and extra ones. Simple as that.

NB: I don't see why you created 2 different radius, but it's not useful in the way you wrote your two triggers.

 

The bis_fnc_spawnGroup is a scheduled code on its own, even if called! In heavy scenario, you can experience some uncompleted spawn and scheduler pass the hand to other code (3 ms limitation).

Never mind. Have fun with your scripts.

Ah yes, this and might work. I'll try that.

I do use spawngroup but, for less than half of my foot mobiles. Also, it's done quite slowly, the spawn of a towns force takes around 20 seconds. There's no way the trigger exists before the men.

But, and I'm going to come back to it, the activation of trg2 was done by a man more then 2km outside the trigger radius

Share this post


Link to post
Share on other sites

The issue I mentioned in the original post occured again yesterday.

 

The last two remaining units were well outside the trigger area and when we killed them (ran them over with a stolen Kamysh) the trigger activated. Grrrr.

Share this post


Link to post
Share on other sites
1 minute ago, Tankbuster said:

The issue I mentioned in the original post occured again yesterday.

 

The last two remaining units were well outside the trigger area and when we killed them (ran them over with a stolen Kamysh) the trigger activated. Grrrr.

Might as well get rid of triggers in the first place, especially when you're already using .sqf to a greater extent.

Something like you described has yet to happen using loops/eventhandlers.

 

Cheers

Share this post


Link to post
Share on other sites
Just now, Grumpy Old Man said:

Might as well get rid of triggers in the first place, especially when you're already using .sqf to a greater extent.

Something like you described has yet to happen using loops/eventhandlers.

 

Cheers

Yes, I'm coming to that conclusion too. Nearentities to the rescue.

  • Like 1

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

×