Page 1 of 1

multiple unit destroyed triggers, not all always fire?

Posted: Sat Sep 01, 2018 4:24 pm
by Whicker
For a single side I have multiple unit destroyed triggers.

- any unit destroyed
- ship destroyed trigger
- ac destroyed trigger
- another any unit destroyed trigger

All are set for one side - blue.

I am finding that sometimes one of them won't fire -so say a plane is destroyed, 3 triggers should be activated, but only 1 or 2 will be. Other times all 3 will be.

Still trying to sort out what is going on, no save to share.

Is it bad form to have that many triggers? I could just create 4 - one for each main type - ship/sub/ac/facility and then reuse them, there would only ever be one trigger firing so maybe it would be more bulletproof?
Do you just make new triggers willy nilly and it works fine?
I have lots of print statements in the various events and monitor the luahistory log so I can tell whether they are doing something or not - well, the action part really.

I'm thinking some of the events have fairly long lua scripts to run, maybe that is interrupting the next trigger from firing?

RE: multiple unit destroyed triggers, not all always fire?

Posted: Sat Sep 01, 2018 10:24 pm
by michaelm75au
The triggers are checked at end of a pulse for each destroyed unit in that pulse and a list of the fired triggers created. For each one fired one, the actions (and conditions) are executed.
So if one unit fell into 3 triggers, then I would expect 3 triggered actions would result.
If one of those actions altered some state of the unit, then it could be possible that the following action might not work as expected.

Note that the order of trigger events is not done in any specific order, as is any actions. I think it is the order events are created.
If an unit is destroyed immediately (removed from the game), I don't think the triggers fire at all.

RE: multiple unit destroyed triggers, not all always fire?

Posted: Sun Sep 02, 2018 12:16 am
by Whicker
I was trying to do 3 things on any unit destroyed - survivor/score/luahistory logging. All had their own separate triggers and all 3 actions were lua - with the survivor one being fairly involved.
I think the survivor script probably took to long to run and maybe the other ones didn't get a chance to run? I also had some return statements in the code, for a second I thought that was the issue but I am not so sure. Something wasn't happy even though all 3 work well on their own.

I ended up adding all 3 things into one Event with one trigger and one action, much cleaner now and all works well.

I was wondering about the order they fire in, but figured it wasn't controllable.